Generic events mechanism and minor cleanups
See individual commits. This is a refactoring for gitlab-org/gitlab#415632 (closed) and some minor optimizations and cleanups.
See individual commits. This is a refactoring for gitlab-org/gitlab#415632 (closed) and some minor optimizations and cleanups.