diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp
index b4bd0d7387..6c4e00ae5c 100644
--- a/apps/openmw/mwgui/statswindow.cpp
+++ b/apps/openmw/mwgui/statswindow.cpp
@@ -488,14 +488,16 @@ namespace MWGui
                     text += "\n#BF9959#{sExpelled}";
                 else
                 {
-                    text += std::string("\n#BF9959") + faction->mRanks[it->second];
+                    int rank = it->second;
+                    rank = std::max(0, std::min(9, rank));
+                    text += std::string("\n#BF9959") + faction->mRanks[rank];
 
-                    if (it->second < 9)
+                    if (rank < 9)
                     {
                         // player doesn't have max rank yet
-                        text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1];
+                        text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[rank+1];
 
-                        ESM::RankData rankData = faction->mData.mRankData[it->second+1];
+                        ESM::RankData rankData = faction->mData.mRankData[rank+1];
                         const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[0]);
                         const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[1]);
 
diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp
index a3bc223aa6..5a0cd8ae68 100644
--- a/apps/openmw/mwscript/statsextensions.cpp
+++ b/apps/openmw/mwscript/statsextensions.cpp
@@ -587,7 +587,9 @@ namespace MWScript
                         }
                         else
                         {
-                            player.getClass().getNpcStats(player).getFactionRanks()[factionID] = player.getClass().getNpcStats(player).getFactionRanks()[factionID] +1;
+                            player.getClass().getNpcStats(player).getFactionRanks()[factionID] =
+                                    std::min(player.getClass().getNpcStats(player).getFactionRanks()[factionID] +1,
+                                             9);
                         }
                     }
                 }