start refactor of StateMachine
End of state machine builder refactoring.

Complete attribute based state machine