Locks added for shared variables in handler.