Add some further refactorings to event generation process