Added more exception handling around event handlers