Fixed deadlocks