Made the state change debug text better and fixed a critical bug with the state machine