Event refactoring, some perf optimizations.

(Spin on #363)