Make deadlock detector more reliable, and more concise.

Signed-off-by: Ross Allan <rallanpcl@gmail.com>