Improve handling of events