Fix broken eventlisten and small refactor.
Merge pull request #12084 from cachedout/12079

Fix broken eventlisten and small refactor.