Added locks for shared resources