Added lock acquisition/release around shared data structure manipulation