diff --git a/src/events/intro/introSummary.tw b/src/events/intro/introSummary.tw
index 47b6f0806c8d92508db510e8516ad7afae250cc0..d94cb4ca98e62d305942b710fd522ba44c5419ef 100644
--- a/src/events/intro/introSummary.tw
+++ b/src/events/intro/introSummary.tw
@@ -286,6 +286,14 @@ __''Slave age settings''__
 
 <br>
 
+<<options $pedo_mode>>
+	<<option 0 "Normal mode">>
+		Randomly generated slaves will generate normally.
+	<<option 1 "Loli mode" "$minimumSlaveAge = 5">>
+		Nearly all randomly generated slaves will be under the age of 18, although custom slaves and slaves related to specific events may be older.
+<</options>>
+<br>
+
 <<if $minimumSlaveAge < 3>>
 	<<set $minimumSlaveAge = 3>>
 <<elseif $minimumSlaveAge < 18>>
@@ -323,13 +331,6 @@ __''Slave age settings''__
 	<<comment>>
 		May cause issues with New Game and initial slaves if set below 45.
 <</options>>
-<br>
-<<options $pedo_mode>>
-	<<option 0 "Normal mode">>
-		Randomly generated slaves will generate normally.
-	<<option 1 "Loli mode" "$minimumSlaveAge = 5">>
-		Nearly all randomly generated slaves will be under the age of 18, although custom slaves and slaves related to specific events may be older.
-<</options>>
 
 <br>
 <<if $fertilityAge < 3>>
@@ -573,7 +574,6 @@ __''The Free City''__
 	<<comment>>
 		<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		5 is default, 4 behaves the same as pre-patch 0.9.9.0, max is 7.
-		Make sure to hit enter to confirm.
 		This option cannot be changed during the game
 <</options>>
 
diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw
index 9f96d205aae06983d48a63cb8ead06e5c6197b27..d0d4bc172409e54b4c0b1cf841e21de24817df14 100644
--- a/src/init/storyInit.tw
+++ b/src/init/storyInit.tw
@@ -142,7 +142,7 @@ You should have received a copy of the GNU General Public License along with thi
 		<<if $slaves[_i].relation != 0>>
 			<<set _seed = 0, _rt = $slaves[_i].relationTarget, _ID = $slaves[_i].ID>>
 			<<set _j = $slaveIndices[_rt]>>
-			<<if def _j && $slaves[_j].relationTarget == _ID>>
+			<<if (def _j) && $slaves[_j].relationTarget == _ID>>
 				<<set _seed = 1>>
 			<</if>>
 			<<if _seed == 0>>
@@ -152,7 +152,7 @@ You should have received a copy of the GNU General Public License along with thi
 		<<if $slaves[_i].relationship > 0>>
 			<<set _seed = 0, _rt = $slaves[_i].relationshipTarget, _ID = $slaves[_i].ID>>
 			<<set _j = $slaveIndices[_rt]>>
-			<<if def _j && $slaves[_j].relationshipTarget == _ID>>
+			<<if (def _j) && $slaves[_j].relationshipTarget == _ID>>
 				<<set _seed = 1>>
 			<</if>>
 			<<if _seed == 0>>
diff --git a/src/npc/descriptions/fLips.tw b/src/npc/descriptions/fLips.tw
index cc147ebc4e224abec364cdd0a6a496e2b9b53e46..d02470336760556ba153e3cf5701789442150eae 100644
--- a/src/npc/descriptions/fLips.tw
+++ b/src/npc/descriptions/fLips.tw
@@ -176,7 +176,7 @@ You tell $activeSlave.slaveName to
 
 <<if passage() != "Slave Interact">>
 	<<set _fl = $slaveIndices[$activeSlave.ID]>>
-	<<if def _fl != -1>>
+	<<if def _fl>>
 		<<set $slaves[_fl] = $activeSlave>>
 	<</if>>
 <</if>>
diff --git a/src/pregmod/hotswapprosthetics.tw b/src/pregmod/hotswapprosthetics.tw
index 9bdaf2764f084ce469976c53b19dd70db8288094..638b62ea01229c4b69f54f1847089f67e183cc25 100644
--- a/src/pregmod/hotswapprosthetics.tw
+++ b/src/pregmod/hotswapprosthetics.tw
@@ -38,7 +38,7 @@
 			<<include "Hotswap Prosthetics">>
 			<</replace>>
 		<</link>>
-	<<elseif def $activeLimbs && $activeLimbs.type == "simple" && $activeSlave.ID == $activeLimbs.ID>>
+	<<elseif (def $activeLimbs) && $activeLimbs.type == "simple" && $activeSlave.ID == $activeLimbs.ID>>
 		//Basic P-limbs being built
 	<<else>>
 		//Basic prostheses unavailable
@@ -59,7 +59,7 @@
 			<<include "Hotswap Prosthetics">>
 			<</replace>>
 		<</link>>
-	<<elseif def $activeLimbs && $activeLimbs.type == "sex" && $activeSlave.ID == $activeLimbs.ID>>
+	<<elseif (def $activeLimbs) && $activeLimbs.type == "sex" && $activeSlave.ID == $activeLimbs.ID>>
 		//Sex focused P-limbs being built
 	<<else>>
 		//Sex focused prostheses unavailable
@@ -80,7 +80,7 @@
 			<<include "Hotswap Prosthetics">>
 			<</replace>>
 		<</link>>
-	<<elseif def $activeLimbs && $activeLimbs.type == "beauty" && $activeSlave.ID == $activeLimbs.ID>>
+	<<elseif (def $activeLimbs) && $activeLimbs.type == "beauty" && $activeSlave.ID == $activeLimbs.ID>>
 		//Natural looking P-limbs being built
 	<<else>>
 		//Natural looking prostheses unavailable
@@ -101,7 +101,7 @@
 			<<include "Hotswap Prosthetics">>
 			<</replace>>
 		<</link>>
-	<<elseif def $activeLimbs && $activeLimbs.type == "combat" && $activeSlave.ID == $activeLimbs.ID>>
+	<<elseif (def $activeLimbs) && $activeLimbs.type == "combat" && $activeSlave.ID == $activeLimbs.ID>>
 		//Combat P-limbs being built
 	<<else>>
 		//Combat prostheses unavailable
@@ -122,7 +122,7 @@
 			<<include "Hotswap Prosthetics">>
 			<</replace>>
 		<</link>>
-	<<elseif def $activeLimbs && $activeLimbs.type == "cyber" && $activeSlave.ID == $activeLimbs.ID>>
+	<<elseif (def $activeLimbs) && $activeLimbs.type == "cyber" && $activeSlave.ID == $activeLimbs.ID>>
 		//Cybernetic P-limbs being built
 	<<else>>
 		//Cybernetic prostheses unavailable
diff --git a/src/pregmod/killedSlave.tw b/src/pregmod/killedSlave.tw
index 71174090cda915aa16331f451eaf9e78d93fc50d..62d0d155fec78005f172c21a22159e26ad4cd804 100644
--- a/src/pregmod/killedSlave.tw
+++ b/src/pregmod/killedSlave.tw
@@ -84,7 +84,7 @@ $activeSlave.slaveName gives an audible sigh of relief and begins to thank you p
 		<<else>>
 			<<if $activeSlave.relation != 0>>
 				<<set _ss = $slaveIndices[$activeSlave.relationTarget]>>
-				<<if def _ss && $slaves[_ss].fetish != "mindbroken">>
+				<<if (def _ss) && $slaves[_ss].fetish != "mindbroken">>
 					$slaves[_ss].slaveName is @@.mediumorchid;grieved@@ that you have killed $his $activeSlave.relation.
 					<<run clearSummaryCache($slaves[_ss])>>
 					<br><br>
@@ -95,7 +95,7 @@ $activeSlave.slaveName gives an audible sigh of relief and begins to thank you p
 		<</if>>
 		<<if $activeSlave.relationship > 0>>
 			<<set _ss = $slaveIndices[$activeSlave.relationshipTarget]>>
-			<<if def _ss && $slaves[_ss].fetish != "mindbroken">>
+			<<if (def _ss) && $slaves[_ss].fetish != "mindbroken">>
 				$slaves[_ss].slaveName is @@.mediumorchid;grieved@@ that you have killed $his best source of comfort and companionship in a life of bondage.
 				<<run clearSummaryCache($slaves[_ss])>>
 				<br><br>
@@ -116,7 +116,7 @@ $activeSlave.slaveName gives an audible sigh of relief and begins to thank you p
 		<</if>>
 		<<if $activeSlave.rivalry != 0>>
 			<<set _ss = $slaveIndices[$activeSlave.rivalryTarget]>>
-			<<if def _ss && $slaves[_ss].fetish != "mindbroken">>
+			<<if (def _ss) && $slaves[_ss].fetish != "mindbroken">>
 				$slaves[_ss].slaveName is @@.hotpink;pleased@@ that $he won't have to see $his rival any more.
 				<<run clearSummaryCache($slaves[_ss])>>
 				<br><br>
diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw
index 78a049d3f9c79b6334efd87c88425ce80d865289..c2c8ca1991d7d1757c49086cb9eebdab8abf9b2e 100644
--- a/src/uncategorized/BackwardsCompatibility.tw
+++ b/src/uncategorized/BackwardsCompatibility.tw
@@ -49,11 +49,11 @@
 	<<unset $badNames>>
 <</if>>
 
-<<if def $origin || def $origins>>
+<<if (def $origin) || def $origins>>
 	<<unset $origin, $origins>>
 <</if>>
 
-<<if def $hare1 || def $hareSpeed1>>
+<<if (def $hare1) || def $hareSpeed1>>
 	<<unset $hare1, $hare2, $hare3, $hareSpeed, $hareSpeed1, $hareSpeed2, $hareSpeed3, $origin1, $origin2, $origin3, $LurcherSpeed>>
 <</if>>
 
@@ -152,16 +152,16 @@
 <<if def $place>>
 	<<unset $place>>
 <</if>>
-<<if def $assayedSlave || def $assayedSlaveAvailable || def $assayType>>
+<<if (def $assayedSlave) || (def $assayedSlaveAvailable) || def $assayType>>
 	<<unset $assayedSlave, $assayedSlaveAvailable, $assayType>>
 <</if>>
-<<if def $RERepressedAnalVirginSub || def $REBoobCollisionSub || def $REIfYouEnjoyItSub || def $RESadisticDescriptionSub || def $REShowerForceSub>>
+<<if (def $RERepressedAnalVirginSub) || (def $REBoobCollisionSub) || (def $REIfYouEnjoyItSub) || (def $RESadisticDescriptionSub) || def $REShowerForceSub>>
 	<<unset $RERepressedAnalVirginSub, $REBoobCollisionSub, $REIfYouEnjoyItSub, $RESadisticDescriptionSub, $REShowerForceSub>>
 <</if>>
-<<if def $unmodded || def $modded || def $XX || def $XY || def $old || def $young || def $pregYes || def $pregNo || def $implanted || def $slimPass || def $slim || def $stacked>>
+<<if (def $unmodded) || (def $modded) || (def $XX) || (def $XY) || (def $old) || (def $young) || (def $pregYes) || (def $pregNo) || (def $implanted) || (def $slimPass) || (def $slim) || def $stacked>>
 	<<unset $unmodded, $modded, $XX, $XY, $old, $young, $pregYes, $pregNo, $implanted, $slimPass, $slim, $stacked>>
 <</if>>
-<<if def $recruiterMother || def $recruiterSister>>
+<<if (def $recruiterMother) || def $recruiterSister>>
 	<<unset $recruiterMother, $recruiterSister>>
 <</if>>
 <<if def $relations>>
@@ -176,19 +176,19 @@
 <<if def $piercingLocation>>
 	<<unset $piercingLocation>>
 <</if>>
-<<if def $target1 || def $target2 || def $target3>>
+<<if (def $target1) || (def $target2) || def $target3>>
 	<<unset $target1, $target2, $target3>>
 <</if>>
-<<if def $targetEscape1 || def $targetEscape2 || def $targetEscape3>>
+<<if (def $targetEscape1) || (def $targetEscape2) || def $targetEscape3>>
 	<<unset $targetEscape1, $targetEscape2, $targetEscape3>>
 <</if>>
-<<if def $oralCount || def $vaginalCount || def $analCount>>
+<<if (def $oralCount) || (def $vaginalCount) || def $analCount>>
 	<<unset $oralCount, $vaginalCount, $analCount>>
 <</if>>
-<<if def $fighterOne || def $fighterTwo>>
+<<if (def $fighterOne) || def $fighterTwo>>
 	<<unset $fighterOne, $fighterTwo>>
 <</if>>
-<<if def $fighterOneDeadliness || def $fighterTwoDeadliness>>
+<<if (def $fighterOneDeadliness) || def $fighterTwoDeadliness>>
 	<<unset $fighterOneDeadliness, $fighterTwoDeadliness>>
 <</if>>
 <<if def $adopted>>
@@ -197,13 +197,13 @@
 <<if def $fetishChangeChance>>
 	<<unset $fetishChangeChance>>
 <</if>>
-<<if def $titles || def $schoolsPresent || def $schoolsPerfected || def $schoolTitle>>
+<<if (def $titles) || (def $schoolsPresent) || (def $schoolsPerfected) || def $schoolTitle>>
 	<<unset $titles, $schoolsPresent, $schoolsPerfected, $schoolTitle>>
 <</if>>
 <<if def $appraiserGender>>
 	<<unset $appraiserGender>>
 <</if>>
-<<if def $assetDirection || def $assetAffected>>
+<<if (def $assetDirection) || def $assetAffected>>
 	<<unset $assetDirection, $assetAffected>>
 <</if>>
 <<if def $rents>>
@@ -1360,7 +1360,7 @@
 	<<set $arcologies[0].leaderID = 0>>
 <</if>>
 
-<<if def $FSSupremacist && $FSSupremacist != "unset">>
+<<if (def $FSSupremacist) && $FSSupremacist != "unset">>
 	<<set $arcologies[0].FSSupremacist = $FSSupremacist>>
 	<<set $arcologies[0].FSSupremacistRace = $FSSupremacistRace>>
 	<<unset $FSSupremacist>>
@@ -1368,7 +1368,7 @@
 <<elseif ndef $arcologies[0].FSSupremacist>>
 	<<set $arcologies[0].FSSupremacist = "unset">>
 <</if>>
-<<if def $FSSupremacistLawME && $FSSupremacistLawME != 0>>
+<<if (def $FSSupremacistLawME) && $FSSupremacistLawME != 0>>
 	<<set $arcologies[0].FSSupremacistLawME = $FSSupremacistLawME>>
 	<<unset $FSSupremacistLawME>>
 <<elseif ndef $arcologies[0].FSSupremacistLawME>>
@@ -1384,7 +1384,7 @@
 	<<set $arcologies[0].FSSupremacistRace = "mixed race">>
 <</if>>
 
-<<if def $FSSubjugationist && $FSSubjugationist != "unset">>
+<<if (def $FSSubjugationist) && $FSSubjugationist != "unset">>
 	<<set $arcologies[0].FSSubjugationist = $FSSubjugationist>>
 	<<set $arcologies[0].FSSubjugationistRace = $FSSubjugationistRace>>
 	<<unset $FSSubjugationist>>
@@ -1392,7 +1392,7 @@
 <<elseif ndef $arcologies[0].FSSubjugationist>>
 	<<set $arcologies[0].FSSubjugationist = "unset">>
 <</if>>
-<<if def $FSSubjugationistLawME && $FSSubjugationistLawME != 0>>
+<<if (def $FSSubjugationistLawME) && $FSSubjugationistLawME != 0>>
 	<<set $arcologies[0].FSSubjugationistLawME = $FSSubjugationistLawME>>
 	<<unset $FSSubjugationistLawME>>
 <<elseif ndef $arcologies[0].FSSubjugationistLawME>>
@@ -1408,42 +1408,42 @@
 	<<set $arcologies[0].FSSubjugationistRace = "mixed race">>
 <</if>>
 
-<<if def $FSDegradationist && $FSDegradationist != "unset">>
+<<if (def $FSDegradationist) && $FSDegradationist != "unset">>
 	<<set $arcologies[0].FSDegradationist = $FSDegradationist>>
 	<<unset $FSDegradationist>>
 <<elseif ndef $arcologies[0].FSDegradationist>>
 	<<set $arcologies[0].FSDegradationist = "unset">>
 <</if>>
 
-<<if def $FSDegradationistLaw && $FSDegradationistLaw != 0>>
+<<if (def $FSDegradationistLaw) && $FSDegradationistLaw != 0>>
 	<<set $arcologies[0].FSDegradationistLaw = $FSDegradationistLaw>>
 	<<unset $FSDegradationistLaw>>
 <<elseif ndef $arcologies[0].FSDegradationistLaw>>
 	<<set $arcologies[0].FSDegradationistLaw = 0>>
 <</if>>
 
-<<if def $FSPaternalist && $FSPaternalist != "unset">>
+<<if (def $FSPaternalist) && $FSPaternalist != "unset">>
 	<<set $arcologies[0].FSPaternalist = $FSPaternalist>>
 	<<unset $FSPaternalist>>
 <<elseif ndef $arcologies[0].FSPaternalist>>
 	<<set $arcologies[0].FSPaternalist = "unset">>
 <</if>>
 
-<<if def $FSPaternalistLaw && $FSPaternalistLaw != 0>>
+<<if (def $FSPaternalistLaw) && $FSPaternalistLaw != 0>>
 	<<set $arcologies[0].FSPaternalistLaw = $FSPaternalistLaw>>
 	<<unset $FSPaternalistLaw>>
 <<elseif ndef $arcologies[0].FSPaternalistLaw>>
 	<<set $arcologies[0].FSPaternalistLaw = 0>>
 <</if>>
 
-<<if def $FSGenderFundamentalist && $FSGenderFundamentalist != "unset">>
+<<if (def $FSGenderFundamentalist) && $FSGenderFundamentalist != "unset">>
 	<<set $arcologies[0].FSGenderFundamentalist = $FSGenderFundamentalist>>
 	<<unset $FSGenderFundamentalist>>
 <<elseif ndef $arcologies[0].FSGenderFundamentalist>>
 	<<set $arcologies[0].FSGenderFundamentalist = "unset">>
 <</if>>
 
-<<if def $FSGenderFundamentalistSMR && $FSGenderFundamentalistSMR != 0>>
+<<if (def $FSGenderFundamentalistSMR) && $FSGenderFundamentalistSMR != 0>>
 	<<set $arcologies[0].FSGenderFundamentalistSMR = $FSGenderFundamentalistSMR>>
 	<<unset $FSGenderFundamentalistSMR>>
 <<elseif ndef $arcologies[0].FSGenderFundamentalistSMR>>
@@ -1453,7 +1453,7 @@
 	<<run delete $arcologies[0].FSGenderFundamentalistLaw>>
 <</if>>
 
-<<if def $FSGenderRadicalist && $FSGenderRadicalist != "unset">>
+<<if (def $FSGenderRadicalist) && $FSGenderRadicalist != "unset">>
 	<<set $arcologies[0].FSGenderRadicalist = $FSGenderRadicalist>>
 	<<unset $FSGenderRadicalist>>
 <<elseif ndef $arcologies[0].FSGenderRadicalist>>
@@ -1475,42 +1475,42 @@
 	<<run delete $arcologies[0].FSGenderRadicalistSMR>>
 <</if>>
 
-<<if def $FSBodyPurist && $FSBodyPurist != "unset">>
+<<if (def $FSBodyPurist) && $FSBodyPurist != "unset">>
 	<<set $arcologies[0].FSBodyPurist = $FSBodyPurist>>
 	<<unset $FSBodyPurist>>
 <<elseif ndef $arcologies[0].FSBodyPurist>>
 	<<set $arcologies[0].FSBodyPurist = "unset">>
 <</if>>
 
-<<if def $FSBodyPuristLaw && $FSBodyPuristLaw != 0>>
+<<if (def $FSBodyPuristLaw) && $FSBodyPuristLaw != 0>>
 	<<set $arcologies[0].FSBodyPuristLaw = $FSBodyPuristLaw>>
 	<<unset $FSBodyPuristLaw>>
 <<elseif ndef $arcologies[0].FSBodyPuristLaw>>
 	<<set $arcologies[0].FSBodyPuristLaw = 0>>
 <</if>>
 
-<<if def $FSPhysicalIdealist && $FSPhysicalIdealist != "unset">>
+<<if (def $FSPhysicalIdealist) && $FSPhysicalIdealist != "unset">>
 	<<set $arcologies[0].FSPhysicalIdealist = $FSPhysicalIdealist>>
 	<<unset $FSPhysicalIdealist>>
 <<elseif ndef $arcologies[0].FSPhysicalIdealist>>
 	<<set $arcologies[0].FSPhysicalIdealist = "unset">>
 <</if>>
 
-<<if def $FSPhysicalIdealistSMR && $FSPhysicalIdealistSMR != 0>>
+<<if (def $FSPhysicalIdealistSMR) && $FSPhysicalIdealistSMR != 0>>
 	<<set $arcologies[0].FSPhysicalIdealistSMR = $FSPhysicalIdealistSMR>>
 	<<unset $FSPhysicalIdealistSMR>>
 <<elseif ndef $arcologies[0].FSPhysicalIdealistSMR>>
 	<<set $arcologies[0].FSPhysicalIdealistSMR = 0>>
 <</if>>
 
-<<if def $FSTransformationFetishist && $FSTransformationFetishist != "unset">>
+<<if (def $FSTransformationFetishist) && $FSTransformationFetishist != "unset">>
 	<<set $arcologies[0].FSTransformationFetishist = $FSTransformationFetishist>>
 	<<unset $FSTransformationFetishist>>
 <<elseif ndef $arcologies[0].FSTransformationFetishist>>
 	<<set $arcologies[0].FSTransformationFetishist = "unset">>
 <</if>>
 
-<<if def $FSTransformationFetishistSMR && $FSTransformationFetishistSMR != 0>>
+<<if (def $FSTransformationFetishistSMR) && $FSTransformationFetishistSMR != 0>>
 	<<set $arcologies[0].FSTransformationFetishistSMR = $FSTransformationFetishistSMR>>
 	<<unset $FSTransformationFetishistSMR>>
 <<elseif ndef $arcologies[0].FSTransformationFetishistSMR>>
@@ -1520,14 +1520,14 @@
 	<<run delete $arcologies[0].FSTransformationFetishistLaw>>
 <</if>>
 
-<<if def $FSAssetExpansionist && $FSAssetExpansionist != "unset">>
+<<if (def $FSAssetExpansionist) && $FSAssetExpansionist != "unset">>
 	<<set $arcologies[0].FSAssetExpansionist = $FSAssetExpansionist>>
 	<<unset $FSAssetExpansionist>>
 <<elseif ndef $arcologies[0].FSAssetExpansionist>>
 	<<set $arcologies[0].FSAssetExpansionist = "unset">>
 <</if>>
 
-<<if def $FSAssetExpansionistSMR && $FSAssetExpansionistSMR != 0>>
+<<if (def $FSAssetExpansionistSMR) && $FSAssetExpansionistSMR != 0>>
 	<<set $arcologies[0].FSAssetExpansionistSMR = $FSAssetExpansionistSMR>>
 	<<unset $FSAssetExpansionistSMR>>
 <<elseif ndef $arcologies[0].FSAssetExpansionistSMR>>
@@ -1537,98 +1537,98 @@
 	<<run delete $arcologies[0].FSAssetExpansionistLaw>>
 <</if>>
 
-<<if def $FSSlimnessEnthusiast && $FSSlimnessEnthusiast != "unset">>
+<<if (def $FSSlimnessEnthusiast) && $FSSlimnessEnthusiast != "unset">>
 	<<set $arcologies[0].FSSlimnessEnthusiast = $FSSlimnessEnthusiast>>
 	<<unset $FSSlimnessEnthusiast>>
 <<elseif ndef $arcologies[0].FSSlimnessEnthusiast>>
 	<<set $arcologies[0].FSSlimnessEnthusiast = "unset">>
 <</if>>
 
-<<if def $FSSlimnessEnthusiastSMR && $FSSlimnessEnthusiastSMR != 0>>
+<<if (def $FSSlimnessEnthusiastSMR) && $FSSlimnessEnthusiastSMR != 0>>
 	<<set $arcologies[0].FSSlimnessEnthusiastSMR = $FSSlimnessEnthusiastSMR>>
 	<<unset $FSSlimnessEnthusiastSMR>>
 <<elseif ndef $arcologies[0].FSSlimnessEnthusiastSMR>>
 	<<set $arcologies[0].FSSlimnessEnthusiastSMR = 0>>
 <</if>>
 
-<<if def $FSMaturityPreferentialist && $FSMaturityPreferentialist != "unset">>
+<<if (def $FSMaturityPreferentialist) && $FSMaturityPreferentialist != "unset">>
 	<<set $arcologies[0].FSMaturityPreferentialist = $FSMaturityPreferentialist>>
 	<<unset $FSMaturityPreferentialist>>
 <<elseif ndef $arcologies[0].FSMaturityPreferentialist>>
 	<<set $arcologies[0].FSMaturityPreferentialist = "unset">>
 <</if>>
 
-<<if def $FSMaturityPreferentialistLaw && $FSMaturityPreferentialistLaw != 0>>
+<<if (def $FSMaturityPreferentialistLaw) && $FSMaturityPreferentialistLaw != 0>>
 	<<set $arcologies[0].FSMaturityPreferentialistLaw = $FSMaturityPreferentialistLaw>>
 	<<unset $FSMaturityPreferentialistLaw>>
 <<elseif ndef $arcologies[0].FSMaturityPreferentialistLaw>>
 	<<set $arcologies[0].FSMaturityPreferentialistLaw = 0>>
 <</if>>
 
-<<if def $FSYouthPreferentialist && $FSYouthPreferentialist != "unset">>
+<<if (def $FSYouthPreferentialist) && $FSYouthPreferentialist != "unset">>
 	<<set $arcologies[0].FSYouthPreferentialist = $FSYouthPreferentialist>>
 	<<unset $FSYouthPreferentialist>>
 <<elseif ndef $arcologies[0].FSYouthPreferentialist>>
 	<<set $arcologies[0].FSYouthPreferentialist = "unset">>
 <</if>>
 
-<<if def $FSYouthPreferentialistLaw && $FSYouthPreferentialistLaw != 0>>
+<<if (def $FSYouthPreferentialistLaw) && $FSYouthPreferentialistLaw != 0>>
 	<<set $arcologies[0].FSYouthPreferentialistLaw = $FSYouthPreferentialistLaw>>
 	<<unset $FSYouthPreferentialistLaw>>
 <<elseif ndef $arcologies[0].FSYouthPreferentialistLaw>>
 	<<set $arcologies[0].FSYouthPreferentialistLaw = 0>>
 <</if>>
 
-<<if def $FSPastoralist && $FSPastoralist != "unset">>
+<<if (def $FSPastoralist) && $FSPastoralist != "unset">>
 	<<set $arcologies[0].FSPastoralist = $FSPastoralist>>
 	<<unset $FSPastoralist>>
 <<elseif ndef $arcologies[0].FSPastoralist>>
 	<<set $arcologies[0].FSPastoralist = "unset">>
 <</if>>
 
-<<if def $FSPastoralistLaw && $FSPastoralistLaw != 0>>
+<<if (def $FSPastoralistLaw) && $FSPastoralistLaw != 0>>
 	<<set $arcologies[0].FSPastoralistLaw = $FSPastoralistLaw>>
 	<<unset $FSPastoralistLaw>>
 <<elseif ndef $arcologies[0].FSPastoralistLaw>>
 	<<set $arcologies[0].FSPastoralistLaw = 0>>
 <</if>>
 
-<<if def $FSChattelReligionist && $FSChattelReligionist != "unset">>
+<<if (def $FSChattelReligionist) && $FSChattelReligionist != "unset">>
 	<<set $arcologies[0].FSChattelReligionist = $FSChattelReligionist>>
 	<<unset $FSChattelReligionist>>
 <<elseif ndef $arcologies[0].FSChattelReligionist>>
 	<<set $arcologies[0].FSChattelReligionist = "unset">>
 <</if>>
 
-<<if def $FSChattelReligionistLaw && $FSChattelReligionistLaw != 0>>
+<<if (def $FSChattelReligionistLaw) && $FSChattelReligionistLaw != 0>>
 	<<set $arcologies[0].FSChattelReligionistLaw = $FSChattelReligionistLaw>>
 	<<unset $FSChattelReligionistLaw>>
 <<elseif ndef $arcologies[0].FSChattelReligionistLaw>>
 	<<set $arcologies[0].FSChattelReligionistLaw = 0>>
 <</if>>
 
-<<if def $FSRomanRevivalist && $FSRomanRevivalist != "unset">>
+<<if (def $FSRomanRevivalist) && $FSRomanRevivalist != "unset">>
 	<<set $arcologies[0].FSRomanRevivalist = $FSRomanRevivalist>>
 	<<unset $FSRomanRevivalist>>
 <<elseif ndef $arcologies[0].FSRomanRevivalist>>
 	<<set $arcologies[0].FSRomanRevivalist = "unset">>
 <</if>>
 
-<<if def $FSRomanRevivalistLaw && $FSRomanRevivalistLaw != 0>>
+<<if (def $FSRomanRevivalistLaw) && $FSRomanRevivalistLaw != 0>>
 	<<set $arcologies[0].FSRomanRevivalistLaw = $FSRomanRevivalistLaw>>
 	<<unset $FSRomanRevivalistLaw>>
 <<elseif ndef $arcologies[0].FSRomanRevivalistLaw>>
 	<<set $arcologies[0].FSRomanRevivalistLaw = 0>>
 <</if>>
 
-<<if def $FSEgyptianRevivalist && $FSEgyptianRevivalist != "unset">>
+<<if (def $FSEgyptianRevivalist) && $FSEgyptianRevivalist != "unset">>
 	<<set $arcologies[0].FSEgyptianRevivalist = $FSEgyptianRevivalist>>
 	<<unset $FSEgyptianRevivalist>>
 <<elseif ndef $arcologies[0].FSEgyptianRevivalist>>
 	<<set $arcologies[0].FSEgyptianRevivalist = "unset">>
 <</if>>
 
-<<if def $FSEgyptianRevivalistLaw && $FSEgyptianRevivalistLaw != 0>>
+<<if (def $FSEgyptianRevivalistLaw) && $FSEgyptianRevivalistLaw != 0>>
 	<<set $arcologies[0].FSEgyptianRevivalistLaw = $FSEgyptianRevivalistLaw>>
 	<<unset $FSEgyptianRevivalistLaw>>
 <<elseif ndef $arcologies[0].FSEgyptianRevivalistLaw>>
@@ -1642,42 +1642,42 @@
 	<<set $arcologies[0].FSEgyptianRevivalistInterest = 0>>
 <</if>>
 
-<<if def $FSEdoRevivalist && $FSEdoRevivalist != "unset">>
+<<if (def $FSEdoRevivalist) && $FSEdoRevivalist != "unset">>
 	<<set $arcologies[0].FSEdoRevivalist = $FSEdoRevivalist>>
 	<<unset $FSEdoRevivalist>>
 <<elseif ndef $arcologies[0].FSEdoRevivalist>>
 	<<set $arcologies[0].FSEdoRevivalist = "unset">>
 <</if>>
 
-<<if def $FSEdoRevivalistLaw && $FSEdoRevivalistLaw != 0>>
+<<if (def $FSEdoRevivalistLaw) && $FSEdoRevivalistLaw != 0>>
 	<<set $arcologies[0].FSEdoRevivalistLaw = $FSEdoRevivalistLaw>>
 	<<unset $FSEdoRevivalistLaw>>
 <<elseif ndef $arcologies[0].FSEdoRevivalistLaw>>
 	<<set $arcologies[0].FSEdoRevivalistLaw = 0>>
 <</if>>
 
-<<if def $FSArabianRevivalist && $FSArabianRevivalist != "unset">>
+<<if (def $FSArabianRevivalist) && $FSArabianRevivalist != "unset">>
 	<<set $arcologies[0].FSArabianRevivalist = $FSArabianRevivalist>>
 	<<unset $FSArabianRevivalist>>
 <<elseif ndef $arcologies[0].FSArabianRevivalist>>
 	<<set $arcologies[0].FSArabianRevivalist = "unset">>
 <</if>>
 
-<<if def $FSArabianRevivalistLaw && $FSArabianRevivalistLaw != 0>>
+<<if (def $FSArabianRevivalistLaw) && $FSArabianRevivalistLaw != 0>>
 	<<set $arcologies[0].FSArabianRevivalistLaw = $FSArabianRevivalistLaw>>
 	<<unset $FSArabianRevivalistLaw>>
 <<elseif ndef $arcologies[0].FSArabianRevivalistLaw>>
 	<<set $arcologies[0].FSArabianRevivalistLaw = 0>>
 <</if>>
 
-<<if def $FSChineseRevivalist && $FSChineseRevivalist != "unset">>
+<<if (def $FSChineseRevivalist) && $FSChineseRevivalist != "unset">>
 	<<set $arcologies[0].FSChineseRevivalist = $FSChineseRevivalist>>
 	<<unset $FSChineseRevivalist>>
 <<elseif ndef $arcologies[0].FSChineseRevivalist>>
 	<<set $arcologies[0].FSChineseRevivalist = "unset">>
 <</if>>
 
-<<if def $FSChineseRevivalistLaw && $FSChineseRevivalistLaw != 0>>
+<<if (def $FSChineseRevivalistLaw) && $FSChineseRevivalistLaw != 0>>
 	<<set $arcologies[0].FSChineseRevivalistLaw = $FSChineseRevivalistLaw>>
 	<<unset $FSChineseRevivalistLaw>>
 <<elseif ndef $arcologies[0].FSChineseRevivalistLaw>>
@@ -2524,10 +2524,10 @@ Setting missing global variables:
 	<<set $NPCSlaves = $ASlaves,
 	$ASlaves += $menials + $fuckdolls + $menialBioreactors>>
 <</if>>
-<<if def $ACitizenLimit || def $ASlaveLimit>>
+<<if (def $ACitizenLimit) || def $ASlaveLimit>>
 	<<unset $ACitizenLimit, $ASlaveLimit>>
 <</if>>
-<<if def $welfare || def $slaveDemandU || def $slaveDemandT|| def $slaveProductivity || def $enslaveChance || def $slaveExpiration>>
+<<if (def $welfare) || (def $slaveDemandU) || def $slaveDemandT|| (def $slaveProductivity) || (def $enslaveChance) || def $slaveExpiration>>
 	<<unset $welfare, $slaveDemandU, $slaveDemandT, $slaveProductivity, $enslaveChance, $slaveExpiration>>
 <</if>>
 
diff --git a/src/uncategorized/PESS.tw b/src/uncategorized/PESS.tw
index 9bc6c000a7ab9ac78361938bda3d5e79e50e2443..9a1c9a1ff8623bc4671906bae6f4dfb06f978706 100644
--- a/src/uncategorized/PESS.tw
+++ b/src/uncategorized/PESS.tw
@@ -95,7 +95,7 @@
 <<set $desc = SlaveTitle($activeSlave)>>
 <<run Enunciate($activeSlave)>>
 <<setLocalPronouns $activeSlave>>
-<<if def $slaves[$j] && $slaves[$j] != 0>>
+<<if (def $slaves[$j]) && $slaves[$j] != 0>>
 	<<setLocalPronouns $slaves[$j] 2>>
 <</if>>
 <<setPlayerPronouns>>
diff --git a/src/uncategorized/addCustomDescriptors.tw b/src/uncategorized/addCustomDescriptors.tw
index 5fc9cc3a0aeae86df5a6425d955e8e8846ee3559..dc4c5aafa9bde41e19d9652580f6b46bfcdd0352 100644
--- a/src/uncategorized/addCustomDescriptors.tw
+++ b/src/uncategorized/addCustomDescriptors.tw
@@ -41,7 +41,7 @@ You may enter custom descriptors for your slave's hair color, hair style, tattoo
 	<</if>>
 	</span>
 <<else>>
-	//You must break $his will further before $he will refer to you by a new title.<<if SlaveStatsChecker.checkForLisp($activeSlave)>><<if def $activeSlave.customTitleLisp && $activeSlave.customTitleLisp != "">> For now, $he intends to keep calling you "<<print $activeSlave.customTitleLisp>>".<</if>><<else>><<if def $activeSlave.customTitle && $activeSlave.customTitle != "">> For now, $he intends to keep calling you "<<print $activeSlave.customTitle>>".<</if>><</if>>//
+	//You must break $his will further before $he will refer to you by a new title.<<if SlaveStatsChecker.checkForLisp($activeSlave)>><<if (def $activeSlave.customTitleLisp) && $activeSlave.customTitleLisp != "">> For now, $he intends to keep calling you "<<print $activeSlave.customTitleLisp>>".<</if>><<else>><<if (def $activeSlave.customTitle) && $activeSlave.customTitle != "">> For now, $he intends to keep calling you "<<print $activeSlave.customTitle>>".<</if>><</if>>//
 <</if>>
 
 <br><br>
@@ -169,4 +169,4 @@ jQuery(function() {
 		<<textbox "$activeSlave.customHairVector" "" "Add custom descriptors">>
 	<</if>>
 	<<link "Reset" "Add custom descriptors">><<set $activeSlave.customHairVector = 0>><</link>>
-<</if>>
\ No newline at end of file
+<</if>>
diff --git a/src/uncategorized/arcmgmt.tw b/src/uncategorized/arcmgmt.tw
index 00e663d8038207b1f80e1f67c3db7c9d6c2c5cf5..542e2e44aaa3e90abb3d407c009531a623bcc64c 100644
--- a/src/uncategorized/arcmgmt.tw
+++ b/src/uncategorized/arcmgmt.tw
@@ -1281,7 +1281,7 @@ earning you @@.yellowgreen;<<print cashFormat(_menialEarnings + _bioreactorEarni
 		<</if>>
 	<</if>>
 
-	<<if def $arcologies[0].embargoTarget && $arcologies[0].embargoTarget != -1>>
+	<<if (def $arcologies[0].embargoTarget) && $arcologies[0].embargoTarget != -1>>
 		The local economy is hurt by the double edged sword of your economic warfare.
 		<<set _AWeekGrowth -= $arcologies[0].embargo*2>>
 	<</if>>
diff --git a/src/uncategorized/freeRangeDairyAssignmentScene.tw b/src/uncategorized/freeRangeDairyAssignmentScene.tw
index 30678a8c4ace4b11ea817531be21c2ad896d5b69..63d11ca6efdaa21b3cfc7c71058936474079c056 100644
--- a/src/uncategorized/freeRangeDairyAssignmentScene.tw
+++ b/src/uncategorized/freeRangeDairyAssignmentScene.tw
@@ -113,7 +113,7 @@ Eventually, $activeSlave.slaveName arrives at $his designated milking stall.
 <<else>>
 	<<if ($activeSlave.relation != 0)>>
 		<<set _assayedSlave = getSlave($activeSlave.relationTarget)>>
-		<<if def _assayedSlave && _assayedSlave.assignment == "work in the dairy">>
+		<<if (def _assayedSlave) && _assayedSlave.assignment == "work in the dairy">>
 			<<set _assayedSlaveAvailable = 1>>
 			<<set _assayType = $activeSlave.relation>>
 		<</if>>
@@ -121,7 +121,7 @@ Eventually, $activeSlave.slaveName arrives at $his designated milking stall.
 <</if>> /*closes extended family mode */
 <<if _assayedSlaveAvailable == 0 && $activeSlave.relationship > 0>>
 	<<set _assayedSlave = getSlave($activeSlave.relationshipTarget)>>
-	<<if def _assayedSlave && _assayedSlave.assignment == "work in the dairy">>
+	<<if (def _assayedSlave) && _assayedSlave.assignment == "work in the dairy">>
 		<<set _assayedSlaveAvailable = 1>>
 		<<switch $activeSlave.relationship>>
 		<<case 1>>
diff --git a/src/uncategorized/longSlaveDescription.tw b/src/uncategorized/longSlaveDescription.tw
index b8bad58b19e7778f30e9cccb281c6234bc5b54ae..7944ae1f4eb210194aaecb51cc1d1da6afb3b567 100644
--- a/src/uncategorized/longSlaveDescription.tw
+++ b/src/uncategorized/longSlaveDescription.tw
@@ -1161,7 +1161,7 @@ is
 				$He is in an @@.lightgreen;incestuous relationship with $his father, <<= SlaveFullName(_lover)>>.@@
 			<<elseif _lover.mother == $activeSlave.ID || _lover.father == $activeSlave.ID>>
 				$He is in an @@.lightgreen;incestuous relationship with $his daughter, <<= SlaveFullName(_lover)>>.@@
-			<<elseif def $showDistantRelatives && $showDistantRelatives == 1>>
+			<<elseif (def $showDistantRelatives) && $showDistantRelatives == 1>>
 				<<if isAunt($activeSlave, _lover)>>
 					$He is in an @@.lightgreen;incestuous relationship with $his aunt, <<= SlaveFullName(_lover)>>.@@
 				<<elseif isAunt(_lover, $activeSlave)>>
@@ -1195,7 +1195,7 @@ is
 			<<elseif $PC.title == 0>>
 				$He is in an @@.lightgreen;incestuous relationship with $his daughter, you.@@
 			<</if>>
-		<<elseif def $showDistantRelatives && $showDistantRelatives == 1>>
+		<<elseif (def $showDistantRelatives) && $showDistantRelatives == 1>>
 			<<if isAunt($activeSlave, $PC)>>
 				<<if $PC.title == 1>>
 					$He is in an @@.lightgreen;incestuous relationship with $his uncle, you.@@
diff --git a/src/uncategorized/main.tw b/src/uncategorized/main.tw
index 568387e5dd8f2e78ce4a0ecd140442f02344a6bd..8a44a769948b53540f29139ae1aed3b82d148a35 100644
--- a/src/uncategorized/main.tw
+++ b/src/uncategorized/main.tw
@@ -178,7 +178,7 @@ __''MAIN MENU''__&nbsp;&nbsp;&nbsp;&nbsp;//[[Summary Options]]//
 		<button class="tablinks" onclick="opentab(event, 'all')" id="tab all">
 			All
 			<<if _penthouseSlaves > 0>>
-				<<if $Headgirl != 0>>
+				<<if $HeadGirl != 0>>
 					<<set _penthouseSlaves++>>
 				<</if>>
 				<<if $Recruiter != 0>>
diff --git a/src/uncategorized/neighborsDevelopment.tw b/src/uncategorized/neighborsDevelopment.tw
index 41fac2215a717ff916549b01b16e07827355662d..35bc6665e950c07193b9f519d4a0a67dd82ba607 100644
--- a/src/uncategorized/neighborsDevelopment.tw
+++ b/src/uncategorized/neighborsDevelopment.tw
@@ -55,7 +55,7 @@
 	<<setLocalPronouns $leaders[_k]>>
 	is being run by your agent @@.deeppink;<<= SlaveFullName($leaders[_k])>>@@.
 	<<set _agentIndex = $slaveIndices[$leaders[_k].ID]>>
-	<<if def _agentIndex && $slaves[_agentIndex].assignment != "be your agent">>
+	<<if (def _agentIndex) && $slaves[_agentIndex].assignment != "be your agent">>
 		@@.red;BUG: $slaves[_agentIndex].slaveName also was <<print $slaves[_agentIndex].assignment>>!@@
 		<<= assignJob($slaves[_agentIndex], "be your agent")>>
 	<</if>>
@@ -84,7 +84,7 @@ has an estimated GSP of @@.yellowgreen;<<print cashFormat(_prosperity)>><<if $sh
 		<<set $arcologies[$i].PCminority = 0>>
 	<</if>>
 	@@.yellow;After a brief power struggle, it undergoes a change of government.@@
-	<<if def _agentIndex && _agentIndex != -1>>
+	<<if (def _agentIndex) && _agentIndex != -1>>
 		<<setLocalPronouns $slaves[_agentIndex]>>
 		@@.deeppink;$slaves[_agentIndex].slaveName@@ manages to escape with the help of a few loyal citizens and returns to you @@.gold;fearing your displeasure at $his failure.@@
 		<<set $slaves[_agentIndex].trust -= 40>>
diff --git a/src/uncategorized/nonRandomEvent.tw b/src/uncategorized/nonRandomEvent.tw
index 777073ae9399abf2af8f987dd9af021861eb19d1..3f7e51e249961e9fa59166ca2a34a71639029879 100644
--- a/src/uncategorized/nonRandomEvent.tw
+++ b/src/uncategorized/nonRandomEvent.tw
@@ -75,7 +75,7 @@
 		<<set $badB = 1>>
 		<<goto "Nonrandom Event">>
 	<</if>>
-<<elseif _effectiveWeek == 54 && def $peacekeepers && $peacekeepers.attitude >= 0>>
+<<elseif _effectiveWeek == 54 && (def $peacekeepers) && $peacekeepers.attitude >= 0>>
 	<<goto "P peacekeepers deficit">>
 <<elseif (_effectiveWeek == 56)>>
 	<<set $collaboration = 0>>
@@ -133,9 +133,9 @@
 	<<goto "Assistant Events">>
 <<elseif (_effectiveWeek > 70) && ($corpIncorporated > 0) && ($rivalOwnerEnslaved > 0) && ($mercenaries >= 3) && ($mercenariesHelpCorp == 0) && ($corpDivExtra > 0)>>
 	<<goto "P Mercs Help Corp">>
-<<elseif _effectiveWeek > 75 && def $peacekeepers && $peacekeepers.strength < 50 && $rivalOwner == 0 && $peacekeepersFate != 1>>
+<<elseif _effectiveWeek > 75 && (def $peacekeepers) && $peacekeepers.strength < 50 && $rivalOwner == 0 && $peacekeepersFate != 1>>
 	<<goto "P peacekeepers independence">>
-<<elseif def $peacekeepers && $peacekeepers.strength >= 50 && $peacekeepers.influenceAnnounced == 0>>
+<<elseif (def $peacekeepers) && $peacekeepers.strength >= 50 && $peacekeepers.influenceAnnounced == 0>>
 	<<goto "P peacekeepers influence">>
 <<elseif ($cash > 120000) && ($rep > 4000) && ($corpAnnounced == 0)>>
 	<<goto "P Corp Announcement">>
diff --git a/src/uncategorized/options.tw b/src/uncategorized/options.tw
index 1084a4c697b90396d86a55b31d3b8faa663ffa78..138df6085a12126684873597cbf538e448979246 100644
--- a/src/uncategorized/options.tw
+++ b/src/uncategorized/options.tw
@@ -350,7 +350,7 @@ Assignment performance vignettes on the end week report are
 <br>
 
 <<if $familyTesting == 1>>
-	<<if def $showDistantRelatives && $showDistantRelatives == 1>>
+	<<if (def $showDistantRelatives) && $showDistantRelatives == 1>>
 		Distant relatives such as aunts, nieces and cousins ''are'' shown
 		[[Hide distant relatives|Options][$showDistantRelatives = 0]]
 	<<else>>
diff --git a/src/uncategorized/saGuardsYou.tw b/src/uncategorized/saGuardsYou.tw
index 03995323f17e82667890480d9560749b637ef444..de9a7292dadd489ce8fc3319fb1b428001d23a0c 100644
--- a/src/uncategorized/saGuardsYou.tw
+++ b/src/uncategorized/saGuardsYou.tw
@@ -187,7 +187,7 @@ Being continually trusted with your life @@.hotpink;increases $his devotion to y
 		<<set _flawedTrainee = 0>>
 		<<if $slaves[$i].relationship > 1>>
 			<<set $subSlave = getSlave($slaves[$i].relationshipTarget)>>
-			<<if def $subSlave && $subSlave.combatSkill == 0 && bodyguardSuccessorEligible($subSlave)>>
+			<<if (def $subSlave) && $subSlave.combatSkill == 0 && bodyguardSuccessorEligible($subSlave)>>
 				$He does $his best to train $subSlave.slaveName whenever $he can, hoping that $his
 				<<if $slaves[$i].relationship > 4>>wife<<elseif $slaves[$i].relationship == 4>>lover<<elseif $slaves[$i].relationship == 3>>girlfriend<<else>>best friend<</if>>
 				can be made capable of stepping into $his place.
diff --git a/src/uncategorized/saLongTermEffects.tw b/src/uncategorized/saLongTermEffects.tw
index e609ec05ba5ec5c530046b4615877f3699d4dfe5..a95851348252b2d78ea9d38ccf13c3caaaa61ef3 100644
--- a/src/uncategorized/saLongTermEffects.tw
+++ b/src/uncategorized/saLongTermEffects.tw
@@ -6394,7 +6394,7 @@
 /* There really is no good place for this since saRules is too early and saRivals/saRelationships is too late */
 <<if $slaves[$i].rivalry > 1 && $universalRulesConsent == 0>>
 	<<set _j = $slaveIndices[$slaves[$i].rivalryTarget]>>
-	<<if def _j && isSlaveAvailable($slaves[$i]) && isSlaveAvailable($slaves[_j])>> /* rape time */
+	<<if (def _j) && isSlaveAvailable($slaves[$i]) && isSlaveAvailable($slaves[_j])>> /* rape time */
 		<<set _fuckCount = random(1,(Math.ceil($slaves[$i].energy/10)+1))>>
 		<<set $slaves[$i].need -= _fuckCount*10>>
 		<<= SimpleSlaveSlaveFucking($slaves[_j], $slaves[$i], _fuckCount)>>
@@ -6402,7 +6402,7 @@
 <</if>>
 <<if $slaves[$i].relationship > 2>>
 	<<set _j = $slaveIndices[$slaves[$i].relationshipTarget]>>
-	<<if def _j && isSlaveAvailable($slaves[$i]) && isSlaveAvailable($slaves[_j])>> /* sexy time */
+	<<if (def _j) && isSlaveAvailable($slaves[$i]) && isSlaveAvailable($slaves[_j])>> /* sexy time */
 		<<if $slaves[$i].relationship == 5 && canPenetrate($slaves[$i])>>
 			<<if $slaves[_j].vagina == 0 && canDoVaginal($slaves[_j])>>
 				<<set $slaves[_j].vagina++, $slaves[_j].vaginalCount++, $vaginalTotal++>>
diff --git a/src/uncategorized/saPleaseYou.tw b/src/uncategorized/saPleaseYou.tw
index 4cc928ffa73dda66d99651a71dc475c23d9228e3..54e041591a318e89f10133c3a2dd03302e7fafd3 100644
--- a/src/uncategorized/saPleaseYou.tw
+++ b/src/uncategorized/saPleaseYou.tw
@@ -1159,7 +1159,7 @@ serves you this week.
 		Keeping your own daughter as a personal fucktoy leaves quite a public impression.
 	<<elseif $slaves[$i].father > 0 && $slaves[$i].mother != $slaves[$i].father>>
 		<<set _spy = $slaveIndices[$slaves[$i].father]>>
-		<<if def _spy && ($slaves[_spy].assignment == "please you" || $slaves[_spy].assignment == "serve in the master suite" || $slaves[_spy].assignment == "be your Concubine")>>
+		<<if (def _spy) && ($slaves[_spy].assignment == "please you" || $slaves[_spy].assignment == "serve in the master suite" || $slaves[_spy].assignment == "be your Concubine")>>
 			Since you are also keeping $his father as a sexual servant, you often use them together, which leaves quite a public impression.
 		<</if>>
 	<</if>>
@@ -1168,7 +1168,7 @@ serves you this week.
 		Keeping your own daughter as a sexual servant leaves quite a public impression.
 	<<elseif $slaves[$i].mother > 0>>
 		<<set _spy = $slaveIndices[$slaves[$i].mother]>>
-		<<if def _spy && ($slaves[_spy].assignment == "please you" || $slaves[_spy].assignment == "serve in the master suite" || $slaves[_spy].assignment == "be your Concubine")>>
+		<<if (def _spy) && ($slaves[_spy].assignment == "please you" || $slaves[_spy].assignment == "serve in the master suite" || $slaves[_spy].assignment == "be your Concubine")>>
 			Since you are also keeping $his mother as a sexual servant, you often use them together, which leaves quite a public impression.
 		<</if>>
 	<</if>>
@@ -1210,7 +1210,7 @@ serves you this week.
 <<else>>
 	<<if ($slaves[$i].relation != 0)>>
 		<<set _spy = $slaveIndices[$slaves[$i].relationTarget]>>
-		<<if def _spy && ($slaves[_spy].assignment == "please you" || $slaves[_spy].assignment == "serve in the master suite" || $slaves[_spy].assignment == "be your Concubine")>>
+		<<if (def _spy) && ($slaves[_spy].assignment == "please you" || $slaves[_spy].assignment == "serve in the master suite" || $slaves[_spy].assignment == "be your Concubine")>>
 			Since you are also keeping $his $slaves[_spy].relation as a sexual servant, you often use them together, which leaves quite a public impression.
 		<</if>>
 	<</if>>
diff --git a/src/uncategorized/saRelationships.tw b/src/uncategorized/saRelationships.tw
index cbbd3947f175172a9e3d329d7cbe010f67e236f1..2f864ee653c4a0846880d210a28146feab7315d1 100644
--- a/src/uncategorized/saRelationships.tw
+++ b/src/uncategorized/saRelationships.tw
@@ -1592,7 +1592,7 @@
 
 	<<if _SlaveI.rivalryTarget != _SlaveI.relationTarget>>
 		<<set _K = $slaveIndices[_SlaveI.relationTarget]>>
-		<<if def _K && _SlaveI.trust <= 95>>
+		<<if (def _K) && _SlaveI.trust <= 95>>
 			<<setLocalPronouns $slaves[_K] 2>>
 			_SlaveI.slaveName
 			<<if _SlaveI.trust < -20>>
diff --git a/src/uncategorized/saRivalries.tw b/src/uncategorized/saRivalries.tw
index 9f712cbb70c4569d4160f07b57571e816400d170..66ed851d903a86abc7f8b027d2e59cf2b3fa2f06 100644
--- a/src/uncategorized/saRivalries.tw
+++ b/src/uncategorized/saRivalries.tw
@@ -286,7 +286,7 @@
 
 <<if $slaves[$i].rivalry>>
 	<<set _j = $slaveIndices[$slaves[$i].rivalryTarget]>>
-	<<if def _j && ($slaves[$i].ID != $slaves[_j].rivalryTarget)>>
+	<<if (def _j) && ($slaves[$i].ID != $slaves[_j].rivalryTarget)>>
 		<<set $slaves[_j].rivalry = 0, $slaves[_j].rivalryTarget = 0>>
 		<<set $slaves[$i].rivalry = 0, $slaves[$i].rivalryTarget = 0>>
 	<</if>>
diff --git a/src/uncategorized/saServeThePublic.tw b/src/uncategorized/saServeThePublic.tw
index de9dab8a4202e71ec78f1a2216d5c946808e74a7..62e63eac6445fa5e4e79606ce31e6891e7f744e0 100644
--- a/src/uncategorized/saServeThePublic.tw
+++ b/src/uncategorized/saServeThePublic.tw
@@ -514,7 +514,7 @@ $His appearance attracted $beauty members of the public (<<print Math.trunc($bea
 <<else>>
 	<<if $slaves[$i].relation != 0>>
 		<<set $j = $slaveIndices[$slaves[$i].relationTarget]>>
-		<<if def $j && $slaves[$j].assignment == $slaves[$i].assignment>>
+		<<if (def $j) && $slaves[$j].assignment == $slaves[$i].assignment>>
 			Since $his $slaves[$j].relation $slaves[$j].slaveName is a public slut too, $he earns extra attention.
 			<<if $arcologies[0].FSEgyptianRevivalist > 20>>
 				Citizens are very excited about being able to participate in incestuous sex like the ancient Egyptians.
@@ -526,7 +526,7 @@ $His appearance attracted $beauty members of the public (<<print Math.trunc($bea
 <</if>>
 <<if $slaves[$i].relationship > 0>>
 	<<set $j = $slaveIndices[$slaves[$i].relationshipTarget]>>
-	<<if def $j && $slaves[$j].assignment == $slaves[$i].assignment>>
+	<<if (def $j) && $slaves[$j].assignment == $slaves[$i].assignment>>
 		$His <<print relationshipTerm($slaves[$i])>> $slaves[$j].slaveName is also serving the public and they work well together.
 	<</if>>
 <<elseif $slaves[$i].relationship == -1>>
@@ -534,7 +534,7 @@ $His appearance attracted $beauty members of the public (<<print Math.trunc($bea
 <</if>>
 <<if $slaves[$i].rivalry != 0>>
 	<<set $j = $slaveIndices[$slaves[$i].rivalryTarget]>>
-	<<if def $j && $slaves[$j].assignment == $slaves[$i].assignment>>
+	<<if (def $j) && $slaves[$j].assignment == $slaves[$i].assignment>>
 		$He's a little less effective due to $his mutual dislike with $slaves[$j].slaveName.
 	<</if>>
 <</if>>
diff --git a/src/uncategorized/saWhore.tw b/src/uncategorized/saWhore.tw
index 19ad644826b6c9b4e6221abb8fbe96bae72cc7e9..36ce08f936b321065c836b44c6e563c4d9c20c55 100644
--- a/src/uncategorized/saWhore.tw
+++ b/src/uncategorized/saWhore.tw
@@ -537,7 +537,7 @@ $His appearance attracted $beauty customers (<<print Math.trunc($beauty/7)>> a d
 <<else>>
 	<<if $slaves[$i].relation != 0>>
 		<<set $j = $slaveIndices[$slaves[$i].relationTarget]>>
-		<<if def $j && $slaves[$j].assignment == $slaves[$i].assignment>>
+		<<if (def $j) && $slaves[$j].assignment == $slaves[$i].assignment>>
 			<<setLocalPronouns $slaves[$j] 2>>
 			Since $his $slaves[$j].relation $slaves[$j].slaveName is selling _himself2 too, $he earns extra ¤ by working with _him2.
 			<<if $arcologies[0].FSEgyptianRevivalist > 20>>
@@ -550,7 +550,7 @@ $His appearance attracted $beauty customers (<<print Math.trunc($beauty/7)>> a d
 <</if>> /*closes extended family mode */
 <<if $slaves[$i].relationship > 0>>
 	<<set $j = $slaveIndices[$slaves[$i].relationshipTarget]>>
-	<<if def $j && $slaves[$j].assignment == $slaves[$i].assignment>>
+	<<if (def $j) && $slaves[$j].assignment == $slaves[$i].assignment>>
 		$His <<print relationshipTerm($slaves[$i])>> $slaves[$j].slaveName is also whoring, so $he earns a bit more.
 	<</if>>
 <<elseif $slaves[$i].relationship == -1>>
@@ -558,7 +558,7 @@ $His appearance attracted $beauty customers (<<print Math.trunc($beauty/7)>> a d
 <</if>>
 <<if $slaves[$i].rivalry != 0>>
 	<<set $j = $slaveIndices[$slaves[$i].rivalryTarget]>>
-	<<if def $j && $slaves[$j].assignment == $slaves[$i].assignment>>
+	<<if (def $j) && $slaves[$j].assignment == $slaves[$i].assignment>>
 		$He earns a little less ¤ due to bickering with $slaves[$j].slaveName.
 	<</if>>
 <</if>>
diff --git a/src/uncategorized/seCustomSlaveDelivery.tw b/src/uncategorized/seCustomSlaveDelivery.tw
index 19eed2188e35846d76c6b9b9408984a3447619ca..3bb2b3d3f1b29a48fbc24b99880c36c2834d61ac 100644
--- a/src/uncategorized/seCustomSlaveDelivery.tw
+++ b/src/uncategorized/seCustomSlaveDelivery.tw
@@ -171,7 +171,7 @@
 <<if $customSlave.analVirgin == 0>>
 	<<set $activeSlave.anus = $customSlave.analVirgin>>
 <</if>>
-<<if def $customSlave.voice && $customSlave.voice != -1>>
+<<if (def $customSlave.voice) && $customSlave.voice != -1>>
 	<<set $activeSlave.voice = $customSlave.voice>>
 <<else>>
 	<<set $activeSlave.voice = random(0,3)>>
diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw
index 4136ca54b71d3312cd9420ed44691535504230fd..874049b7645a8bfeb386fec2a869776f56ad36cd 100644
--- a/src/uncategorized/slaveAssignmentsReport.tw
+++ b/src/uncategorized/slaveAssignmentsReport.tw
@@ -449,7 +449,7 @@
 <</if>>
 */
 <<if $slaves[$i].fetish == "mindbroken" && $slaves[$i].relationship == -3>>
-	<<if def $slaves[$i].kindness && $slaves[$i].kindness > 0>>
+	<<if (def $slaves[$i].kindness) && $slaves[$i].kindness > 0>>
 		<<set $slaves[$i].kindness-->>
 	<</if>>
 <</if>>
diff --git a/src/uncategorized/slaveSold.tw b/src/uncategorized/slaveSold.tw
index 296de31fc13d8ad125609b72a4232fc22a872b16..aa4d1cfc2f7cc46c506edb5aeb415ba890e71fff 100644
--- a/src/uncategorized/slaveSold.tw
+++ b/src/uncategorized/slaveSold.tw
@@ -141,7 +141,7 @@
 <<else>>
 	<<if $activeSlave.relation != 0>>
 		<<set _ss = $slaveIndices[$activeSlave.relationTarget]>>
-		<<if def _ss && $slaves[_ss].fetish != "mindbroken">>
+		<<if (def _ss) && $slaves[_ss].fetish != "mindbroken">>
 			<<setLocalPronouns $slaves[_ss] 2>>
 			$slaves[_ss].slaveName is @@.mediumorchid;grieved@@ that you are selling _his2 $activeSlave.relation.
 			<<run clearSummaryCache($slaves[_ss])>>
@@ -153,7 +153,7 @@
 <</if>>
 <<if $activeSlave.relationship > 0>>
 	<<set _ss = $slaveIndices[$activeSlave.relationshipTarget]>>
-	<<if def _ss && $slaves[_ss].fetish != "mindbroken">>
+	<<if (def _ss) && $slaves[_ss].fetish != "mindbroken">>
 		<<setLocalPronouns $slaves[_ss] 2>>
 		$slaves[_ss].slaveName is @@.mediumorchid;grieved@@ that you are selling _his2 best source of comfort and companionship in a life of bondage.
 		<<run clearSummaryCache($slaves[_ss])>>
@@ -175,7 +175,7 @@
 <</if>>
 <<if $activeSlave.rivalry != 0>>
 	<<set _ss = $slaveIndices[$activeSlave.rivalryTarget]>>
-	<<if def _ss && $slaves[_ss].fetish != "mindbroken">>
+	<<if (def _ss) && $slaves[_ss].fetish != "mindbroken">>
 		<<setLocalPronouns $slaves[_ss] 2>>
 		$slaves[_ss].slaveName is @@.hotpink;pleased@@ that _he2 won't have to see _his2 rival any more.
 		<<run clearSummaryCache($slaves[_ss])>>
diff --git a/src/utility/extendedFamilyWidgets.tw b/src/utility/extendedFamilyWidgets.tw
index 848bfd1c7be37d8e639c0a92dc72d8689c572cb6..86e86c9a783d3be075da9d0ab0efe00388a4047d 100644
--- a/src/utility/extendedFamilyWidgets.tw
+++ b/src/utility/extendedFamilyWidgets.tw
@@ -76,7 +76,7 @@
 	$He @@.lightgreen;gave birth to a single one of your slaves: _children[0].slaveName.@@
 <</if>>
 
-<<if def $showDistantRelatives && $showDistantRelatives == 1>>
+<<if (def $showDistantRelatives) && $showDistantRelatives == 1>>
 	/*testtest maternal grandma passage - determines if the current slave has a maternal grandmother*/
 	<<set _mi = $slaveIndices[$activeSlave.mother]>>
 	<<set _fi = $slaveIndices[$activeSlave.father]>>
@@ -96,7 +96,7 @@
 	<</if>>
 	<<if (def _mi || def _fi) && ndef _mmi && ndef _fmi && ndef _mfi && ndef _ffi>>
 		<<if def _mi>>
-			<<if def _fi && _mi == _fi>>
+			<<if (def _fi) && _mi == _fi>>
 				<<if $PC.ID == $slaves[_mi].mother && $PC.ID == $slaves[_fi].father>>
 					$He is @@.lightgreen;your grandchild.@@ You impregnated yourself with $his sole biological parent.
 				<<elseif $PC.ID == $slaves[_mi].mother>>
@@ -104,9 +104,9 @@
 				<<elseif $PC.ID == $slaves[_fi].father>>
 					$He is @@.lightgreen;your grandchild.@@ You fathered $his sole biological parent.
 				<</if>>
-			<<elseif def _fi && $PC.ID == $slaves[_mi].mother && $PC.ID == $slaves[_fi].mother>>
+			<<elseif (def _fi) && $PC.ID == $slaves[_mi].mother && $PC.ID == $slaves[_fi].mother>>
 				$He is @@.lightgreen;your grandchild.@@ You gave birth to both of $his parents.
-			<<elseif def _fi && $PC.ID == $slaves[_mi].father && $PC.ID == $slaves[_fi].father>>
+			<<elseif (def _fi) && $PC.ID == $slaves[_mi].father && $PC.ID == $slaves[_fi].father>>
 				$He is @@.lightgreen;your grandchild.@@ You fathered both of $his parents.
 			<<elseif $PC.ID == $slaves[_mi].mother>>
 				$He is @@.lightgreen;your grandchild.@@ You gave birth to $his mother.
@@ -121,10 +121,10 @@
 			<</if>>
 		<</if>>
 	<<else>>
-		<<if def _mmi && def _ffi && _mmi == _ffi>>
+		<<if (def _mmi) && (def _ffi) && _mmi == _ffi>>
 			$His sole @@.lightgreen;grandparent is $slaves[_mmi].slaveName.@@
 		<<else>>
-			<<if def _mmi && def _mfi && _mmi == _mfi>>
+			<<if (def _mmi) && (def _mfi) && _mmi == _mfi>>
 				$His sole @@.lightgreen;grandmother is $slaves[_mmi].slaveName.@@
 			<<else>>
 				<<if def _mmi>>
@@ -134,7 +134,7 @@
 					$His paternal @@.lightgreen;grandmother is $slaves[_mfi].slaveName.@@
 				<</if>>
 			<</if>>
-			<<if def _fmi && def _ffi && _fmi == _ffi>>
+			<<if (def _fmi) && (def _ffi) && _fmi == _ffi>>
 				$His sole @@.lightgreen;grandfather is $slaves[_ffi].slaveName.@@
 			<<else>>
 				<<if def _fmi>>
@@ -152,7 +152,7 @@
 	<<set _pcMother = $slaveIndices[$PC.mother]>>
 	<<set _pcFather = $slaveIndices[$PC.father]>>
 	<<if def _pcMother>>
-		<<if def _pcFather && _pcMother == _pcFather>>
+		<<if (def _pcFather) && _pcMother == _pcFather>>
 			<<if $activeSlave.ID == $slaves[_pcMother].mother && $activeSlave.ID == $slaves[_pcFather].father>>
 				$He is @@.lightgreen;your sole grandparent.@@ $He impregnated $himself with your mother/father who in turn impregnated themselves with you.
 			<<elseif $activeSlave.ID == $slaves[_pcMother].mother>>
@@ -160,9 +160,9 @@
 			<<elseif $activeSlave.ID == $slaves[_pcFather].father>>
 				$He is @@.lightgreen;your sole grandfather.@@ $He fathered $slaves[_pcFather].slaveName who in turn impregnated themselves with you.
 			<</if>>
-		<<elseif def _pcFather && $activeSlave.ID == $slaves[_pcMother].mother && $activeSlave.ID == $slaves[_pcFather].mother>>
+		<<elseif (def _pcFather) && $activeSlave.ID == $slaves[_pcMother].mother && $activeSlave.ID == $slaves[_pcFather].mother>>
 			$He is @@.lightgreen;your sole grandmother.@@ $He gave birth to both of your parents, $slaves[_pcMother].slaveName and $slaves[_pcFather].slaveName.
-		<<elseif def _pcFather && $activeSlave.ID == $slaves[_pcMother].father && $activeSlave.ID == $slaves[_pcFather].father>>
+		<<elseif (def _pcFather) && $activeSlave.ID == $slaves[_pcMother].father && $activeSlave.ID == $slaves[_pcFather].father>>
 			$He is @@.lightgreen;your sole grandfather.@@ $He fathered both of your parents, $slaves[_pcFather].slaveName and $slaves[_pcMother].slaveName.
 		<<elseif $activeSlave.ID == $slaves[_pcMother].mother>>
 			$He is @@.lightgreen;your maternal grandmother.@@
@@ -572,7 +572,7 @@
 	<<if _sisterCheck == 3>>
 		<<run ($slaves[_efw].genes == 'XX' ? _halfsisters : _halfbrothers).push($slaves[_efw])>>
 	<</if>>
-	<<if def $showDistantRelatives && $showDistantRelatives == 1>>
+	<<if (def $showDistantRelatives) && $showDistantRelatives == 1>>
 		<<set _cousinCheck = areCousins($slaves[_efw], $activeSlave)>>
 		<<if _cousinCheck == true>>
 			<<run _cousins.push($slaves[_efw])>>
@@ -706,7 +706,7 @@
 	@@.lightgreen;_children[0].slaveName is a half-brother to $him.@@
 <</if>>
 
-<<if def $showDistantRelatives && $showDistantRelatives == 1>>
+<<if (def $showDistantRelatives) && $showDistantRelatives == 1>>
 	/*testtest PC cousin passage - determines how many cousins you have*/
 	<<if areCousins($activeSlave, $PC)>>
 		$He
diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw
index 681062bdccf01cb13eb901fc892f19c52eb4c0a0..9a6bcacd6eb3c573f1ecb3ee0d3c705b13a54152 100644
--- a/src/utility/miscWidgets.tw
+++ b/src/utility/miscWidgets.tw
@@ -543,7 +543,7 @@
 <</widget>>
 
 <<widget "Master">><<if def $args[0]>><<run Enunciate($args[0])>><<elseif ndef $titleEnunciate>><<run Enunciate($activeSlave)>><</if>>$titleEnunciate<</widget>>
-<<widget "say">><<if def $args[0] && $sayEnunciate != "lisp">>$args[0]<<else>>$sayEnunciate<</if>><</widget>>
+<<widget "say">><<if (def $args[0]) && $sayEnunciate != "lisp">>$args[0]<<else>>$sayEnunciate<</if>><</widget>>
 <<widget "s">>$sEnunciate<</widget>>
 <<widget "S">>$SEnunciate<</widget>>
 <<widget "ss">>$ssEnunciate<</widget>>