Implement full state machine, #12