fix fsm bugs.