Correctly handle adding and removing statemachines
Set the priority of deferred events one level below max