clean up locking code