State machine clean up