Fix deadlock detection bug