diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index 826336b85b7bf743f5e2d44340f3fedffb50acd8..d32802dc7fce45330a32fcf8e6efccc7f8835397 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -70,7 +70,7 @@ You should have received a copy of the GNU General Public License along with thi
 		<</if>>
 		<<set $slaves[_i].rivalry = 0, $slaves[_i].rivalryTarget = 0, $slaves[_i].subTarget = 0>>
 	<<else>>
-		<<set _dump = $slaves.deleteAt(_i), _i--, _SL-->>
+		<<set _dump = removeSlave(_i), _i--, _SL-->>
 	<</if>>
 	<</for>>
 	<<for _k = 0; _k < _SL; _k++>>
@@ -240,6 +240,7 @@ You should have received a copy of the GNU General Public License along with thi
 	<<set $genePool = []>>
 <</if>>
 
+<<set $slaveIndices = slaves2indices()>>
 <<set $organs = []>>
 <<set $ArcadeiIDs = [], $BrothiIDs = [], $CellBiIDs = [], $CliniciIDs = [], $ClubiIDs = [], $DairyiIDs = [], $HGSuiteiIDs = [], $MastSiIDs = [], $SchlRiIDs = [], $ServQiIDs = [], $SpaiIDs = [], $FacSupIDs = []>>
 
diff --git a/src/js/assayJS.tw b/src/js/assayJS.tw
index c89035b3ab3dbe1bd53cf4d04a55ac339ad48509..56a9667e890841ae9f1c6e9b5f52e0cac3b30444 100644
--- a/src/js/assayJS.tw
+++ b/src/js/assayJS.tw
@@ -214,3 +214,25 @@ window.supremeRaceP = function supremeRaceP(slave) {
 window.inferiorRaceP = function inferiorRaceP(slave) {
 	return State.variables.arcologies[0].FSSubjugationistRace === slave.race
 }
+
+window.addSlave = function addSlave(slave) {
+	State.variables.slaves.push(slave);
+	State.variables.slaveIndices[slave.id] = State.variables.slaves.length - 1;
+};
+
+window.removeSlave = function removeSlave(index) {
+	delete State.variables.slaveIndices[State.variables.slaves[index].id];
+	return State.variables.slaves.deleteAt(index);
+};
+
+window.slaves2indices = function slaves2indices() {
+	const obj = {};
+	State.variables.slaves.forEach((slave, i) => obj[slave.id] = i);
+	return obj;
+};
+
+window.getSlave = function getSlave(ID) {
+	const index = State.variables.slaveIndices[ID];
+	if (index === undefined) return null;
+	else return State.variables.slaves[State.variables.slaveIndices[ID]];
+};
diff --git a/src/js/fresult.tw b/src/js/fresult.tw
index 861a46cca1c87be0491256c77e88ee1212a79438..22141b5042510ce5158ded803c364ff0d3e43d1e 100644
--- a/src/js/fresult.tw
+++ b/src/js/fresult.tw
@@ -91,27 +91,23 @@ window.FResult = (function() {
 	}
 
 	function calcWorksWithRelativesVanilla(slave) {
-		const fre = V.slaves.findIndex(s => {
-			return haveRelationP(slave, s) && sameAssignmentP(slave, s);
-		});
-		if (fre !== -1) {
+		const fre = getSlave(slave.relationTarget)
+		if (free !== null && sameAssignmentP(slave, fre))
 			V.FResult += 2;
 			if (incest_bonus) V.FResult += 2;
 		}
 	}
 
 	function calcWorksWithRelationship(slave) {
-		const fre = V.slaves.findIndex(s => {
-			return haveRelationshipP(slave, s) && sameAssignmentP(slave, s);
-		});
-		if (fre !== -1) V.FResult += 1;
+		const fre = getSlave(slave.relationshipTarget)
+		if (fre !== null && sameAssignmentP(slave, fre))
+			V.FResult += 1;
 	}
 	
 	function calcWorksWithRival(slave) {
-		const en = V.slaves.findIndex(s => {
-			return isRivalP(slave, s) && sameAssignmentP(slave, s);
-		});
-		if (en !== -1) V.FResult -= 1;
+		const en = getSlave(slave.rivalryTarget)
+		if (en !== null && sameAssignmentP(slave, en))
+			V.FResult -= 1;
 	}
 
 	function calcHInjectionsDiet(slave) {
diff --git a/src/npc/removeActiveSlave.tw b/src/npc/removeActiveSlave.tw
index c7e2ee0387c82b534d3ae03f810ffff0cfc90dfd..cf8ee8ab4346d335144e36b10e6c05673bd742a9 100644
--- a/src/npc/removeActiveSlave.tw
+++ b/src/npc/removeActiveSlave.tw
@@ -143,7 +143,7 @@
 		<<set $limbs.deleteAt(_o)>>
 	<</if>>
 	
-	<<set _dump = $slaves.deleteAt(_x), _SL--, $activeSlave = 0>>
+	<<set _dump = removeSlave(_x), _SL--, $activeSlave = 0>>
 	
 	<<if _missingID == 1>>
 		<<set $missingParentID-->>
diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw
index 4d6a56df85467369696d390be59f37f60feda4ef..0555cdb92a0d14cf8426a19692254791f24897c7 100644
--- a/src/utility/miscWidgets.tw
+++ b/src/utility/miscWidgets.tw
@@ -1737,7 +1737,7 @@
 	<<set $REReductionCheckinIDs.push($args[0].ID)>>
 <</if>>
 
-<<set $slaves.push($args[0])>>
+<<set addSlave($args[0])>>
 <<if $args[0].origin != "She was your slave, but you freed her, which she repaid by participating in a coup attempt against you. It failed, and she is again your chattel.">>
 	<<set $genePool.push($args[0])>>
 <<else>>
@@ -2059,9 +2059,9 @@ This experience
 			<<set $args[0] = $args[0].sort(function(a, b){return b.devotion-a.devotion})>>
 		<</if>>
 	<</switch>>
+	<<set $slaveIndices = slaves2indices()>>
 <<else>>
-	<<set $slaveIndices = {}>>
-	<<set $slaves.forEach(function(s, i) { $slaveIndices[s.ID] = i; })>>
+	<<set $slaveIndices = slaves2indices()>>
 	<<set filterInPlace($args[0], function(s) { return $slaveIndices[s] !== undefined; })>>
 	<<set $args[0].sort(function(a, b) { return $slaveIndices[a] - $slaveIndices[b]; })>>
 <</if>>