Improved handling of callbacks with events