Finished draft for the statemachine

Testing later today