Fixing behaviour of uncaught exceptions