Fixed deadlocks.