Move from Finite to SM
Fixes and updates
Merge pull request #1563 from winzou/state-machine

Move from Finite to SM