Simple state machine and main controller