Added state machine.