Fixing a crash caused by incorrectly handled exceptions