Semi-working state machine.