Feature/state transition machine

See above