Repaired locking bugs