Updated to use latest state machine library