Correct bugs in fsm_template