Worked on state machine. Seems ok.