fixing deadlocks