Fix uncaught exception crash