Moved event dispatching in to its own method.