Some major refactoring for event publishing