Fixed button debouncing code.