Hardening the event system for the before and error event so that events are not emitted twice that are encountered during the before event