Fixed locking bug