Fix crashes sometimes with generate_ore.