Fixed dialyzer warnings.
Improved FSM behaviour.