Refactor event handling

Create *Event classes and pass instances to on_event.