Added checks for invalid pointers to find the problematic crash when exporting owl files