Fix problems with dispatching events.