Account for undefined before/afterListeners