Altered the event generation code slightly.