lots of event-related refactoring