Fixed issue with dispatching events.