Corrected bugs in button debouncing code