State machine

The state machine is super fast now and I believe does everything we need.