Modified locking code to actually acquire locks :þ