EventDispatcher refactor and changes to exception types and shutdown wor...

Mainly a change to the EventDispatcher class to implement suggestions from Ignasi.
Wrong exception types were being used in a number of places.