Patched event handler to check for null listeners