Implemented locking.