Switch to using fsm for mode transitions