fix possible overflow in blocking detection, and reindent