Added a helper function to dispatch entity modified events and arrays of events.