Fix deadlock bugs!