Improving handling of uncaught exceptions