bug fixes in new state machine