Fix uncaught exceptions