Added locks to the data structures