Fixed locking errors