fix deadlocks