Cleaning up the event wrapping code