Refactor debouncing code to hopefully be a little more durable across interrupts