Added the button state machine.