Added fix to hopefully prevent crashes