Added a stateMachine creation global function