diff --git a/devTools/FC.d.ts b/devTools/FC.d.ts
index e53d61b75dc2d1ca1d0c7b25bfddb2369d5b875b..b7c8bba5af347186763c1e01580cbb1251250b37 100644
--- a/devTools/FC.d.ts
+++ b/devTools/FC.d.ts
@@ -1,26 +1,3 @@
-interface Window {
-
-	jsRandom(min: number, max: number): number;
-
-	SlaveDataSchemeCleanup(slave: App.Entity.SlaveState): void;
-
-	walkPasts(slave: App.Entity.SlaveState, seed: any): string;
-	WombInit(actor: any): void;
-	WombImpregnate(actor, fCount, fatherID, age, surrogate?): void;
-	WombSurrogate(actor, fCount, mother, fatherID, age): void;
-	WombSort(actor): void;
-
-	capFirstChar(s: string): string;
-
-	canWalk(slave: App.Entity.SlaveState): boolean;
-
-	rulesAutosurgery: any;
-	ruleApplied: any;
-	SlaveSummary: any;
-
-	slaveStateById(id: number): App.Entity.SlaveState;
-}
-
 declare namespace App {
 	namespace Art {}
 
@@ -380,5 +357,3 @@ declare namespace FC {
 }
 
 const V: FC.GameVariables;
-
-function slaveStateById(ID: number): FC.SlaveState;
diff --git a/src/004-base/proxies.js b/src/004-base/proxies.js
index 03fc68bf390c917ca8c95735fa47a3463e24287a..40af52badfbb5fff43cec0fbf2036be990dbfec2 100644
--- a/src/004-base/proxies.js
+++ b/src/004-base/proxies.js
@@ -1,6 +1,6 @@
 (function() {
 	const readOnlySymbol = Symbol("readonly proxy");
-	window.createReadonlyProxy = function(target) {
+	globalThis.createReadonlyProxy = function(target) {
 		if (target == null) return target; //intentionally ==
 		if (target[readOnlySymbol]) { return target; }
 		if (_.isArray(target)) {
@@ -43,7 +43,7 @@
 		return target;
 	};
 	const cheaterSymbol = Symbol("cheating proxy");
-	window.createCheatProxy = function(target) {
+	globalThis.createCheatProxy = function(target) {
 		if (target == null) return target; //intentionally ==
 		if (target[cheaterSymbol]) { return target; }
 		if (_.isArray(target)) {
@@ -104,20 +104,20 @@ Object.defineProperty(window, "V", {
 	}
 });
 //This should be used if the user might use V under normal, non-cheating circumstances but shouldn't be punished for accidentally setting the value. The attempt to make the change will simply be disregarded.
-window.runWithReadonlyProxy = function(callback) {
-	window.storyProxy = createReadonlyProxy(State.variables);
+globalThis.runWithReadonlyProxy = function(callback) {
+	globalThis.storyProxy = createReadonlyProxy(State.variables);
 	try {
 		return callback();
 	} finally {
-		window.storyProxy = null;
+		globalThis.storyProxy = null;
 	}
 };
 // This should be used if setting values would constitute cheating. For example, a debug view that shows all variables in an editable form; showing isn't cheating, but making a change would be.
-window.runWithCheatProxy = function(callback) {
-	window.storyProxy = createCheatProxy(State.variables);
+globalThis.runWithCheatProxy = function(callback) {
+	globalThis.storyProxy = createCheatProxy(State.variables);
 	try {
 		return callback();
 	} finally {
-		window.storyProxy = null;
+		globalThis.storyProxy = null;
 	}
 };
diff --git a/src/Corporation/corporate.js b/src/Corporation/corporate.js
index 6028170bdf72b48f3275d435184035efca9e11e5..432c470483304b8b167a24c0c7db83b5154ed0bc 100644
--- a/src/Corporation/corporate.js
+++ b/src/Corporation/corporate.js
@@ -1,4 +1,4 @@
-window.averageRange = class {
+globalThis.averageRange = class {
 	constructor({center, range}) {
 		this._const = {
 			center,
@@ -17,7 +17,7 @@ window.averageRange = class {
 		return retval;
 	}
 };
-window.evenFillArray = function(array, amount, lookupAmount) {
+globalThis.evenFillArray = function(array, amount, lookupAmount) {
 	let perItem, changed;
 	let retval = [];
 	do {
@@ -48,7 +48,7 @@ window.evenFillArray = function(array, amount, lookupAmount) {
 	}
 	return retval;
 };
-window.typeHiddenMembers = class {
+globalThis.typeHiddenMembers = class {
 	constructor() {
 		this._const = {};
 		this._var   = {};
@@ -914,7 +914,7 @@ App.Corporate.Init = function() {
 // Corporation Share Price
 // A positive q means adding shares to the market, negative means removing them
 
-window.corpSharePrice = function(q = 0, personalShares = null, publicShares = null) {
+globalThis.corpSharePrice = function(q = 0, personalShares = null, publicShares = null) {
 	if (V.corp.Incorporated === 0) {
 		return 0;
 	}
@@ -925,7 +925,7 @@ window.corpSharePrice = function(q = 0, personalShares = null, publicShares = nu
 
 // Corporation race blacklisting/whitelisting
 // race is the lowercase string representing the race, 'blacklist' is either 1 or 0. 1 means we are blacklisting and 0 means we are whitelisting said race
-window.corpBlacklistRace = function(race, blacklist) {
+globalThis.corpBlacklistRace = function(race, blacklist) {
 	let raceArray = V.corp.SpecRaces;
 	if (raceArray.length > 0 && blacklist === 1) {
 		raceArray.delete(race);
diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js
index 84952230dac5da90dfab7b1d79d97a216e7d3db9..425d5388b4a4fc7f99dc421a597e5611eb8d53f4 100644
--- a/src/Mods/SecExp/js/secExp.js
+++ b/src/Mods/SecExp/js/secExp.js
@@ -1,4 +1,4 @@
-window.SecExpBase = function SecExpBase() {
+globalThis.SecExpBase = function() {
 	return new App.SecExp.SecurityExpansionState();
 };
 
diff --git a/src/Mods/SecExp/widgets/battleWidgets.js b/src/Mods/SecExp/widgets/battleWidgets.js
index ec7188cc8f91aa328024bfc0684ba5dab4754017..4a677410e70014a32111e8fb2db1649f5ca8fb86 100644
--- a/src/Mods/SecExp/widgets/battleWidgets.js
+++ b/src/Mods/SecExp/widgets/battleWidgets.js
@@ -1,4 +1,4 @@
-window.calcSFStatistics = function() {
+globalThis.calcSFStatistics = function() {
 	let upgradesSum = V.SF.Squad.Armoury + V.SF.Squad.Drugs + (V.SF.Squad.AA+V.SF.Squad.TA < 1) + (V.SF.Squad.AV+V.SF.Squad.TV);
 	if (!Number.isInteger(upgradesSum)) {
 		upgradesSum = jsRandom(10, 15);
@@ -31,7 +31,7 @@ window.calcSFStatistics = function() {
 /**
  * @param {Array<number>} rebellionIDs Array of unit IDs to be removed.
  */
-window.removeUnits = function(rebellionIDs) {
+globalThis.removeUnits = function(rebellionIDs) {
 	V.militiaUnits = V.militiaUnits.filter(unit => !rebellionIDs.includes(unit.ID));
 	V.slaveUnits = V.slaveUnits.filter(unit => !rebellionIDs.includes(unit.ID));
 	V.mercUnits = V.mercUnits.filter(unit => !rebellionIDs.includes(unit.ID));
diff --git a/src/art/artJS.js b/src/art/artJS.js
index d1fcb88fdb28f87f1da3429a6647643875e8ae22..a52575cb1d236eb928820cf29550d7eb12920231 100644
--- a/src/art/artJS.js
+++ b/src/art/artJS.js
@@ -11,7 +11,7 @@
  * @param {number} [UIDisplay] (optional, only used by legacy art): icon UI Display for vector art, 1 for on
  * @returns {string}
  */
-window.SlaveArt = function(artSlave, artSize, UIDisplay) {
+globalThis.SlaveArt = function(artSlave, artSize, UIDisplay) {
 	const imageChoice = V.imageChoice;
 	if (artSlave.custom.image !== null && artSlave.custom.image.filename !== "") {
 		return CustomArt(artSlave, artSize);
@@ -87,7 +87,7 @@ App.Art.refreshSlaveArt = function(artSlave, artSize, elementID, UIDisplay=0) {
 	return;
 };
 
-window.ArtControlRendered = function ArtControlRendered(slave, sizePlacement) {
+globalThis.ArtControlRendered = function(slave, sizePlacement) {
 	return App.Art.elementToMarkup(App.Art.renderedArtElement(slave, sizePlacement));
 };
 
@@ -96,7 +96,7 @@ window.ArtControlRendered = function ArtControlRendered(slave, sizePlacement) {
  * @param {number} imageSize
  * @returns {string}
  */
-window.CustomArt = function(slave, imageSize) {
+globalThis.CustomArt = function(slave, imageSize) {
 	return App.Art.elementToMarkup(App.Art.customArtElement(slave, imageSize));
 };
 
@@ -223,7 +223,7 @@ eyes can be nearly anything, it only indicates that the function is being used f
 This code's working is described to the user in the Encyclopedia, chapter "Lore", section "Dyes".
 */
 
-window.extractColor = function(color, eyes) {
+globalThis.extractColor = function(color, eyes) {
 	/*
 	these are color names known and used in FreeCities
 	attributed color names are at the front of the array
@@ -314,7 +314,7 @@ window.extractColor = function(color, eyes) {
 	return colorCode;
 };
 
-window.clothing2artSuffix = function(v) {
+globalThis.clothing2artSuffix = function(v) {
 	if (v === "restrictive latex") {
 		v = "latex";
 	} /* universal "special case": latex art is actually "restrictive latex" TODO: align name in vector source */
@@ -330,7 +330,7 @@ window.clothing2artSuffix = function(v) {
 		.replace(/\W/g, ""); /* remove remaining whitespace */
 };
 
-window.skinColorCatcher = function(artSlave) {
+globalThis.skinColorCatcher = function(artSlave) {
 	let colorSlave = {
 		skinColor: "#e8b693",
 		areolaColor: "#d76b93",
diff --git a/src/art/assistantArt.js b/src/art/assistantArt.js
index 5c431001c9e266571de04d428662f5f74ca4c665..1e7e3c3dc440ff52300128e748d86f2f16b700aa 100644
--- a/src/art/assistantArt.js
+++ b/src/art/assistantArt.js
@@ -4,7 +4,7 @@ sizePlacement: Image size/center.
 	3: Large, right. Example: description.
 	2: Medium, right. Example: random events.
 */
-window.assistantArt = function assistantArt(sizePlacement) {
+globalThis.assistantArt = function(sizePlacement) {
 	let fileName = "";
 
 	if (V.seeAvatar !== 1) { return; }
diff --git a/src/art/vector/VectorArtJS.js b/src/art/vector/VectorArtJS.js
index 77001e7f3698eed684dd69e44842d94e515c9aff..ab842c9c0b06812875be75bd0af263ccf8d04937 100644
--- a/src/art/vector/VectorArtJS.js
+++ b/src/art/vector/VectorArtJS.js
@@ -1,8 +1,8 @@
-window.VectorArt = function(artSlave, artSize) {
+globalThis.VectorArt = function(artSlave, artSize) {
 	return App.Art.elementToMarkup(App.Art.SlaveArtElement(artSlave, artSize));
 };
 
-window.LegacyVectorArt = function(slave, artSize) {
+globalThis.LegacyVectorArt = function(slave, artSize) {
 	return App.Art.elementToMarkup(App.Art.legacyVectorArtElement(slave, artSize));
 };
 
diff --git a/src/art/vector_revamp/vectorRevampedArtControl.js b/src/art/vector_revamp/vectorRevampedArtControl.js
index 668ec900ba3144637f116c9167166247ca610bf9..b7b6b3bf725b05efaccb1977d94781ce62a1791e 100644
--- a/src/art/vector_revamp/vectorRevampedArtControl.js
+++ b/src/art/vector_revamp/vectorRevampedArtControl.js
@@ -1,5 +1,5 @@
 /* eslint-disable camelcase */
-window.RevampedVectorArt = function(slave) {
+globalThis.RevampedVectorArt = function(slave) {
 	return App.Art.elementToMarkup(App.Art.revampedVectorArtElement(slave));
 };
 
@@ -67,7 +67,7 @@ App.Art.revampedVectorArtElement = function(slave) {
 	return res;
 };
 
-window.getVectorArtRevampedControl = function(artDisplayClass, artSlave, globalShowHighlights, globalShowBodyMods) {
+globalThis.getVectorArtRevampedControl = function(artDisplayClass, artSlave, globalShowHighlights, globalShowBodyMods) {
 	return new RevampedArtControl(artDisplayClass, artSlave, globalShowHighlights, globalShowBodyMods);
 };
 
diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js
index 35d84b553e698e83d7a85823f4c12e3b07b8218c..4eef584acb282eb4dfc97d2b0c3e74b246e86426 100644
--- a/src/data/backwardsCompatibility/datatypeCleanup.js
+++ b/src/data/backwardsCompatibility/datatypeCleanup.js
@@ -438,7 +438,7 @@ App.Entity.Utils.SlaveDataSchemeCleanup = (function() {
 		If you want slave.value to be a string, there's no easy tricks to make sure it's already an accepted value. The simplest way is the following
 			if (typeof slave.value !== "string") slave.value = default;
 */
-window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
+globalThis.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 	"use strict";
 
 	return SlaveDatatypeCleanup;
@@ -1120,7 +1120,7 @@ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 })();
 
 /* a lot of this may need to be removed */
-window.ChildDatatypeCleanup = function ChildDatatypeCleanup(child) {
+globalThis.ChildDatatypeCleanup = function(child) {
 	childAgeDatatypeCleanup(child);
 	childPhysicalDatatypeCleanup(child);
 	childFaceDatatypeCleanup(child);
@@ -1146,7 +1146,7 @@ window.ChildDatatypeCleanup = function ChildDatatypeCleanup(child) {
 	generatePronouns(child);
 };
 
-window.childAgeDatatypeCleanup = function childAgeDatatypeCleanup(child) {
+globalThis.childAgeDatatypeCleanup = function(child) {
 	child.birthWeek = Math.clamp(+child.birthWeek, 0, 51) || 0;
 	if (child.age > 0) {
 		child.actualAge = Math.clamp(+child.actualAge, V.minimumChildAge, Infinity) || child.age; /* if undefined, this sets to child.age */
@@ -1161,7 +1161,7 @@ window.childAgeDatatypeCleanup = function childAgeDatatypeCleanup(child) {
 	child.pubertyAgeXY = Math.max(+child.pubertyAgeXY, 0) || V.potencyAge;
 };
 
-window.childPhysicalDatatypeCleanup = function childPhysicalDatatypeCleanup(child) {
+globalThis.childPhysicalDatatypeCleanup = function(child) {
 	if (typeof child.nationality !== "string") {
 		child.nationality = "child";
 	}
@@ -1199,7 +1199,7 @@ window.childPhysicalDatatypeCleanup = function childPhysicalDatatypeCleanup(chil
 	child.hips = Math.clamp(+child.hips, -2, 3) || 0;
 };
 
-window.childFaceDatatypeCleanup = function childFaceDatatypeCleanup(child) {
+globalThis.childFaceDatatypeCleanup = function(child) {
 	child.face = Math.clamp(+child.face, -100, 100) || 0;
 	if (typeof child.faceShape !== "string") {
 		child.faceShape = "normal";
@@ -1209,7 +1209,7 @@ window.childFaceDatatypeCleanup = function childFaceDatatypeCleanup(child) {
 	}
 };
 
-window.childHairDatatypeCleanup = function childHairDatatypeCleanup(child) {
+globalThis.childHairDatatypeCleanup = function(child) {
 	if (typeof child.hColor !== "string") {
 		child.hColor = "brown";
 	}
@@ -1247,7 +1247,7 @@ window.childHairDatatypeCleanup = function childHairDatatypeCleanup(child) {
 	}
 };
 
-window.childBoobsDatatypeCleanup = function childBoobsDatatypeCleanup(child) {
+globalThis.childBoobsDatatypeCleanup = function(child) {
 	child.boobs = Math.max(+child.boobs, 100) || 200;
 	if (typeof child.boobShape !== "string") {
 		child.boobShape = "normal";
@@ -1266,7 +1266,7 @@ window.childBoobsDatatypeCleanup = function childBoobsDatatypeCleanup(child) {
 	child.lactationAdaptation = Math.clamp(+child.lactationAdaptation, 0, 100) || 0;
 };
 
-window.childButtDatatypeCleanup = function childButtDatatypeCleanup(child) {
+globalThis.childButtDatatypeCleanup = function(child) {
 	if (child.butt !== 0) {
 		child.butt = Math.clamp(+child.butt, 0, 20) || 1;
 	}
@@ -1274,7 +1274,7 @@ window.childButtDatatypeCleanup = function childButtDatatypeCleanup(child) {
 	child.analArea = Math.max(+child.analArea, 0) || 0;
 };
 
-window.childPregnancyDatatypeCleanup = function childPregnancyDatatypeCleanup(child) {
+globalThis.childPregnancyDatatypeCleanup = function(child) {
 	child.induce = Math.clamp(+child.induce, 0, 1) || 0;
 	child.labor = Math.clamp(+child.labor, 0, 1) || 0;
 	child.prematureBirth = Math.clamp(+child.prematureBirth, 0, 1) || 0;
@@ -1292,13 +1292,13 @@ window.childPregnancyDatatypeCleanup = function childPregnancyDatatypeCleanup(ch
 	WombNormalizePreg(child);
 };
 
-window.childBellyDatatypeCleanup = function childBellyDatatypeCleanup(child) {
+globalThis.childBellyDatatypeCleanup = function(child) {
 	child.bellySag = Math.max(+child.bellySag, 0) || 0;
 	child.bellySagPreg = Math.max(+child.bellySagPreg, 0) || child.bellySag;
 	SetBellySize(child);
 };
 
-window.childGenitaliaDatatypeCleanup = function childGenitaliaDatatypeCleanup(child) {
+globalThis.childGenitaliaDatatypeCleanup = function(child) {
 	child.vagina = Math.clamp(+child.vagina, -1, 10) || 0;
 	child.vaginaLube = Math.clamp(+child.vaginaLube, 0, 2) || 0;
 	child.labia = Math.clamp(+child.labia, 0, 3) || 0;
@@ -1316,7 +1316,7 @@ window.childGenitaliaDatatypeCleanup = function childGenitaliaDatatypeCleanup(ch
 	}
 };
 
-window.childImplantsDatatypeCleanup = function childImplantsDatatypeCleanup(child) {
+globalThis.childImplantsDatatypeCleanup = function(child) {
 	child.ageImplant = Math.clamp(+child.ageImplant, 0, 1) || 0;
 	child.faceImplant = Math.clamp(+child.faceImplant, 0, 100) || 0;
 	child.lipsImplant = Math.clamp(+child.lipsImplant, 0, 100) || 0;
@@ -1337,7 +1337,7 @@ window.childImplantsDatatypeCleanup = function childImplantsDatatypeCleanup(chil
 	child.earImplant = Math.clamp(+child.earImplant, 0, 1) || 0;
 };
 
-window.childPiercingsDatatypeCleanup = function childPiercingsDatatypeCleanup(child) {
+globalThis.childPiercingsDatatypeCleanup = function(child) {
 	child.earPiercing = Math.clamp(+child.earPiercing, 0, 2) || 0;
 	child.nosePiercing = Math.clamp(+child.nosePiercing, 0, 2) || 0;
 	child.eyebrowPiercing = Math.clamp(+child.eyebrowPiercing, 0, 2) || 0;
@@ -1353,7 +1353,7 @@ window.childPiercingsDatatypeCleanup = function childPiercingsDatatypeCleanup(ch
 	child.anusPiercing = Math.clamp(+child.anusPiercing, 0, 2) || 0;
 };
 
-window.childTattooDatatypeCleanup = function childTattooDatatypeCleanup(child) {
+globalThis.childTattooDatatypeCleanup = function(child) {
 	if (typeof child.shouldersTat !== "string") {
 		child.shouldersTat = 0;
 	}
@@ -1395,7 +1395,7 @@ window.childTattooDatatypeCleanup = function childTattooDatatypeCleanup(child) {
 	}
 };
 
-window.childCosmeticsDatatypeCleanup = function childCosmeticsDatatypeCleanup(child) {
+globalThis.childCosmeticsDatatypeCleanup = function(child) {
 	child.makeup = Math.clamp(+child.makeup, 0, 8) || 0;
 	child.nails = Math.clamp(+child.nails, 0, 9) || 0;
 	child.chastityAnus = Math.clamp(+child.chastityAnus, 0, 1) || 0;
@@ -1452,7 +1452,7 @@ window.childCosmeticsDatatypeCleanup = function childCosmeticsDatatypeCleanup(ch
 	}
 };
 
-window.childDietDatatypeCleanup = function childDietDatatypeCleanup(child) {
+globalThis.childDietDatatypeCleanup = function(child) {
 	if (typeof child.diet !== "string") {
 		child.diet = "healthy";
 	}
@@ -1461,14 +1461,14 @@ window.childDietDatatypeCleanup = function childDietDatatypeCleanup(child) {
 	child.onDiet = Math.clamp(+child.onDiet, 0, 1) || 0;
 	child.hormones = Math.clamp(+child.hormones, -2, 2) || 0;
 	child.hormoneBalance = Math.clamp(+child.hormoneBalance, -400, 400) || 0;
-	if (typeof child.drugs !== "string" || slave.drugs === "none") {
+	if (typeof child.drugs !== "string" || child.drugs === "none") {
 		child.drugs = "no drugs";
 	}
 	child.aphrodisiacs = Math.clamp(+child.aphrodisiacs, 0, 2) || 0;
 	child.curatives = Math.clamp(+child.curatives, 0, 2) || 0;
 };
 
-window.childPornDatatypeCleanup = function childPornDatatypeCleanup(child) {
+globalThis.childPornDatatypeCleanup = function(child) {
 	child.porn.feed = Math.clamp(+child.porn.feed, 0, 1) || 0;
 	child.porn.viewerCount = Math.max(+child.porn.viewerCount, 0) || 0;
 	child.porn.spending = Math.max(+child.porn.spending, 0) || 0;
@@ -1487,7 +1487,7 @@ window.childPornDatatypeCleanup = function childPornDatatypeCleanup(child) {
 	}
 };
 
-window.childRelationDatatypeCleanup = function childRelationDatatypeCleanup(child) {
+globalThis.childRelationDatatypeCleanup = function(child) {
 	child.mother = +child.mother || 0;
 	child.father = +child.father || 0;
 	child.canRecruit = Math.clamp(+child.canRecruit, 0, 1) || 0;
@@ -1497,7 +1497,7 @@ window.childRelationDatatypeCleanup = function childRelationDatatypeCleanup(chil
 	child.rivalry = Math.clamp(+child.rivalry, 0, 3) || 0;
 };
 
-window.childSkillsDatatypeCleanup = function childSkillsDatatypeCleanup(child) {
+globalThis.childSkillsDatatypeCleanup = function(child) {
 	child.skill.oral = Math.clamp(+child.skill.oral, 0, 100) || 0;
 	child.skill.vaginal = Math.clamp(+child.skill.vaginal, 0, 100) || 0;
 	child.skill.anal = Math.clamp(+child.skill.anal, 0, 100) || 0;
@@ -1522,7 +1522,7 @@ window.childSkillsDatatypeCleanup = function childSkillsDatatypeCleanup(child) {
 	child.skill.whore = Math.clamp(+child.skill.whore, 0, 200) || 0;
 };
 
-window.childStatCountDatatypeCleanup = function childStatCountDatatypeCleanup(child) {
+globalThis.childStatCountDatatypeCleanup = function(child) {
 	child.counter.oral = Math.max(+child.counter.oral, 0) || 0;
 	child.counter.vaginal = Math.max(+child.counter.vaginal, 0) || 0;
 	child.counter.anal = Math.max(+child.counter.anal, 0) || 0;
@@ -1542,7 +1542,7 @@ window.childStatCountDatatypeCleanup = function childStatCountDatatypeCleanup(ch
 	child.bodySwap = Math.max(+child.bodySwap, 0) || 0;
 };
 
-window.childPreferencesDatatypeCleanup = function childPreferencesDatatypeCleanup(child) {
+globalThis.childPreferencesDatatypeCleanup = function(child) {
 	child.energy = Math.clamp(+child.energy, 0, 100) || 0;
 	child.need = Math.max(+child.need, 0) || 0;
 	child.attrXY = Math.clamp(+child.attrXY, 0, 100) || 0;
@@ -1552,12 +1552,12 @@ window.childPreferencesDatatypeCleanup = function childPreferencesDatatypeCleanu
 	child.fetishKnown = Math.clamp(+child.fetishKnown, 0, 1) || 0;
 };
 
-window.childRulesDatatypeCleanup = function childRulesDatatypeCleanup(child) {
+globalThis.childRulesDatatypeCleanup = function(child) {
 	child.breedingMark = Math.clamp(+child.breedingMark, 0, 1) || 0;
 	child.rudeTitle = Math.clamp(+child.rudeTitle, 0, 1) || 0;
 };
 
-window.childCustomStatsDatatypeCleanup = function childCustomStatsDatatypeCleanup(child) {
+globalThis.childCustomStatsDatatypeCleanup = function(child) {
 	if (typeof child.custom.label !== "string") {
 		child.custom.label = "";
 	}
@@ -1577,7 +1577,7 @@ window.childCustomStatsDatatypeCleanup = function childCustomStatsDatatypeCleanu
 	}
 };
 
-window.childMiscellaneousDatatypeCleanup = function childMiscellaneousDatatypeCleanup(child) {
+globalThis.childMiscellaneousDatatypeCleanup = function(child) {
 	child.weekAcquired = Math.max(+child.weekAcquired, 0) || 0;
 	child.prestige = Math.clamp(+child.prestige, 0, 3) || 0;
 	child.devotion = Math.clamp(+child.devotion, -100, 100) || 0;
@@ -1604,7 +1604,7 @@ window.childMiscellaneousDatatypeCleanup = function childMiscellaneousDatatypeCl
 };
 
 /* Make sure any new PC variables put into use are added to this! */
-window.PCDatatypeCleanup = function PCDatatypeCleanup() {
+globalThis.PCDatatypeCleanup = function() {
 	const PC = V.PC;
 
 	if (PC.title !== 0) {
@@ -1787,7 +1787,7 @@ window.PCDatatypeCleanup = function PCDatatypeCleanup() {
 	PC.accent = 0;
 };
 
-window.EconomyDatatypeCleanup = function EconomyDatatypeCleanup() {
+globalThis.EconomyDatatypeCleanup = function() {
 	V.arcologies[0].prosperity = Math.clamp(+V.arcologies[0].prosperity, 1, V.AProsperityCap) || 1;
 	V.AProsperityCap = Math.max(+V.AProsperityCap, 0) || 0;
 	V.economy = Math.max(+V.economy, 20) || 100;
@@ -1916,7 +1916,7 @@ window.EconomyDatatypeCleanup = function EconomyDatatypeCleanup() {
 	}
 };
 
-window.ArcologyDatatypeCleanup = function ArcologyDatatypeCleanup() {
+globalThis.ArcologyDatatypeCleanup = function() {
 	V.arcologies[0].ownership = Math.clamp(+V.arcologies[0].ownership, 0, 100) || 0;
 	V.arcologies[0].minority = Math.clamp(+V.arcologies[0].minority, 0, 100) || 0;
 
@@ -1963,7 +1963,7 @@ window.ArcologyDatatypeCleanup = function ArcologyDatatypeCleanup() {
 	V.NUL.schoolProsperity = Math.clamp(+V.NUL.schoolProsperity, -10, 10) || 0;
 };
 
-window.FacilityDatatypeCleanup = (function() {
+globalThis.FacilityDatatypeCleanup = (function() {
 	"use strict";
 
 	return FacilityDatatypeCleanup;
diff --git a/src/debugging/debugJS.js b/src/debugging/debugJS.js
index 92f29adeb43750a93d37d3053a083816f3b243e3..87387e4ecc83960db3b92bb8f41dda16a14a4af1 100644
--- a/src/debugging/debugJS.js
+++ b/src/debugging/debugJS.js
@@ -4,7 +4,7 @@
 Given an object, this will return an array where for each property of the original object, we include the object
 {variable: property, oldVal: _oldDiff.property, newVal: _newDiff.property}
 */
-window.generateDiffArray = function generateDiffArray(obj) {
+globalThis.generateDiffArray = function(obj) {
 	let diffArray = Object.keys(obj).map(function(key) {
 		return {variable: key, oldVal: State.temporary.oldDiff[key], newVal: State.temporary.newDiff[key]};
 	});
@@ -15,7 +15,7 @@ window.generateDiffArray = function generateDiffArray(obj) {
 Shamelessly copied from https://codereview.stackexchange.com/a/11580
 Finds and returns the difference between two objects. Potentially will have arbitrary nestings of objects.
 */
-window.difference = function difference(o1, o2) {
+globalThis.difference = function(o1, o2) {
 	let k, kDiff, diff = {};
 	for (k in o1) {
 		if (!o1.hasOwnProperty(k)) {
@@ -48,7 +48,7 @@ Shamelessly copied from https://stackoverflow.com/a/19101235
 Flattens an object while concatenating property names.
 For example {id: {number: 4, name: "A"}} --> {id.number: 4, id.name: "A"}
 */
-window.diffFlatten = function diffFlatten(data) {
+globalThis.diffFlatten = function(data) {
 	let result = {};
 	function recurse(cur, prop) {
 		if (Object(cur) !== cur) {
@@ -76,7 +76,7 @@ window.diffFlatten = function diffFlatten(data) {
 /*
 Finds all NaN values anywhere in the State.variables object. Returns an array with the names of the NaNed variables.
 */
-window.findNaN = function findNan() {
+globalThis.findNaN = function() {
 	const flatV = diffFlatten(State.variables);
 	let result = [];
 	for (let key in flatV) {
diff --git a/src/debugging/profileInclude.js b/src/debugging/profileInclude.js
index e686dcb3862cb856bb427cee73faffc34a840e2a..c390d6d7da595f49aacaf50df149da15746785f9 100644
--- a/src/debugging/profileInclude.js
+++ b/src/debugging/profileInclude.js
@@ -1,6 +1,6 @@
 /* This is a terrible hack, but it actually seems to yield decent results, so...yay? */
 
-window.ProfileInclude = (function() {
+globalThis.ProfileInclude = (function() {
 	let stack = [];
 	let tally = new Map();
 	let builtinIncludeHandler = null;
diff --git a/src/endWeek/endWeek.js b/src/endWeek/endWeek.js
index fd821723648583d827faedd2b8fe235dbb4755e8..b83b57856a8d267b55968890fd21d99b9a0d9777 100644
--- a/src/endWeek/endWeek.js
+++ b/src/endWeek/endWeek.js
@@ -1,4 +1,4 @@
-window.endWeek = (function() {
+globalThis.endWeek = (function() {
 	function doEndWeek() {
 		// purge SugarCube's expired state cache
 		State.expired.length = 0;
diff --git a/src/endWeek/healthFunctions.js b/src/endWeek/healthFunctions.js
index a75e392f7043104b2b013c5edd751df417541c0a..f4ccbdf1db78429286ab3a55650c0107d2aafbeb 100644
--- a/src/endWeek/healthFunctions.js
+++ b/src/endWeek/healthFunctions.js
@@ -56,7 +56,7 @@ Health
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.illness = function illness(slave) {
+globalThis.illness = function(slave) {
 	const random = jsRandom(1, 100); // high rolls are good
 	const H = slave.health;
 	let r = ``;
@@ -153,7 +153,7 @@ window.illness = function illness(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {void}
  */
-window.getIll = function getIll(slave) {
+globalThis.getIll = function(slave) {
 	const H = slave.health;
 	const illness = jsRandom(1, 6) + jsRandom(1, 6) + jsRandom(1, 6) - Math.trunc(slave.chem / 150) + Math.trunc(H.condition / 20);
 	if (V.seeIllness !== 0) {
@@ -181,7 +181,7 @@ window.getIll = function getIll(slave) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {string}
  */
-window.passIllness = function passIllness(slave1, slave2) {
+globalThis.passIllness = function(slave1, slave2) {
 	if (V.seeIllness !== 0) {
 		if (slave1.curatives !== 1) {
 			if (slave1.assignment !== "get treatment in the clinic") {
@@ -197,7 +197,7 @@ window.passIllness = function passIllness(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave
  * @returns {void}
  */
-window.poorHealthNeedReduction = function poorHealthNeedReduction(slave) {
+globalThis.poorHealthNeedReduction = function(slave) {
 	// Slave .need reduction if ill or tired
 	if (slave.energy > 20) {
 		slave.need = Math.trunc(slave.need * healthPenalty(slave));
@@ -209,7 +209,7 @@ window.poorHealthNeedReduction = function poorHealthNeedReduction(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.nurseEffectiveness = function nurseEffectiveness(slave) {
+globalThis.nurseEffectiveness = function(slave) {
 	const H = slave.health;
 	const clinicUpgrade = 1; // Creating a purchasable upgrade to increase the amount of slaves the nurse can handle -- TODO
 	const clinicScreening = 1; // Assumes the clinic is set to screening all slaves to improve their chances of staying healthy. Turning it off would allow the nurse to focus on just her patients in the clinic -- TODO
@@ -244,7 +244,7 @@ window.nurseEffectiveness = function nurseEffectiveness(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {void}
  */
-window.endWeekHealthDamage = function endWeekHealthDamage(slave) {
+globalThis.endWeekHealthDamage = function(slave) {
 	const H = slave.health;
 	let chemToShort = 0;
 	let shortToCondition = 0;
@@ -331,7 +331,7 @@ window.endWeekHealthDamage = function endWeekHealthDamage(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.willWorkToDeath = function willWorkToDeath(slave) {
+globalThis.willWorkToDeath = function(slave) {
 	// More to come in the future
 	if (slave.trust < -50) { // Maybe lower
 		return true;
@@ -354,7 +354,7 @@ window.willWorkToDeath = function willWorkToDeath(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.slaveResting = function slaveResting(slave) {
+globalThis.slaveResting = function(slave) {
 	if (slave.rules.rest === "cruel" && slave.health.tired > 90) {
 		return true;
 	} else if (slave.rules.rest === "restrictive" && slave.health.tired > 60) {
@@ -370,7 +370,7 @@ window.slaveResting = function slaveResting(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {void}
  */
-window.tired = function tired(slave) {
+globalThis.tired = function(slave) {
 	const H = slave.health;
 	let livingRules = 0;
 	let restRules = 0;
@@ -644,14 +644,14 @@ window.tired = function tired(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.restEffects = function restEffects(slave, exhaustion) {
+globalThis.restEffects = function(slave, exhaustion) {
 	// exhaustion holds the weekly .tired gain from the assignment.
 	if (!slave.fuckdoll) {
 		if (slave.rules.rest === "mandatory") {
 			return .86;
 		} else if (slaveResting(slave)) {
 			return .25;
-		} else if (slave.tired + exhaustion >= 90 && !willWorkToDeath(slave)) {
+		} else if (slave.health.tired + exhaustion >= 90 && !willWorkToDeath(slave)) {
 			return .10;
 		} else {
 			return healthPenalty(slave);
@@ -664,7 +664,7 @@ window.restEffects = function restEffects(slave, exhaustion) {
  * @param {App.Entity.SlaveState} slave
  * @returns {void}
  */
-window.tiredFucks = function tiredFucks(slave) {
+globalThis.tiredFucks = function(slave) {
 	if (!slave.fuckdoll) {
 		let acceptance = 0;
 		acceptance += Math.trunc(slave.energy / 10);
diff --git a/src/endWeek/minorInjuryResponse.js b/src/endWeek/minorInjuryResponse.js
index deed5a56dcd86a83cfe7120a7aaf3b32f73514ca..fb5d62b6b5d8ead77510d69cbfbfc49066be3f3b 100644
--- a/src/endWeek/minorInjuryResponse.js
+++ b/src/endWeek/minorInjuryResponse.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.minorInjuryResponse = function minorInjuryResponse(slave) {
+globalThis.minorInjuryResponse = function(slave) {
 	const arcology = State.variables.arcologies[0];
 	const arcologyUpgrade = State.variables.arcologyUpgrade;
 	const {he, himself, He} = getPronouns(slave);
diff --git a/src/endWeek/saBeYourHeadGirl.js b/src/endWeek/saBeYourHeadGirl.js
index 3aa599ad6c37c88631e1f1d254d4941081154931..25bfce33c8d2c85c44f0c3ff277063b340012574 100644
--- a/src/endWeek/saBeYourHeadGirl.js
+++ b/src/endWeek/saBeYourHeadGirl.js
@@ -1,4 +1,4 @@
-window.saBeYourHeadGirl = (function saBeYourHeadGirl() {
+globalThis.saBeYourHeadGirl = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saChoosesOwnClothes.js b/src/endWeek/saChoosesOwnClothes.js
index d8bc48000d45c9dfb906b402bc2d7034fa50bb8e..392f21a6b1bd4b0edc56956354b09f1e61f59e52 100644
--- a/src/endWeek/saChoosesOwnClothes.js
+++ b/src/endWeek/saChoosesOwnClothes.js
@@ -1,4 +1,4 @@
-window.saChoosesOwnClothes = (function() {
+globalThis.saChoosesOwnClothes = (function() {
 	"use strict";
 
 	let player;
diff --git a/src/endWeek/saClothes.js b/src/endWeek/saClothes.js
index 258045a377410a66e622b0a1416fe97bd90bbe71..8651a09b2d6fee642bfe789be7bf628217619899 100644
--- a/src/endWeek/saClothes.js
+++ b/src/endWeek/saClothes.js
@@ -1,4 +1,4 @@
-window.saClothes = (function saClothes() {
+globalThis.saClothes = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saDrugs.js b/src/endWeek/saDrugs.js
index c6d122eefb3001caa7dda52d561410343ce0402f..b4f5bfc76e03420f5a7f08908f1b405712381fe3 100644
--- a/src/endWeek/saDrugs.js
+++ b/src/endWeek/saDrugs.js
@@ -1,4 +1,4 @@
-window.saDrugs = (function saDrugs() {
+globalThis.saDrugs = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saGetMilked.js b/src/endWeek/saGetMilked.js
index 9c513255cbbe2836e336e6b3d28ccff32f0a8593..e178a13dc56308ca5bd3ab9eea63251afc9b4ff8 100644
--- a/src/endWeek/saGetMilked.js
+++ b/src/endWeek/saGetMilked.js
@@ -1,4 +1,4 @@
-window.saGetMilked = (function saGetMilked() {
+globalThis.saGetMilked = (function() {
 	"use strict";
 
 	let T;
diff --git a/src/endWeek/saGuardYou.js b/src/endWeek/saGuardYou.js
index 21377d5828596ec5820a7c2286ebf3c9d9b272b6..08d35a6aa362653ad836af01691227d75734d74c 100644
--- a/src/endWeek/saGuardYou.js
+++ b/src/endWeek/saGuardYou.js
@@ -1,4 +1,4 @@
-window.saGuardYou = (function saGuardYou() {
+globalThis.saGuardYou = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saHormonesEffects.js b/src/endWeek/saHormonesEffects.js
index adff23b7d629c37f15ec208475600f50cbf8e3d4..91fba50e91a48564ed60126670e4964145db7f37 100644
--- a/src/endWeek/saHormonesEffects.js
+++ b/src/endWeek/saHormonesEffects.js
@@ -1,4 +1,4 @@
-window.saHormonesEffects = (function saHormonesEffects() {
+globalThis.saHormonesEffects = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saInflation.js b/src/endWeek/saInflation.js
index 81525bfce6c021a457862ea0a5c100d2fe214594..5dfc3d380b7d15aedb28759e12ac14731e4f8188 100644
--- a/src/endWeek/saInflation.js
+++ b/src/endWeek/saInflation.js
@@ -1,4 +1,4 @@
-window.saInflation = (function saInflation() {
+globalThis.saInflation = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saNanny.js b/src/endWeek/saNanny.js
index ab67f1e354bf758fc26e41842e0e1100023a36e5..2859da0af2495f53ad74201c01dd35ded6ce33d3 100644
--- a/src/endWeek/saNanny.js
+++ b/src/endWeek/saNanny.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.saNanny = function saNanny(slave) {
+globalThis.saNanny = function(slave) {
 	"use strict";
 	const
 		{
diff --git a/src/endWeek/saPleaseYou.js b/src/endWeek/saPleaseYou.js
index 59831fcac7e636b73802e6624e286a8d82830a20..d906d0f0b64594cbe6b5196f4bf2f51f9d8b3d10 100644
--- a/src/endWeek/saPleaseYou.js
+++ b/src/endWeek/saPleaseYou.js
@@ -1,4 +1,4 @@
-window.saPleaseYou = (function saPleaseYou() {
+globalThis.saPleaseYou = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saPorn.js b/src/endWeek/saPorn.js
index 16592123383b108988c78aa57a315ab447af138b..60e49865afa45fc278613cfa47285d974bf7dafa 100644
--- a/src/endWeek/saPorn.js
+++ b/src/endWeek/saPorn.js
@@ -1,4 +1,4 @@
-window.saPorn = (function saPorn() {
+globalThis.saPorn = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saRest.js b/src/endWeek/saRest.js
index dfb6d41cd547316bbad89d14335f9ed85cff1754..1e9d7b0a2dde1fc9e86c410c85261e0b1bdb45eb 100644
--- a/src/endWeek/saRest.js
+++ b/src/endWeek/saRest.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.saRest = function saRest(slave) {
+globalThis.saRest = function(slave) {
 	/* eslint-disable no-unused-vars*/
 	const {
 		he, him, his, hers, himself, boy,
diff --git a/src/endWeek/saRules_old.js b/src/endWeek/saRules_old.js
index 3e8bdf5df3c012e44273e8f1fd33e2dbdb544314..1cab056664fa81f669f7b88a5d5671ffcce85c5d 100644
--- a/src/endWeek/saRules_old.js
+++ b/src/endWeek/saRules_old.js
@@ -1638,5 +1638,5 @@
 		return false;
 	}
 
-	window.saRules = saRules;
+	globalThis.saRules = saRules;
 })();
diff --git a/src/endWeek/saServant.js b/src/endWeek/saServant.js
index b4ab2088361a24c5f7fad88e856dab260c7eb3bb..a6ddb0e2e8761b24bd74cb56772b60b50e2f4f7f 100644
--- a/src/endWeek/saServant.js
+++ b/src/endWeek/saServant.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.saServant = function saServant(slave) {
+globalThis.saServant = function(slave) {
 	/* eslint-disable no-unused-vars*/
 	const {
 		he, him, his, hers, himself, boy, wife,
diff --git a/src/endWeek/saServeThePublic.js b/src/endWeek/saServeThePublic.js
index 347e4de74f78cfb8561764a40adb2b3ef270c478..ac97dda560488c8be374db5cb975dc5e5f638ee9 100644
--- a/src/endWeek/saServeThePublic.js
+++ b/src/endWeek/saServeThePublic.js
@@ -1,4 +1,4 @@
-window.saServeThePublic = (function saServeThePublic() {
+globalThis.saServeThePublic = (function() {
 	"use strict";
 
 	let T;
diff --git a/src/endWeek/saStayConfined.js b/src/endWeek/saStayConfined.js
index 8ecc54d2ff41e51365e96168fda799b5c17e7f63..69601cdbdec5622bb2ce04c2c9e1ac9fc7b0d31f 100644
--- a/src/endWeek/saStayConfined.js
+++ b/src/endWeek/saStayConfined.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.saStayConfined = function saStayConfined(slave) {
+globalThis.saStayConfined = function(slave) {
 	/* eslint-disable no-unused-vars*/
 	const {
 		he, him, his, hers, himself, boy,
diff --git a/src/endWeek/saTakeClasses.js b/src/endWeek/saTakeClasses.js
index 1b90d9daf7ff5b76cb34e388bd78401f1a96c319..2a896bb1336cff0df39a364805e3f45e29a6a9b1 100644
--- a/src/endWeek/saTakeClasses.js
+++ b/src/endWeek/saTakeClasses.js
@@ -1,4 +1,4 @@
-window.saTakeClasses = (function saTakeClasses() {
+globalThis.saTakeClasses = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/endWeek/saWhore.js b/src/endWeek/saWhore.js
index 6116407ffc83bad29c488e3bce0780680a6cb2b4..1caa97a22ae59b24320e71acb3207fb82edfa0ec 100644
--- a/src/endWeek/saWhore.js
+++ b/src/endWeek/saWhore.js
@@ -1,4 +1,4 @@
-window.saWhore = (function saWhore() {
+globalThis.saWhore = (function() {
 	"use strict";
 
 	let T;
diff --git a/src/endWeek/saWorkAGloryHole.js b/src/endWeek/saWorkAGloryHole.js
index 975690d2d6577cd2d780654047de135e25178191..bac90ca10002ed6f1e5f7413c5e01174a8e0101b 100644
--- a/src/endWeek/saWorkAGloryHole.js
+++ b/src/endWeek/saWorkAGloryHole.js
@@ -1,4 +1,4 @@
-window.saWorkAGloryHole = (function saWorkAGloryHole() {
+globalThis.saWorkAGloryHole = (function() {
 	"use strict";
 
 	let T;
diff --git a/src/endWeek/saWorkTheFarm.js b/src/endWeek/saWorkTheFarm.js
index 9df9ad1a7a17bd82e1b0e9fcde1225c842661442..da4addd71997a29d805e8821a471bb6f17deba33 100644
--- a/src/endWeek/saWorkTheFarm.js
+++ b/src/endWeek/saWorkTheFarm.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.saWorkTheFarm = function(slave) {
+globalThis.saWorkTheFarm = function(slave) {
 	const arcology = V.arcologies[0];
 	const {
 			he, him, his, hers, himself, boy, He, His
diff --git a/src/interaction/main/walkPast.js b/src/interaction/main/walkPast.js
index d5fd629b5cb85b7e3c28a37b2e239d59398c0520..f7f2b89d69e066a77c37da844561d78655809be3 100644
--- a/src/interaction/main/walkPast.js
+++ b/src/interaction/main/walkPast.js
@@ -1,6 +1,6 @@
 /* eslint-disable no-unused-vars */
 
-window.walkPast = (function() {
+globalThis.walkPast = (function() {
 	"use strict";
 
 
diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js
index 578b394c81681e6ec7285726276f2dbbf5034663..ff21553bc557d27458c13f2fc57ddf552ae1a052 100644
--- a/src/js/DefaultRules.js
+++ b/src/js/DefaultRules.js
@@ -1,5 +1,5 @@
 // this code applies RA rules onto slaves
-window.DefaultRules = (function() {
+globalThis.DefaultRules = (function() {
 	"use strict";
 
 	const assignedTypes = {
@@ -2920,9 +2920,9 @@ window.DefaultRules = (function() {
 		}
 		return true;
 	};
-	window.RuleHasError = (rule) => rule.condition.function === "custom"
+	globalThis.RuleHasError = (rule) => rule.condition.function === "custom"
 								 && (rule.condition.data.match(rxCheckEqual)
 								 || !compileCheck(rule.condition.data));
-	window.DefaultRulesError = () => V.defaultRules.some(r => RuleHasError(r));
+	globalThis.DefaultRulesError = () => V.defaultRules.some(r => RuleHasError(r));
 	return DefaultRules;
 })();
diff --git a/src/js/SetBellySize.js b/src/js/SetBellySize.js
index abe9d645c9d6eb5f404fce22772d2b8d6bdef957..93485c47a428acfad0e78d367deb1f040201abe7 100644
--- a/src/js/SetBellySize.js
+++ b/src/js/SetBellySize.js
@@ -1,7 +1,7 @@
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.SetBellySize = function SetBellySize(slave) {
+globalThis.SetBellySize = function(slave) {
 	WombNormalizePreg(slave); /* now with support for legacy code that advances pregnancy by setting .preg++ */
 
 	const _implantSize = (slave.bellyImplant > 0) ? slave.bellyImplant : 0;
diff --git a/src/js/assayJS.js b/src/js/assayJS.js
index ece61679cb89ed4f6ded9a9a55882d0bffc78218..8f76ac9f40eb637e4e37a67b7d85ebd2b09a7714 100644
--- a/src/js/assayJS.js
+++ b/src/js/assayJS.js
@@ -3,7 +3,7 @@
  * @param {App.Entity.SlaveState} B
  * @returns {boolean}
  */
-window.sameAssignmentP = function sameAssignmentP(A, B) {
+globalThis.sameAssignmentP = function(A, B) {
 	return A.assignment === B.assignment;
 };
 
@@ -11,7 +11,7 @@ window.sameAssignmentP = function sameAssignmentP(A, B) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canImproveIntelligence = function canImproveIntelligence(slave) {
+globalThis.canImproveIntelligence = function(slave) {
 	let origIntel = V.genePool.find(function(s) { return s.ID === slave.ID; }).intelligence;
 	return (slave.intelligence < origIntel + 15) && (slave.intelligence < 100);
 };
@@ -20,7 +20,7 @@ window.canImproveIntelligence = function canImproveIntelligence(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.maxHeight = function maxHeight(slave) {
+globalThis.maxHeight = function(slave) {
 	let max = Math.trunc(Math.clamp((Height.mean(slave) * 1.25), 0, 274)); /* max achievable height is expected height plus 25% */
 
 	if (slave.geneticQuirks.dwarfism === 2 && slave.geneticQuirks.gigantism !== 2) {
@@ -34,7 +34,7 @@ window.maxHeight = function maxHeight(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canImproveHeight = function canImproveHeight(slave) {
+globalThis.canImproveHeight = function(slave) {
 	return slave.height < maxHeight(slave);
 };
 
@@ -43,7 +43,7 @@ window.canImproveHeight = function canImproveHeight(slave) {
  * @param {App.Entity.SlaveState} target
  * @returns {boolean}
  */
-window.haveRelationshipP = function haveRelationshipP(slave, target) {
+globalThis.haveRelationshipP = function(slave, target) {
 	return slave.relationshipTarget === target.ID;
 };
 
@@ -52,7 +52,7 @@ window.haveRelationshipP = function haveRelationshipP(slave, target) {
  * @param {App.Entity.SlaveState} target
  * @returns {boolean}
  */
-window.isRivalP = function isRivalP(slave, target) {
+globalThis.isRivalP = function(slave, target) {
 	return slave.rivalryTarget === target.ID;
 };
 
@@ -60,7 +60,7 @@ window.isRivalP = function isRivalP(slave, target) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.supremeRaceP = function supremeRaceP(slave) {
+globalThis.supremeRaceP = function(slave) {
 	return State.variables.arcologies[0].FSSupremacistRace === slave.race;
 };
 
@@ -68,7 +68,7 @@ window.supremeRaceP = function supremeRaceP(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.inferiorRaceP = function inferiorRaceP(slave) {
+globalThis.inferiorRaceP = function(slave) {
 	return State.variables.arcologies[0].FSSubjugationistRace === slave.race;
 };
 
@@ -76,8 +76,8 @@ window.inferiorRaceP = function inferiorRaceP(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isLeaderP = function isLeaderP(slave) {
-	/** @type {App.Entity.SlaveState[]} */
+globalThis.isLeaderP = function(slave) {
+	/** @type {FC.SlaveStateOrZero[]} */
 	const leaders = [V.HeadGirl, V.Bodyguard, V.Recruiter, V.Concubine, V.Nurse, V.Attendant, V.Matron, V.Madam, V.DJ, V.Milkmaid, V.Farmer, V.Stewardess, V.Schoolteacher, V.Wardeness];
 	return leaders.some(leader => leader.ID && leader.ID === slave.ID);
 };
@@ -88,7 +88,7 @@ window.isLeaderP = function isLeaderP(slave) {
  *
  * @param {App.Entity.SlaveState} slave
  */
-window.applyGeneticColor = function(slave) {
+globalThis.applyGeneticColor = function(slave) {
 	if (slave.override_Eye_Color !== 1) {
 		resetEyeColor(slave, "both");
 	}
@@ -114,7 +114,7 @@ window.applyGeneticColor = function(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.newSlave = function newSlave(slave) {
+globalThis.newSlave = function(slave) {
 	if (slave.override_Race !== 1) {
 		slave.origRace = slave.race;
 	}
@@ -257,12 +257,12 @@ window.newSlave = function newSlave(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.addSlave = function addSlave(slave) {
+globalThis.addSlave = function(slave) {
 	State.variables.slaves.push(slave);
 	State.variables.slaveIndices[slave.ID] = State.variables.slaves.length - 1;
 };
 
-window.removeSlave = function removeSlave(index) {
+globalThis.removeSlave = function(index) {
 	const ret = State.variables.slaves.deleteAt(index);
 	State.variables.slaveIndices = slaves2indices();
 	return ret;
@@ -270,9 +270,9 @@ window.removeSlave = function removeSlave(index) {
 
 /**
  * @param {App.Entity.SlaveState[]} [slaves]
- * @returns {object.<number, number>}
+ * @returns {Object.<number, number>}
  */
-window.slaves2indices = function slaves2indices(slaves = State.variables.slaves) {
+globalThis.slaves2indices = function(slaves = State.variables.slaves) {
 	return slaves.reduce((acc, slave, i) => { acc[slave.ID] = i; return acc; }, {});
 };
 
@@ -280,7 +280,7 @@ window.slaves2indices = function slaves2indices(slaves = State.variables.slaves)
  * @param {number} ID
  * @returns {App.Entity.SlaveState}
  */
-window.getSlave = function getSlave(ID) {
+globalThis.getSlave = function(ID) {
 	const index = State.variables.slaveIndices[ID];
 	return index === undefined ? undefined : State.variables.slaves[index];
 };
@@ -289,12 +289,12 @@ window.getSlave = function getSlave(ID) {
  * @param {number} ID
  * @returns {App.Entity.SlaveState}
  */
-window.slaveStateById = function(ID) {
+globalThis.slaveStateById = function(ID) {
 	const index = State.variables.slaveIndices[ID];
 	return index === undefined ? undefined : State.variables.slaves[index];
 };
 
-window.getChild = function getChild(ID) {
+globalThis.getChild = function(ID) {
 	return State.variables.cribs.find(s => s.ID === ID);
 };
 
@@ -391,7 +391,7 @@ App.Utils.Pronouns = class {
  * @param {{pronoun: number}} obj
  * @returns {App.Utils.Pronouns}
  */
-window.getPronouns = function(obj) {
+globalThis.getPronouns = function(obj) {
 	return new App.Utils.Pronouns(obj);
 };
 
@@ -399,7 +399,7 @@ window.getPronouns = function(obj) {
  * @param {number} dickRatio
  * @returns {App.Utils.Pronouns}
  */
-window.getNonlocalPronouns = function(dickRatio) {
+globalThis.getNonlocalPronouns = function(dickRatio) {
 	/* a fake slave object, we need the .pronoun attribute only */
 	const slave = {pronoun: App.Data.Pronouns.Kind.female};
 	/* Used for generic slaves, citizens, security, etc. */
@@ -414,7 +414,7 @@ window.getNonlocalPronouns = function(dickRatio) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.WrittenMaster = function WrittenMaster(slave) {
+globalThis.WrittenMaster = function(slave) {
 	if (slave !== undefined) {
 		Enunciate(slave);
 	} else if (V.titleEnunciate === undefined) {
@@ -426,7 +426,7 @@ window.WrittenMaster = function WrittenMaster(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.Enunciate = function Enunciate(slave) {
+globalThis.Enunciate = function(slave) {
 	if (SlaveStatsChecker.checkForLisp(slave)) {
 		if (V.PC.customTitleLisp !== undefined) {
 			V.titleEnunciate = V.PC.customTitleLisp;
@@ -601,7 +601,7 @@ window.Enunciate = function Enunciate(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.fetishChangeChance = function fetishChangeChance(slave) {
+globalThis.fetishChangeChance = function(slave) {
 	let chance = 0,
 		fetish = (slave.fetishStrength / 4),
 		sex = 0;
@@ -633,7 +633,7 @@ window.fetishChangeChance = function fetishChangeChance(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.SlaveFullName = function SlaveFullName(slave) {
+globalThis.SlaveFullName = function(slave) {
 	const pair = slave.slaveSurname ? [slave.slaveName, slave.slaveSurname] : [slave.slaveName];
 	if ((V.surnameOrder !== 1 && ["Cambodian", "Chinese", "Hungarian", "Japanese", "Korean", "Mongolian", "Taiwanese", "Vietnamese"].includes(slave.nationality)) || (V.surnameOrder === 2)) {
 		pair.reverse();
@@ -645,7 +645,7 @@ window.SlaveFullName = function SlaveFullName(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.SlaveFullBirthName = function SlaveFullBirthName(slave) {
+globalThis.SlaveFullBirthName = function(slave) {
 	const pair = slave.birthSurname ? [slave.birthName, slave.birthSurname] : [slave.birthName];
 	if ((V.surnameOrder !== 1 && ["Cambodian", "Chinese", "Hungarian", "Japanese", "Korean", "Mongolian", "Taiwanese", "Vietnamese"].includes(slave.nationality)) || (V.surnameOrder === 2)) {
 		pair.reverse();
@@ -657,7 +657,7 @@ window.SlaveFullBirthName = function SlaveFullBirthName(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.PoliteRudeTitle = function PoliteRudeTitle(slave) {
+globalThis.PoliteRudeTitle = function(slave) {
 	const PC = V.PC;
 	const s = V.sEnunciate;
 	const ss = V.ssEnunciate;
@@ -687,7 +687,7 @@ window.PoliteRudeTitle = function PoliteRudeTitle(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.SlaveTitle = function SlaveTitle(slave) {
+globalThis.SlaveTitle = function(slave) {
 	let r;
 	if (V.newDescriptions === 1) {
 		if (slave.dick > 0 && slave.balls > 0 && slave.boobs > 300 && slave.vagina > -1 && slave.ovaries === 1) {
@@ -1063,7 +1063,7 @@ window.SlaveTitle = function SlaveTitle(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.DegradingName = function DegradingName(slave) {
+globalThis.DegradingName = function(slave) {
 	const leadershipPosition = [
 		"be the Attendant",
 		"be the Matron",
@@ -1463,7 +1463,7 @@ window.DegradingName = function DegradingName(slave) {
 	slave.slaveSurname = surname;
 };
 
-window.PaternalistName = function PaternalistName(slave) {
+globalThis.PaternalistName = function(slave) {
 	if (slave.slaveName.search("Miss") === -1) {
 		if (slave.slaveName.search("Ms.") === -1) {
 			if (slave.slaveName.search("Mrs.") === -1) {
@@ -1479,7 +1479,7 @@ window.PaternalistName = function PaternalistName(slave) {
 	}
 };
 
-window.SlaveSort = function() {
+globalThis.SlaveSort = function() {
 	const comparators = {
 		Aassignment: (a, b) => a.assignment < b.assignment ? -1 : 1,
 		Dassignment: (a, b) => a.assignment > b.assignment ? -1 : 1,
@@ -1558,11 +1558,11 @@ window.SlaveSort = function() {
 /**
  * @param {App.Entity.SlaveState[]} slaves
  */
-window.slaveSortMinor = function slaveSortMinor(slaves) {
+globalThis.slaveSortMinor = function(slaves) {
 	slaves.sort((a, b) => a.slaveName < b.slaveName ? -1 : 1);
 };
 
-window.MenialPopCap = function MenialPopCap() {
+globalThis.MenialPopCap = function() {
 	let r = "";
 
 	let popCap = 500 * (1 + V.building.findCells(cell => cell instanceof App.Arcology.Cell.Manufacturing && cell.type === "Pens").length);
@@ -1616,7 +1616,7 @@ window.MenialPopCap = function MenialPopCap() {
  * @param {number} amount
  * @returns {string}
  */
-window.faceIncrease = function faceIncrease(slave, amount) {
+globalThis.faceIncrease = function(slave, amount) {
 	const pronouns = getPronouns(slave);
 	const his = pronouns.possessive;
 	const His = capFirstChar(his);
@@ -1645,7 +1645,7 @@ window.faceIncrease = function faceIncrease(slave, amount) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.Deadliness = function Deadliness(slave) {
+globalThis.Deadliness = function(slave) {
 	let deadliness = 2;
 
 	if (slave.skill.combat > 0) {
@@ -1799,7 +1799,7 @@ window.Deadliness = function Deadliness(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.retirementReady = function RetirementReady(slave) {
+globalThis.retirementReady = function(slave) {
 	// indentured slaves don't retire, they expire
 	if (slave.indenture >= 0) {
 		return false;
@@ -1835,9 +1835,9 @@ window.retirementReady = function RetirementReady(slave) {
 
 /** advances the age of a slave by one year, incurring all aging side effects
  * @param {App.Entity.SlaveState} slave
- * @param {bool} [forceDevelopment=false]
+ * @param {boolean} [forceDevelopment=false]
  */
-window.ageSlave = function ageSlave(slave, forceDevelopment=false) {
+globalThis.ageSlave = function (slave, forceDevelopment=false) {
 	slave.physicalAge++;
 	slave.actualAge++;
 	if (slave.geneMods.NCS === 0) {
@@ -1859,7 +1859,7 @@ window.ageSlave = function ageSlave(slave, forceDevelopment=false) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isShelterSlave = function isShelterSlave(slave) {
+globalThis.isShelterSlave = function(slave) {
 	return (typeof slave.origin === "string" && slave.origin.includes("Slave Shelter"));
 };
 
@@ -1869,6 +1869,6 @@ window.isShelterSlave = function isShelterSlave(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.perceivedGender = function(slave) {
+globalThis.perceivedGender = function(slave) {
 	return -1;
 };
diff --git a/src/js/assignJS.js b/src/js/assignJS.js
index 83149f60dbb1a0c89cda60754372f189194e9cae..1002f2fe32ec8a752a207334e8c007dfb8f0262a 100644
--- a/src/js/assignJS.js
+++ b/src/js/assignJS.js
@@ -5,7 +5,7 @@
  * @param {string} job
  * @returns {string}
  */
-window.assignJob = function assignJob(slave, job) {
+globalThis.assignJob = function(slave, job) {
 	"use strict";
 	let r = "";
 	let oldJob = slave.assignment;
@@ -418,7 +418,7 @@ window.assignJob = function assignJob(slave, job) {
  * @param {App.Entity.SlaveState} slave
  * @param {string} assignmentStr
  */
-window.assignJobSafely = function assignJobSafely(slave, assignmentStr) {
+globalThis.assignJobSafely = function(slave, assignmentStr) {
 	if (V.assignmentRecords[slave.ID] === "choose her own job") {
 		assignJob(slave, "rest");
 		slave.choosesOwnAssignment = 1;
@@ -440,7 +440,7 @@ window.assignJobSafely = function assignJobSafely(slave, assignmentStr) {
  * @param {boolean} saveRecord
  * @returns {string}
  */
-window.removeJob = function removeJob(slave, assignment, saveRecord) {
+globalThis.removeJob = function(slave, assignment, saveRecord) {
 	"use strict";
 	let r = "";
 	if (typeof saveRecord === undefined) {
@@ -666,7 +666,7 @@ window.removeJob = function removeJob(slave, assignment, saveRecord) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.assignmentVisible = function assignmentVisible(slave) {
+globalThis.assignmentVisible = function(slave) {
 	switch (slave.assignment) {
 		/* normal out-of-penthouse jobs */
 		case "be confined in the arcade":
@@ -712,7 +712,7 @@ window.assignmentVisible = function assignmentVisible(slave) {
 	return true;
 };
 
-window.resetJobIDArray = function resetJobIDArray() {
+globalThis.resetJobIDArray = function() {
 	/* todo: expand to all assignments */
 
 	/** @type {Array<App.Entity.SlaveState>} */
diff --git a/src/js/colorModeJS.js b/src/js/colorModeJS.js
index a9f57c5981134b898f9893c0bf14578d64135899..7a44f54f894ca31e7c47b6c891f0530a815d8267 100644
--- a/src/js/colorModeJS.js
+++ b/src/js/colorModeJS.js
@@ -1,13 +1,13 @@
-window.flipColors = function(lightColorMap) {
-	if (!window.savedColorMap) {
-		window.savedColorMap = setColors(lightColorMap);
+globalThis.flipColors = function(lightColorMap) {
+	if (!globalThis.savedColorMap) {
+		globalThis.savedColorMap = setColors(lightColorMap);
 	} else {
-		restoreColors(window.savedColorMap);
-		window.savedColorMap = null;
+		restoreColors(globalThis.savedColorMap);
+		globalThis.savedColorMap = null;
 	}
 };
 
-window.setColors = function(colorMap) {
+globalThis.setColors = function(colorMap) {
 	let originalState = [];
 	let props = ["color", "backgroundColor", "backgroundImage"];
 	let styleSheetArray = Array.from(document.styleSheets);
@@ -42,7 +42,7 @@ window.setColors = function(colorMap) {
 	return originalState;
 };
 
-window.restoreColors = function(styleMap) {
+globalThis.restoreColors = function(styleMap) {
 	styleMap.forEach(
 		item => {
 			item.element.style[item.propName] = item.value;
diff --git a/src/js/economyJS.js b/src/js/economyJS.js
index 5f3464847d262fcc6ff229a1ec46567f17a33e68..3518192480bcfee60de613648e04e96891cd8eea 100644
--- a/src/js/economyJS.js
+++ b/src/js/economyJS.js
@@ -1,5 +1,5 @@
-window.LivingRule = Object.freeze({LUXURIOUS: 'luxurious', NORMAL: 'normal', SPARE: 'spare'});
-window.Job = Object.freeze({
+globalThis.LivingRule = Object.freeze({LUXURIOUS: 'luxurious', NORMAL: 'normal', SPARE: 'spare'});
+globalThis.Job = Object.freeze({
 	// Penthouse Assignments
 	REST: 'rest',
 	FUCKTOY: 'please you',
@@ -45,7 +45,7 @@ window.Job = Object.freeze({
 	// Does this one exist?
 	BABY_FACTORY: 'labor in the production line',
 });
-window.PersonalAttention = Object.freeze({
+globalThis.PersonalAttention = Object.freeze({
 	TRADE: 'trading',
 	WAR: 'warfare',
 	SLAVING: 'slaving',
@@ -55,7 +55,7 @@ window.PersonalAttention = Object.freeze({
 	HACKING: 'hacking'
 });
 
-window.CategoryAssociatedGroup = Object.freeze({
+globalThis.CategoryAssociatedGroup = Object.freeze({
 	PENTHOUSE: [
 		'slaveAssignmentRest',
 		'slaveAssignmentRestVign',
@@ -229,7 +229,7 @@ window.CategoryAssociatedGroup = Object.freeze({
 		]
 });
 
-window.calculateCosts = (function() {
+globalThis.calculateCosts = (function() {
 	return {
 		predict: predictCost,
 		bill: getCost,
@@ -936,7 +936,7 @@ window.calculateCosts = (function() {
  * @param {App.Entity.SlaveState} s
  * @returns {Array}
  */
-window.getSlaveCostArray = function(s) {
+globalThis.getSlaveCostArray = function(s) {
 	if (!s) {
 		return 0;
 	}
@@ -1355,7 +1355,7 @@ window.getSlaveCostArray = function(s) {
  * @param {App.Entity.SlaveState} s
  * @returns {number}
  */
-window.getSlaveCost = function(s) {
+globalThis.getSlaveCost = function(s) {
 	return getSlaveCostArray(s).reduce((result, {value})=>result + value, 0);
 };
 
@@ -1365,7 +1365,7 @@ window.getSlaveCost = function(s) {
  * @param {number} q
  * @returns {number}
  */
-window.menialSlaveCost = function(q = 0) {
+globalThis.menialSlaveCost = function(q = 0) {
 	const demand = State.variables.menialDemandFactor;
 	const supply = State.variables.menialSupplyFactor;
 	const baseCost = 1000;
@@ -1373,7 +1373,7 @@ window.menialSlaveCost = function(q = 0) {
 	return (Math.trunc(baseCost + demand / 400 - supply / 400 + q / 400) + random);
 };
 
-window.NPCSexSupply = function(lowerDemandLeft, lowerTotalDemand, middleDemandLeft, middleTotalDemand, upperDemandLeft, upperTotalDemand, topDemandLeft, topTotalDemand) {
+globalThis.NPCSexSupply = function(lowerDemandLeft, lowerTotalDemand, middleDemandLeft, middleTotalDemand, upperDemandLeft, upperTotalDemand, topDemandLeft, topTotalDemand) {
 	const NPCSexSupply = {
 		lowerClass: V.NPCSexSupply.lowerClass,
 		middleClass: V.NPCSexSupply.middleClass,
@@ -1450,7 +1450,7 @@ window.NPCSexSupply = function(lowerDemandLeft, lowerTotalDemand, middleDemandLe
 };
 
 // The function for calculating and storing a slave's sexual interaction with citizens/'the outside'
-window.slaveJobValues = function(lowerClassSexDemandRef, middleClassSexDemandRef, upperClassSexDemandRef, topClassSexDemandRef) {
+globalThis.slaveJobValues = function(lowerClassSexDemandRef, middleClassSexDemandRef, upperClassSexDemandRef, topClassSexDemandRef) {
 	const slaveJobValues = {
 		arcade: 0,
 		club: 0,
@@ -2092,7 +2092,7 @@ window.slaveJobValues = function(lowerClassSexDemandRef, middleClassSexDemandRef
  * @param {App.Entity.SlaveState} s
  * @returns {number}
  */
-window.effectiveWhoreClass = function(s) {
+globalThis.effectiveWhoreClass = function(s) {
 	let score = s.sexAmount * s.sexQuality;
 	let result;
 	if (typeof s.whoreClass === 'undefined' || s.whoreClass === 0) {
@@ -2118,7 +2118,7 @@ window.effectiveWhoreClass = function(s) {
  * End week function to handle the (menial) slave market prices through supply and demand
  * @returns {void}
  */
-window.endWeekSlaveMarket = function() {
+globalThis.endWeekSlaveMarket = function() {
 	const demandVariance = jsRandom(-10, 10) * 20;
 	const supplyVariance = jsRandom(-10, 10) * 20;
 	const demand = V.menialDemandFactor;
@@ -2253,7 +2253,7 @@ window.endWeekSlaveMarket = function() {
  * @param {object|undefined} facility
  * @returns {Object}
  */
-window.getSlaveStatisticData = function(s, facility) {
+globalThis.getSlaveStatisticData = function(s, facility) {
 	if (!facility) { // Base data, even without facility
 		return {
 			ID: s.ID,
@@ -2291,7 +2291,7 @@ window.getSlaveStatisticData = function(s, facility) {
 	return data;
 };
 
-window.initFacilityStatistics = function(facility = {}) {
+globalThis.initFacilityStatistics = function(facility = {}) {
 	facility.adsIncome = 0;
 	facility.maintenance = 0;
 	facility.totalIncome = 0;
@@ -2327,7 +2327,7 @@ A full list of categories (slaveMod, slaveTransfer, event) are in the widget "se
 The third category, the "slave slot" is completely optional. Sometimes you just want to spend money by yourself.
 
 */
-window.cashX = function(cost, what, who) {
+globalThis.cashX = function(cost, what, who) {
 	if (!Number.isFinite(cost)) {
 		V.lastWeeksCashErrors += `Expected a finite number for ${what}, but got ${cost}<br>`;
 		return 0;
@@ -2396,7 +2396,7 @@ window.cashX = function(cost, what, who) {
 	return cost;
 };
 
-window.repX = function(rep, what, who) {
+globalThis.repX = function(rep, what, who) {
 	if (!Number.isFinite(rep)) {
 		V.lastWeeksRepErrors += `Expected a finite number for ${what}, but got ${rep}<br>`;
 		return 0;
@@ -2454,7 +2454,7 @@ window.repX = function(rep, what, who) {
 	return rep;
 };
 
-window.forceNeg = function(x) {
+globalThis.forceNeg = function(x) {
 	return -Math.abs(x);
 };
 
@@ -2462,7 +2462,7 @@ Number.prototype.toFixedHTML = function() {
 	return num(Number.prototype.toFixed.apply(this, arguments)).replace(/\.0+$/, '<span style="opacity: 0.3">$&</span>');
 };
 
-window.SectorCounts = function() {
+globalThis.SectorCounts = function() {
 	// Ternaries: - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
 	V.AProsperityCapModified = V.AProsperityCapModified > 0 ? V.AProsperityCapModified : 0;
 	const caps = [
@@ -2518,7 +2518,7 @@ window.SectorCounts = function() {
  * @param {number} arcology Arcology Index
  * @returns {number}
  */
-window.agentBonus = function(arcology) {
+globalThis.agentBonus = function(arcology) {
 	const agent = App.currentAgent(arcology);
 	let bonus = Math.floor((agent.intelligence+agent.intelligenceImplant)/32);
 	if (agent.actualAge > 35) {
@@ -2548,7 +2548,7 @@ window.agentBonus = function(arcology) {
  * @param {string} NPCclass One of "lower", "middle", "upper", or "top"
  * @returns {string}
  */
-window.supplyPoliciesReport = function(NPCclass) {
+globalThis.supplyPoliciesReport = function(NPCclass) {
 	let r = ``;
 	const varName = `${NPCclass}Class`;
 	const className = NPCclass !== 'top' ? `<b>${NPCclass} class citizens</b>` : `<b>arcology's millionaires</b>`;
@@ -2610,7 +2610,7 @@ window.supplyPoliciesReport = function(NPCclass) {
 	return r;
 };
 
-window.ownershipReport = function({sidebar}) {
+globalThis.ownershipReport = function({sidebar}) {
 	let tint, warning = false, detail = `${V.arcologies[0].ownership}%`;
 	detail += V.assistant.power >= 1 && V.arcologies[0].ownership < 100 ? `:${V.arcologies[0].minority}%` : ``;
 	if (V.arcologies[0].ownership < 100 && V.arcologies[0].minority+5 >= V.arcologies[0].ownership) {
@@ -2633,7 +2633,7 @@ window.ownershipReport = function({sidebar}) {
 	}
 };
 
-window.setupLastWeeksCash = function() {
+globalThis.setupLastWeeksCash = function() {
 	V.lastWeeksCashIncome = new App.Data.Records.LastWeeksCash();
 	V.lastWeeksCashExpenses = new App.Data.Records.LastWeeksCash();
 	V.lastWeeksCashProfits = new App.Data.Records.LastWeeksCash();
@@ -2649,7 +2649,7 @@ window.setupLastWeeksCash = function() {
 	}
 };
 
-window.setupLastWeeksRep = function() {
+globalThis.setupLastWeeksRep = function() {
 	V.lastWeeksRepIncome = new App.Data.Records.LastWeeksRep();
 	V.lastWeeksRepExpenses = new App.Data.Records.LastWeeksRep();
 	V.lastWeeksRepProfits = new App.Data.Records.LastWeeksRep();
diff --git a/src/js/eventSelectionJS.js b/src/js/eventSelectionJS.js
index fa771cadd520e892c37dde1433f191d2c9d9ac1b..75d8654c64343e083f01339f85e403d52d0d5f2f 100644
--- a/src/js/eventSelectionJS.js
+++ b/src/js/eventSelectionJS.js
@@ -1,4 +1,4 @@
-window.generateRandomEventPoolStandard = function(eventSlave) {
+globalThis.generateRandomEventPoolStandard = function(eventSlave) {
 	/* STANDARD EVENTS */
 
 	if (eventSlave.fetish !== "mindbroken") {
@@ -1799,7 +1799,7 @@ window.generateRandomEventPoolStandard = function(eventSlave) {
 };
 
 /* servants spend a lot of time in the penthouse, so should be eligible for a number (but not all) random events */
-window.generateRandomEventPoolServant = function(eventSlave) {
+globalThis.generateRandomEventPoolServant = function(eventSlave) {
 	/* STANDARD EVENTS */
 
 	if (eventSlave.fetish !== "mindbroken") {
@@ -2848,7 +2848,7 @@ window.generateRandomEventPoolServant = function(eventSlave) {
 	}
 };
 
-window.populateEventArray = function(RESS = State.variables.RESSevent.length, RESSTR = State.variables.RESSTRevent.length, RETS = State.variables.RETSevent.length, RECI = State.variables.RECIevent.length) {
+globalThis.populateEventArray = function(RESS = State.variables.RESSevent.length, RESSTR = State.variables.RESSTRevent.length, RETS = State.variables.RETSevent.length, RECI = State.variables.RECIevent.length) {
 	/* EVENT RANDOMIZATION */
 	let events = State.variables.events;
 	let i = 0;
diff --git a/src/js/extendedFamilyModeJS.js b/src/js/extendedFamilyModeJS.js
index 11930ccaa147092c2ebd2b84dd70fb98d1bc3ee8..94ebac59bb1a85ec89bf1579d97718eefd269715 100644
--- a/src/js/extendedFamilyModeJS.js
+++ b/src/js/extendedFamilyModeJS.js
@@ -1,18 +1,18 @@
 /* see documentation for details /devNotes/Extended Family Mode Explained.txt */
 
-window.isMotherP = function isMotherP(daughter, mother) {
+globalThis.isMotherP = function(daughter, mother) {
 	return daughter.mother === mother.ID;
 };
 
-window.isFatherP = function isFatherP(daughter, father) {
+globalThis.isFatherP = function(daughter, father) {
 	return daughter.father === father.ID;
 };
 
-window.isParentP = function isParentP(daughter, parent) {
+globalThis.isParentP = function(daughter, parent) {
 	return isMotherP(daughter, parent) || isFatherP(daughter, parent);
 };
 
-window.isGrandmotherP = function isGrandmotherP(granddaughter, grandmother) {
+globalThis.isGrandmotherP = function(granddaughter, grandmother) {
 	let father;
 	let mother;
 	if (((mother = getSlave(granddaughter.mother)) && (mother.mother === grandmother.ID)) || ((father = getSlave(granddaughter.father)) && (father.mother === grandmother.ID))) {
@@ -21,7 +21,7 @@ window.isGrandmotherP = function isGrandmotherP(granddaughter, grandmother) {
 	return false;
 };
 
-window.isGrandfatherP = function isGrandfatherP(granddaughter, grandfather) {
+globalThis.isGrandfatherP = function(granddaughter, grandfather) {
 	let father;
 	let mother;
 	if (((mother = getSlave(granddaughter.mother)) && (mother.father === grandfather.ID)) || ((father = getSlave(granddaughter.father)) && (father.father === grandfather.ID))) {
@@ -30,33 +30,33 @@ window.isGrandfatherP = function isGrandfatherP(granddaughter, grandfather) {
 	return false;
 };
 
-window.isGrandparentP = function isGrandparentP(granddaughter, grandparent) {
+globalThis.isGrandparentP = function(granddaughter, grandparent) {
 	return isGrandmotherP(granddaughter, grandparent) || isGrandfatherP(granddaughter, grandparent);
 };
 
-window.sameDad = function(slave1, slave2) {
+globalThis.sameDad = function(slave1, slave2) {
 	if ((slave1.father === slave2.father) && (specificDad(slave1))) {
 		return true;
 	}
 	return false;
 };
 
-window.sameMom = function(slave1, slave2) {
+globalThis.sameMom = function(slave1, slave2) {
 	if ((slave1.mother === slave2.mother) && (specificMom(slave1))) {
 		return true;
 	}
 	return false;
 };
 
-window.sameParent = function(slave1, slave2) {
+globalThis.sameParent = function(slave1, slave2) {
 	return sameMom(slave1, slave2) || sameDad(slave1, slave2);
 };
 
-window.specificDad = function(slave) {
+globalThis.specificDad = function(slave) {
 	return (slave.father !== 0 && slave.father !== -2 && slave.father !== -4 && slave.father !== -5 && slave.father !== -6 && slave.father !== -7 && slave.father !== -8 && slave.father !== -9);
 };
 
-window.specificMom = function(slave) {
+globalThis.specificMom = function(slave) {
 	return (slave.mother !== 0 && slave.mother !== -2 && slave.mother !== -4 && slave.mother !== -5 && slave.mother !== -6 && slave.mother !== -7 && slave.mother !== -8 && slave.mother !== -9);
 };
 
@@ -65,7 +65,7 @@ window.specificMom = function(slave) {
  * @param {App.Entity.SlaveState} aunt
  * @returns {boolean}
  */
-window.isAunt = function(niece, aunt) {
+globalThis.isAunt = function(niece, aunt) {
 	if (!State.variables.showDistantRelatives) {
 		return false;
 	}
@@ -85,7 +85,7 @@ window.isAunt = function(niece, aunt) {
 };
 
 // testtest catches the case if a mother is a father or a father a mother - thank you familyAnon, for this code
-window.sameTParent = function(slave1, slave2) {
+globalThis.sameTParent = function(slave1, slave2) {
 	if (slave1.mother === -1 && slave1.father === -1 && slave2.mother === -1 && slave2.father === -1) {
 		return 1;
 	} else if (slave1.mother === slave2.father && slave1.father === slave2.mother && specificMom(slave1) && specificDad(slave1) && slave1.mother !== slave1.father) {
@@ -97,7 +97,7 @@ window.sameTParent = function(slave1, slave2) {
 };
 
 /*
-window.sameTParent = function(slave1, slave2) {
+globalThis.sameTParent = function(slave1, slave2) {
 	if ((slave1.mother === slave2.father || slave1.father === slave2.mother) && (slave1.mother !== 0 && slave1.mother !== -2 && slave1.father !== 0 && slave1.father !== -2)) {
 		return true; //testtest catches the case if a mother is a father or a father a mother
 	} else {
@@ -106,7 +106,7 @@ window.sameTParent = function(slave1, slave2) {
 };
 */
 
-window.areTwins = function(slave1, slave2) {
+globalThis.areTwins = function(slave1, slave2) {
 	if (!sameDad(slave1, slave2)) {
 		return false;
 	} else if (!sameMom(slave1, slave2)) {
@@ -122,7 +122,7 @@ window.areTwins = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {number}
  */
-window.areSisters = function(slave1, slave2) {
+globalThis.areSisters = function(slave1, slave2) {
 	if (slave1.ID === slave2.ID) {
 		return 0; // you are not your own sister
 	} else if (!specificDad(slave1) && !specificMom(slave1)) {
@@ -153,7 +153,7 @@ window.areSisters = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {boolean}
  */
-window.areCousins = function(slave1, slave2) {
+globalThis.areCousins = function(slave1, slave2) {
 	if (!State.variables.showDistantRelatives) {
 		return false;
 	}
@@ -187,7 +187,7 @@ window.areCousins = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {boolean}
  */
-window.areRelated = function(slave1, slave2) {
+globalThis.areRelated = function(slave1, slave2) {
 	return (slave1.father === slave2.ID || slave1.mother === slave2.ID || slave2.father === slave1.ID || slave2.mother === slave1.ID || areSisters(slave1, slave2) > 0);
 };
 
@@ -195,7 +195,7 @@ window.areRelated = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.totalRelatives = function(slave) {
+globalThis.totalRelatives = function(slave) {
 	let relatives = 0;
 	if (slave.mother > 0) {
 		relatives += 1;
@@ -216,9 +216,9 @@ window.totalRelatives = function(slave) {
  * @param {App.Entity.SlaveState} slave1
  * @param {App.Entity.SlaveState} slave2
  * @param {App.Entity.SlaveState[]} slaves
- * @returns {Array}	// I think
+ * @returns {number}
  */
-window.mutualChildren = function(slave1, slave2, slaves) {
+globalThis.mutualChildren = function(slave1, slave2, slaves) {
 	return slaves.filter(function(s) {
 		return s.ID !== slave1.ID && s.ID !== slave2.ID && s.mother > 0 && s.father > 0 && ((s.mother === slave1.ID && s.father === slave2.ID) || (s.mother === slave2.ID && s.father === slave1.ID));
 	}).length;
@@ -229,7 +229,7 @@ window.mutualChildren = function(slave1, slave2, slaves) {
  * @param {function(App.Entity.SlaveState): boolean} filterFunction
  * @returns {App.Entity.SlaveState}
  */
-window.randomRelatedSlave = function(slave, filterFunction) {
+globalThis.randomRelatedSlave = function(slave, filterFunction) {
 	if (!slave || !SugarCube) {
 		return undefined;
 	}
@@ -253,7 +253,7 @@ window.randomRelatedSlave = function(slave, filterFunction) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomRelatedAvailableSlave = function(slave) {
+globalThis.randomRelatedAvailableSlave = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return isSlaveAvailable(s);
 	});
@@ -263,7 +263,7 @@ window.randomRelatedAvailableSlave = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomSister = function(slave) {
+globalThis.randomSister = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return areSisters(slave, s);
 	});
@@ -273,7 +273,7 @@ window.randomSister = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomTwinSister = function(slave) {
+globalThis.randomTwinSister = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return areSisters(slave, s);
 	});
@@ -283,7 +283,7 @@ window.randomTwinSister = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomAvailableSister = function(slave) {
+globalThis.randomAvailableSister = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return isSlaveAvailable(s) && areSisters(slave, s);
 	});
@@ -293,7 +293,7 @@ window.randomAvailableSister = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomAvailableTwinSister = function(slave) {
+globalThis.randomAvailableTwinSister = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return isSlaveAvailable(s) && areSisters(slave, s);
 	});
@@ -303,7 +303,7 @@ window.randomAvailableTwinSister = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomDaughter = function(slave) {
+globalThis.randomDaughter = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return s.mother === slave.ID || s.father === slave.ID;
 	});
@@ -313,7 +313,7 @@ window.randomDaughter = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomAvailableDaughter = function(slave) {
+globalThis.randomAvailableDaughter = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return isSlaveAvailable(s) && (s.mother === slave.ID || s.father === slave.ID);
 	});
@@ -323,7 +323,7 @@ window.randomAvailableDaughter = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomParent = function(slave) {
+globalThis.randomParent = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return s.ID === slave.mother || s.ID === slave.father;
 	});
@@ -333,7 +333,7 @@ window.randomParent = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {App.Entity.SlaveState}
  */
-window.randomAvailableParent = function(slave) {
+globalThis.randomAvailableParent = function(slave) {
 	return randomRelatedSlave(slave, function(s) {
 		return isSlaveAvailable(s) && (s.ID === slave.mother || s.ID === slave.father);
 	});
@@ -343,7 +343,7 @@ window.randomAvailableParent = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {object}
  */
-window.availableRelatives = function(slave) {
+globalThis.availableRelatives = function(slave) {
 	let avail = {
 		mother: false, motherName: null, father: false, fatherName: null, sisters: 0, daughters: 0, oneSisterRel: null, oneDaughterRel: null
 	};
@@ -380,7 +380,7 @@ window.availableRelatives = function(slave) {
 	return avail;
 };
 
-window.totalPlayerRelatives = function(pc) {
+globalThis.totalPlayerRelatives = function(pc) {
 	let relatives = 0;
 	if (pc.mother > 0) {
 		relatives += 1;
@@ -404,7 +404,7 @@ window.totalPlayerRelatives = function(pc) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {string|null} - returns null if the slaves are not related, even distantly.
  */
-window.relativeTerm = function(slave1, slave2) {
+globalThis.relativeTerm = function(slave1, slave2) {
 	if (slave2.mother === slave1.ID || slave2.father === slave1.ID) {
 		if (slave2.genes === "XY" && V.diversePronouns) {
 			return "son";
@@ -465,7 +465,7 @@ window.relativeTerm = function(slave1, slave2) {
 };
 
 /** completely reset all the family counters in the game state (for both PC and slaves) */
-window.resetFamilyCounters = function() {
+globalThis.resetFamilyCounters = function() {
 	for (let slave of V.slaves) {
 		slave.daughters = 0;
 		slave.sisters = 0;
@@ -494,7 +494,7 @@ window.resetFamilyCounters = function() {
 /** Set any missing parents to a known ID for the given slave (usually so that a sibling can be safely generated)
  * @param {App.Entity.SlaveState} slave
  */
-window.setMissingParents = function(slave) {
+globalThis.setMissingParents = function(slave) {
 	function untraceableParentID(ID) { return ID === 0 || (ID < -1 && ID >= -20 && ID !== -3); }
 
 	if (untraceableParentID(slave.mother)) {
diff --git a/src/js/facilityUINaming.js b/src/js/facilityUINaming.js
index 5d74383cd4effd03fe317aadf65a5fa54a07f65f..890755833a6db80f8162fc274b287049844e3d95 100644
--- a/src/js/facilityUINaming.js
+++ b/src/js/facilityUINaming.js
@@ -1,97 +1,97 @@
 /**
  * @returns {string}
  */
-window.masterSuiteUIName = function() {
+globalThis.masterSuiteUIName = function() {
 	return V.masterSuiteNameCaps === "The Master Suite" ? "Master Suite" : V.masterSuiteNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.headGirlSuiteUIName = function() {
+globalThis.headGirlSuiteUIName = function() {
 	return V.HGSuiteNameCaps === "The Head Girl Suite" ? "Head Girl Suite" : V.HGSuiteNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.servantQuartersUIName = function() {
+globalThis.servantQuartersUIName = function() {
 	return V.servantsQuartersNameCaps === "The Servants' Quarters" ? "Servants' Quarters" : V.servantsQuartersNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.spaUIName = function() {
+globalThis.spaUIName = function() {
 	return V.spaNameCaps === "The Spa" ? "Spa" : V.spaNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.nurseryUIName = function() {
+globalThis.nurseryUIName = function() {
 	return V.nurseryNameCaps === "The Nursery" ? "Nursery" : V.nurseryNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.clinicUIName = function() {
+globalThis.clinicUIName = function() {
 	return V.clinicNameCaps === "The Clinic" ? "Clinic" : V.clinicNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.schoolRoomUIName = function() {
+globalThis.schoolRoomUIName = function() {
 	return V.schoolroomNameCaps === "The Schoolroom" ? "Schoolroom" : V.schoolroomNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.cellblockUIName = function() {
+globalThis.cellblockUIName = function() {
 	return V.cellblockNameCaps === "The Cellblock" ? "Cellblock" : V.cellblockNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.incubatorUIName = function() {
+globalThis.incubatorUIName = function() {
 	return V.incubatorNameCaps === "The Incubator" ? "Incubator" : V.incubatorNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.clubUIName = function() {
+globalThis.clubUIName = function() {
 	return V.clubNameCaps === "The Club" ? "Club" : V.clubNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.brothelUIName = function() {
+globalThis.brothelUIName = function() {
 	return V.brothelNameCaps === "The Brothel" ? "Brothel" : V.brothelNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.pitUIName = function() {
+globalThis.pitUIName = function() {
 	return V.pitNameCaps === "The Pit" ? "Pit" : V.pitNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.arcadeUIName = function() {
+globalThis.arcadeUIName = function() {
 	return V.arcadeNameCaps === "The Arcade" ? "Arcade" : V.arcadeNameCaps;
 };
 
 /**
  * @returns {string}
  */
-window.dairyUIName = function() {
+globalThis.dairyUIName = function() {
 	return V.dairyNameCaps === "The Dairy" ? "Dairy" : V.dairyNameCaps;
 };
diff --git a/src/js/familyTreeJS.js b/src/js/familyTreeJS.js
index 9c0f6eeae0c39db373aa990ac9ef81f128fd409e..2cef01d4dc267e810a006f8bce6a68497fb85656 100644
--- a/src/js/familyTreeJS.js
+++ b/src/js/familyTreeJS.js
@@ -16,7 +16,7 @@ let lastActiveSlave, lastSlaves, lastPC;
 
 */
 
-window.renderFamilyTree = function(slaves, filterID) {
+globalThis.renderFamilyTree = function(slaves, filterID) {
 	'use strict';
 
 	let ftreeWidth, ftreeHeight;
@@ -208,7 +208,7 @@ window.renderFamilyTree = function(slaves, filterID) {
 	}
 };
 
-window.buildFamilyTree = function(slaves, filterID) {
+globalThis.buildFamilyTree = function(slaves, filterID) {
 	let family_graph = {nodes: [], links: []};
 	let node_lookup = {};
 	let preset_lookup = {
@@ -529,7 +529,7 @@ If there's no active slave, you can do:
 <<run updateFamilyTree(null, $slaves, $PC)>>
 */
 
-window.updateFamilyTree = function(activeSlave = lastActiveSlave, slaves = lastSlaves, PC = lastPC) {
+globalThis.updateFamilyTree = function(activeSlave = lastActiveSlave, slaves = lastSlaves, PC = lastPC) {
 	lastActiveSlave = activeSlave;
 	lastSlaves = slaves;
 	lastPC = PC;
diff --git a/src/js/futureSocietyJS.js b/src/js/futureSocietyJS.js
index c4d7e32c52309ea33f52e8f22d8acc637481e339..683c9aef65c846c6d8f0c22af258e6e0d3efdb21 100644
--- a/src/js/futureSocietyJS.js
+++ b/src/js/futureSocietyJS.js
@@ -1,4 +1,4 @@
-window.FutureSocieties = (function() {
+globalThis.FutureSocieties = (function() {
 	"use strict";
 	const FSString2Property = { // blame Hedonism and Eugenics for this
 		Supremacist: "FSSupremacist",
diff --git a/src/js/generateGenetics.js b/src/js/generateGenetics.js
index 51cda03ac36ac13139e3c342a983f4fa4bdc7ddb..6d4c1a755da8af9955001a727e814e40908f29fc 100644
--- a/src/js/generateGenetics.js
+++ b/src/js/generateGenetics.js
@@ -1,6 +1,6 @@
 // Generates a child's genetics based off mother and father and returns it as an object to be attached to an ovum
 
-window.generateGenetics = (function() {
+globalThis.generateGenetics = (function() {
 	"use strict";
 	let genes;
 	let mother;
@@ -1061,7 +1061,7 @@ window.generateGenetics = (function() {
 /**
  * @param {App.Entity.SlaveState} mother
  */
-window.generateChild = function(mother, ova, destination) {
+globalThis.generateChild = function(mother, ova, destination) {
 	let genes = ova.genetics; // maybe just argument this? We'll see.
 	let pregUpgrade = V.pregnancyMonitoringUpgrade;
 	let child = {};
diff --git a/src/js/generateMarketSlave.js b/src/js/generateMarketSlave.js
index d3a025ac5ad1461b827333d559bb7f5d6e6e7192..19bb229f68e329c4a3205dbb8d3e43140317ec07 100644
--- a/src/js/generateMarketSlave.js
+++ b/src/js/generateMarketSlave.js
@@ -4,7 +4,7 @@
  * @param {number} [numArcology=1] Defaults to 1 (V.arcologies[1]) since it refers to neighboring arcology, and V.arcologies[0] is the player's arcology.
  * @returns {{text:string, slave:Object}}
  */
-window.generateMarketSlave = function(market = "kidnappers", numArcology = 1) {
+globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1) {
 	let r = ``;
 	let sisterAge;
 	let minHeight;
diff --git a/src/js/generateNewSlaveJS.js b/src/js/generateNewSlaveJS.js
index 8e6eaa906ac97ecb4d11541e2bbac39dd9085e58..c4c89f6feeee79fe46bf7309bf635b09e2a3a301 100644
--- a/src/js/generateNewSlaveJS.js
+++ b/src/js/generateNewSlaveJS.js
@@ -1,4 +1,4 @@
-window.GenerateChromosome = function() {
+globalThis.GenerateChromosome = function() {
 	if (jsRandom(0, 99) < V.seeDicks) {
 		return "XY";
 	} else if (V.seeDicks > 0) {
@@ -19,14 +19,14 @@ window.GenerateChromosome = function() {
 };
 
 /* eslint-disable camelcase */
-window.GenerateNewSlave = (function() {
+globalThis.GenerateNewSlave = (function() {
 	"use strict";
 
 	let chance;
 	let x = {};
 	let slave;
 	/**
-	 * @type {App.Entity.SlaveState}
+	 * @returns {App.Entity.SlaveState}
 	 * @param {?string} sex "XY" or "XX", or "" or null to use default rules
 	 * @param {Object} Obj
 	 * @param {number} Obj.minAge
diff --git a/src/js/generateRelatedSlave.js b/src/js/generateRelatedSlave.js
index 8a30ce252fea925bdadf300bec72bf604115e3d1..3ca1d676a686db5cf3ed4a909aab1839b1774617 100644
--- a/src/js/generateRelatedSlave.js
+++ b/src/js/generateRelatedSlave.js
@@ -1,4 +1,4 @@
-window.generateRelatedSlave = (function() {
+globalThis.generateRelatedSlave = (function() {
 	let sourceID;
 
 	/**
diff --git a/src/js/health.js b/src/js/health.js
index 099bc5c641ada6399ef7903967c13acdc355d8b2..bc874f9cda6ebaed76ba90db1f0dba1158416518 100644
--- a/src/js/health.js
+++ b/src/js/health.js
@@ -4,7 +4,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.healthPenalty = function healthPenalty(slave) {
+globalThis.healthPenalty = function(slave) {
 	const H = slave.health;
 	let penalty = 100;
 	if (slave.assignment !== "work a glory hole") {
@@ -27,7 +27,7 @@ window.healthPenalty = function healthPenalty(slave) {
  * @param {number} damage
  * @returns {void}
  */
-window.healthDamage = function healthDamage(slave, damage) {
+globalThis.healthDamage = function(slave, damage) {
 	const H = slave.health;
 	damage = Math.max(Math.trunc(damage), 0);
 	H.shortDamage += damage;
@@ -42,7 +42,7 @@ window.healthDamage = function healthDamage(slave, damage) {
  * @param {number} cure
  * @returns {void}
  */
-window.healthCure = function healthCure(slave, cure) {
+globalThis.healthCure = function(slave, cure) {
 	const H = slave.health;
 	cure = Math.max(Math.trunc(cure), 0);
 	if (cure > H.shortDamage) {
@@ -59,7 +59,7 @@ window.healthCure = function healthCure(slave, cure) {
  * @param {number} damage
  * @returns {void}
  */
-window.surgeryDamage = function surgeryDamage(slave, damage) {
+globalThis.surgeryDamage = function(slave, damage) {
 	const playerSkillFactor = 1 + Math.clamp(Math.pow(State.variables.PC.skill.medicine / 100, 2), 0, 1);
 	healthDamage(slave, Math.trunc(damage / playerSkillFactor));
 };
@@ -70,7 +70,7 @@ window.surgeryDamage = function surgeryDamage(slave, damage) {
  * @param {number} condition
  * @returns {void}
  */
-window.improveCondition = function improveCondition(slave, condition) {
+globalThis.improveCondition = function(slave, condition) {
 	const H = slave.health;
 	H.condition += Math.max(Math.trunc(condition), 0);
 	updateHealth(slave);
@@ -81,7 +81,7 @@ window.improveCondition = function improveCondition(slave, condition) {
  * @param {App.Entity.SlaveState} slave
  * @returns {void}
  */
-window.updateHealth = function updateHealth(slave) {
+globalThis.updateHealth = function(slave) {
 	const H = slave.health;
 	const condition = H.condition;
 
@@ -105,7 +105,7 @@ window.updateHealth = function updateHealth(slave) {
  * @param {number} [tired]
  * @returns {void}
  */
-window.setHealth = function setHealth(slave, condition = -101, shortDamage = -1, longDamage = -1, illness = -1, tired = -1) {
+globalThis.setHealth = function(slave, condition = -101, shortDamage = -1, longDamage = -1, illness = -1, tired = -1) {
 	const H = slave.health;
 
 	// Making sure all values get set to either a default or their desired value
diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js
index 46a3925b6b2e74929c6383bcc4ae718d44730f4f..6897171593e49a8f7c095b2250e268f056f51bb6 100644
--- a/src/js/itemAvailability.js
+++ b/src/js/itemAvailability.js
@@ -1,4 +1,4 @@
-window.isItemAccessible = (function() {
+globalThis.isItemAccessible = (function() {
 	return {
 		array: array,
 		entry: entry,
@@ -68,7 +68,7 @@ window.isItemAccessible = (function() {
 	}
 	/**
 	 * Returns array of wearable clothing in format [name, value], basically player facing / game data.
-	 * @param {string} db Name of array to look in (such as "App.Data.misc.niceClothes")
+	 * @param {Array} db Array to look in (such as App.Data.misc.niceClothes)
 	 * @returns {Array}
 	 */
 	function array(db) {
@@ -341,7 +341,7 @@ window.isItemAccessible = (function() {
  * @param {string} prosthetic
  * @returns {boolean}
  */
-window.isProstheticAvailable = function(slave, prosthetic) {
+globalThis.isProstheticAvailable = function(slave, prosthetic) {
 	return slave.readyProsthetics.findIndex(function(p) { return p.id === prosthetic; }) !== -1;
 };
 
@@ -349,7 +349,7 @@ window.isProstheticAvailable = function(slave, prosthetic) {
  * @param {App.Entity.SlaveState} slave
  * @param {string} prosthetic
  */
-window.addProsthetic = function(slave, prosthetic) {
+globalThis.addProsthetic = function(slave, prosthetic) {
 	if (!isProstheticAvailable(slave, prosthetic)) {
 		let limb = prostheticToLimb(prosthetic);
 		if (limb > 0) {
@@ -374,7 +374,7 @@ window.addProsthetic = function(slave, prosthetic) {
  * @param {string} prosthetic
  * @returns {{}}
  */
-window.findProsthetic = function(slave, prosthetic) {
+globalThis.findProsthetic = function(slave, prosthetic) {
 	return slave.readyProsthetics.find(p => p.id === prosthetic);
 };
 
@@ -382,7 +382,7 @@ window.findProsthetic = function(slave, prosthetic) {
  * @param {string} prosthetic
  * @returns {number}
  */
-window.prostheticToLimb = function(prosthetic) {
+globalThis.prostheticToLimb = function(prosthetic) {
 	switch (prosthetic) {
 		case "basicL":
 			return 2;
@@ -404,7 +404,7 @@ window.prostheticToLimb = function(prosthetic) {
  * @param {number} limb
  * @returns {string}
  */
-window.limbToProsthetic = function(limb) {
+globalThis.limbToProsthetic = function(limb) {
 	switch (limb) {
 		case 2:
 			return "basicL";
diff --git a/src/js/physicalDevelopment.js b/src/js/physicalDevelopment.js
index b01cada78887d7b61462faa96e43ebe512b87314..029fb46fbee29cf2b56190139cb8be965b69ce1b 100644
--- a/src/js/physicalDevelopment.js
+++ b/src/js/physicalDevelopment.js
@@ -1,4 +1,4 @@
-window.physicalDevelopment = (function physicalDevelopment() {
+globalThis.physicalDevelopment = (function physicalDevelopment() {
 	"use strict";
 
 	let gigantomastiaMod;
diff --git a/src/js/pregJS.js b/src/js/pregJS.js
index e9029a52ac368ea85f3006924a4b61e660f3929b..7020d4edc56737f81f8b6163fc32f43c4d08f02a 100644
--- a/src/js/pregJS.js
+++ b/src/js/pregJS.js
@@ -1,5 +1,5 @@
 /* Major props to the anons who worked together to forge the Super Pregnancy Project. Let your legacy go unforgotten.*/
-window.getPregBellySize = function(s) {
+globalThis.getPregBellySize = function(s) {
 	let targetLen;
 	let gestastionWeek = s.preg;
 	let fetuses = s.pregType;
@@ -21,7 +21,7 @@ window.getPregBellySize = function(s) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.bellyAdjective = function(slave) {
+globalThis.bellyAdjective = function(slave) {
 	if (slave.belly >= 1500) {
 		if (slave.belly >= 1000000) {
 			if (slave.preg > slave.pregData.normalBirth / 4) {
@@ -63,7 +63,7 @@ window.bellyAdjective = function(slave) {
 };
 
 /* calculates and returns expected ovum count during conception*/
-window.setPregType = function(actor) {
+globalThis.setPregType = function(actor) {
 	/* IMHO rework is possible. Can be more interesting to play, if this code will take in account more body conditions - age, fat, food, hormone levels, etc. */
 
 	let ovum = jsRandom(actor.pregData.normalOvaMin, actor.pregData.normalOvaMax); // for default human profile it's always 1.
@@ -422,7 +422,7 @@ window.setPregType = function(actor) {
  fatherID is the ID of her sire or 0 if undefined.
  displayOverride is an override if defined - fatherID must be defined in this case.
 */
-window.knockMeUp = function(target, chance, hole, fatherID, displayOverride) {
+globalThis.knockMeUp = function(target, chance, hole, fatherID, displayOverride) {
 	let He;
 	let r = ``;
 	if (target.ID !== -1) {
@@ -513,15 +513,15 @@ window.knockMeUp = function(target, chance, hole, fatherID, displayOverride) {
 	return r;
 };
 
-window.getIncubatorReserved = function( /* slaves */ ) {
+globalThis.getIncubatorReserved = function( /* slaves */ ) {
 	return FetusGlobalReserveCount("incubator");
 };
 
-window.getNurseryReserved = function( /* slaves */ ) {
+globalThis.getNurseryReserved = function( /* slaves */ ) {
 	return FetusGlobalReserveCount("nursery");
 };
 
-window.findFather = function(fatherID) {
+globalThis.findFather = function(fatherID) {
 	let father;
 
 	father = V.slaves[V.slaveIndices[fatherID]];
@@ -539,7 +539,7 @@ window.findFather = function(fatherID) {
 	return father;
 };
 
-window.adjustFatherProperty = function(actor, property, newValue) {
+globalThis.adjustFatherProperty = function(actor, property, newValue) {
 	let father = findFather(actor.ID);
 	if (father) {
 		father[property] = newValue;
@@ -547,7 +547,7 @@ window.adjustFatherProperty = function(actor, property, newValue) {
 };
 
 /* OLD
-window.adjustFatherProperty = function(actor, property, newValue) {
+globalThis.adjustFatherProperty = function(actor, property, newValue) {
 	let fatherIndex;
 
 	fatherIndex = V.slaves.findIndex(function(s) { return s.ID === actor.ID; });
@@ -575,7 +575,7 @@ window.adjustFatherProperty = function(actor, property, newValue) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getBaseBoobs = function(slave) {
+globalThis.getBaseBoobs = function(slave) {
 	return slave.boobs - slave.boobsImplant - slave.boobsMilk - slave.boobsWombVolume;
 };
 
@@ -583,7 +583,7 @@ window.getBaseBoobs = function(slave) {
  * Terminate a pregnancy without birth (i.e. miscarriage/abortion), while automatically applying the correct postpartum length
  * @param {App.Entity.SlaveState} slave
  */
-window.TerminatePregnancy = function(slave) {
+globalThis.TerminatePregnancy = function(slave) {
 	if (slave.bellyPreg > 1500) {
 		// late term - highly fertile slaves spring back quicker
 		if (slave.geneticQuirks.fertility+slave.geneticQuirks.hyperFertility >= 4) {
diff --git a/src/js/quickListJS.js b/src/js/quickListJS.js
index fe4e110b654bbef3eba912082f63d337e127313b..55d77886b3cf0d507cade41176153eea71680385 100644
--- a/src/js/quickListJS.js
+++ b/src/js/quickListJS.js
@@ -1,4 +1,4 @@
-window.sortDomObjects = function(objects, attrName, reverse = 0) {
+globalThis.sortDomObjects = function(objects, attrName, reverse = 0) {
 	reverse = (reverse) ? -1 : 1;
 
 	function sortingByAttr(a, b) {
@@ -15,21 +15,21 @@ window.sortDomObjects = function(objects, attrName, reverse = 0) {
 	return objects.toArray().sort(sortingByAttr);
 };
 
-window.sortButtonsByDevotion = function() {
+globalThis.sortButtonsByDevotion = function() {
 	let $sortedButtons = $('#qlWrapper button').remove();
 	$sortedButtons = sortDomObjects($sortedButtons, 'data-devotion');
 	$($sortedButtons).appendTo($('#qlWrapper'));
 	quickListBuildLinks();
 };
 
-window.sortButtonsByTrust = function() {
+globalThis.sortButtonsByTrust = function() {
 	let $sortedButtons = $('#qlWrapper button').remove();
 	$sortedButtons = sortDomObjects($sortedButtons, 'data-trust');
 	$($sortedButtons).appendTo($('#qlWrapper'));
 	quickListBuildLinks();
 };
 
-window.quickListBuildLinks = function() {
+globalThis.quickListBuildLinks = function() {
 	$("[data-scroll-to]").click(App.UI.quickBtnScrollToHandler);
 };
 
@@ -46,31 +46,31 @@ App.UI.quickBtnScrollToHandler = function() {
 	}, $speed);
 };
 
-window.sortIncubatorPossiblesByName = function() {
+globalThis.sortIncubatorPossiblesByName = function() {
 	let $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
 	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-name');
 	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
 };
 
-window.sortIncubatorPossiblesByPregnancyWeek = function() {
+globalThis.sortIncubatorPossiblesByPregnancyWeek = function() {
 	let $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
 	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-preg-week');
 	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
 };
 
-window.sortIncubatorPossiblesByPregnancyCount = function() {
+globalThis.sortIncubatorPossiblesByPregnancyCount = function() {
 	let $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
 	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-preg-count');
 	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
 };
 
-window.sortIncubatorPossiblesByReservedSpots = function() {
+globalThis.sortIncubatorPossiblesByReservedSpots = function() {
 	let $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
 	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-reserved-spots');
 	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
 };
 
-window.sortIncubatorPossiblesByPreviousSort = function() {
+globalThis.sortIncubatorPossiblesByPreviousSort = function() {
 	let sort = State.variables.sortIncubatorList;
 	if (sort !== 'unsorted') {
 		if (sort === 'Name') {
@@ -85,31 +85,31 @@ window.sortIncubatorPossiblesByPreviousSort = function() {
 	}
 };
 
-window.sortNurseryPossiblesByName = function() {
+globalThis.sortNurseryPossiblesByName = function() {
 	let $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
 	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-name');
 	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
 };
 
-window.sortNurseryPossiblesByPregnancyWeek = function() {
+globalThis.sortNurseryPossiblesByPregnancyWeek = function() {
 	let $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
 	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-preg-week');
 	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
 };
 
-window.sortNurseryPossiblesByPregnancyCount = function() {
+globalThis.sortNurseryPossiblesByPregnancyCount = function() {
 	let $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
 	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-preg-count');
 	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
 };
 
-window.sortNurseryPossiblesByReservedSpots = function() {
+globalThis.sortNurseryPossiblesByReservedSpots = function() {
 	let $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
 	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-reserved-spots');
 	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
 };
 
-window.sortNurseryPossiblesByPreviousSort = function() {
+globalThis.sortNurseryPossiblesByPreviousSort = function() {
 	let sort = State.variables.sortNurseryList;
 	if (sort !== 'unsorted') {
 		if (sort === 'Name') {
diff --git a/src/js/relationshipChecks.js b/src/js/relationshipChecks.js
index 127a392ae788cfe292b9df08a970e70f5e040218..ccc74a3c2591b05e6469385435a4f3790597d3e3 100644
--- a/src/js/relationshipChecks.js
+++ b/src/js/relationshipChecks.js
@@ -2,7 +2,7 @@
  * @param {{ rivalry: number; }} id
  * @returns {string}
  */
-window.rivalryTerm = function(id) {
+globalThis.rivalryTerm = function(id) {
 	if (id.rivalry === 1) {
 		return "growing rival";
 	} else if (id.rivalry === 2) {
@@ -16,7 +16,7 @@ window.rivalryTerm = function(id) {
  * @param {{ relationship: number; }} id
  * @returns {string}
  */
-window.relationshipTerm = function(id) {
+globalThis.relationshipTerm = function(id) {
 	if (id.relationship === 1) {
 		return "friend";
 	} else if (id.relationship === 2) {
@@ -34,7 +34,7 @@ window.relationshipTerm = function(id) {
  * @param {{ relationship: number; }} id
  * @returns {string}
  */
-window.relationshipTermShort = function(id) {
+globalThis.relationshipTermShort = function(id) {
 	if (id.relationship === 1) {
 		return "friend";
 	} else if (id.relationship === 2) {
@@ -52,7 +52,7 @@ window.relationshipTermShort = function(id) {
  * @param {{ relationship: number; }} id
  * @returns {string}
  */
-window.PCrelationshipTerm = function(id) {
+globalThis.PCrelationshipTerm = function(id) {
 	if (id.relationship === -2) {
 		return "lover";
 	} else if (id.relationship === -3) {
@@ -72,7 +72,7 @@ window.PCrelationshipTerm = function(id) {
  * @param {boolean} [insertComma=false] - when true, if a relationship is found, it will be separated from the actor's name by a comma ("her father, Dave" instead of "her father Dave")
  * @returns {string}
  */
-window.contextualIntro = function(context, actor, asLink=false, insertComma=false) {
+globalThis.contextualIntro = function(context, actor, asLink=false, insertComma=false) {
 	let first = true;
 	let r = ``;
 	const firstPreamble = (context === V.PC) ? "your" : getPronouns(context).possessive;
diff --git a/src/js/removeActiveSlave.js b/src/js/removeActiveSlave.js
index 7c7848cdba1bf79e5968c8bb4c5e822cdaebc638..96ff072885d60422f1cd9c7db8f5d83587b9b322 100644
--- a/src/js/removeActiveSlave.js
+++ b/src/js/removeActiveSlave.js
@@ -1,4 +1,4 @@
-window.removeActiveSlave = function removeActiveSlave() {
+globalThis.removeActiveSlave = function() {
 	"use strict";
 
 	const AS_ID = V.activeSlave.ID;
@@ -241,7 +241,7 @@ window.removeActiveSlave = function removeActiveSlave() {
 /**
  * @param {App.Entity.SlaveState} removedSlave
  */
-window.removeNonNGPSlave = function removeNonNGPSlave(removedSlave) {
+globalThis.removeNonNGPSlave = function(removedSlave) {
 	"use strict";
 	const ID = removedSlave.ID;
 	let LENGTH = V.slaves.length;
diff --git a/src/js/rulesAssistant.js b/src/js/rulesAssistant.js
index c732c59d9da6ffe70edceff7ec0886437a7a7239..c6cf2e9837aa99050596838209e512c975ba45a7 100644
--- a/src/js/rulesAssistant.js
+++ b/src/js/rulesAssistant.js
@@ -3,7 +3,7 @@
  * @param {object[]} rules
  * @returns {boolean}
  */
-window.hasSurgeryRule = function(slave, rules) {
+globalThis.hasSurgeryRule = function(slave, rules) {
 	return rules.some(
 		rule => ruleApplied(slave, rule) && rule.set.autoSurgery > 0);
 };
@@ -14,7 +14,7 @@ window.hasSurgeryRule = function(slave, rules) {
  * @param {string} what
  * @returns {boolean}
  */
-window.hasRuleFor = function(slave, rules, what) {
+globalThis.hasRuleFor = function(slave, rules, what) {
 	return rules.some(
 		rule => ruleApplied(slave, rule) && rule[what] !== null);
 };
@@ -24,7 +24,7 @@ window.hasRuleFor = function(slave, rules, what) {
  * @param {object[]} rules
  * @returns {boolean}
  */
-window.hasHColorRule = function(slave, rules) {
+globalThis.hasHColorRule = function(slave, rules) {
 	return hasRuleFor(slave, rules, "hColor");
 };
 
@@ -33,7 +33,7 @@ window.hasHColorRule = function(slave, rules) {
  * @param {App.RA.Rule[]} rules
  * @returns {boolean}
  * */
-window.hasHStyleRule = function(slave, rules) {
+globalThis.hasHStyleRule = function(slave, rules) {
 	return hasRuleFor(slave, rules, "hStyle");
 };
 
@@ -42,7 +42,7 @@ window.hasHStyleRule = function(slave, rules) {
  * @param {App.RA.Rule[]} rules
  * @returns {boolean}
  * */
-window.hasEyeColorRule = function(slave, rules) {
+globalThis.hasEyeColorRule = function(slave, rules) {
 	return hasRuleFor(slave, rules, "eyeColor");
 };
 
@@ -52,7 +52,7 @@ window.hasEyeColorRule = function(slave, rules) {
  * @param {App.RA.Rule[]} rules
  * @returns {boolean}
  */
-window.lastPregRule = function(slave, rules) {
+globalThis.lastPregRule = function(slave, rules) {
 	return rules.some(rule =>
 		ruleApplied(slave, rule) && rule.set.preg === -1);
 };
@@ -61,7 +61,7 @@ window.lastPregRule = function(slave, rules) {
  * @param {App.RA.RuleSetters[]} rules
  * @returns {App.RA.RuleSetters}
  */
-window.mergeRules = function(rules) {
+globalThis.mergeRules = function(rules) {
 	if (rules.length === 0) {
 		return emptyDefaultRule().set;
 	}
@@ -80,7 +80,7 @@ window.mergeRules = function(rules) {
  * @param {App.RA.Rule} rule
  * @returns {boolean}
  */
-window.ruleApplied = function(slave, rule) {
+globalThis.ruleApplied = function(slave, rule) {
 	return slave.currentRules.includes(rule.ID);
 };
 
@@ -90,7 +90,7 @@ window.ruleApplied = function(slave, rule) {
  * @param {object} rule
  * @returns {string}
  */
-window.RAFacilityRemove = function RAFacilityRemove(slave, rule) {
+globalThis.RAFacilityRemove = function(slave, rule) {
 	let r = "";
 	if (!rule.facilityRemove) { return r; }
 	if (slave.assignment === rule.setAssignment) {
@@ -146,7 +146,7 @@ window.RAFacilityRemove = function RAFacilityRemove(slave, rule) {
  * @param {App.RA.RuleConditions} cond
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean} flag */
-window.ruleAppliesP = function ruleAppliesP(cond, slave) {
+globalThis.ruleAppliesP = function(cond, slave) {
 	let flag = true;
 	let slaveAttribute = slave[cond.data.attribute];
 
@@ -397,14 +397,14 @@ App.RA.newRule = function() {
 /**
  * @returns {App.RA.Rule}
  */
-window.emptyDefaultRule = App.RA.newRule.rule;
+globalThis.emptyDefaultRule = App.RA.newRule.rule;
 
 /**
  * Saves the slave, silently fires the RA, saves the slave's after-RA state, and then reverts the slave.
  * Call and then check potential change against $slaveAfterRA to see if the RA would revert it.
  * @param {App.Entity.SlaveState} slave
  */
-window.RulesDeconfliction = function RulesDeconfliction(slave) {
+globalThis.RulesDeconfliction = function(slave) {
 	const before = clone(slave);
 	DefaultRules(slave);
 	State.variables.slaveAfterRA = clone(slave);
@@ -415,7 +415,7 @@ window.RulesDeconfliction = function RulesDeconfliction(slave) {
  * Creates a table to summarize RA
  * @returns {string}
  */
-window.RASummaryCell = function() {
+globalThis.RASummaryCell = function() {
 	/**
 	 * @param {object[]} objects
 	 * @param {string[]} member
diff --git a/src/js/rulesAssistantOptions.js b/src/js/rulesAssistantOptions.js
index b39c224105cee224f6a5a063b81813b37d549c13..27554ebb74a037bebae672b5144a0a41b47c159f 100644
--- a/src/js/rulesAssistantOptions.js
+++ b/src/js/rulesAssistantOptions.js
@@ -5,7 +5,7 @@
 // wrapped in a closure so as not to pollute the global namespace
 // the widgets are generic enough to be reusable; if similar user interfaces are ported to JS, we could move the classes to the global scope
 
-window.rulesAssistantOptions = (function() {
+globalThis.rulesAssistantOptions = (function() {
 	"use strict";
 	const noDefaultSetting = {value: "!NDS!", text: "no default setting"};
 
diff --git a/src/js/rulesAutosurgery.js b/src/js/rulesAutosurgery.js
index aa4f9623fe895e806578e2dc8d33f3ce42b8d1fc..d9ea3a45d75dc0272b96f57422091ab3cd668e14 100644
--- a/src/js/rulesAutosurgery.js
+++ b/src/js/rulesAutosurgery.js
@@ -1,5 +1,5 @@
 /* eslint-disable camelcase */
-window.rulesAutosurgery = (function() {
+globalThis.rulesAutosurgery = (function() {
 	"use strict";
 
 	let r;
diff --git a/src/js/sexActsJS.js b/src/js/sexActsJS.js
index ba43aff1d96f52096d6417982fe3d6f606463e08..a8774864fd96a495fe7f4d6538794b20488ca44c 100644
--- a/src/js/sexActsJS.js
+++ b/src/js/sexActsJS.js
@@ -1,4 +1,4 @@
-window.VCheck = (function() {
+globalThis.VCheck = (function() {
 	"use strict";
 	/* eslint-disable no-unused-vars*/
 	let he;
@@ -300,7 +300,7 @@ window.VCheck = (function() {
 	}
 })();
 
-window.SimpleSexAct = (function() {
+globalThis.SimpleSexAct = (function() {
 	"use strict";
 
 	return {
@@ -452,7 +452,7 @@ window.SimpleSexAct = (function() {
  * @param {string} act oral, anal, etc
  * @param {number} count
  */
-window.actX = function actX(slave, act, count = 1) {
+globalThis.actX = function(slave, act, count = 1) {
 	switch (act) {
 		case "PCChildrenFathered":
 			break;
@@ -513,7 +513,7 @@ window.actX = function actX(slave, act, count = 1) {
  * @param {string} act2 oral, anal, etc
  * @param {number} count
  */
-window.seX = function seX(slave1, act1, slave2, act2, count = 1) {
+globalThis.seX = function(slave1, act1, slave2, act2, count = 1) {
 	// Slave 1 does their normal thing
 	actX(slave1, act1, count);
 
diff --git a/src/js/slaveCostJS.js b/src/js/slaveCostJS.js
index 8f1282c10561f03d258f2824ff738bbcb525f6bd..bcc6cfd9c16934822ab9b3f39f221c7ccc01eda4 100644
--- a/src/js/slaveCostJS.js
+++ b/src/js/slaveCostJS.js
@@ -1,4 +1,4 @@
-window.minimumSlaveCost = function() {
+globalThis.minimumSlaveCost = function() {
 	let value = 3000;
 
 	if (V.terrain === "urban") {
@@ -65,7 +65,7 @@ window.minimumSlaveCost = function() {
  * @param {App.Entity.SlaveState} slave
  * @returns {Array}
  */
-window.BeautyArray = (function() {
+globalThis.BeautyArray = (function() {
 	"use strict";
 
 	let arcology;
@@ -1570,7 +1570,7 @@ window.BeautyArray = (function() {
 	return BeautyReturn;
 })();
 
-window.Beauty = function(s) {
+globalThis.Beauty = function(s) {
 	let beauty = BeautyArray(s).reduce((result, {value})=>result + value, 0);
 	beauty = Math.max(1, Math.trunc(0.5 * beauty));
 	return beauty;
@@ -1578,7 +1578,7 @@ window.Beauty = function(s) {
 
 
 
-window.BeautyTooltip = function(slave) {
+globalThis.BeautyTooltip = function(slave) {
 	// Make a link. Text should be slave'slave beauty. Clicking the link will display detailed info about that beauty where the link used to be
 	if (V.cheatMode || V.debugMode) {
 		return jQuery('#BeautyTooltip').empty().append(BeautyDisplay(slave));
@@ -1683,7 +1683,7 @@ window.BeautyTooltip = function(slave) {
 // it has been wrapped in a closure so as not to pollute the global namespace
 // and so that nested functions are only evaluated once
 
-window.FResultArray = (function() {
+globalThis.FResultArray = (function() {
 	"use strict";
 	// we can't initialize our global variables on load, because SugarCube.State isn't initialized
 	// instead, declare them and initialize on run time
@@ -2120,7 +2120,7 @@ window.FResultArray = (function() {
 	return FResult;
 })();
 
-window.FResult = function(s) {
+globalThis.FResult = function(s) {
 	let FResult = FResultArray(s).reduce((result, {value})=>result + value, 0);
 	FResult = Math.trunc(FResult);
 	return FResult;
@@ -2128,7 +2128,7 @@ window.FResult = function(s) {
 
 
 
-window.FResultTooltip = function(slave) {
+globalThis.FResultTooltip = function(slave) {
 	// Make a link. Text should be slave'slave FResult. Clicking the link will display detailed info about that beauty where the link used to be
 	if (V.cheatMode || V.debugMode) {
 		return jQuery('#FResultTooltip').empty().append(FResultDisplay(slave));
@@ -2226,7 +2226,7 @@ window.FResultTooltip = function(slave) {
 	}
 };
 
-window.slaveCost = function slaveCost(slave, isStartingSlave) {
+globalThis.slaveCost = function(slave, isStartingSlave) {
 	const milked = saGetMilked(slave, true);
 	const beauty = slaveCostBeauty(slave, isStartingSlave);
 	if ((milked*52) > beauty && !isStartingSlave) { // Arbitrarily, let's say their milk worth is what they would make in a year. Blocking starting slave for now because milk makes so much money, the estimation makes game start impossible.
@@ -2236,7 +2236,7 @@ window.slaveCost = function slaveCost(slave, isStartingSlave) {
 	}
 };
 
-window.slaveCostBeauty = (function() {
+globalThis.slaveCostBeauty = (function() {
 	"use strict";
 
 	let arcology;
@@ -2740,7 +2740,7 @@ window.slaveCostBeauty = (function() {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.startingSlaveCost = function startingSlaveCost(slave) {
+globalThis.startingSlaveCost = function(slave) {
 	return slaveCost(slave, true);
 };
 
@@ -2750,7 +2750,7 @@ window.startingSlaveCost = function startingSlaveCost(slave) {
  * @param {number} costFloor - if a slave is worth less than this amount, add between 1/2 and 3/2 this much to it
  * @returns {number}
  */
-window.heroSlaveCost = function(slave, costFloor) {
+globalThis.heroSlaveCost = function(slave, costFloor) {
 	V.specialSlavesPriceOverride = 1; // TODO: this probably shouldn't be a global
 	let cost = (10*Math.trunc((slaveCost(slave)/10)*2));
 	V.specialSlavesPriceOverride = 0;
diff --git a/src/js/slaveGenerationJS.js b/src/js/slaveGenerationJS.js
index d69fa16847b620434c591158f135d66308919a20..2c37aaf9c085ea319206e921a3c25cbe01f17a0d 100644
--- a/src/js/slaveGenerationJS.js
+++ b/src/js/slaveGenerationJS.js
@@ -1,14 +1,14 @@
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.nationalityToRace = function nationalityToRace(slave) {
+globalThis.nationalityToRace = function(slave) {
 	slave.race = hashChoice(setup.raceSelector[slave.nationality] || setup.raceSelector[""]);
 };
 
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.raceToNationality = function raceToNationality(slave) {
+globalThis.raceToNationality = function(slave) {
 	/* consider this placeholder until raceNationalities gets fixed up */
 	slave.nationality = hashChoice(V.nationalities);
 	/* Maximum of 100 attempts */
@@ -34,7 +34,7 @@ window.raceToNationality = function raceToNationality(slave) {
  * @param {undefined} [filter] Default: allow all
  * @returns {string}
  */
-window.generateName = function generateName(nationality, race, male, filter = _.stubTrue) {
+globalThis.generateName = function(nationality, race, male, filter = _.stubTrue) {
 	const lookup = (male ? setup.malenamePoolSelector : setup.namePoolSelector);
 	const result = jsEither(
 		(lookup[`${nationality}.${race}`] || lookup[nationality] ||
@@ -53,7 +53,7 @@ window.generateName = function generateName(nationality, race, male, filter = _.
  * @param {Function} [filter] Default: allow all
  * @returns {string}
  */
-window.generateSurname = function generateSurname(nationality, race, male, filter = _.stubTrue) {
+globalThis.generateSurname = function(nationality, race, male, filter = _.stubTrue) {
 	const result = jsEither(
 		(setup.surnamePoolSelector[`${nationality}.${race}`] ||
 			setup.surnamePoolSelector[nationality] ||
@@ -74,7 +74,7 @@ window.generateSurname = function generateSurname(nationality, race, male, filte
  * @param {any} race
  * @returns {boolean}
  */
-window.isMaleName = function isMaleName(name, nationality, race) {
+globalThis.isMaleName = function(name, nationality, race) {
 	const names = setup.malenamePoolSelector[`${nationality}.${race}`] ||
 		setup.malenamePoolSelector[nationality] ||
 		setup.whiteAmericanMaleNames;
@@ -84,7 +84,7 @@ window.isMaleName = function isMaleName(name, nationality, race) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.nationalityToName = function nationalityToName(slave) {
+globalThis.nationalityToName = function(slave) {
 	const male = (slave.genes === "XY");
 
 	slave.birthName = generateName(slave.nationality, slave.race, male);
@@ -144,7 +144,7 @@ window.nationalityToName = function nationalityToName(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.nationalityToAccent = function nationalityToAccent(slave) {
+globalThis.nationalityToAccent = function(slave) {
 	const naturalAccent = jsEither([0, 1, 1, 2, 2, 2, 3, 3, 3, 3]);
 
 	switch (slave.nationality) {
@@ -1344,7 +1344,7 @@ window.nationalityToAccent = function nationalityToAccent(slave) {
 Backup and then apply gingering modifiers to $activeSlave - no changes should be made to $activeSlave until after calling removeGingering() to restore the backup
 Called from lawCompliance
 */
-window.checkForGingering = function checkForGingering() {
+globalThis.checkForGingering = function() {
 	let r = "";
 	const {he, him, his, He, His} = getPronouns(V.activeSlave);
 
@@ -1467,7 +1467,7 @@ Retrieve original $activeSlave without gingering modifiers
 Call as removeGingering()
 Called from newSlaveIntro, bulkSlaveGenerate
 */
-window.removeGingering = function removeGingering() {
+globalThis.removeGingering = function() {
 	if (V.gingering !== 0 && V.beforeGingering !== 0 && V.activeSlave !== 0 && V.beforeGingering.ID === V.activeSlave.ID) {
 		/* extra checks to ensure gingering state is not left over from a different slave that was inspected but not purchased */
 		V.activeSlave = V.beforeGingering;
@@ -1482,7 +1482,7 @@ window.removeGingering = function removeGingering() {
 
 /**
  * @param {App.Entity.SlaveState} slave*/
-window.randomizeAttraction = function randomizeAttraction(slave) {
+globalThis.randomizeAttraction = function(slave) {
 	const sexuality = jsRandom(0, 100);
 	let attraction = Math.clamp(slave.energy * 2, 60, 180);
 
@@ -1517,13 +1517,13 @@ window.randomizeAttraction = function randomizeAttraction(slave) {
 	slave.attrXY = Math.clamp(slave.attrXY + jsRandom(-5, 5), 0, 100);
 };
 
-window.BaseSlave = function BaseSlave() {
+globalThis.BaseSlave = function() {
 	return new App.Entity.SlaveState();
 };
 
 /**
  * @param {App.Entity.SlaveState} slave*/
-window.generatePronouns = function generatePronouns(slave) {
+globalThis.generatePronouns = function(slave) {
 	if (slave.fuckdoll > 0) {
 		slave.pronoun = App.Data.Pronouns.Kind.toy;
 	} else if (slave.dick > 0 && slave.vagina === -1 && State.variables.diversePronouns === 1) {
@@ -1536,7 +1536,7 @@ window.generatePronouns = function generatePronouns(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.generatePuberty = function(slave) {
+globalThis.generatePuberty = function(slave) {
 	if ((slave.ovaries === 1 || slave.mpreg === 1) && slave.physicalAge >= slave.pubertyAgeXX) {
 		slave.pubertyXX = 1;
 	} else {
@@ -1553,7 +1553,7 @@ window.generatePuberty = function(slave) {
  * Apply the effects of an age lift (make them appear younger than they do currently)
  * @param {App.Entity.SlaveState} slave
  */
-window.applyAgeImplant = function(slave) {
+globalThis.applyAgeImplant = function(slave) {
 	if (slave.visualAge >= 25) {
 		slave.ageImplant = 1;
 		/* roughly: 25 -> 19, 35 -> 25, 50 -> 32, 80 -> 40, 130 -> 50 */
@@ -1565,7 +1565,7 @@ window.applyAgeImplant = function(slave) {
  * Makes someone appear older than they do currently
  * @param {App.Entity.SlaveState} slave
  */
-window.applyAgeImplantOlder = function(slave) {
+globalThis.applyAgeImplantOlder = function(slave) {
 	if (slave.visualAge < 80) {
 		// doesn't currently set ageImplant
 		/* roughly: 5 -> 20, 35 -> 45, 50 -> 56, 60 -> 64, 79 -> 80 */
diff --git a/src/js/statsChecker/eyeChecker.js b/src/js/statsChecker/eyeChecker.js
index a98ddd2201a6e7205d31b4d5f56c0b86ac5a947d..85b49c03ab04f3ee036fb69ad8b2ace5755c8848 100644
--- a/src/js/statsChecker/eyeChecker.js
+++ b/src/js/statsChecker/eyeChecker.js
@@ -4,7 +4,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyEyes = function(slave) {
+globalThis.hasAnyEyes = function(slave) {
 	return !!slave.eye.right || !!slave.eye.left;
 };
 
@@ -14,7 +14,7 @@ window.hasAnyEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyNaturalEyes = function(slave) {
+globalThis.hasAnyNaturalEyes = function(slave) {
 	return getLeftEyeType(slave) === 1 || getRightEyeType(slave) === 1;
 };
 
@@ -24,7 +24,7 @@ window.hasAnyNaturalEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyProstheticEyes = function(slave) {
+globalThis.hasAnyProstheticEyes = function(slave) {
 	return getLeftEyeType(slave) > 1 || getRightEyeType(slave) > 1;
 };
 
@@ -34,7 +34,7 @@ window.hasAnyProstheticEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyCyberneticEyes = function(slave) {
+globalThis.hasAnyCyberneticEyes = function(slave) {
 	return getLeftEyeType(slave) === 3 || getRightEyeType(slave) === 3;
 };
 
@@ -44,7 +44,7 @@ window.hasAnyCyberneticEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothEyes = function(slave) {
+globalThis.hasBothEyes = function(slave) {
 	return !!slave.eye.right && !!slave.eye.left;
 };
 
@@ -54,7 +54,7 @@ window.hasBothEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothNaturalEyes = function(slave) {
+globalThis.hasBothNaturalEyes = function(slave) {
 	return getLeftEyeType(slave) === 1 && getRightEyeType(slave) === 1;
 };
 
@@ -64,7 +64,7 @@ window.hasBothNaturalEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothProstheticEyes = function(slave) {
+globalThis.hasBothProstheticEyes = function(slave) {
 	return getLeftEyeType(slave) > 1 && getRightEyeType(slave) > 1;
 };
 
@@ -74,7 +74,7 @@ window.hasBothProstheticEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothCyberneticEyes = function(slave) {
+globalThis.hasBothCyberneticEyes = function(slave) {
 	return getLeftEyeType(slave) === 3 && getRightEyeType(slave) === 3;
 };
 
@@ -84,7 +84,7 @@ window.hasBothCyberneticEyes = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasLeftEye = function(slave) {
+globalThis.hasLeftEye = function(slave) {
 	return !!slave.eye.left;
 };
 /**
@@ -93,7 +93,7 @@ window.hasLeftEye = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasRightEye = function(slave) {
+globalThis.hasRightEye = function(slave) {
 	return !!slave.eye.right;
 };
 
@@ -103,7 +103,7 @@ window.hasRightEye = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getLeftEyeType = function(slave) {
+globalThis.getLeftEyeType = function(slave) {
 	if (hasLeftEye(slave)) {
 		return slave.eye.left.type;
 	} else {
@@ -117,7 +117,7 @@ window.getLeftEyeType = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getRightEyeType = function(slave) {
+globalThis.getRightEyeType = function(slave) {
 	if (hasRightEye(slave)) {
 		return slave.eye.right.type;
 	} else {
@@ -129,7 +129,7 @@ window.getRightEyeType = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getLeftEyeVision = function(slave) {
+globalThis.getLeftEyeVision = function(slave) {
 	if (hasLeftEye(slave)) {
 		return slave.eye.left.vision;
 	} else {
@@ -141,7 +141,7 @@ window.getLeftEyeVision = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getRightEyeVision = function(slave) {
+globalThis.getRightEyeVision = function(slave) {
 	if (hasRightEye(slave)) {
 		return slave.eye.right.vision;
 	} else {
@@ -153,7 +153,7 @@ window.getRightEyeVision = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getBestVision = function(slave) {
+globalThis.getBestVision = function(slave) {
 	return Math.max(getRightEyeVision(slave), getLeftEyeVision(slave));
 };
 
@@ -161,7 +161,7 @@ window.getBestVision = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getWorstVision = function(slave) {
+globalThis.getWorstVision = function(slave) {
 	return Math.min(getRightEyeVision(slave), getLeftEyeVision(slave));
 };
 
@@ -171,7 +171,7 @@ window.getWorstVision = function(slave) {
  * @param {number} vision
  * @returns {boolean}
  */
-window.anyVisionEquals = function(slave, vision) {
+globalThis.anyVisionEquals = function(slave, vision) {
 	return getRightEyeVision(slave) === vision || getLeftEyeVision(slave) === vision;
 };
 
@@ -179,7 +179,7 @@ window.anyVisionEquals = function(slave, vision) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getLeftEyeColor = function(slave) {
+globalThis.getLeftEyeColor = function(slave) {
 	if (hasLeftEye(slave)) {
 		return slave.eye.left.iris;
 	} else {
@@ -191,7 +191,7 @@ window.getLeftEyeColor = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getRightEyeColor = function(slave) {
+globalThis.getRightEyeColor = function(slave) {
 	if (hasLeftEye(slave)) {
 		return slave.eye.right.iris;
 	} else {
@@ -203,7 +203,7 @@ window.getRightEyeColor = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getLeftEyePupil = function(slave) {
+globalThis.getLeftEyePupil = function(slave) {
 	if (hasLeftEye(slave)) {
 		return slave.eye.left.pupil;
 	} else {
@@ -215,7 +215,7 @@ window.getLeftEyePupil = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getRightEyePupil = function(slave) {
+globalThis.getRightEyePupil = function(slave) {
 	if (hasLeftEye(slave)) {
 		return slave.eye.right.pupil;
 	} else {
@@ -227,7 +227,7 @@ window.getRightEyePupil = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasVisibleHeterochromia = function(slave) {
+globalThis.hasVisibleHeterochromia = function(slave) {
 	return hasAnyEyes(slave) && getLeftEyeColor(slave) !== getRightEyeColor(slave);
 };
 
@@ -238,7 +238,7 @@ window.hasVisibleHeterochromia = function(slave) {
  * @param {string} side
  * @returns {string}
  */
-window.getGeneticEyeColor = function(slave, side) {
+globalThis.getGeneticEyeColor = function(slave, side) {
 	if (side !== "left" && side !== "right") { return "ERROR:" + side; }
 
 	if (slave.geneticQuirks.albinism === 2) {
@@ -258,7 +258,7 @@ window.getGeneticEyeColor = function(slave, side) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getLenseCount = function(slave) {
+globalThis.getLenseCount = function(slave) {
 	let count = 0;
 
 	if (hasRightEye(slave) && getRightEyeColor(slave) !== getGeneticEyeColor(slave, "right")) {
diff --git a/src/js/statsChecker/limbChecker.js b/src/js/statsChecker/limbChecker.js
index 2a4d48226e45a3f80b36b46eaceb048bf4928d18..7c69c9cea3724c50d541f0d24b8ba5353ec4480b 100644
--- a/src/js/statsChecker/limbChecker.js
+++ b/src/js/statsChecker/limbChecker.js
@@ -6,7 +6,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isAmputee = function(slave) {
+globalThis.isAmputee = function(slave) {
 	return !(slave.leg.right || slave.leg.left || slave.arm.right || slave.arm.left);
 };
 
@@ -16,7 +16,7 @@ window.isAmputee = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyNaturalLimbs = function(slave) {
+globalThis.hasAnyNaturalLimbs = function(slave) {
 	return getLeftArmID(slave) === 1 || getRightArmID(slave) === 1 || getLeftLegID(slave) === 1 || getRightLegID(slave) === 1;
 };
 
@@ -26,7 +26,7 @@ window.hasAnyNaturalLimbs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyProstheticLimbs = function(slave) {
+globalThis.hasAnyProstheticLimbs = function(slave) {
 	return getLeftArmID(slave) > 1 || getRightArmID(slave) > 1 || getLeftLegID(slave) > 1 || getRightLegID(slave) > 1;
 };
 
@@ -36,7 +36,7 @@ window.hasAnyProstheticLimbs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyLegs = function(slave) {
+globalThis.hasAnyLegs = function(slave) {
 	return !!slave.leg.right || !!slave.leg.left;
 };
 
@@ -46,7 +46,7 @@ window.hasAnyLegs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyArms = function(slave) {
+globalThis.hasAnyArms = function(slave) {
 	return !!slave.arm.right || !!slave.arm.left;
 };
 
@@ -56,7 +56,7 @@ window.hasAnyArms = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyNaturalLegs = function(slave) {
+globalThis.hasAnyNaturalLegs = function(slave) {
 	return getLeftLegID(slave) === 1 || getRightLegID(slave) === 1;
 };
 
@@ -66,7 +66,7 @@ window.hasAnyNaturalLegs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyNaturalArms = function(slave) {
+globalThis.hasAnyNaturalArms = function(slave) {
 	return getLeftArmID(slave) === 1 || getRightArmID(slave) === 1;
 };
 
@@ -76,7 +76,7 @@ window.hasAnyNaturalArms = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyProstheticLegs = function(slave) {
+globalThis.hasAnyProstheticLegs = function(slave) {
 	return getLeftLegID(slave) > 1 || getRightLegID(slave) > 1;
 };
 
@@ -86,7 +86,7 @@ window.hasAnyProstheticLegs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAnyProstheticArms = function(slave) {
+globalThis.hasAnyProstheticArms = function(slave) {
 	return getLeftArmID(slave) > 1 || getRightArmID(slave) > 1;
 };
 
@@ -96,7 +96,7 @@ window.hasAnyProstheticArms = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothLegs = function(slave) {
+globalThis.hasBothLegs = function(slave) {
 	return !!slave.leg.right && !!slave.leg.left;
 };
 
@@ -106,7 +106,7 @@ window.hasBothLegs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothArms = function(slave) {
+globalThis.hasBothArms = function(slave) {
 	return !!slave.arm.right && !!slave.arm.left;
 };
 
@@ -116,7 +116,7 @@ window.hasBothArms = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothNaturalLegs = function(slave) {
+globalThis.hasBothNaturalLegs = function(slave) {
 	return getLeftLegID(slave) === 1 && getRightLegID(slave) === 1;
 };
 
@@ -126,7 +126,7 @@ window.hasBothNaturalLegs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothNaturalArms = function(slave) {
+globalThis.hasBothNaturalArms = function(slave) {
 	return getLeftArmID(slave) === 1 && getRightArmID(slave) === 1;
 };
 
@@ -136,7 +136,7 @@ window.hasBothNaturalArms = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothProstheticArms = function(slave) {
+globalThis.hasBothProstheticArms = function(slave) {
 	return getLeftArmID(slave) > 1 && getRightArmID(slave) > 1;
 };
 
@@ -146,7 +146,7 @@ window.hasBothProstheticArms = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasBothProstheticLegs = function(slave) {
+globalThis.hasBothProstheticLegs = function(slave) {
 	return getLeftLegID(slave) > 1 && getRightLegID(slave) > 1;
 };
 
@@ -156,7 +156,7 @@ window.hasBothProstheticLegs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAllLimbs = function(slave) {
+globalThis.hasAllLimbs = function(slave) {
 	return hasBothLegs(slave) && hasBothArms(slave);
 };
 
@@ -166,7 +166,7 @@ window.hasAllLimbs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasAllNaturalLimbs = function(slave) {
+globalThis.hasAllNaturalLimbs = function(slave) {
 	return hasBothNaturalLegs(slave) && hasBothNaturalArms(slave);
 };
 
@@ -176,7 +176,7 @@ window.hasAllNaturalLimbs = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasLeftArm = function(slave) {
+globalThis.hasLeftArm = function(slave) {
 	return !!slave.arm.left;
 };
 
@@ -186,7 +186,7 @@ window.hasLeftArm = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasRightArm = function(slave) {
+globalThis.hasRightArm = function(slave) {
 	return !!slave.arm.right;
 };
 
@@ -196,7 +196,7 @@ window.hasRightArm = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasLeftLeg = function(slave) {
+globalThis.hasLeftLeg = function(slave) {
 	return !!slave.leg.left;
 };
 
@@ -206,7 +206,7 @@ window.hasLeftLeg = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.hasRightLeg = function(slave) {
+globalThis.hasRightLeg = function(slave) {
 	return !!slave.leg.right;
 };
 
@@ -216,7 +216,7 @@ window.hasRightLeg = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getLeftArmID = function(slave) {
+globalThis.getLeftArmID = function(slave) {
 	if (hasLeftArm(slave)) {
 		return slave.arm.left.type;
 	} else {
@@ -230,7 +230,7 @@ window.getLeftArmID = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getRightArmID = function(slave) {
+globalThis.getRightArmID = function(slave) {
 	if (hasRightArm(slave)) {
 		return slave.arm.right.type;
 	} else {
@@ -244,7 +244,7 @@ window.getRightArmID = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getLeftLegID = function(slave) {
+globalThis.getLeftLegID = function(slave) {
 	if (hasLeftLeg(slave)) {
 		return slave.leg.left.type;
 	} else {
@@ -258,7 +258,7 @@ window.getLeftLegID = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.getRightLegID = function(slave) {
+globalThis.getRightLegID = function(slave) {
 	if (hasRightLeg(slave)) {
 		return slave.leg.right.type;
 	} else {
@@ -272,7 +272,7 @@ window.getRightLegID = function(slave) {
  * @param {number} id
  * @returns {string}
  */
-window.idToDescription = function(id) {
+globalThis.idToDescription = function(id) {
 	switch (id) {
 		case 0:
 			return "amputated";
@@ -318,7 +318,7 @@ window.idToDescription = function(id) {
  * @param {number} [id]
  * @returns {number}
  */
-window.getLimbCount = function(slave, id = 101) {
+globalThis.getLimbCount = function(slave, id = 101) {
 	if (id < 100) {
 		let n = 0;
 		if (getLeftArmID(slave) === id) {
@@ -358,7 +358,7 @@ window.getLimbCount = function(slave, id = 101) {
  * @param {number} id
  * @returns {number}
  */
-window.getLegCount = function(slave, id) {
+globalThis.getLegCount = function(slave, id) {
 	let n = 0;
 
 	if (getLeftLegID(slave) === id) {
@@ -378,7 +378,7 @@ window.getLegCount = function(slave, id) {
  * @param {number} id
  * @returns {number}
  */
-window.getArmCount = function(slave, id) {
+globalThis.getArmCount = function(slave, id) {
 	let n = 0;
 
 	if (getLeftArmID(slave) === id) {
@@ -402,7 +402,7 @@ window.getArmCount = function(slave, id) {
  * @param {string} [legs]
  * @param {string} [leg]
  */
-window.armsAndLegs = function(slave, arms = "arms", arm = "arm", legs = "legs", leg = "leg") {
+globalThis.armsAndLegs = function(slave, arms = "arms", arm = "arm", legs = "legs", leg = "leg") {
 	let r = "";
 	if (hasAnyArms(slave)) {
 		if (hasBothArms(slave)) {
diff --git a/src/js/statsChecker/statsChecker.js b/src/js/statsChecker/statsChecker.js
index 954cc2ec3766d397bde3345cc8ad5af9e97ae5d6..9ad2c095648f8c4bcae5fc6cd06ac1b37f18401f 100644
--- a/src/js/statsChecker/statsChecker.js
+++ b/src/js/statsChecker/statsChecker.js
@@ -2,7 +2,7 @@
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isSexuallyPure = function(slave) {
+globalThis.isSexuallyPure = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -13,7 +13,7 @@ window.isSexuallyPure = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isSlaveAvailable = function(slave) {
+globalThis.isSlaveAvailable = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.assignment === "be your agent") {
@@ -28,7 +28,7 @@ window.isSlaveAvailable = function(slave) {
 	return true;
 };
 
-window.SlaveStatsChecker = (function() {
+globalThis.SlaveStatsChecker = (function() {
 	return {
 		checkForLisp: hasLisp,
 		isModded: isModded,
@@ -243,7 +243,7 @@ window.SlaveStatsChecker = (function() {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isSlim = function(slave) {
+globalThis.isSlim = function(slave) {
 	let slim = false;
 	const ArcologyZero = State.variables.arcologies[0];
 
@@ -275,7 +275,7 @@ window.isSlim = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number} 1: yes, 0: no
  */
-window.genderLawPass = function(slave) {
+globalThis.genderLawPass = function(slave) {
 	let genderLawPass = 1;
 
 	const arcology = V.arcologies[0];
@@ -307,7 +307,7 @@ window.genderLawPass = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number} 1: yes, 0: no
  */
-window.slimLawPass = function(slave) {
+globalThis.slimLawPass = function(slave) {
 	let slimLawPass = 0;
 	const ArcologyZero = V.arcologies[0];
 
@@ -338,7 +338,7 @@ window.slimLawPass = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.heightPass = function(slave) {
+globalThis.heightPass = function(slave) {
 	let arcology = V.arcologies[0];
 
 	if (arcology.FSPetiteAdmiration !== "unset") {
@@ -370,7 +370,7 @@ window.heightPass = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.heelLength = function(slave) {
+globalThis.heelLength = function(slave) {
 	switch (slave.shoes) {
 		case "pumps":
 			// 2 inch heels
@@ -399,7 +399,7 @@ window.heelLength = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.bimboScore = function(slave) {
+globalThis.bimboScore = function(slave) {
 	let degree = 0;
 	let mods = SlaveStatsChecker.modScore(slave);
 
@@ -482,7 +482,7 @@ window.bimboScore = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isStacked = function(slave) {
+globalThis.isStacked = function(slave) {
 	return (slave.butt > 4) && (slave.boobs > 800);
 };
 
@@ -490,7 +490,7 @@ window.isStacked = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isXY = function(slave) {
+globalThis.isXY = function(slave) {
 	return (slave.dick > 0);
 };
 
@@ -498,7 +498,7 @@ window.isXY = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isYoung = function(slave) {
+globalThis.isYoung = function(slave) {
 	return (slave.visualAge < 30);
 };
 
@@ -506,7 +506,7 @@ window.isYoung = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isPreg = function(slave) {
+globalThis.isPreg = function(slave) {
 	return ((slave.bellyPreg >= 5000) || (slave.bellyImplant >= 5000));
 };
 
@@ -514,7 +514,7 @@ window.isPreg = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isNotPreg = function(slave) {
+globalThis.isNotPreg = function(slave) {
 	return (!isPreg(slave) && (slave.belly < 100) && (slave.weight < 30) && !setup.fakeBellies.includes(slave.bellyAccessory));
 };
 
@@ -522,7 +522,7 @@ window.isNotPreg = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isPure = function(slave) {
+globalThis.isPure = function(slave) {
 	return ((slave.boobsImplant === 0) && (slave.buttImplant === 0) && (slave.waist >= -95) && (slave.lipsImplant === 0) && (slave.faceImplant < 30) && (slave.bellyImplant === -1) && (Math.abs(slave.shouldersImplant) < 2) && (Math.abs(slave.hipsImplant) < 2));
 };
 
@@ -530,7 +530,7 @@ window.isPure = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isSurgicallyImproved = function(slave) {
+globalThis.isSurgicallyImproved = function(slave) {
 	return ((slave.boobsImplant > 0) && (slave.buttImplant > 0) && (slave.waist < -10) && (slave.lipsImplant > 0));
 };
 
@@ -538,7 +538,7 @@ window.isSurgicallyImproved = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isFullyPotent = function(slave) {
+globalThis.isFullyPotent = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.dick > 0 && slave.balls > 0 && slave.ballType !== "sterile" && slave.hormoneBalance < 100 && slave.drugs !== "hormone blockers" && slave.pubertyXY === 1) {
@@ -551,7 +551,7 @@ window.isFullyPotent = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canGetPregnant = function(slave) {
+globalThis.canGetPregnant = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.preg === -1) { /* contraceptives check */
@@ -571,7 +571,7 @@ window.canGetPregnant = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isFertile = function(slave) {
+globalThis.isFertile = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -612,7 +612,7 @@ window.isFertile = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canAchieveErection = function(slave) {
+globalThis.canAchieveErection = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.dick <= 0) {
@@ -637,7 +637,7 @@ window.canAchieveErection = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canPenetrate = function(slave) {
+globalThis.canPenetrate = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (!canAchieveErection(slave)) {
@@ -654,7 +654,7 @@ window.canPenetrate = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canSee = function(slave) {
+globalThis.canSee = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -666,7 +666,7 @@ window.canSee = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canSeePerfectly = function(slave) {
+globalThis.canSeePerfectly = function(slave) {
 	if (!canSee(slave)) {
 		return false;
 	}
@@ -685,7 +685,7 @@ window.canSeePerfectly = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canHear = function(slave) {
+globalThis.canHear = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -696,7 +696,7 @@ window.canHear = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canSmell = function(slave) {
+globalThis.canSmell = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -707,7 +707,7 @@ window.canSmell = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canTaste = function(slave) {
+globalThis.canTaste = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -718,7 +718,7 @@ window.canTaste = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canHold = function(slave) {
+globalThis.canHold = function(slave) {
 	if (!slave) {
 		return null;
 	}
@@ -729,7 +729,7 @@ window.canHold = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canWalk = function(slave) {
+globalThis.canWalk = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (!hasBothLegs(slave)) {
@@ -757,7 +757,7 @@ window.canWalk = function(slave) {
  * @param {boolean} checkLanguage Does a bad accent count as being unable to speak?
  * @returns {boolean}
  */
-window.canTalk = function(slave, checkLanguage = true) {
+globalThis.canTalk = function(slave, checkLanguage = true) {
 	if (!slave) {
 		return null;
 	} else if (checkLanguage && slave.accent > 2) {
@@ -782,7 +782,7 @@ window.canTalk = function(slave, checkLanguage = true) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canDoAnal = function(slave) {
+globalThis.canDoAnal = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.chastityAnus === 1) {
@@ -795,7 +795,7 @@ window.canDoAnal = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.canDoVaginal = function(slave) {
+globalThis.canDoVaginal = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.vagina < 0) {
@@ -810,7 +810,7 @@ window.canDoVaginal = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.tooFatSlave = function(slave) {
+globalThis.tooFatSlave = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.weight > 190 + (slave.muscles / 5) && slave.physicalAge >= 18) {
@@ -829,7 +829,7 @@ window.tooFatSlave = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.tooBigBreasts = function(slave) {
+globalThis.tooBigBreasts = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.boobs > 30000 + (slave.muscles * 100) && slave.physicalAge >= 18) {
@@ -848,7 +848,7 @@ window.tooBigBreasts = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.tooBigBelly = function(slave) {
+globalThis.tooBigBelly = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.belly >= 450000 + (slave.muscles * 2000) && slave.physicalAge >= 18) {
@@ -867,7 +867,7 @@ window.tooBigBelly = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.tooBigBalls = function(slave) {
+globalThis.tooBigBalls = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.balls >= 30 + (slave.muscles * 0.3) && slave.physicalAge <= 3) {
@@ -884,7 +884,7 @@ window.tooBigBalls = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.tooBigDick = function(slave) {
+globalThis.tooBigDick = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.dick >= 20 + (slave.muscles * 0.1) && slave.physicalAge <= 3 && slave.dick !== 0) {
@@ -901,7 +901,7 @@ window.tooBigDick = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.tooBigButt = function(slave) {
+globalThis.tooBigButt = function(slave) {
 	if (!slave) {
 		return null;
 	} else if (slave.butt > 10 && slave.physicalAge <= 3) {
@@ -916,7 +916,7 @@ window.tooBigButt = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.isVegetable = function(slave) {
+globalThis.isVegetable = function(slave) {
 	if (!slave) {
 		return false;
 	}
@@ -930,7 +930,7 @@ window.isVegetable = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getGeneticHairColor = function(slave) {
+globalThis.getGeneticHairColor = function(slave) {
 	if (slave.geneticQuirks.albinism === 2) {
 		return slave.albinismOverride.hColor;
 	}
@@ -943,7 +943,7 @@ window.getGeneticHairColor = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getGeneticSkinColor = function(slave) {
+globalThis.getGeneticSkinColor = function(slave) {
 	if (slave.geneticQuirks.albinism === 2) {
 		return slave.albinismOverride.skin;
 	}
diff --git a/src/js/storyJS.js b/src/js/storyJS.js
index f4aed7f1e86f0236dcadaf8b977a2e0604062ddc..77dc9c3ed18754b9a09ea0405d5f45aa8359e963 100644
--- a/src/js/storyJS.js
+++ b/src/js/storyJS.js
@@ -8,7 +8,7 @@
  * @param {number} [defaultValue=0]
  * @returns {number}
  */
-window.variableAsNumber = function(x, minValue, maxValue, defaultValue = 0) {
+globalThis.variableAsNumber = function(x, minValue, maxValue, defaultValue = 0) {
 	x = Number(x);
 	if (isNaN(x)) {
 		return defaultValue;
@@ -32,7 +32,7 @@ if (typeof interpolate === "undefined") {
 			return (x - x0) * ((y1 - y0) / (x1 - x0)) + y0;
 		}
 	};
-	window.interpolate = interpolate;
+	globalThis.interpolate = interpolate;
 }
 
 /**
@@ -40,7 +40,7 @@ if (typeof interpolate === "undefined") {
  * @param {any} val
  * @returns {any[]}
  */
-window.removeFromArray = function(arr, val) {
+globalThis.removeFromArray = function(arr, val) {
 	for (let i = 0; i < arr.length; i++) {
 		if (val === arr[i]) {
 			return arr.splice(i, 1);
@@ -55,7 +55,7 @@ window.removeFromArray = function(arr, val) {
  * @param {any} thisArg
  * @returns {Array}
  */
-window.filterInPlace = function(arr, callback, thisArg) {
+globalThis.filterInPlace = function(arr, callback, thisArg) {
 	let j = 0;
 
 	arr.forEach(function(e, i) {
@@ -73,7 +73,7 @@ window.filterInPlace = function(arr, callback, thisArg) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {boolean}
  */
-window.canBreed = function(slave1, slave2) {
+globalThis.canBreed = function(slave1, slave2) {
 	if (!slave1 || !slave2) {
 		return null;
 	}
@@ -87,7 +87,7 @@ window.canBreed = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {boolean}
  */
-window.canImpreg = function(slave1, slave2) {
+globalThis.canImpreg = function(slave1, slave2) {
 	if (!slave1 || !slave2) {
 		return null;
 	} else if (slave2.dick < 1) {
@@ -118,7 +118,7 @@ window.canImpreg = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave2
  * @returns {boolean}
  */
-window.canFemImpreg = function(slave1, slave2) {
+globalThis.canFemImpreg = function(slave1, slave2) {
 	if (!slave1 || !slave2) {
 		return null;
 	} else if (slave2.balls < 1) {
@@ -144,7 +144,7 @@ window.canFemImpreg = function(slave1, slave2) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.milkAmount = function(slave) {
+globalThis.milkAmount = function(slave) {
 	let milk;
 	let calcs;
 	if (!slave) {
@@ -195,7 +195,7 @@ window.milkAmount = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.cumAmount = function(slave) {
+globalThis.cumAmount = function(slave) {
 	let cum = 0;
 	let calcs = 0;
 	if (!slave) {
@@ -245,7 +245,7 @@ window.cumAmount = function(slave) {
  * @param {string} text
  * @returns {string}
  */
-window.lispReplace = function(text) {
+globalThis.lispReplace = function(text) {
 	text = text.replace(/Sh/g, "Th");
 	text = text.replace(/SS/g, "Th");
 	text = text.replace(/Ss/g, "Th");
@@ -333,7 +333,7 @@ window.lispReplace = function(text) {
  * @param {object} arcology
  * @returns {number}
  */
-window.repGainSacrifice = function(slave, arcology) {
+globalThis.repGainSacrifice = function(slave, arcology) {
 	if (!slave || !arcology || arcology.FSAztecRevivalist === "unset" || arcology.FSAztecRevivalist <= 0) {
 		return 0;
 	}
@@ -345,7 +345,7 @@ window.repGainSacrifice = function(slave, arcology) {
  * @param {App.Entity.SlaveState} slave
  * @returns {boolean}
  */
-window.bodyguardSuccessorEligible = function(slave) {
+globalThis.bodyguardSuccessorEligible = function(slave) {
 	if (!slave) {
 		return false;
 	}
@@ -356,7 +356,7 @@ window.bodyguardSuccessorEligible = function(slave) {
  * @param {any} obj
  * @returns {string}
  */
-window.toJson = function(obj) {
+globalThis.toJson = function(obj) {
 	let jsontext = JSON.stringify(obj);
 	jsontext = jsontext.replace(/^{/, "");
 	jsontext = jsontext.replace(/}$/, "");
@@ -367,7 +367,7 @@ window.toJson = function(obj) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.nippleColor = function(slave) {
+globalThis.nippleColor = function(slave) {
 	if (skinToneLevel(slave.skin) < 8) {
 		if (slave.preg > slave.pregData.normalBirth / 4 || (slave.counter.birthsTotal > 0 && slave.lactation > 0)) {
 			return "brown";
@@ -400,7 +400,7 @@ window.nippleColor = function(slave) {
  * @param {object} PC
  * @returns {number}
  */
-window.overpowerCheck = function(slave, PC) {
+globalThis.overpowerCheck = function(slave, PC) {
 	let strength;
 
 	if (State.variables.arcologies[0].FSPhysicalIdealist !== "unset") {
@@ -427,7 +427,7 @@ window.overpowerCheck = function(slave, PC) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number[]}
  */
-window.impregnatedBy = function(slave, genepool=false) {
+globalThis.impregnatedBy = function(slave, genepool=false) {
 	const IDArray = [];
 	if (!Array.isArray(slave.womb)) {
 		if (genepool) {
@@ -448,14 +448,14 @@ window.impregnatedBy = function(slave, genepool=false) {
  * @param {App.Entity.SlaveState} father
  * @returns {boolean}
  */
-window.isImpregnatedBy = function(mother, father, genepool=false) {
+globalThis.isImpregnatedBy = function(mother, father, genepool=false) {
 	return impregnatedBy(mother, genepool).includes(father.ID);
 };
 
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.SoftenBehavioralFlaw = function SoftenBehavioralFlaw(slave) {
+globalThis.SoftenBehavioralFlaw = function(slave) {
 	switch (slave.behavioralFlaw) {
 		case "arrogant":
 			slave.behavioralQuirk = "confident";
@@ -491,7 +491,7 @@ window.SoftenBehavioralFlaw = function SoftenBehavioralFlaw(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.SoftenSexualFlaw = function SoftenSexualFlaw(slave) {
+globalThis.SoftenSexualFlaw = function(slave) {
 	switch (slave.sexualFlaw) {
 		case "hates oral":
 			slave.sexualQuirk = "gagfuck queen";
@@ -527,7 +527,7 @@ window.SoftenSexualFlaw = function SoftenSexualFlaw(slave) {
 /**
  * @param {object} PC
  */
-window.generatePlayerPronouns = function(PC) {
+globalThis.generatePlayerPronouns = function(PC) {
 	if (PC.title === 0) {
 		PC.pronoun = App.Data.Pronouns.Kind.female;
 	} else {
@@ -535,7 +535,7 @@ window.generatePlayerPronouns = function(PC) {
 	}
 };
 
-window.printTrinkets = function printTrinkets() {
+globalThis.printTrinkets = function() {
 	function trinketPluralReplacer(desc) {
 		let r;
 		switch (desc) {
@@ -622,7 +622,7 @@ window.printTrinkets = function printTrinkets() {
  * @param {number} nmbr1
  * @param {number} nmbr2
  */
-window.pregNumberName = function(nmbr1, nmbr2) {
+globalThis.pregNumberName = function(nmbr1, nmbr2) {
 	let pt = "";
 	let p1 = nmbr1 % 10;
 	let p2 = ((nmbr1 % 100) - (nmbr1 % 10)) / 10;
diff --git a/src/js/summaryWidgets.js b/src/js/summaryWidgets.js
index 41ab0e275a2826f22636312702230da2d7d51457..f33bedfe8f5a65cf4bddfafe69e5d8554ed8eecd 100644
--- a/src/js/summaryWidgets.js
+++ b/src/js/summaryWidgets.js
@@ -1,7 +1,7 @@
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.SlaveStatClamp = function SlaveStatClamp(slave) {
+globalThis.SlaveStatClamp = function(slave) {
 	slave.energy = Math.clamp(slave.energy, 0, 100);
 
 	if (slave.devotion > 100) {
diff --git a/src/js/textboxJS.js b/src/js/textboxJS.js
index 573fac9a376304f75ca63366eaed93e6af5e080a..0e0aaae708ffe40f67d5ef6b435489a3ac9e7b02 100644
--- a/src/js/textboxJS.js
+++ b/src/js/textboxJS.js
@@ -1,5 +1,5 @@
 /* Nicked off greyelf, works for replace textboxes */
-window.setReplaceTextboxMaxLength = function(storyVarName, maxLength) {
+globalThis.setReplaceTextboxMaxLength = function(storyVarName, maxLength) {
 	const textboxId = `#textbox-${Util.slugify(storyVarName)}`;
 	$(textboxId)
 		.attr("maxlength", maxLength)
@@ -11,7 +11,7 @@ window.setReplaceTextboxMaxLength = function(storyVarName, maxLength) {
 };
 
 /* Nicked off TheMadExile, works for non-replace textboxes */
-window.setTextboxMaxLength = function(storyVarName, maxLength) {
+globalThis.setTextboxMaxLength = function(storyVarName, maxLength) {
 	const textboxId = `#textbox-${Util.slugify(storyVarName)}`;
 	postdisplay[`${textboxId}-maxlength`] = function(taskName) {
 		delete postdisplay[taskName];
diff --git a/src/js/utilsFC.js b/src/js/utilsFC.js
index a4cf51d691f97b4cd8c8dcab3996fbb16303c8ac..f4de4b5aab932f2d16c346a8e5e2d3c7cce5dca1 100644
--- a/src/js/utilsFC.js
+++ b/src/js/utilsFC.js
@@ -53,7 +53,7 @@
  *
  * There's also limitHeight which you're not using. It's basically limitMult in different units.
  */
-window.Height = (function() {
+globalThis.Height = (function() {
 	"use strict";
 
 	// Global configuration (for different game modes/options/types)
@@ -771,7 +771,7 @@ window.Height = (function() {
  *  This was modeled using the Height generator above. For some more information, see the comments for that.
  * @returns {{random: number, _config: object}}
  */
-window.Intelligence = (function() {
+globalThis.Intelligence = (function() {
 	"use strict";
 
 	// Global configuration (for different game modes/options/types)
@@ -913,7 +913,7 @@ As a categorizer
 <<print $cats.muscleCat.cat(_Slave.muscles)>>
 */
 
-window.Categorizer = function() {
+globalThis.Categorizer = function() {
 	this.cats = Array.prototype.slice.call(arguments)
 		.filter(function(e, i, a) {
 			return Array.isArray(e) && e.length === 2 && typeof e[0] === "number" && !isNaN(e[0]) &&
@@ -926,7 +926,7 @@ window.Categorizer = function() {
 		});
 };
 
-window.Categorizer.prototype.cat = function(val, def) {
+globalThis.Categorizer.prototype.cat = function(val, def) {
 	let result = def;
 	if (typeof val === "number" && !isNaN(val)) {
 		let foundCat = this.cats.find(function(e) {
@@ -950,7 +950,7 @@ window.Categorizer.prototype.cat = function(val, def) {
  * @param {boolean} [printText=false] (optional)
  * @returns {string}
  */
-window.num = function(x, printText = false) {
+globalThis.num = function(x, printText = false) {
 	const max = V.showNumbersMax;
 
 	const ONE_TO_NINETEEN = [
@@ -1070,7 +1070,7 @@ window.num = function(x, printText = false) {
 	}
 };
 
-window.asPlural = function(single, plural) {
+globalThis.asPlural = function(single, plural) {
 	if (typeof single !== 'string') {
 		let asObj = single;
 		single = asObj.single;
@@ -1081,7 +1081,7 @@ window.asPlural = function(single, plural) {
 	}
 	return plural;
 };
-window.asSingular = function(single) {
+globalThis.asSingular = function(single) {
 	if (typeof single !== 'string') {
 		let asObj = single;
 		single = asObj.single;
@@ -1089,7 +1089,7 @@ window.asSingular = function(single) {
 	return single;
 };
 // When 1, shows "a (slave)"
-window.numberWithPlural = function(number, single, plural) {
+globalThis.numberWithPlural = function(number, single, plural) {
 	if (number === 0) {
 		return "no " + asPlural(single, plural);
 	} else if (number === 1) {
@@ -1102,7 +1102,7 @@ window.numberWithPlural = function(number, single, plural) {
 };
 
 // when 1, shows "one (slave)"
-window.numberWithPluralOne = function(number, single, plural) {
+globalThis.numberWithPluralOne = function(number, single, plural) {
 	if (number === 0) {
 		return "no " + asPlural(single, plural);
 	} else if (number === 1) {
@@ -1114,19 +1114,19 @@ window.numberWithPluralOne = function(number, single, plural) {
 	}
 };
 // shows "less than one (slave)" instead of "no (slaves)" when number is 0.
-window.numberWithPluralNonZero = function(number, single, plural) {
+globalThis.numberWithPluralNonZero = function(number, single, plural) {
 	if (number === 0) {
 		number = 0.1;
 	}
 	return numberWithPlural(number, single, plural);
 };
-window.onlyPlural = function(number, single, plural) {
+globalThis.onlyPlural = function(number, single, plural) {
 	if (number > 0 && number <= 1) {
 		return asSingular(single);
 	}
 	return asPlural(single, plural);
 };
-window.Seperator = function(seperatorObject) {
+globalThis.Seperator = function(seperatorObject) {
 	if (seperatorObject.need) {
 		return seperatorObject.text;
 	}
@@ -1138,7 +1138,7 @@ window.Seperator = function(seperatorObject) {
  * @param {number} s
  * @returns {string}
  */
-window.commaNum = function(s) {
+globalThis.commaNum = function(s) {
 	// Separated from num because some places in code (like long lists, tables) should never have numbers spelled out, but still benefit from commas
 	if (!s) {
 		return "0";
@@ -1155,7 +1155,7 @@ window.commaNum = function(s) {
  * @param {number} weeks
  * @returns {string}
  */
-window.years = function(weeks) {
+globalThis.years = function(weeks) {
 	let
 		r = ``,
 		years = 0,
@@ -1209,7 +1209,7 @@ window.years = function(weeks) {
  * @param {number} [bonusDay]
  * @returns {Date}
  */
-window.asDate = function(weeks = null, bonusDay = 0) {
+globalThis.asDate = function(weeks = null, bonusDay = 0) {
 	if (weeks == null) {
 		weeks = V.week;
 	}
@@ -1222,7 +1222,7 @@ window.asDate = function(weeks = null, bonusDay = 0) {
  * @param {number} [bonusDay]
  * @returns {string}
  */
-window.asDateString = function(weeks = null, bonusDay = 0) {
+globalThis.asDateString = function(weeks = null, bonusDay = 0) {
 	return asDate(weeks, bonusDay).toLocaleString(undefined, {year: 'numeric', month: 'long', day: 'numeric'});
 };
 
@@ -1230,13 +1230,13 @@ window.asDateString = function(weeks = null, bonusDay = 0) {
  * @param {number} s
  * @returns {string}
  */
-window.cashFormat = function(s) {
+globalThis.cashFormat = function(s) {
 	if (s < 0) {
 		return `-¤${commaNum(Math.abs(s))}`;
 	}
 	return `¤${commaNum(s)}`;
 };
-window.cashFormatColor = function(s, invert = false) {
+globalThis.cashFormatColor = function(s, invert = false) {
 	if (invert) {
 		s = -1 * s;
 	}
@@ -1256,7 +1256,7 @@ window.cashFormatColor = function(s, invert = false) {
  * @param {number} s
  * @returns {string}
  */
-window.repFormat = function(s) {
+globalThis.repFormat = function(s) {
 	/* if (!s) { s = 0; }*/
 	if (V.cheatMode === 1 || V.debugMode === 1) {
 		if (s > 0) {
@@ -1300,7 +1300,7 @@ window.repFormat = function(s) {
  * @param {number} s
  * @returns {string}
  */
-window.massFormat = function(s) {
+globalThis.massFormat = function(s) {
 	if (!s) {
 		s = 0;
 	}
@@ -1321,7 +1321,7 @@ window.massFormat = function(s) {
  * @param {string} title
  * @returns {string}
  */
-window.budgetLine = function(category, title) {
+globalThis.budgetLine = function(category, title) {
 	let income;
 	let expenses;
 	let profits;
@@ -1376,7 +1376,7 @@ jQuery(document).trigger("categorizer.ready");
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getSlaveDevotionClass = function(slave) {
+globalThis.getSlaveDevotionClass = function(slave) {
 	if ((!slave) || (!State)) {
 		return undefined;
 	}
@@ -1404,7 +1404,7 @@ window.getSlaveDevotionClass = function(slave) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.getSlaveTrustClass = function(slave) {
+globalThis.getSlaveTrustClass = function(slave) {
 	if ((!slave) || (!State)) {
 		return undefined;
 	}
@@ -1445,7 +1445,7 @@ window.getSlaveTrustClass = function(slave) {
  * @param {number} cm
  * @returns {string}
  */
-window.cmToInchString = function(cm) {
+globalThis.cmToInchString = function(cm) {
 	let inches = cm / 2.54;
 	if (inches > 0 && inches < 1) {
 		return "less than an inch";
@@ -1462,7 +1462,7 @@ window.cmToInchString = function(cm) {
  * @param {number} cm
  * @returns {string}
  */
-window.cmToFootInchString = function(cm) {
+globalThis.cmToFootInchString = function(cm) {
 	if (Math.round(cm / 2.54) < 12) {
 		return cmToInchString(cm);
 	}
@@ -1474,7 +1474,7 @@ window.cmToFootInchString = function(cm) {
  * @param {number} dick
  * @returns {string}
  */
-window.dickToInchString = function(dick) {
+globalThis.dickToInchString = function(dick) {
 	return cmToInchString(dickToCM(dick));
 };
 
@@ -1483,7 +1483,7 @@ window.dickToInchString = function(dick) {
  * @param {number} dick
  * @returns {number}
  */
-window.dickToCM = function(dick) {
+globalThis.dickToCM = function(dick) {
 	if (dick < 9) {
 		return dick * 5;
 	} else if (dick === 9) {
@@ -1496,7 +1496,7 @@ window.dickToCM = function(dick) {
  * @param {number} balls
  * @returns {string}
  */
-window.ballsToInchString = function(balls) {
+globalThis.ballsToInchString = function(balls) {
 	return cmToInchString(ballsToCM(balls));
 };
 
@@ -1505,7 +1505,7 @@ window.ballsToInchString = function(balls) {
  * @param {number} balls
  * @returns {number}
  */
-window.ballsToCM = function(balls) {
+globalThis.ballsToCM = function(balls) {
 	if (balls < 2) {
 		return 0;
 	}
@@ -1517,7 +1517,7 @@ window.ballsToCM = function(balls) {
  * @param {number} dick
  * @returns {string}
  */
-window.dickToEitherUnit = function(dick) {
+globalThis.dickToEitherUnit = function(dick) {
 	if (V.showInches === 1) {
 		return `${dickToCM(dick)}cm (${dickToInchString(dick)})`;
 	}
@@ -1532,7 +1532,7 @@ window.dickToEitherUnit = function(dick) {
  * @param {number} balls
  * @returns {string}
  */
-window.ballsToEitherUnit = function(balls) {
+globalThis.ballsToEitherUnit = function(balls) {
 	if (V.showInches === 1) {
 		return `${ballsToCM(balls)}cm (${ballsToInchString(balls)})`;
 	}
@@ -1547,7 +1547,7 @@ window.ballsToEitherUnit = function(balls) {
  * @param {number} height
  * @returns {string}
  */
-window.heightToEitherUnit = function(height) {
+globalThis.heightToEitherUnit = function(height) {
 	if (V.showInches === 1) {
 		return `${height}cm (${cmToFootInchString(height)})`;
 	}
@@ -1562,7 +1562,7 @@ window.heightToEitherUnit = function(height) {
  * @param {number} length
  * @returns {string}
  */
-window.lengthToEitherUnit = function(length) {
+globalThis.lengthToEitherUnit = function(length) {
 	if (V.showInches === 1) {
 		return `${length}cm (${cmToInchString(length)})`;
 	}
@@ -1576,7 +1576,7 @@ window.lengthToEitherUnit = function(length) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.induceLactation = function induceLactation(slave) {
+globalThis.induceLactation = function(slave) {
 	const {His} = getPronouns(slave);
 	let r = "";
 	if (slave.induceLactation >= 10) {
@@ -1590,7 +1590,7 @@ window.induceLactation = function induceLactation(slave) {
 	return r;
 };
 
-window.getProstheticsStockpile = function() {
+globalThis.getProstheticsStockpile = function() {
 	return `<div>Prosthetics interfaces: ${num(V.prosthetics.interfaceP1.amount + V.prosthetics.interfaceP2.amount)}</div>` +
 		`<div class="choices">Basic: ${V.prosthetics.interfaceP1.amount}</div>` +
 		`<div class="choices">Advanced: ${V.prosthetics.interfaceP2.amount}</div>` +
@@ -1613,7 +1613,7 @@ window.getProstheticsStockpile = function() {
 		`<div class="choices">Combat: ${V.prosthetics.combatT.amount}</div>`;
 };
 
-window.pronounReplacer = function(slavetext) {
+globalThis.pronounReplacer = function(slavetext) {
 	switch (slavetext) {
 		case "After her short but very promising slave racing career, during which she made it through several competitions as a virgin, many people fondly remember fantasizing about taking her.":
 			slavetext = "After $his short but very promising slave racing career, during which $he made it through several competitions as a virgin, many people fondly remember fantasizing about taking $him.";
@@ -2075,7 +2075,7 @@ window.pronounReplacer = function(slavetext) {
 	return slavetext;
 };
 
-window.convertCareer = function(slave) {
+globalThis.convertCareer = function(slave) {
 	let job = slave.career;
 	if ((V.diversePronouns === 1) && (slave.pronoun === App.Data.Pronouns.Kind.male)) {
 		switch (job) {
@@ -2177,7 +2177,7 @@ window.convertCareer = function(slave) {
 	return job;
 };
 
-window.SkillIncrease = (function() {
+globalThis.SkillIncrease = (function() {
 	return {
 		Oral: OralSkillIncrease,
 		Vaginal: VaginalSkillIncrease,
@@ -2342,7 +2342,7 @@ window.SkillIncrease = (function() {
 	}
 })();
 
-window.upgradeMultiplier = function(skill) {
+globalThis.upgradeMultiplier = function(skill) {
 	if (skill === 'medicine' && V.PC.career === "medicine" || skill === 'engineering' && V.PC.career === "engineer"
 		|| ((skill === 'medicine' || skill === 'engineering') && V.arcologies[0].FSRestartDecoration >= 100 && V.eugenicsFullControl === 0)) {
 		return 0.6;
@@ -2380,7 +2380,7 @@ window.upgradeMultiplier = function(skill) {
  * @param {App.Entity.SlaveState} slave
  * @returns {string}
  */
-window.randomCareer = function(slave) {
+globalThis.randomCareer = function(slave) {
 	if (slave.actualAge < 16) {
 		return setup.veryYoungCareers.random();
 	} else if (slave.actualAge <= 24) {
@@ -2395,14 +2395,14 @@ window.randomCareer = function(slave) {
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.resyncSlaveHight = function(slave) {
+globalThis.resyncSlaveHight = function(slave) {
 	slave.height = Math.round(Height.random(slave));
 };
 
 /**
  * @param {App.Entity.SlaveState} slave
  */
-window.resyncSlaveToAge = function(slave) {
+globalThis.resyncSlaveToAge = function(slave) {
 	resyncSlaveHight(slave);
 	slave.pubertyXX = slave.actualAge < slave.pubertyAgeXX ? 0 : 1;
 	slave.pubertyXY = slave.actualAge < slave.pubertyAgeXY ? 0 : 1;
@@ -2447,7 +2447,7 @@ window.resyncSlaveToAge = function(slave) {
  * @param {string} raceName
  * @returns {string}
  */
-window.randomRaceSkin = function(raceName) {
+globalThis.randomRaceSkin = function(raceName) {
 	let skin;
 	switch (raceName) {
 		case "asian":
@@ -2484,7 +2484,7 @@ window.randomRaceSkin = function(raceName) {
  * @param {string} raceName
  * @returns {string}
  */
-window.randomRaceEye = function(raceName) {
+globalThis.randomRaceEye = function(raceName) {
 	let eye;
 	switch (raceName) {
 		case "asian":
@@ -2517,7 +2517,7 @@ window.randomRaceEye = function(raceName) {
  * @param {string} raceName
  * @returns {string}
  */
-window.randomRaceHair = function(raceName) {
+globalThis.randomRaceHair = function(raceName) {
 	let hair;
 	switch (raceName) {
 		case "asian":
@@ -2548,7 +2548,7 @@ window.randomRaceHair = function(raceName) {
  * @param {string} skinTone
  * @returns {number}
  */
-window.skinToneLevel = function(skinTone) {
+globalThis.skinToneLevel = function(skinTone) {
 	if (!setup.naturalSkins.includes(skinTone)) {
 		return undefined;
 	}
@@ -2589,7 +2589,7 @@ window.skinToneLevel = function(skinTone) {
  * @returns {string}
  */
 
-window.changeSkinTone = function(skin, value) {
+globalThis.changeSkinTone = function(skin, value) {
 	if (!setup.naturalSkins.includes(skin)) {
 		return skin;
 	}
@@ -2642,7 +2642,7 @@ window.changeSkinTone = function(skin, value) {
  * @param {string} color
  * @returns {number}
  */
-window.nippleColorLevel = function(color) {
+globalThis.nippleColorLevel = function(color) {
 	if (!setup.naturalNippleColors.includes(color)) {
 		return undefined;
 	}
@@ -2741,7 +2741,7 @@ App.Utils.setLocalPronouns = function(slave, suffix, pronouns) {
  * @returns {string}
  */
 
-window.aNational = function(nation) {
+globalThis.aNational = function(nation) {
 	let country;
 	if (nation === "a Cook Islander") {
 		country = "Cook Islander";
@@ -2763,7 +2763,7 @@ window.aNational = function(nation) {
  * @returns {string}
  */
 
-window.moreNational = function(nation) {
+globalThis.moreNational = function(nation) {
 	let country;
 	if (nation === "a Cook Islander") {
 		country = "Cook Islander";
@@ -2788,7 +2788,7 @@ window.moreNational = function(nation) {
  * @param {App.Entity.SlaveState} slave
  * @returns {number}
  */
-window.disobedience = function(slave) {
+globalThis.disobedience = function(slave) {
 	const devotionBaseline = 20; // with devotion above this number slaves will obey completely
 	const trustBaseline = -20; // with trust below this number slaves will obey completely
 
@@ -2808,7 +2808,7 @@ window.disobedience = function(slave) {
  * @param {function(App.Entity.SlaveState): boolean} predicate
  * @returns {App.Entity.SlaveState | undefined}
  */
-window.randomRapeRivalryTarget = function(slave, predicate) {
+globalThis.randomRapeRivalryTarget = function(slave, predicate) {
 	const willIgnoreRules = disobedience(slave) > jsRandom(0, 100);
 
 	function canBeARapeRival(s) {
@@ -2839,7 +2839,7 @@ window.randomRapeRivalryTarget = function(slave, predicate) {
  * @param {function(App.Entity.SlaveState): boolean} [params.filter] filter out undesired slaves
  * @returns {App.Entity.SlaveState[]} sorted from best to worst
  */
-window.getBestSlaves = function({part, count = 3, largest = true, filter = (() => true)} = {}) {
+globalThis.getBestSlaves = function({part, count = 3, largest = true, filter = (() => true)} = {}) {
 	if (!_.isFunction(part)) {
 		const partName = part;
 		part = (slave) => slave[partName];
@@ -2855,7 +2855,7 @@ window.getBestSlaves = function({part, count = 3, largest = true, filter = (() =
  * @param {{}} info see getBestSlaves()
  * @returns {number[]}
  */
-window.getBestSlavesIndices = function(info) {
+globalThis.getBestSlavesIndices = function(info) {
 	return getBestSlaves(info).map(slave => V.slaveIndices[slave.ID]);
 };
 
@@ -2871,7 +2871,7 @@ getBestSlaves({part:slave=>slave.intelligence+slave.intelligenceImplant});
  * Generates a new slave ID that is guaranteed to be unused
  * @returns {number} slave ID
  */
-window.generateSlaveID = function() {
+globalThis.generateSlaveID = function() {
 	// household liquidators and recETS generate slaves at an offset of 1000 (and many such slaves already exist)
 	// if you go through enough slaves you WILL generate collisions, so make sure we haven't just done that.
 	let allSlaveIDs = [...V.slaves.map((s) => s.ID), ...V.tanks.map((s) => s.ID), ...V.cribs.map((s) => s.ID)];
@@ -2881,7 +2881,7 @@ window.generateSlaveID = function() {
 	return V.IDNumber++;
 };
 
-window.ASDump = function() {
+globalThis.ASDump = function() {
 	if ((typeof V.activeSlave === undefined) || (V.activeSlave === 0)) {
 		return `<span class="red">ERROR:</span> AS Dump, activeSlave invalid, returnTo is 'V.returnTo', previous passage was '${previous()}'. Please report this. `;
 	} else {
@@ -2900,7 +2900,7 @@ window.ASDump = function() {
 	}
 };
 
-window.getRevivalistNationality = function() {
+globalThis.getRevivalistNationality = function() {
 	if (V.arcologies[0].FSRomanRevivalist > 90) {
 		return "Roman Revivalist";
 	} else if (V.arcologies[0].FSAztecRevivalist > 90) {
@@ -2917,7 +2917,7 @@ window.getRevivalistNationality = function() {
 	return 0;
 };
 
-window.penthouseCensus = function() {
+globalThis.penthouseCensus = function() {
 	function occupiesRoom(slave) {
 		if (slave.rules.living !== "luxurious") {
 			return false; // assigned to dormitory
diff --git a/src/js/utilsSC.js b/src/js/utilsSC.js
index 593846b922a0a33eceb0e0071099cbba9e269728..e6931d4c235e991c3ef81ab4ca0628bfe8c04889 100644
--- a/src/js/utilsSC.js
+++ b/src/js/utilsSC.js
@@ -3,7 +3,7 @@
  *
  * @param {function(HTMLElement): HTMLElement} passageFunction
  */
-window.html5passage = function html5passage(passageFunction) {
+globalThis.html5passage = function(passageFunction) {
 	$(document).one(":passagedisplay", (ev) => {
 		const element = document.createElement("div");
 		element.classList.add("passage");
@@ -18,7 +18,7 @@ window.html5passage = function html5passage(passageFunction) {
  * @param {string} passageTitle
  * @returns {string}
  */
-window.jsInclude = function(passageTitle) {
+globalThis.jsInclude = function(passageTitle) {
 	if (Story.has(passageTitle)) {
 		return Story.get(passageTitle).processText();
 	} else {
diff --git a/src/js/vignettes.js b/src/js/vignettes.js
index 0a7bd6de169e97ba4306e5b21eaf3b93686451c5..c68e8c72d9dab0c24df55c7801b3ea7430d78c8e 100644
--- a/src/js/vignettes.js
+++ b/src/js/vignettes.js
@@ -1,8 +1,9 @@
 /**
  * @param {App.Entity.SlaveState} slave
- * @returns {string}
+ * @returns {{text: string, type: string, effect: number}}
  */
-window.GetVignette = function GetVignette(slave) {
+globalThis.GetVignette = function(slave) {
+	/** @type {{text: string, type: string, effect: number}[]} */
 	let vignettes = [];
 
 	const {he, him, his, hers, himself, boy, He/* , His */} = getPronouns(slave);
diff --git a/src/js/wombJS.js b/src/js/wombJS.js
index e37ab2f3262d1008bf287dbc41da587307f3b8ff..df9d8831ba3d771542f60d77eb0316f97179d610 100644
--- a/src/js/wombJS.js
+++ b/src/js/wombJS.js
@@ -24,7 +24,7 @@ $slave.bellyPreg = WombGetVolume($slave) - return double, with current womb volu
 */
 
 // Init womb system.
-window.WombInit = function(actor) {
+globalThis.WombInit = function(actor) {
 	let i;
 
 	if (!Array.isArray(actor.womb)) {
@@ -79,7 +79,7 @@ window.WombInit = function(actor) {
 	}
 };
 
-window.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) {
+globalThis.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) {
 	let i;
 	let tf;
 	for (i = 0; i < fCount; i++) {
@@ -120,11 +120,11 @@ window.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) {
 	WombUpdatePregVars(actor);
 };
 
-window.WombSurrogate = function(actor, fCount, mother, fatherID, age) {
+globalThis.WombSurrogate = function(actor, fCount, mother, fatherID, age) {
 	WombImpregnate(actor, fCount, fatherID, age, mother);
 };
 
-window.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age) {
+globalThis.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age) {
 	let i;
 	let tf;
 	for (i = 0; i < fCount; i++) {
@@ -182,7 +182,7 @@ window.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age
 };
 
 // Should be used to set biological age for fetus (ageToAdd), AND chronological (realAgeToAdd). Speed up or slow down gestation drugs should affect ONLY biological.
-window.WombProgress = function(actor, ageToAdd, realAgeToAdd = ageToAdd) {
+globalThis.WombProgress = function(actor, ageToAdd, realAgeToAdd = ageToAdd) {
 	ageToAdd = Math.ceil(ageToAdd * 10) / 10;
 	realAgeToAdd = Math.ceil(realAgeToAdd * 10) / 10;
 	try {
@@ -196,7 +196,7 @@ window.WombProgress = function(actor, ageToAdd, realAgeToAdd = ageToAdd) {
 	}
 };
 
-window.WombBirth = function(actor, readyAge) {
+globalThis.WombBirth = function(actor, readyAge) {
 	try {
 		WombSort(actor); // For normal processing fetuses that more old should be first. Now - they are.
 	} catch (err) {
@@ -215,12 +215,12 @@ window.WombBirth = function(actor, readyAge) {
 	return birthed;
 };
 
-window.WombFlush = function(actor) {
+globalThis.WombFlush = function(actor) {
 	actor.womb = [];
 	WombUpdatePregVars(actor);
 };
 
-window.WombBirthReady = function(actor, readyAge) {
+globalThis.WombBirthReady = function(actor, readyAge) {
 	let readyCnt = 0;
 	try {
 		readyCnt += actor.womb.filter(ft => ft.age >= readyAge).length;
@@ -233,7 +233,7 @@ window.WombBirthReady = function(actor, readyAge) {
 	return readyCnt;
 };
 
-window.WombGetVolume = function(actor) { // most legacy code from pregJS.tw with minor adaptation.
+globalThis.WombGetVolume = function(actor) { // most legacy code from pregJS.tw with minor adaptation.
 	if (actor.pregData.sizeType === 0) {
 		return getVolByLen(actor);
 	} else if (actor.pregData.sizeType === 1) {
@@ -369,7 +369,7 @@ window.WombGetVolume = function(actor) { // most legacy code from pregJS.tw with
 	}
 };
 
-window.FetusGetPrediction = function(actor, age) {
+globalThis.FetusGetPrediction = function(actor, age) {
 	let vol = 0.1;
 	if (actor.pregData.sizeType === 0) {
 		vol = getVolByLen(actor, age);
@@ -466,7 +466,7 @@ window.FetusGetPrediction = function(actor, age) {
 	}
 };
 
-window.WombUpdatePregVars = function(actor) {
+globalThis.WombUpdatePregVars = function(actor) {
 	WombSort(actor);
 	if (actor.womb.length > 0) {
 		if (actor.preg > 0 && actor.womb[0].age > 0) {
@@ -484,7 +484,7 @@ window.WombUpdatePregVars = function(actor) {
 	}
 };
 
-window.WombMinPreg = function(actor) {
+globalThis.WombMinPreg = function(actor) {
 	WombSort(actor);
 	if (actor.womb.length > 0) {
 		return actor.womb[actor.womb.length - 1].age;
@@ -493,7 +493,7 @@ window.WombMinPreg = function(actor) {
 	}
 };
 
-window.WombMaxPreg = function(actor) {
+globalThis.WombMaxPreg = function(actor) {
 	WombSort(actor);
 	if (actor.womb.length > 0) {
 		return actor.womb[0].age;
@@ -502,7 +502,7 @@ window.WombMaxPreg = function(actor) {
 	}
 };
 
-window.WombNormalizePreg = function(actor) {
+globalThis.WombNormalizePreg = function(actor) {
 	// console.log("New actor: " + actor.slaveName + " ===============" + actor.name);
 	WombInit(actor);
 
@@ -574,7 +574,7 @@ window.WombNormalizePreg = function(actor) {
 	actor.bellyPreg = WombGetVolume(actor);
 };
 
-window.WombZeroID = function(actor, id) {
+globalThis.WombZeroID = function(actor, id) {
 	WombInit(actor);
 	actor.womb
 		.filter(ft => ft.fatherID === id)
@@ -582,7 +582,7 @@ window.WombZeroID = function(actor, id) {
 	WombNormalizePreg(actor);
 };
 
-window.WombChangeID = function(actor, fromID, toID) {
+globalThis.WombChangeID = function(actor, fromID, toID) {
 	WombInit(actor);
 	actor.womb
 		.filter(ft => ft.fatherID === fromID)
@@ -590,7 +590,7 @@ window.WombChangeID = function(actor, fromID, toID) {
 	WombNormalizePreg(actor);
 };
 
-window.WombChangeGeneID = function(actor, fromID, toID) {
+globalThis.WombChangeGeneID = function(actor, fromID, toID) {
 	WombInit(actor);
 	actor.womb
 		.filter(ft => ft.genetics.father === fromID)
@@ -602,14 +602,14 @@ window.WombChangeGeneID = function(actor, fromID, toID) {
 };
 
 /* Sorts the womb object by age with oldest and thus soonest to be born, first. This will be needed in the future once individual fertilization is a possibility.*/
-window.WombSort = function(actor) {
+globalThis.WombSort = function(actor) {
 	actor.womb.sort((a, b) => {
 		return b.age - a.age;
 	});
 };
 
 // now function work with chance. Literary we give it "one from X" as chance.
-window.fetalSplit = function(actor, chance) {
+globalThis.fetalSplit = function(actor, chance) {
 	let nft;
 
 	actor.womb.forEach(function(s) {
@@ -639,13 +639,13 @@ window.fetalSplit = function(actor, chance) {
 };
 
 // safe alternative to .womb.length.
-window.WombFetusCount = function(actor) {
+globalThis.WombFetusCount = function(actor) {
 	WombInit(actor);
 	return actor.womb.length;
 };
 
 // give reference to fetus object, but not remove fetus, use for manipulation in the womb.
-window.WombGetFetus = function(actor, fetusNum) {
+globalThis.WombGetFetus = function(actor, fetusNum) {
 	WombInit(actor);
 	if (actor.womb.length >= fetusNum) {
 		return actor.womb[fetusNum];
@@ -655,7 +655,7 @@ window.WombGetFetus = function(actor, fetusNum) {
 };
 
 // give reference to fetus object, and remove it form the womb.
-window.WombRemoveFetus = function(actor, fetusNum) {
+globalThis.WombRemoveFetus = function(actor, fetusNum) {
 	WombInit(actor);
 	if (actor.womb.length >= fetusNum) {
 		let ft = actor.womb[fetusNum];
@@ -668,26 +668,26 @@ window.WombRemoveFetus = function(actor, fetusNum) {
 };
 
 /* to add fetus object in the womb. Be warned - you can add one single fetus to many wombs, or even add it many times to one womb. It will not show error, but behavior becomes strange, as fetus object will be the same - it's reference, not full copies. If this is not desired - use clone() on fetus before adding.*/
-window.WombAddFetus = function(actor, fetus) {
+globalThis.WombAddFetus = function(actor, fetus) {
 	WombInit(actor);
 	actor.womb.push(fetus);
 	WombSort(actor);
 };
 
 // change property for all fetuses. Like fetus.age = X.
-window.WombChangeFetus = function(actor, propName, newValue) {
+globalThis.WombChangeFetus = function(actor, propName, newValue) {
 	WombInit(actor);
 	actor.womb.forEach(ft => ft[propName] = newValue);
 };
 
 // change genetic property of all fetuses. Like fetus.genetic.intelligence = X
-window.WombChangeGene = function(actor, geneName, newValue) {
+globalThis.WombChangeGene = function(actor, geneName, newValue) {
 	WombInit(actor);
 	actor.womb.forEach(ft => ft.genetics[geneName] = newValue);
 };
 
 // change genetic property of all fetuses based on race
-window.WombFatherRace = function(actor, raceName) {
+globalThis.WombFatherRace = function(actor, raceName) {
 	let skinColor = randomRaceSkin(raceName);
 	let eyeColor = randomRaceEye(raceName);
 	let hairColor = randomRaceHair(raceName);
@@ -698,7 +698,7 @@ window.WombFatherRace = function(actor, raceName) {
 };
 
 // replaces untraceable fatherIDs with missingParentID. Required for concurrent pregnancy to differentiate between siblings.
-window.MissingParentIDCorrection = function(actor) {
+globalThis.MissingParentIDCorrection = function(actor) {
 	WombInit(actor);
 	actor.womb
 		.filter(ft => (ft.genetics.father === 0 || (ft.genetics.father < -1 && ft.genetics.father >= -20 && ft.genetics.father !== -3)))
@@ -706,7 +706,7 @@ window.MissingParentIDCorrection = function(actor) {
 	State.variables.missingParentID--;
 };
 
-window.WombCleanYYFetuses = function(actor) {
+globalThis.WombCleanYYFetuses = function(actor) {
 	let reserved = [];
 
 	let i = actor.womb.length - 1;
@@ -727,7 +727,7 @@ window.WombCleanYYFetuses = function(actor) {
 	return reserved;
 };
 
-window.FetusGlobalReserveCount = function(reserveType) {
+globalThis.FetusGlobalReserveCount = function(reserveType) {
 	let cnt = 0;
 
 	if (typeof reserveType !== 'string') {
@@ -751,7 +751,7 @@ window.FetusGlobalReserveCount = function(reserveType) {
 	return cnt;
 };
 
-window.WombSetGenericReserve = function(actor, type, count) {
+globalThis.WombSetGenericReserve = function(actor, type, count) {
 	// console.log ("actor: " + actor + "  type: " + type + "  typeof: " + typeof type + "  count: " + count);
 	actor.womb.forEach(function(ft) {
 		// console.log ("  type: " + ft.reserve + "  typeof: " + typeof ft.reserve);
@@ -763,11 +763,11 @@ window.WombSetGenericReserve = function(actor, type, count) {
 	});
 };
 
-window.WombAddToGenericReserve = function(actor, type, count) {
+globalThis.WombAddToGenericReserve = function(actor, type, count) {
 	WombSetGenericReserve(actor, type, (WombReserveCount(actor, type) + count));
 };
 
-window.WombChangeReserveType = function(actor, oldType, newType) {
+globalThis.WombChangeReserveType = function(actor, oldType, newType) {
 	let count = 0;
 
 	actor.womb.forEach(function(ft) {
@@ -780,7 +780,7 @@ window.WombChangeReserveType = function(actor, oldType, newType) {
 	return count;
 };
 
-window.WombCleanGenericReserve = function(actor, type, count) {
+globalThis.WombCleanGenericReserve = function(actor, type, count) {
 	actor.womb.forEach(function(ft) {
 		if (ft.reserve === type && count > 0) {
 			ft.reserve = "";
@@ -789,7 +789,7 @@ window.WombCleanGenericReserve = function(actor, type, count) {
 	});
 };
 
-window.WombReserveCount = function(actor, type) {
+globalThis.WombReserveCount = function(actor, type) {
 	let cnt = 0;
 
 	actor.womb.forEach(function(ft) {
@@ -801,7 +801,7 @@ window.WombReserveCount = function(actor, type) {
 	return cnt;
 };
 
-window.WombGetReservedFetuses = function(actor, type) {
+globalThis.WombGetReservedFetuses = function(actor, type) {
 	let reserved = [];
 
 	actor.womb.forEach(function(ft) {
@@ -813,7 +813,7 @@ window.WombGetReservedFetuses = function(actor, type) {
 	return reserved;
 };
 
-window.WombRemoveReservedFetuses = function(actor, type) {
+globalThis.WombRemoveReservedFetuses = function(actor, type) {
 	let reserved = [];
 
 	let i = actor.womb.length - 1;
@@ -833,7 +833,7 @@ window.WombRemoveReservedFetuses = function(actor, type) {
 	return reserved;
 };
 
-window.WombCleanAllReserve = function(actor) {
+globalThis.WombCleanAllReserve = function(actor) {
 	actor.womb.forEach(function(ft) {
 		ft.reserve = "";
 	});
@@ -855,7 +855,7 @@ $He is _wd.litters[0] weeks pregnant with $his first set of _wd.countLitter[0] c
 In summary $he carry _wd.litters.length separate sets of children. $His most progressed fetus of second pregnancy is already reached _wd.litterData[1][0].age biological week of gestation.
 ---
 */
-window.WombGetLittersData = function(actor) {
+globalThis.WombGetLittersData = function(actor) {
 	let data = {};
 	let unicLiters = []; // array with realAges of separate litters.
 	let countLitter = [];
@@ -883,7 +883,7 @@ window.WombGetLittersData = function(actor) {
 	return data;
 };
 
-window.BCReserveInit = function() {
+globalThis.BCReserveInit = function() {
 	V.slaves.forEach(function(slave) {
 		slave.womb.forEach(function(ft) {
 			if (typeof ft.reserve !== 'string') {
diff --git a/src/neighbor/arcologyOpinion.js b/src/neighbor/arcologyOpinion.js
index b3f840779722aa9954a652d7852f702ee80fd9a3..8642f89fc1934c35de09a76deeac9f4c92dce93e 100644
--- a/src/neighbor/arcologyOpinion.js
+++ b/src/neighbor/arcologyOpinion.js
@@ -1,4 +1,4 @@
-window.arcologyOpinion = function(activeArcology, targetArcology) {
+globalThis.arcologyOpinion = function(activeArcology, targetArcology) {
 	if (typeof activeArcology.FSNull === "undefined") { activeArcology.FSNull = "unset"; }
 	if (typeof targetArcology.FSNull === "undefined") { targetArcology.FSNull = "unset"; }
 
diff --git a/src/npc/surgery/surgery.js b/src/npc/surgery/surgery.js
index 59fccf5e02d7e045f16351e565028f5288496cc2..a1b984d2f947c61a89190d2b613eb6c4f34d19e0 100644
--- a/src/npc/surgery/surgery.js
+++ b/src/npc/surgery/surgery.js
@@ -578,7 +578,7 @@ App.Medicine.Surgery.sizingProcedures = function() {
  * @param {App.Entity.SlaveState} slave
  * @param {string} part
  */
-window.surgeryAmp = function(slave, part) {
+globalThis.surgeryAmp = function(slave, part) {
 	switch (part) {
 		case "left ear":
 			delete slave.brand["left ear"];
@@ -644,7 +644,7 @@ window.surgeryAmp = function(slave, part) {
  * @param {string} side
  * @param {string} action
  */
-window.eyeSurgery = function(slave, side, action) {
+globalThis.eyeSurgery = function(slave, side, action) {
 	if (side === "both") {
 		eyeSurgery(slave, "left", action);
 		eyeSurgery(slave, "right", action);
@@ -709,7 +709,7 @@ window.eyeSurgery = function(slave, side, action) {
  * @param {string} color to set eye to
  * @param {string} [side] "left", "right", "both"
  */
-window.setEyeColor = function setEyeColor(slave, color, side = "both") {
+globalThis.setEyeColor = function(slave, color, side = "both") {
 	if (side === "both") {
 		setEyeColor(slave, color, "left");
 		setEyeColor(slave, color, "right");
@@ -730,7 +730,7 @@ window.setEyeColor = function setEyeColor(slave, color, side = "both") {
  * @param {string} sclera
  * @param {string} side
  */
-window.setEyeColorFull = function setEyeColorFull(slave, iris = "brown", pupil = "circular", sclera = "white", side) {
+globalThis.setEyeColorFull = function(slave, iris = "brown", pupil = "circular", sclera = "white", side) {
 	if (side === "both") {
 		setEyeColorFull(slave, iris, pupil, sclera, "left");
 		setEyeColorFull(slave, iris, pupil, sclera, "right");
@@ -757,7 +757,7 @@ window.setEyeColorFull = function setEyeColorFull(slave, iris = "brown", pupil =
  * @param {string} color
  * @param {boolean} heterochromia
  */
-window.setGeneticEyeColor = function(slave, color, heterochromia = false) {
+globalThis.setGeneticEyeColor = function(slave, color, heterochromia = false) {
 	if (heterochromia) {
 		slave.geneticQuirks.heterochromia = color;
 	} else {
@@ -772,7 +772,7 @@ window.setGeneticEyeColor = function(slave, color, heterochromia = false) {
  * @param {App.Entity.SlaveState} slave
  * @param {string} [side]
  */
-window.resetEyeColor = function(slave, side = "both") {
+globalThis.resetEyeColor = function(slave, side = "both") {
 	if (side === "both") {
 		resetEyeColor(slave, "left");
 		resetEyeColor(slave, "right");
@@ -788,7 +788,7 @@ window.resetEyeColor = function(slave, side = "both") {
  * @param {App.Entity.SlaveState} slave
  * @param {number} level
  */
-window.induceAlbinism = function(slave, level) {
+globalThis.induceAlbinism = function(slave, level) {
 	slave.geneticQuirks.albinism = level;
 	if (level < 2) {
 		slave.albinismOverride = null;
@@ -829,7 +829,7 @@ window.induceAlbinism = function(slave, level) {
  * @param {App.Entity.SlaveState} slave
  * @param {string} limb
  */
-window.removeLimbs = function(slave, limb) {
+globalThis.removeLimbs = function(slave, limb) {
 	function remove(limb, side) {
 		const prosthetic = findProsthetic(slave, limbToProsthetic(slave[limb][side].type));
 
@@ -926,7 +926,7 @@ window.removeLimbs = function(slave, limb) {
  * @param {string} limb
  * @param {number} id
  */
-window.attachLimbs = function(slave, limb, id) {
+globalThis.attachLimbs = function(slave, limb, id) {
 	function attach(limb, side) {
 		let prosthetic = findProsthetic(slave, limbToProsthetic(id));
 
@@ -963,7 +963,7 @@ window.attachLimbs = function(slave, limb, id) {
 	}
 };
 
-window.upgradeLimbs = function(slave, newId) {
+globalThis.upgradeLimbs = function(slave, newId) {
 	let changed = false;
 
 	/**
@@ -1021,7 +1021,7 @@ window.upgradeLimbs = function(slave, newId) {
  * @param {number} id
  * @param {boolean} clean if the slave should be cleaned of all existing
  */
-window.configureLimbs = function(slave, limb, id, clean = false) {
+globalThis.configureLimbs = function(slave, limb, id, clean = false) {
 	if (limb === "all") {
 		configureLimbs(slave, "left arm", id);
 		configureLimbs(slave, "right arm", id);
@@ -1088,7 +1088,7 @@ window.configureLimbs = function(slave, limb, id, clean = false) {
  * Prepare and set up for new Fuckdoll
  * @param {App.Entity.SlaveState} slave
  */
-window.beginFuckdoll = function(slave) {
+globalThis.beginFuckdoll = function(slave) {
 	slave.fuckdoll = 1;
 	slave.toyHole = "all her holes";
 	if ((slave.pubicHStyle !== "bald") && (slave.pubicHStyle !== "hairless")) {
diff --git a/src/personalAssistant/assistant.js b/src/personalAssistant/assistant.js
index dbe3c99bd22e76149e0f99a79114e2dd7a5f4d3a..19712cbac6e288288d68d496f898fbbc34304187 100644
--- a/src/personalAssistant/assistant.js
+++ b/src/personalAssistant/assistant.js
@@ -1,4 +1,4 @@
-window.assistant = (function() {
+globalThis.assistant = (function() {
 	return {
 		BC: BC,
 		object: manage,
diff --git a/src/player/js/enslavePlayer.js b/src/player/js/enslavePlayer.js
index b6a20e12957adbe880c7d84cd7ef333d619dd6dc..692443f9dc83344472e17c60bf261a8696b46998 100644
--- a/src/player/js/enslavePlayer.js
+++ b/src/player/js/enslavePlayer.js
@@ -1,6 +1,6 @@
 /* This function adds the missing slave object variables to the player object and prunes player exclusive variables. You can only imagine what this is used for. */
 /* This needs to find some way to survive refresh/newgame without showing up on all saves */
-window.convertPlayerToSlave = function(slave, badEnd = "boring") {
+globalThis.convertPlayerToSlave = function(slave, badEnd = "boring") {
 	/* add slave variables */
 	slave.skill.vaginal = 100;
 	slave.skill.oral = 100;
diff --git a/src/player/js/playerJS.js b/src/player/js/playerJS.js
index 3f325158cc4e3565866cdf20a3e8074b84ee449e..64350c2ed52913b44ceec7495f895b712315749a 100644
--- a/src/player/js/playerJS.js
+++ b/src/player/js/playerJS.js
@@ -1,4 +1,4 @@
-window.basePlayer = function basePlayer() {
+globalThis.basePlayer = function() {
 	return new App.Entity.PlayerState();
 };
 
@@ -6,7 +6,7 @@ window.basePlayer = function basePlayer() {
  * Helper function returning PC's title
  * @returns {string}
  */
-window.properTitle = function properTitle() {
+globalThis.properTitle = function() {
 	const PC = State.variables.PC;
 	if (PC.customTitle) {
 		return PC.customTitle;
@@ -21,7 +21,7 @@ window.properTitle = function properTitle() {
  * Helper function returning slave's title for PC in situations where WrittenMaster() is inappropriate
  * @returns {string}
  */
-window.properMaster = function properMaster() {
+globalThis.properMaster = function() {
 	const PC = State.variables.PC;
 	if (PC.customTitle) {
 		return PC.customTitle;
@@ -32,7 +32,7 @@ window.properMaster = function properMaster() {
 	}
 };
 
-window.PlayerName = function PlayerName() {
+globalThis.PlayerName = function() {
 	const names = V.PC.slaveSurname ? [V.PC.slaveName, V.PC.slaveSurname] : [V.PC.slaveName];
 	if ((V.surnameOrder !== 1 && ["Cambodian", "Chinese", "Hungarian", "Japanese", "Korean", "Mongolian", "Taiwanese", "Vietnamese"].includes(V.PC.nationality)) || (V.surnameOrder === 2)) {
 		names.reverse();
@@ -40,7 +40,7 @@ window.PlayerName = function PlayerName() {
 	return names.join(" ");
 };
 
-window.PCTitle = function PCTitle() {
+globalThis.PCTitle = function() {
 	const titles = [];
 
 	V.PCTitle = PlayerName();
@@ -630,7 +630,7 @@ window.PCTitle = function PCTitle() {
  * @param {number} [increase=1]
  * @returns {string}
  */
-window.IncreasePCSkills = function(input, increase = 1) {
+globalThis.IncreasePCSkills = function(input, increase = 1) {
 	if (Array.isArray(input)) {
 		return input.reduce((r, inputArray) => r + IncreasePCSkills(inputArray, increase), '');
 	}
diff --git a/src/pregmod/FCTV/FCTV.js b/src/pregmod/FCTV/FCTV.js
index 087125b10ac2ae69b6d45af634465a66d35651c9..95dd65e9359951e869284d4ed2fbc8538dc3e01c 100644
--- a/src/pregmod/FCTV/FCTV.js
+++ b/src/pregmod/FCTV/FCTV.js
@@ -14,7 +14,7 @@ pcViewership.frequency - How oftern should the PC watch FCTV.
 remote - Does the PC have a FCTV branded remote (also used to trigger a slave acquisition event).
 weekEnabled - The week FCTV was installed.
 */
-window.FCTV = (function() {
+globalThis.FCTV = (function() {
 	return {
 		channels:channels,
 		manage: manage,