Improve locking code consistency, avoid creating references to lock objects.