Defined a small, simple state machine
It should kind of work now, though I'm getting a weird warning
Will commit again later...