Added a simple state machine.