Event refactoring, some perf optimizations.