Mod: got rid of jquery for state machine.