First implementations of the FSM. Tests are coming...