Added handling in the state machine to compact events into a single
event if the transition results in an ending state that is the same as
the starting state.