State machine to detect changes of events.