Need reimplementation (w/o FSM).