Compiles and runs with generic events. Needs more testing.