Remove unused code
Improved locking behavior.