Added null check to prevent crashes with certain mods