Port of robotlegs-utilities-StateMachine originally created by Joel Hooks.