diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp
index 6b79f3ab7e..97debd3298 100644
--- a/apps/openmw/mwclass/npc.cpp
+++ b/apps/openmw/mwclass/npc.cpp
@@ -2,6 +2,7 @@
 
 #include <MyGUI_TextIterator.h>
 
+#include <cassert>
 #include <memory>
 
 #include <components/misc/constants.hpp>
@@ -93,8 +94,10 @@ namespace
         int level = creatureStats.getLevel();
         for (const ESM::Attribute& attribute : attributes)
         {
-            const ESM::Race::MaleFemale& value
-                = race->mData.mAttributeValues[static_cast<size_t>(ESM::Attribute::refIdToIndex(attribute.mId))];
+            auto index = ESM::Attribute::refIdToIndex(attribute.mId);
+            assert(index >= 0);
+
+            const ESM::Race::MaleFemale& value = race->mData.mAttributeValues[static_cast<size_t>(index)];
             creatureStats.setAttribute(attribute.mId, male ? value.mMale : value.mFemale);
         }
 
diff --git a/apps/openmw/mwmechanics/magiceffects.cpp b/apps/openmw/mwmechanics/magiceffects.cpp
index 0d626c9e11..477e8b36a6 100644
--- a/apps/openmw/mwmechanics/magiceffects.cpp
+++ b/apps/openmw/mwmechanics/magiceffects.cpp
@@ -48,9 +48,9 @@ namespace MWMechanics
     std::string EffectKey::toString() const
     {
         const auto& store = MWBase::Environment::get().getESMStore();
-        const ESM::MagicEffect* magicEffect = store->get<ESM::MagicEffect>().search(mId);
+        const ESM::MagicEffect* magicEffect = store->get<ESM::MagicEffect>().find(mId);
         return getMagicEffectString(
-            *magicEffect, store->get<ESM::Attribute>().search(mArg), store->get<ESM::Skill>().search(mArg));
+            *magicEffect, store->get<ESM::Attribute>().find(mArg), store->get<ESM::Skill>().find(mArg));
     }
 
     bool operator<(const EffectKey& left, const EffectKey& right)
diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp
index ff720345bc..36ff9db7ac 100644
--- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp
+++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp
@@ -1,5 +1,7 @@
 #include "mechanicsmanagerimp.hpp"
 
+#include <cassert>
+
 #include <osg/Stats>
 
 #include <components/misc/rng.hpp>
@@ -150,9 +152,10 @@ namespace MWMechanics
 
             for (const ESM::Attribute& attribute : esmStore.get<ESM::Attribute>())
             {
-                const ESM::Race::MaleFemale& value
-                    = race->mData.mAttributeValues[static_cast<size_t>(ESM::Attribute::refIdToIndex(attribute.mId))];
+                auto index = ESM::Attribute::refIdToIndex(attribute.mId);
+                assert(index >= 0);
 
+                const ESM::Race::MaleFemale& value = race->mData.mAttributeValues[static_cast<size_t>(index)];
                 creatureStats.setAttribute(attribute.mId, male ? value.mMale : value.mFemale);
             }
 
diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp
index 3427e460c3..1ee463e622 100644
--- a/apps/openmw/mwmechanics/npcstats.cpp
+++ b/apps/openmw/mwmechanics/npcstats.cpp
@@ -488,7 +488,12 @@ void MWMechanics::NpcStats::writeState(ESM::NpcStats& state) const
 
     state.mSkillIncrease.fill(0);
     for (const auto& [key, value] : mSkillIncreases)
-        state.mSkillIncrease[static_cast<size_t>(ESM::Attribute::refIdToIndex(key))] = value;
+    {
+        // TODO extend format
+        auto index = ESM::Attribute::refIdToIndex(key);
+        assert(index >= 0);
+        state.mSkillIncrease[static_cast<size_t>(index)] = value;
+    }
 
     for (size_t i = 0; i < state.mSpecIncreases.size(); ++i)
         state.mSpecIncreases[i] = mSpecIncreases[i];
diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp
index ff6752358e..61de2ab90d 100644
--- a/apps/openmw/mwworld/cellstore.cpp
+++ b/apps/openmw/mwworld/cellstore.cpp
@@ -556,7 +556,7 @@ namespace MWWorld
         return false;
     }
 
-    CellStore::CellStore(MWWorld::Cell cell, const MWWorld::ESMStore& esmStore, ESM::ReadersCache& readers)
+    CellStore::CellStore(MWWorld::Cell&& cell, const MWWorld::ESMStore& esmStore, ESM::ReadersCache& readers)
         : mStore(esmStore)
         , mReaders(readers)
         , mCellVariant(std::move(cell))
diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp
index 496e98bf1a..23bd071ff1 100644
--- a/apps/openmw/mwworld/cellstore.hpp
+++ b/apps/openmw/mwworld/cellstore.hpp
@@ -140,7 +140,7 @@ namespace MWWorld
         }
 
         /// @param readerList The readers to use for loading of the cell on-demand.
-        CellStore(MWWorld::Cell cell, const MWWorld::ESMStore& store, ESM::ReadersCache& readers);
+        CellStore(MWWorld::Cell&& cell, const MWWorld::ESMStore& store, ESM::ReadersCache& readers);
 
         CellStore(const CellStore&) = delete;
 
diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp
index d76dc36c15..e643f947aa 100644
--- a/apps/openmw/mwworld/containerstore.cpp
+++ b/apps/openmw/mwworld/containerstore.cpp
@@ -159,9 +159,16 @@ MWWorld::ContainerStore::ContainerStore()
 
 MWWorld::ContainerStore::~ContainerStore()
 {
-    MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
-    for (MWWorld::ContainerStoreIterator iter(begin()); iter != end(); ++iter)
-        worldModel->deregisterPtr(*iter);
+    try
+    {
+        MWWorld::WorldModel* worldModel = MWBase::Environment::get().getWorldModel();
+        for (MWWorld::ContainerStoreIterator iter(begin()); iter != end(); ++iter)
+            worldModel->deregisterPtr(*iter);
+    }
+    catch (const std::exception& e)
+    {
+        Log(Debug::Error) << "Failed to deregister container store: " << e.what();
+    }
 }
 
 MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cbegin(int mask) const
diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp
index a4b8548e52..6e5b56d9ff 100644
--- a/apps/openmw/mwworld/store.cpp
+++ b/apps/openmw/mwworld/store.cpp
@@ -1017,11 +1017,12 @@ namespace MWWorld
     void Store<ESM::GameSetting>::setUp()
     {
         auto addSetting = [&](const std::string& key, ESM::Variant value) {
+            auto id = ESM::RefId::stringRefId(key);
             ESM::GameSetting setting;
             setting.blank();
-            setting.mId = ESM::RefId::stringRefId(key);
+            setting.mId = id;
             setting.mValue = std::move(value);
-            auto [iter, inserted] = mStatic.insert_or_assign(setting.mId, std::move(setting));
+            auto [iter, inserted] = mStatic.insert_or_assign(id, std::move(setting));
             if (inserted)
                 mShared.push_back(&iter->second);
         };