Events 2.0

This removes the macro-style code generation in Events to a templated and safer API.