Added some debug facilities and used that to fix a bug in an EventDispatcher method.