Changed state machine to better reflect the actual states