Refactored code to put the callback registration in TemporalEngine instead of each state object, since it will most likely be common code.