diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index 83efb9eb52a578af86c334c0da8a633d087b992f..a5ceaf051c159e02537c7285687f5d8f630769d5 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -139,6 +139,9 @@
 <<if def $eventSlaves>>
 	<<unset $eventSlaves>>
 <</if>>
+<<if def $place>>
+	<<unset $place>>
+<</if>>
 
 /* pregmod stuff */
 
diff --git a/src/uncategorized/nextSlaveInLine.tw b/src/uncategorized/nextSlaveInLine.tw
index 26d49052a6ec35ce55485ec3c5ac51e9180731d8..8149ceb874272eefd16d1b25f04427b722d09daa 100644
--- a/src/uncategorized/nextSlaveInLine.tw
+++ b/src/uncategorized/nextSlaveInLine.tw
@@ -2,15 +2,11 @@
 
 <<silently>>
 
-<<set $i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
+<<set $i = $slaveIndices[$activeSlave.ID]>>
 <<ClearSummaryCache $activeSlave>>
 <<set $slaves[$i] = $activeSlave>> /* save changes before switching */
 
-<<if $place == $slavesInLine.length-1>>
-	<<set $activeSlave = $slavesInLine[0]>>
-<<else>>
-	<<set $activeSlave = $slavesInLine[$place+1]>>
-<</if>>
+<<set $activeSlave = $slaves[$slavesInLine[1]]>>
 
 <<goto "Slave Interact">>
 
diff --git a/src/uncategorized/placeInLine.tw b/src/uncategorized/placeInLine.tw
index 4cd42eb226f2ee4eee7a092830f24ab95277f9e8..30ac0fdf046b140a3945b03cfdc0216487c6860c 100644
--- a/src/uncategorized/placeInLine.tw
+++ b/src/uncategorized/placeInLine.tw
@@ -3,21 +3,52 @@
 <<silently>>
 
 <<set $slavesInLine = []>>
+<<set _activeSlaveIndex = $slaveIndices[$activeSlave.ID]>>
+<<set _SL = $slaves.length>>
 
 <<if ($activeSlave.assignmentVisible == 1)>>
-	<<for $i = 0; $i < $slaves.length; $i++>>
-	<<if ($slaves[$i].assignmentVisible == 1)>>
-		<<set $slavesInLine.push($slaves[$i])>>
-	<</if>>
+	<<for _pil = _activeSlaveIndex - 1; _pil != _activeSlaveIndex; _pil-->> /* loops backwards through the $slaves array */
+		<<if _pil < 0>>
+			<<set _pil = _SL - 1>>
+		<</if>>
+		<<if $slaves[_pil].assignmentVisible == 1>>
+			<<set $slavesInLine.push(_pil)>> /* index of the previous slave in line */
+			<<break>>
+		<</if>>
+	<</for>>
+	<<for _pil = _activeSlaveIndex + 1; _pil != _activeSlaveIndex; _pil++>> /* this loops forwards through the $slaves array */
+		<<if _pil == _SL>>
+			<<set _pil = 0>>
+		<</if>>
+		<<if $slaves[_pil].assignmentVisible == 1>>
+			<<set $slavesInLine.push(_pil)>> /* index of the next slave in line */
+			<<break>>
+		<</if>>
 	<</for>>
 <<else>>
-	<<for $i = 0; $i < $slaves.length; $i++>>
-	<<if ($slaves[$i].assignment == $activeSlave.assignment)>>
-		<<set $slavesInLine.push($slaves[$i])>>
-	<</if>>
+	<<for _pil = _activeSlaveIndex - 1; _pil != _activeSlaveIndex; _pil-->> /* loops backwards through the $slaves array */
+		<<if _pil < 0>>
+			<<set _pil = _SL - 1>>
+		<</if>>
+		<<if ($slaves[_pil].assignment == $activeSlave.assignment)>>
+			<<set $slavesInLine.push(_pil)>> /* index of the previous slave in line */
+			<<break>>
+		<</if>>
+	<</for>>
+	<<for _pil = _activeSlaveIndex + 1; _pil != _activeSlaveIndex; _pil++>> /* this loops forwards through the $slaves array */
+		<<if _pil == _SL>>
+			<<set _pil = 0>>
+		<</if>>
+		<<if ($slaves[_pil].assignment == $activeSlave.assignment)>>
+			<<set $slavesInLine.push(_pil)>> /* index of the next slave in line */
+			<<break>>
+		<</if>>
 	<</for>>
 <</if>>
 
-<<set $place = $slavesInLine.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
+<<if $slavesInLine.length == 0>> /* if there are no other slaves available, set previous/next slave to self */
+	<<set $slavesInLine[0] = _activeSlaveIndex>>
+	<<set $slavesInLine[1] = _activeSlaveIndex>>
+<</if>>
 
 <</silently>>
diff --git a/src/uncategorized/previousSlaveInLine.tw b/src/uncategorized/previousSlaveInLine.tw
index d8c858a33473f87f912b1b0221cd05dd9b0bc7a7..008ccb819a4a11d80f23e05299820fb4256d5d66 100644
--- a/src/uncategorized/previousSlaveInLine.tw
+++ b/src/uncategorized/previousSlaveInLine.tw
@@ -2,15 +2,11 @@
 
 <<silently>>
 
-<<set $i = $slaves.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
+<<set $i = $slaveIndices[$activeSlave.ID]>>
 <<ClearSummaryCache $activeSlave>>
 <<set $slaves[$i] = $activeSlave>> /* save changes before switching */
 
-<<if $place == 0>>
-	<<set $activeSlave = $slavesInLine[$slavesInLine.length-1]>>
-<<else>>
-	<<set $activeSlave = $slavesInLine[$place-1]>>
-<</if>>
+<<set $activeSlave = $slaves[$slavesInLine[0]]>>
 
 <<goto "Slave Interact">>