The event dispatcher is optional; check it exists before using it

Quick fix for issue #3.