Fix for deadlocks