removed some explicit TMS transitions, added check_state()