Added logging for uncaught exceptions