StateMachine now working properly.