code:
App.Facilities.Nursery.ChildDatatypeCleanup = function(child) {
	childAgeDatatypeCleanup(child);
	childPhysicalDatatypeCleanup(child);
	childFaceDatatypeCleanup(child);
	childHairDatatypeCleanup(child);
	childBoobsDatatypeCleanup(child);
	childButtDatatypeCleanup(child);
	childPregnancyDatatypeCleanup(child);
	childBellyDatatypeCleanup(child);
	childGenitaliaDatatypeCleanup(child);
	childImplantsDatatypeCleanup(child);
	childPiercingsDatatypeCleanup(child);
	childTattooDatatypeCleanup(child);
	childCosmeticsDatatypeCleanup(child);
	childDietDatatypeCleanup(child);
	childPornDatatypeCleanup(child);
	childRelationDatatypeCleanup(child);
	childSkillsDatatypeCleanup(child);
	childStatCountDatatypeCleanup(child);
	childPreferencesDatatypeCleanup(child);
	childRulesDatatypeCleanup(child);
	childCustomStatsDatatypeCleanup(child);
	childMiscellaneousDatatypeCleanup(child);
	generatePronouns(child);

	function childAgeDatatypeCleanup(child) {
		child.birthWeek = Math.clamp(+child.birthWeek, 0, 51) || 0;
		if (child.age > 0) {
			child.actualAge = Math.clamp(+child.actualAge, 0, Infinity) || child.age; /* if undefined, this sets to child.age */
			delete child.age;
		} else {
			child.actualAge = Math.clamp(+child.actualAge, 0, Infinity) || 3;
		}
		child.visualAge = Math.max(+child.visualAge, 0) || child.actualAge;
		child.physicalAge = Math.max(+child.physicalAge, 0) || child.actualAge;
		child.ovaryAge = Math.max(+child.ovaryAge, 0) || child.physicalAge;
		child.pubertyAgeXX = Math.max(+child.pubertyAgeXX, 0) || V.fertilityAge;
		child.pubertyAgeXY = Math.max(+child.pubertyAgeXY, 0) || V.potencyAge;
	}

	function childPhysicalDatatypeCleanup(child) {
		if (typeof child.nationality !== "string" || child.nationality === "child") {
			child.nationality = "slave";
		}
		if (typeof child.race !== "string") {
			nationalityToRace(child);
		}
		if (typeof child.origRace !== "string") {
			child.origRace = child.race;
		}
		if (typeof child.skin !== "string") {
			child.skin = "light";
		}
		if (typeof child.origSkin !== "string") {
			child.origSkin = child.skin;
		}
		if (typeof child.minorInjury !== "string") {
			child.minorInjury = 0;
		}
		if (typeof child.health === "number") {
			const condition = child.health;
			child.health = {};
			child.health.condition = condition;
		}
		child.health.condition = Math.clamp(+child.health.condition, -100, 100) || 0;
		child.health.shortDamage = Math.max(+child.health.shortDamage, 0) || 0;
		child.health.longDamage = Math.max(+child.health.longDamage, 0) || 0;
		child.health.illness = Math.max(+child.health.illness, 0) || 0;
		child.health.tired = Math.clamp(+child.health.tired, 0, 100) || 0;
		child.muscles = Math.clamp(+child.muscles, -100, 100) || 0;
		child.weight = Math.clamp(+child.weight, -100, 200) || 0;
		child.waist = Math.clamp(+child.waist, -100, 100) || 0;
		child.height = Math.round(Math.max(+child.height, 0)) || Height.mean(child);
		child.shoulders = Math.clamp(+child.shoulders, -2, 2) || 0;
		child.hips = Math.clamp(+child.hips, -2, 3) || 0;
	}

	function childFaceDatatypeCleanup(child) {
		child.face = Math.clamp(+child.face, -100, 100) || 0;
		if (typeof child.faceShape !== "string") {
			child.faceShape = "normal";
		}
		if (child.lips !== 0) {
			child.lips = Math.clamp(+child.lips, 0, 100) || 15;
		}
	}

	function childHairDatatypeCleanup(child) {
		if (typeof child.hColor !== "string") {
			child.hColor = "brown";
		}
		if (typeof child.origHColor !== "string") {
			child.origHColor = child.hColor;
		}
		if (child.hLength !== 0) {
			child.hLength = Math.clamp(+child.hLength, 0, 300) || 60;
		}
		if (typeof child.hStyle !== "string") {
			child.hStyle = "long";
		}
		child.haircuts = Math.clamp(+child.haircuts, 0, 1) || 0;
		child.bald = Math.clamp(+child.bald, 0, 1) || 0;
		if (typeof child.pubicHColor !== "string") {
			child.pubicHColor = child.hColor;
		}
		if (typeof child.pubicHStyle !== "string") {
			child.pubicHStyle = "neat";
		}
		if (typeof child.underArmHColor !== "string") {
			child.underArmHColor = child.hColor;
		}
		if (typeof child.underArmHStyle !== "string") {
			child.underArmHStyle = "waxed";
		}
		if (typeof child.eyebrowHColor !== "string") {
			child.eyebrowHColor = child.hColor;
		}
		if (typeof child.eyebrowHStyle !== "string") {
			child.eyebrowHStyle = "natural";
		}
		if (typeof child.eyebrowFullness !== "string") {
			child.eyebrowFullness = "natural";
		}
	}

	function childBoobsDatatypeCleanup(child) {
		child.boobs = Math.max(+child.boobs, 100) || 200;
		if (typeof child.boobShape !== "string") {
			child.boobShape = "normal";
		}
		if (typeof child.nipples !== "string") {
			child.nipples = "cute";
		}
		if (typeof child.nipplesAccessory !== "string") {
			child.nipplesAccessory = "none";
		}
		child.areolae = Math.clamp(+child.areolae, 0, 4) || 0;
		if (typeof child.areolaeShape !== "string") {
			child.areolaeShape = "circle";
		}
		child.lactation = Math.clamp(+child.lactation, 0, 2) || 0;
		child.lactationAdaptation = Math.clamp(+child.lactationAdaptation, 0, 100) || 0;
	}

	function childButtDatatypeCleanup(child) {
		if (child.butt !== 0) {
			child.butt = Math.clamp(+child.butt, 0, 20) || 1;
		}
		child.anus = Math.clamp(+child.anus, 0, 4) || 0;
		child.analArea = Math.max(+child.analArea, 0) || 0;
	}

	function childPregnancyDatatypeCleanup(child) {
		child.induce = Math.clamp(+child.induce, 0, 1) || 0;
		child.labor = Math.clamp(+child.labor, 0, 1) || 0;
		if (child.hasOwnProperty("cSec")) {
			if (child.cSec > 0) {
				App.Medicine.Modification.addScar(child, "belly", "c-section");
			}
			delete child.cSec;
		}
		child.prematureBirth = Math.clamp(+child.prematureBirth, 0, 1) || 0;
		child.ovaries = Math.clamp(+child.ovaries, 0, 1) || 0;
		child.vasectomy = Math.clamp(+child.vasectomy, 0, 1) || 0;
		child.mpreg = Math.clamp(+child.mpreg, 0, 1) || 0;
		if (child.pregAdaptation !== 0) {
			child.pregAdaptation = Math.max(+child.pregAdaptation, 0) || 50;
		}
		child.pregSource = +child.pregSource || 0;
		if (typeof child.pregControl !== "string") {
			child.pregControl = "none";
		}
		child.fertPeak = Math.clamp(+child.fertPeak, 0, 4) || 0;
		WombNormalizePreg(child);
	}

	function childBellyDatatypeCleanup(child) {
		child.bellySag = Math.max(+child.bellySag, 0) || 0;
		child.bellySagPreg = Math.max(+child.bellySagPreg, 0) || child.bellySag;
		SetBellySize(child);
	}

	function childGenitaliaDatatypeCleanup(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;
		child.clit = Math.clamp(+child.clit, 0, 5) || 0;
		child.foreskin = Math.max(+child.foreskin, 0) || 0;
		child.dick = Math.max(+child.dick, 0) || 0;
		if (child.dick && child.prostate !== 0) {
			child.prostate = Math.clamp(+child.prostate, 0, 3) || 1;
		} else {
			child.prostate = Math.clamp(+child.prostate, 0, 3) || 0;
		}
		child.balls = Math.max(+child.balls, 0) || 0;
		if (child.scrotum !== 0) {
			child.scrotum = Math.max(+child.scrotum, 0) || child.balls;
		}
	}

	function childImplantsDatatypeCleanup(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;
		child.voiceImplant = Math.clamp(+child.voiceImplant, -1, 1) || 0;
		child.boobsImplant = Math.max(+child.boobsImplant, 0) || 0;
		if (child.boobsImplant === 0) {
			child.boobsImplantType = "none";
		} else if (child.boobsImplantType === "none") {
			child.boobsImplantType = "normal";
		}
		child.breastMesh = Math.clamp(+child.breastMesh, 0, 1) || 0;
		child.buttImplant = Math.clamp(+child.buttImplant, 0, 3) || 0;
		if (child.buttImplant === 0) {
			child.buttImplantType = "none";
		} else if (child.buttImplantType === "none") {
			child.buttImplantType = "normal";
		}
		child.earImplant = Math.clamp(+child.earImplant, 0, 1) || 0;
	}

	function childPiercingsDatatypeCleanup(child) {
		child.piercing = child.piercing || {}; // areolae and nipples
		const oldPiercings = new Map([
			["nipple", "nipples"],
			["areola", "areolae"],
		]);
		for (const piercing of Object.keys(App.Data.Piercings)) {
			child.piercing[piercing] = child.piercing[piercing] || new App.Entity.piercingState();
			const oldPiercing = `${oldPiercings.get(piercing) || piercing}Piercing`; // the old variable names were sometimes plural and sometimes singular. The new standard is to use singular when possible.
			if (child.hasOwnProperty(oldPiercing)) {
				if (child[oldPiercing] === 3) { // 3 used to indicate a smart piercing. We now track this on a separate property as a bool.
					child.piercing[piercing].weight = 2;
					child.piercing[piercing].smart = true;
				} else if (child[oldPiercing]) {
					child.piercing[piercing].weight = child[oldPiercing];
				}
				delete child[oldPiercing];
			}
		}
	}

	function childTattooDatatypeCleanup(child) {
		if (typeof child.shouldersTat !== "string") {
			child.shouldersTat = 0;
		}
		if (typeof child.lipsTat !== "string") {
			child.lipsTat = 0;
		}
		if (typeof child.boobsTat !== "string") {
			child.boobsTat = 0;
		}
		if (typeof child.armsTat !== "string") {
			child.armsTat = 0;
		}
		if (typeof child.backTat !== "string") {
			child.backTat = 0;
		}
		if (typeof child.stampTat !== "string") {
			child.stampTat = 0;
		}
		if (typeof child.buttTat !== "string") {
			child.buttTat = 0;
		}
		if (typeof child.vaginaTat !== "string") {
			child.vaginaTat = 0;
		}
		if (typeof child.dickTat !== "string") {
			child.dickTat = 0;
		}
		if (typeof child.anusTat !== "string") {
			child.anusTat = 0;
		}
		if (typeof child.legsTat !== "string") {
			child.legsTat = 0;
		}
		if (typeof child.bellyTat !== "string") {
			child.bellyTat = 0;
		}
		if (typeof child.custom.tattoo !== "string") {
			child.custom.tattoo = "";
		}
	}

	function childCosmeticsDatatypeCleanup(child) {
		child.makeup = Math.clamp(+child.makeup, 0, 8) || 0;
		child.nails = Math.clamp(+child.nails, 0, 9) || 0;
		child.scars = Math.clamp(+child.scars, 0, 6) || 0;
		child.chastityAnus = Math.clamp(+child.chastityAnus, 0, 1) || 0;
		child.chastityPenis = Math.clamp(+child.chastityPenis, 0, 1) || 0;
		child.chastityVagina = Math.clamp(+child.chastityVagina, 0, 1) || 0;
		child.choosesOwnClothes = Math.clamp(+child.choosesOwnClothes, 0, 1) || 0;
		if (typeof child.clothes !== "string") {
			child.clothes = "no clothing";
		}
		if (typeof child.collar !== "string") {
			child.collar = "none";
		}
		if (typeof child.shoes !== "string") {
			child.shoes = "none";
		}
		if (typeof child.eyewear !== "string") {
			child.eyewear = "none";
		}
		if (typeof child.brand !== "object") {
			let brand = {};
			if (child.brand !== 0) {
				brand["left buttock"] = child.brand;
			}
			child.brand = brand;
		} else if (typeof child.brand === "object") { // Make sure key and value are strings
			for (let [key, value] of Object.entries(child.brand)) {
				if (typeof key !== "string" || typeof value !== "string") {
					delete child.brand[key];
				}
			}
		}
		if (typeof child.markings !== "string") {
			child.markings = "none";
		}
		if (typeof child.bellyAccessory !== "string") {
			child.bellyAccessory = "none";
		}
		if (typeof child.vaginalAccessory !== "string") {
			child.vaginalAccessory = "none";
		}
		if (typeof child.vaginalAttachment !== "string") {
			child.vaginalAttachment = "none";
		}
		if (typeof child.dickAccessory !== "string") {
			child.dickAccessory = "none";
		}
		if (typeof child.legAccessory !== "string") {
			child.legAccessory = "none";
		}
		if (typeof child.buttplug !== "string") {
			child.buttplug = "none";
		}
		if (typeof child.buttplugAttachment !== "string") {
			child.buttplugAttachment = "none";
		}
		if (typeof child.faceAccessory !== "string") {
			child.faceAccessory = "none";
		}
		if (typeof child.mouthAccessory !== "string") {
			child.mouthAccessory = "none";
		}
		switch (child.collar) {
			case "porcelain mask":
				child.faceAccessory = child.collar;
				child.collar = "none";
				break;
			case "bit gag":
			case "dildo gag":
			case "massive dildo gag":
			case "ball gag":
			case "ring gag":
				child.mouthAccessory = child.collar;
				child.collar = "none";
				break;
		}
	}

	function childDietDatatypeCleanup(child) {
		if (typeof child.diet !== "string") {
			child.diet = "healthy";
		}
		child.dietCum = Math.clamp(+child.dietCum, 0, 2) || 0;
		child.dietMilk = Math.clamp(+child.dietMilk, 0, 2) || 0;
		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") {
			child.drugs = "no drugs";
		}
		child.aphrodisiacs = Math.clamp(+child.aphrodisiacs, 0, 2) || 0;
		child.curatives = Math.clamp(+child.curatives, 0, 2) || 0;
	}

	function childPornDatatypeCleanup(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;
		child.porn.prestige = Math.clamp(+child.porn.prestige, 0, 3) || 0;
		if (typeof child.porn.prestigeDesc !== "string") {
			child.porn.prestigeDesc = 0;
		}
		if (typeof child.porn.fameType !== "string") {
			child.porn.fameType = "none";
		}
		if (typeof child.porn.focus !== "string") {
			child.porn.focus = "none";
		}
		for (const genre of App.Porn.getAllGenres()) {
			child.porn.fame[genre.fameVar] = Math.max(+child.porn.fame[genre.fameVar], 0) || 0;
		}
	}

	function childRelationDatatypeCleanup(child) {
		child.mother = +child.mother || 0;
		child.father = +child.father || 0;
		child.canRecruit = Math.clamp(+child.canRecruit, 0, 1) || 0;
		child.relationship = Math.clamp(+child.relationship, -3, 5) || 0;
		child.relationshipTarget = Math.max(+child.relationshipTarget, 0) || 0;
		child.rivalryTarget = Math.max(+child.rivalryTarget, 0) || 0;
		child.rivalry = Math.clamp(+child.rivalry, 0, 3) || 0;
	}

	function childSkillsDatatypeCleanup(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.penetrative = Math.clamp(+child.skill.penetrative, 0, 100) || 0;
		child.skill.anal = Math.clamp(+child.skill.anal, 0, 100) || 0;
		child.skill.whoring = Math.clamp(+child.skill.whoring, 0, 100) || 0;
		child.skill.entertainment = Math.clamp(+child.skill.entertainment, 0, 100) || 0;
		child.skill.combat = Math.clamp(+child.skill.combat, 0, 100) || 0;
		child.skill.headGirl = Math.clamp(+child.skill.headGirl, 0, 200) || 0;
		child.skill.recruiter = Math.clamp(+child.skill.recruiter, 0, 200) || 0;
		child.skill.bodyguard = Math.clamp(+child.skill.bodyguard, 0, 200) || 0;
		child.skill.madam = Math.clamp(+child.skill.madam, 0, 200) || 0;
		child.skill.DJ = Math.clamp(+child.skill.DJ, 0, 200) || 0;
		child.skill.nurse = Math.clamp(+child.skill.nurse, 0, 200) || 0;
		child.skill.teacher = Math.clamp(+child.skill.teacher, 0, 200) || 0;
		child.skill.attendant = Math.clamp(+child.skill.attendant, 0, 200) || 0;
		child.skill.matron = Math.clamp(+child.skill.matron, 0, 200) || 0;
		child.skill.stewardess = Math.clamp(+child.skill.stewardess, 0, 200) || 0;
		child.skill.milkmaid = Math.clamp(+child.skill.milkmaid, 0, 200) || 0;
		child.skill.farmer = Math.clamp(+child.skill.farmer, 0, 200) || 0;
		child.skill.wardeness = Math.clamp(+child.skill.wardeness, 0, 200) || 0;
		child.skill.servant = Math.clamp(+child.skill.servant, 0, 200) || 0;
		child.skill.entertainer = Math.clamp(+child.skill.entertainer, 0, 200) || 0;
		child.skill.whore = Math.clamp(+child.skill.whore, 0, 200) || 0;
	}

	function childStatCountDatatypeCleanup(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;
		child.counter.publicUse = Math.max(+child.counter.publicUse, 0) || 0;
		child.counter.mammary = Math.max(+child.counter.mammary, 0) || 0;
		child.counter.penetrative = Math.max(+child.counter.penetrative, 0) || 0;
		child.counter.pitKills = Math.max(+child.counter.pitKills, 0) || 0;
		child.counter.milk = Math.max(+child.counter.milk, 0) || 0;
		child.counter.cum = Math.max(+child.counter.cum, 0) || 0;
		child.counter.births = Math.max(+child.counter.births, 0) || 0;
		child.counter.birthsTotal = Math.max(+child.counter.birthsTotal, 0) || child.counter.births;
		child.counter.laborCount = Math.max(+child.counter.laborCount, 0) || child.counter.birthsTotal;
		child.counter.PCChildrenFathered = Math.max(+child.counter.PCChildrenFathered, 0) || 0;
		child.counter.PCKnockedUp = Math.max(+child.counter.PCKnockedUp, 0) || 0;
		child.bodySwap = Math.max(+child.bodySwap, 0) || 0;
	}

	function childPreferencesDatatypeCleanup(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;
		child.attrXX = Math.clamp(+child.attrXX, 0, 100) || 0;
		child.attrKnown = Math.clamp(+child.attrKnown, 0, 1) || 0;
		child.fetishStrength = Math.clamp(+child.fetishStrength, 0, 100) || 0;
		child.fetishKnown = Math.clamp(+child.fetishKnown, 0, 1) || 0;
	}

	function childRulesDatatypeCleanup(child) {
		child.breedingMark = Math.clamp(+child.breedingMark, 0, 1) || 0;
		child.rudeTitle = Math.clamp(+child.rudeTitle, 0, 1) || 0;
	}

	function childCustomStatsDatatypeCleanup(child) {
		if (typeof child.custom.label !== "string") {
			child.custom.label = "";
		}
		if (typeof child.custom.desc !== "string") {
			child.custom.desc = "";
		}
		if (typeof child.custom.title !== "string") {
			child.custom.title = "";
		}
		if (typeof child.custom.titleLisp !== "string") {
			child.custom.titleLisp = "";
		}
		if (child.custom.image !== null) {
			if (typeof child.custom.image.filename !== "string") {
				child.custom.image = null;
			}
		}
	}

	function childMiscellaneousDatatypeCleanup(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;
		child.oldDevotion = Math.clamp(+child.oldDevotion, -100, 100) || 0;
		child.trust = Math.clamp(+child.trust, -100, 100) || 0;
		child.oldTrust = Math.clamp(+child.oldTrust, -100, 100) || 0;
		child.chem = Math.max(+child.chem, 0) || 0;
		child.addict = Math.max(+child.addict, 0) || 0;
		child.intelligence = Math.clamp(+child.intelligence, -100, 100) || 0;
		child.intelligenceImplant = Math.clamp(+child.intelligenceImplant, 0, 30) || 0;
		child.premature = Math.clamp(+child.premature, 0, 1) || 0;
		child.training = Math.clamp(+child.training, 0, 150) || 0;
		child.hears = Math.clamp(+child.hears, -2, 0) || 0;
		child.smells = Math.clamp(+child.smells, -1, 0) || 0;
		child.tastes = Math.clamp(+child.tastes, -1, 0) || 0;
		if (typeof child.earwear !== "string") {
			child.earwear = "none";
		}
		if (child.voice !== 0) {
			child.voice = Math.clamp(+child.voice, 0, 3) || 1;
		}
		child.electrolarynx = Math.clamp(+child.electrolarynx, 0, 1) || 0;
		child.accent = Math.clamp(+child.accent, 0, 3) || 0;
	}
};

App.Facilities.Nursery.InfantDatatypeCleanup = function(child) {
	"use strict";

	ageDatatypeCleanup(child);
	physicalDatatypeCleanup(child);
	faceDatatypeCleanup(child);
	hairDatatypeCleanup(child);
	relationDatatypeCleanup(child);
	originDatatypeCleanup(child);
	generatePronouns(child);

	child.premature = Math.clamp(+child.premature, 0, 1) || 0;
	child.addict = Math.max(+child.addict, 0) || 0;

	// old versions of FC assign overlapping IDs to infants and other slaves, which needs to be fixed
	// deconflict IDs between infants and older children/tank babies/adults by reassigning the infant's ID
	if (V.cribs.find((s) => s.ID === child.ID && (s.birthWeek !== child.birthWeek || s.actualAge !== child.actualAge)) !== undefined ||
	 V.slaves.find((s) => s.ID === child.ID) !== undefined || (V.incubator.tanks.find((s) => s.ID === child.ID) !== undefined)) {
		child.ID = generateSlaveID();
	}

	function ageDatatypeCleanup(child) {
		child.birthWeek = Math.clamp(+child.birthWeek, 0, 51) || 0;
		child.actualAge = Math.clamp(+child.actualAge, 0, Infinity) || 0;
	}

	function physicalDatatypeCleanup(child) {
		if (typeof child.nationality !== "string" || child.nationality === "child") {
			child.nationality = "slave";
		}
		if (typeof child.race !== "string") {
			nationalityToRace(child);
		}
		if (typeof child.skin !== "string") {
			child.skin = "light";
		}
		child.weight = Math.clamp(+child.weight, -100, 200) || 0;
	}

	function faceDatatypeCleanup(child) {
		child.face = Math.clamp(+child.face, -100, 100) || 0;
		if (typeof child.faceShape !== "string") {
			child.faceShape = "normal";
		}
	}

	function hairDatatypeCleanup(child) {
		if (typeof child.hColor !== "string") {
			child.hColor = "brown";
		}
		if (typeof child.pubicHStyle !== "string") {
			child.pubicHStyle = "neat";
		}
		if (typeof child.eyebrowHColor !== "string") {
			child.eyebrowHColor = child.hColor;
		}
	}

	function relationDatatypeCleanup(child) {
		child.mother = +child.mother || 0;
		child.father = +child.father || 0;
		child.cloneID = +child.cloneID || 0;
	}

	function originDatatypeCleanup(child) {
		if (typeof child.origin !== "string") {
			child.origin = `${capFirstChar(child.pronoun)} was born and raised in your arcology. `;
		}
	}
};


code:
:: Nursery Discard Workaround [nobr]

$activeSlave.slaveName has been given away to another arcology to be raised, never to be seen again.

<<set $returnTo = "Main">>

repo_name: Arkerthan/fc

license: mit


code:
/** @type {FC.FacilityFramework} */
App.Data.Facilities.nursery = {
	baseName: "nursery",
	genericName: null,
	jobs: {
		nanny: {
			position: "nanny",
			assignment: Job.NURSERY,
			publicSexUse: false,
			fuckdollAccepted: false
		}
	},
	defaultJob: "nanny",
	manager: {
		position: "matron",
		assignment: Job.MATRON,
		careers: App.Data.Careers.Leader.matron,
		skill: "matron",
		publicSexUse: false,
		fuckdollAccepted: false,
		broodmotherAccepted: false,
		shouldWalk: true,
		shouldHold: true,
		shouldSee: true,
		shouldHear: true,
		shouldTalk: true,
		shouldThink: true,
		requiredDevotion: 51
	},
	decorated: true
};

App.Entity.Facilities.NurseryNannyJob = class extends App.Entity.Facilities.FacilitySingleJob {
	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {string[]}
	 */
	checkRequirements(slave) {
		let r = super.checkRequirements(slave);

		if (!App.Entity.Facilities.Job._isBrokenEnough(slave, 51, 21, -20, -95)) {
			r.push(App.Entity.Facilities.Job._stdBreakageMessage(slave));
		}

		return r;
	}

	/**
	 * @override
	 */
	get assignment() {
		return `work in ${this.facility.name}`;
	}
};

App.Entity.Facilities.Nursery = class extends App.Entity.Facilities.SingleJobFacility {
	constructor() {
		super(App.Data.Facilities.nursery,
			{
				nanny: new App.Entity.Facilities.NurseryNannyJob()
			});
	}

	// get capacity() {
	// 	return State.Variables.nurseryNannies;
	// }

	/** @override */
	occupancyReport(long) {
		return long
			? `${V.nurseryChildren}/${V.nurseryCribs} babies, ${this.hostedSlaves()}/${V.nursery} nannies${this.manager.currentEmployee ? `, ${this.manager.desc.position}` : ""}`
			: `${V.nurseryChildren}/${V.nurseryCribs}, ${this.hostedSlaves()}/${V.nursery}${this.manager.currentEmployee ? ", L" : ""}`;
	}
};

App.Entity.facilities.nursery = new App.Entity.Facilities.Nursery();


code:
:: Previous Child In Line

<<silently>>

<<set $i = $cribs.findIndex(function(c) { return c.ID === $activeChild.ID; })>>
<<set $cribs[$i] = $activeChild>> /* save changes before switching */
<<if $i == 0>>
	<<set $activeChild = $cribs[$cribs.length - 1]>>
	<<if $activeChild.actualAge < 3>>
		<<goto "Infant Interact">>
	<<else>>
		<<goto "Child Interact">>
	<</if>>
<<else>>
	<<set $activeChild = $cribs[$i-1]>>
	<<if $activeChild.actualAge < 3>>
		<<goto "Infant Interact">>
	<<else>>
		<<goto "Child Interact">>
	<</if>>
<</if>>

<</silently>>


code:
App.Facilities.Nursery.fChildOral = function fChildOral(child) {
	"use strict";

	let r = ``;

	actX(child, "oral");// TODO: will this counts towards the total count?

	// TODO: all of this

	return r;
};

App.Facilities.Nursery.fChildVaginal = function fChildVaginal(child) {
	"use strict";

	let r = ``;

	actX(child, "vaginal");// TODO: will this counts towards the total count?

	// TODO: all of this

	return r;
};

App.Facilities.Nursery.fChildAnal = function fChildAnal(child) {
	"use strict";

	let r = ``;

	actX(child, "anal");

	// TODO: all of this

	return r;
};

App.Facilities.Nursery.fChildImpreg = function fChildImpreg(child) {
	const bonus = jsRandom(6, 20);

	let r = ``;

	if (child.mpreg) {
		actX(child, "anal", (bonus + 1));
	} else {
		actX(child, "vaginal", (bonus + 1));
	}

	// TODO: all of this

	return r;
};


code:
/**
 * Displays a list of the children in the Nursery
 * @returns {DocumentFragment}
 */
App.Facilities.Nursery.childList = function childList() {
	const cribs = V.cribs;

	let frag = document.createDocumentFragment();
	let r = [];

	if (V.nurseryChildren) {
		App.UI.DOM.appendNewElement("h3", frag, `Children in ${V.nurseryName}`, "indent");

		const list = App.UI.DOM.appendNewElement("p", frag, '', "indent");

		for (const child of cribs) {
			const weeksOwned = V.week - child.weekAcquired;
			const weeksLeft = (V.targetAgeNursery * 52) - weeksOwned;
			const {he, him, He} = getPronouns(child);
			const hr = document.createElement("hr");

			hr.style.margin = "0";
			list.appendChild(hr);

			if (child.actualAge < 3) {
				$(list).append(App.UI.DOM.link(SlaveFullName(child), (id) => V.activeChild = getChild(id), [child.ID], "Infant Interact"));
				$(list).append(App.Facilities.Nursery.InfantSummary(child));
			} else {
				$(list).append(App.UI.DOM.link(SlaveFullName(child), (id) => V.activeChild = getChild(id), [child.ID], "Child Interact"));
				$(list).append(App.Facilities.Nursery.ChildSummary(child));
			}

			if (child.actualAge >= 18) {
				if (child.targetLocation === "freedom") {
					V.freedSlaves.push(child);
				}

				V.readySlave = cribs.pluck();
				r.push(`<<goto "Nursery Retrieval Workaround">>`);
				return r;
			}

			if (child.growTime <= 0 || child.actualAge >= V.targetAgeNursery) {
				const targetText = child.targetLocation === "slavery" ? `"Introduce ${him} to life as a slave"` : `"Set ${him} free"`;

				list.appendChild(document.createElement("br"));

				r.push(`${He} is ready to leave ${V.nurseryName} and ${child.targetLocation === "slavery" ? `join your ménage` : `become a free citizen`}.`);
				$(list).append(App.UI.DOM.passageLink(targetText, "Nursery Retrieval Workaround", () => { V.readySlave = child; }));
			} else {
				list.appendChild(document.createElement("br"));

				r.push(`${He} is to continue staying in ${V.nurseryName} for another ${years(weeksLeft)}. ${He} is destined for ${child.targetLocation} once ${he} is of age.`);
			}

			$(list).append(r.join(' '));

			r = [];	// reset for next child
		}
	}

	return frag;
};

/**
 * Converts the infant object into a new child object
 * @param {object} child
 * @returns {object}
 */
App.Facilities.Nursery.infantToChild = function infantToChild(child) {
	child.abortionTat = -1;
	child.accent = 0;
	child.ageImplant = 0;
	child.arm = {
		left: new App.Entity.ArmState(),
		right: new App.Entity.LegState()
	};
	child.leg = {
		left: new App.Entity.LegState(),
		right: new App.Entity.LegState()
	};
	child.analArea = 0;
	child.anus = 0;
	child.piercing = new App.Entity.completePiercingState();
	child.anusTat = 0;
	child.aphrodisiacs = 0;
	child.areolae = 0;
	child.areolaeShape = "circle";
	child.armAccessory = "none";
	child.armsTat = 0;
	child.attrKnown = 0;
	child.attrXX = 0;
	child.attrXY = 0;
	child.backTat = 0;
	child.bald = 0;
	child.balls = 0;
	child.behavioralFlaw = "none";
	child.belly = 0;
	child.bellyAccessory = "none";
	child.bellyFluid = 0;
	child.bellyImplant = -1;
	child.bellyPreg = 0;
	child.bellySag = 0;
	child.bellySagPreg = 0;
	child.bellyTat = 0;
	child.bodySwap = 0;
	child.boobShape = jsEither(["normal", "normal", "normal", "perky", "perky", "perky", "torpedo-shaped", "downward-facing", "wide-set"]);
	child.boobs = jsRandom(200, 500);
	child.boobsImplant = 0;
	child.boobsImplantType = "none";
	child.boobsTat = 0;
	child.brand = {};
	child.breastMesh = 0;
	child.breedingMark = 0;
	child.butt = jsRandom(0, 3);
	child.buttImplant = 0;
	child.buttImplantType = "none";
	child.buttTat = 0;
	child.buttplug = "none";
	child.buttplugAttachment = "none";
	child.canRecruit = 0;
	child.chastityAnus = 0;
	child.chastityPenis = 0;
	child.chastityVagina = 0;
	child.chem = 0;
	child.choosesOwnClothes = 0;
	child.clit = jsRandom(0, 2);
	child.clothes = "no clothing";
	child.collar = "none";
	child.counter = {
		PCChildrenFathered: 0,
		PCKnockedUp: 0,
		anal: 0,
		births: 0,
		birthsTotal: 0,
		cum: 0,
		laborCount: 0,
		mammary: 0,
		milk: 0,
		oral: 0,
		penetrative: 0,
		pitKills: 0,
		publicUse: 0,
		slavesFathered: 0,
		slavesKnockedUp: 0,
		vaginal: 0
	};
	child.curatives = 0;
	child.custom = {
		desc: "",
		hairVector: "",
		image: null,
		label: "",
		tattoo: "",
		title: "",
		titleLisp: ""
	};
	child.daughters = 0;
	child.devotion = 40;
	child.dick = 0;
	child.dickAccessory = "none";
	child.dickTat = 0;
	child.diet = "healthy";
	child.dietCum = 0;
	child.dietMilk = 0;
	child.drugs = "no drugs";
	if (child.race !== "catgirl") {
		child.earImplant = 0;
		child.earShape = "normal";
		child.earT = "none";
		child.earTColor = "hairless";
	}
	if (child.race === "catgirl") {
		child.earImplant = 1;
		child.earShape = "none";
		child.earT = "cat";
		child.earTColor = child.hColor;
	}
	child.earwear = "none";
	child.electrolarynx = 0;
	child.energy = 0;
	child.eyebrowFullness = "natural";
	child.eyebrowHStyle = "natural";
	child.eyewear = "none";
	child.faceImplant = 0;
	child.fertKnown = 1;
	child.fertPeak = 0;
	child.fetishKnown = 0;
	child.fetishStrength = 0;
	child.foreskin = 0;
	child.geneMods = {
		NCS: 0,
		rapidCellGrowth: 0,
		immortality: 0
	};
	child.hLength = jsRandom(30, 70);
	child.hStyle = "long";
	child.haircuts = 0;
	child.health = {};
	setHealth(child, jsRandom(80, 100), 0, 0, 0, 0);
	child.hears = 0;
	child.heels = 0;
	child.hips = 0;
	child.hormoneBalance = 0;
	child.hormones = 0;
	child.horn = "none";
	child.hornColor = "none";
	child.induce = 0;
	child.induceLactation = 0;
	child.intelligence = 100;
	child.intelligenceImplant = 0;
	child.labia = jsRandom(0, 2);
	child.labor = 0;
	child.lactation = 0;
	child.lactationAdaptation = 0;
	child.lactationDuration = 0;
	child.rules = new App.Entity.RuleState();
	child.rules.lactation = "none";
	child.legAccessory = "none";
	child.legsTat = 0;
	child.lips = jsRandom(10, 30);
	child.lipsImplant = 0;
	child.lipsTat = 0;
	child.rules.living = "normal";
	child.makeup = 0;
	child.markings = "none";
	child.minorInjury = 0;
	child.mpreg = 0;
	child.muscles = jsRandom(-10, 10);
	child.nails = 0;
	child.need = 0;
	if (child.boobs > 500 || child.weight > 95) {
		child.nipples = jsEither(["cute", "puffy", "partially inverted", "inverted", "tiny"]);
	} else {
		child.nipples = jsEither(["cute", "cute", "cute", "tiny"]);
	}
	child.nipplesAccessory = "none";
	child.oldDevotion = 0;
	child.oldTrust = 0;
	child.onDiet = 0;
	child.origRace = child.race;
	child.eye = new App.Entity.EyeState();
	child.eye.origColor = child.eyeColor;
	child.origHColor = child.hColor;
	child.origSkin = child.skin;
	child.ovaries = child.genes === "XX" ? 1 : 0;
	child.ovaryAge = child.actualAge;
	/* eslint-disable camelcase */
	child.override_Arm_H_Color = 0;
	child.override_Brow_H_Color = 0;
	child.override_Eye_Color = 0;
	child.override_H_Color = 0;
	child.override_Pubic_H_Color = 0;
	child.override_Race = 0;
	child.override_Skin = 0;
	/* eslint-enable camelcase */
	child.physicalAge = child.actualAge;
	child.porn = new App.Entity.SlavePornPerformanceState();
	child.pregAdaptation = 50;
	child.pregControl = "none";
	child.pregData = {
		drugsEffect: 1,
		fetusRate: [1, 1, 1, 0.64, 0.6513, 0.6459, 0.644, 0.6393, 0.58, 0.51],
		fetusSize: [1, 3, 16, 25.6, 51, 60, 67.5, 71.6, 129.5, 130],
		fetusWeek: [0, 9, 20, 20, 40, 52, 64, 80, 384, 99999],
		minLiveBirth: 32,
		normalBirth: 40,
		normalOvaMax: 1,
		normalOvaMin: 1,
		sizeType: 0,
		type: "human"
	};
	child.pregKnown = 0;
	child.pregSource = 0;
	child.pregType = 0;
	child.pregWeek = 0;
	child.prematureBirth = 0;
	child.prestige = 0;
	child.prostate = 0;
	child.pubertyAgeXX = 10;
	child.pubertyAgeXY = 12;
	child.pubertyXX = 1;
	child.pubicHColor = "black";
	child.pubicHStyle = "bushy";
	child.readyOva = 0;
	child.relationship = 0;
	child.rules.relationship = "restrictive";
	child.relationshipTarget = 0;
	child.rules.release = new App.Entity.ReleaseRulesState();
	child.rivalry = 0;
	child.rivalryTarget = 0;
	child.rudeTitle = 0;
	child.scar = {};
	child.scrotum = 0;
	child.shoes = "none";
	child.shoulders = 0;
	child.shouldersTat = 0;
	child.sisters = 0;
	child.skill = {
		DJ: 0,
		anal: 0,
		attendant: 0,
		bodyguard: 0,
		combat: 0,
		entertainer: 0,
		entertainment: 0,
		farmer: 0,
		headGirl: 0,
		madam: 0,
		matron: 0,
		milkmaid: 0,
		nurse: 0,
		oral: 0,
		recruiter: 0,
		servant: 0,
		stewardess: 0,
		teacher: 0,
		vaginal: 0,
		penetrative: 0,
		wardeness: 0,
		whore: 0,
		whoring: 8
	};
	child.smells = 0;
	child.rules.speech = "restrictive";
	child.stampTat = 0;
	child.rules.punishment = "situational";
	child.rules.reward = "situational";
	if (child.race !== "catgirl") {
		child.tailColor = "none";
		child.tailShape = "none";
	} else {
		child.tailColor = child.hColor;
		child.tailShape = "cat";
	}
	child.tastes = 0;
	child.teeth = "baby";
	child.training = 0;
	child.trust = 0;
	child.underArmHStyle = "natural";
	child.vagina = child.genes === "XX" ? 0 : -1;
	child.vaginaLube = 0;
	child.vaginaTat = 0;
	child.vaginalAccessory = "none";
	child.vaginalAttachment = "none";
	child.vasectomy = 0;
	child.visualAge = child.actualAge;
	child.voice = 1;
	child.voiceImplant = 0;
	child.waist = 0;
	child.weeksLeft = 0;
	child.weight = jsRandom(-10, 10);
	child.womb = [];
	child.wombImplant = "none";
	resetEyeColor(child, "both");
	generatePronouns(child);
	child.height = Height.forAge(child.natural.height, child);

	return child;
};

/**
 * Allows the player to name the infant
 * FIXME: Does not currently work
 * @param {object} child
 * @returns {string}
 */
App.Facilities.Nursery.nameChild = function nameChild(child) {
	const PC = V.PC;
	const arcology = V.arcologies[0];
	const girl = child.genes === "XX" ? "girl" : "boy";

	let r = ``;
	/** @type {App.Entity.SlaveState} */
	let father = 0;
	/** @type {App.Entity.SlaveState} */
	let mother = 0;

	const {him, his, he} = getPronouns(child);

	if (child.father === -1 && child.mother === -1) {
		father = PC;
		mother = PC;
	} else {
		if (child.father === -1) {
			father = PC;
			mother = getSlave(child.mother);
		} else if (child.mother === -1) {
			father = getSlave(child.father);
			mother = PC;
		} else {
			father = getSlave(child.father);
			mother = getSlave(child.mother);
		}
	}

	function newChildName(child) {
		child.birthName = generateName(child.nationality, child.race, child.genes === "XY");

		if (child.genes === "XY" && !V.allowMaleSlaveNames && isMaleName(child.birthName, child.nationality, child.race)) {
			child.slaveName = generateName(child.nationality, child.race, false);
		} else {
			child.slaveName = child.birthName;
		}
	}

	r += `You can name the new child, if you so desire. `;

	r += `<br><<textbox "${child.slaveName}" ${child.slaveName}>>`;
	r += App.UI.passageLink("Commit name", "Nursery Workaround", `${child.birthName = child.slaveName}, ${App.UI.replace("#naming", `You instruct ${V.assistant.name} to register the new ${girl} as "${child.slaveName}" in the slave registry.`)}`);
	r += `<br>`;
	r += App.UI.passageLink(`Have your PA assign ${him} a random name`, "Nursery Workaround", `${App.UI.replace("#naming", `${newChildName(child)}
${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.`)}`);

	if (FutureSocieties.isActive('FSPastoralist', arcology)) {
		if (child.lactation > 0) {
			r += `

			<<link "Have your PA assign ${him} a random cow name">>
			<<replace "#naming">>`;
			child.slaveName = App.Data.misc.cowSlaveNames.random();
			child.birthName = child.slaveName;
			r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
			<</link>>`;
		}
	}
	if (child.race === "catgirl") {
		r += `

		<<link "Have your PA assign ${him} a random cat name">>
		<<replace "#naming">>`;
		child.slaveName = App.Data.misc.catSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
		<</replace>>
		<</link>>`;
	}
	if (FutureSocieties.isActive('FSChattelReligionist', arcology)) {
		r += `

		<<link "Have your PA assign ${him} a random devotional name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.chattelReligionistSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	}
	if (FutureSocieties.isActive('FSRomanRevivalist', arcology)) {
		r += `

		<<link "Have your PA assign ${him} a random Roman name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.romanSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	} else if (FutureSocieties.isActive('FSAztecRevivalist', arcology)) {
		r += `

		<<link "Have your PA assign ${him} a random Aztec name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.aztecSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	} else if (FutureSocieties.isActive('FSEgyptianRevivalist', arcology)) {
		r += `

		<<link "Have your PA assign ${him} a random ancient Egyptian name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.ancientEgyptianSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	} else if (FutureSocieties.isActive('FSEdoRevivalist', arcology)) {
		r += `

		<<link "Have your PA assign ${him} a random feudal Japanese name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.edoSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	}
	if (FutureSocieties.isActive('FSDegradationist', arcology)) {
		r += `

		<<link "Have your PA assign ${him} a degrading name">>
			<<replace "#naming">>`;
		DegradingName(child);
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	}
	if (mother !== PC && mother !== 0) {
		const {He2, he2, his2} = getPronouns(mother).appendSuffix('2');
		if (mother.ID === V.ConcubineID) {
			r += `

			<<link "Permit your Concubine to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} picks a name ${he2} thinks you might find attractive; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (mother.relationship === -3 && mother.devotion >= -20) {
			r += `

			<<link "Permit your wife to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} picks a name suitable for your daughter; from now on ${he2} will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (mother.ID === V.BodyguardID) {
			r += `

			<<link "Permit your bodyguard to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} decides on "${child.slaveName}" for ${his2} daughter. ${He2} hopes you'll find it fitting ${his} station.
				<</replace>>
			<</link>>`;
		} else if (mother.ID === V.HeadGirlID) {
			r += `

			<<link "Permit your Head Girl to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} decides on "${child.slaveName}" for ${his2} daughter, and hopes it will be a name your other slaves will learn to respect.
				<</replace>>
			<</link>>`;
		} else if (mother.devotion > 50 && mother.trust > 50) {
			r += `

			<<link "Permit ${his} devoted mother to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} picks a name ${he2} hopes you'll like; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		}
	}
	if (father !== PC && father !== 0 && father !== mother) {
		const {He2, he2, his2} = getPronouns(father).appendSuffix('2');
		if (father.ID === V.ConcubineID) {
			r += `

			<<link "Permit your Concubine to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} picks a name ${he2} thinks you might find attractive; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (father.relationship === -3 && father.devotion >= -20) {
			r += `

			<<link "Permit your wife to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} picks a name suitable for your daughter; from now on ${he} will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (father.ID === V.BodyguardID) {
			r += `

			<<link "Permit your bodyguard to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} decides on "${child.slaveName}" for ${his2} daughter. ${He2} hopes you'll find it fitting ${his} station.
				<</replace>>
			<</link>>`;
		} else if (father.ID === V.HeadGirlID) {
			r += `

			<<link "Permit your Head Girl to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} decides on "${child.slaveName}" for ${his2} daughter, and hopes it will be a name your other slaves will learn to respect.
				<</replace>>
			<</link>>`;
		} else if (father.devotion > 50 && father.trust > 50) {
			r += `

			<<link "Permit ${his} devoted father to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} picks a name ${he2} hopes you'll like; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		}
	}

	return r;
};

/**
 * Adds an infant to a the cribs
 * @param {App.Facilities.Nursery.InfantState} child
 */
App.Facilities.Nursery.newChild = function newChild(child) {
	child.ID = generateSlaveID();

	child.actualAge = 0;
	child.birthWeek = 0;

	if (child.override_Race !== 1) {
		child.origRace = child.race;
	}

	if (child.override_H_Color !== 1) {
		child.hColor = getGeneticHairColor(child);
	}
	if (child.override_Arm_H_Color !== 1) {
		child.underArmHColor = getGeneticHairColor(child);
	}
	if (child.override_Pubic_H_Color !== 1) {
		child.pubicHColor = getGeneticHairColor(child);
	}
	if (child.override_Brow_H_Color !== 1) {
		child.eyebrowHColor = getGeneticHairColor(child);
	}
	if (child.override_Skin !== 1) {
		child.origSkin = getGeneticSkinColor(child);
	}
	/* eslint-disable camelcase*/
	child.override_Race = 0;
	child.override_H_Color = 0;
	child.override_Arm_H_Color = 0;
	child.override_Pubic_H_Color = 0;
	child.override_Brow_H_Color = 0;
	child.override_Skin = 0;
	child.override_Eye_Color = 0;
	/* eslint-enable */

	child.arm = {
		left: new App.Entity.ArmState(),
		right: new App.Entity.ArmState()
	};
	child.leg = {
		left: new App.Entity.LegState(),
		right: new App.Entity.LegState()
	};

	if (V.surnamesForbidden === 1) {
		child.slaveSurname = 0;
	}

	if (child.clone !== 0) {
		child.canRecruit = 0;
	}
	generatePronouns(child);
	child.origin = `$He was born and raised in your arcology. `;
	child.targetLocation = "slavery";
	child.growTime = V.targetAgeNursery * 52;
	V.cribs.push(child);
	V.cribsIndices = App.Facilities.Nursery.cribsToIndices();
	V.nurseryChildren++;
};

/**
 * @param {App.Entity.ChildState[]} [cribs]
 * @returns {object.<number, number>}
 */
App.Facilities.Nursery.cribsToIndices = function cribsToIndices(cribs = V.cribs) {
	return cribs.reduce((acc, child, i) => { acc[child.ID] = i; return acc; }, {});
};

/**
 * Returns index in the children array for the given ID
 * @param {number} id child's ID
 * @returns {number}
 */
App.Facilities.Nursery.childIndexForID = function childIndexForID(id) {
	return V.cribsIndices[id];
};

/**
 * Removes the child using the child's ID
 * @param {number} index
 * @returns {Array}
 */
App.Facilities.Nursery.removeChild = function removeChild(index) {
	return V.cribs.deleteAt(index);
};

/**
 * Displays a list of slaves with children eligible for the Nursery
 * FIXME: Does not currently work
 * @returns {string}
 */
App.Facilities.Nursery.nurserySort = function nurserySort() {
	const PC = V.PC;
	const SL = V.slaves.length;
	const arcology = V.arcologies[0];
	const freeCribs = (V.nurseryCribs - V.cribs.length);

	let r = ``;
	let eligibility = 0;
	let sortNurseryList = V.sortNurseryList || "Unsorted";
	let nurseryHasReservedChildren = false;
	let reservedChildrenNursery = FetusGlobalReserveCount("nursery");

	r += `<br><i>Sorting:</i> <b><span id="ql-nursery-sort">${sortNurseryList}.</span></b> `;
	r += `${App.UI.passageLink("Sort by Name", "Nursery", `${sortNurseryList = "Name"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byName()}`)} | `;
	r += `${App.UI.passageLink("Sort by Reserved Nursery Spots", "Nursery", `${sortNurseryList = "Reserved Nursery Spots"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byReservedSpots()}`)} | `;
	r += `${App.UI.passageLink("Sort by Pregnancy Week", "Nursery", `${sortNurseryList = "Pregnancy Week"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byPregnancyWeek()}`)} | `;
	r += `${App.UI.passageLink("Sort by Number of Children", "Nursery", `${sortNurseryList = "Number of Children"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byPregnancyCount()}`)}`;
	r += `<br>`;

	r += `<div id="ql-nursery">`;

	for (const slave of V.slaves) {
		const {His, his} = getPronouns(slave);

		if (slave.preg > 0 && !slave.broodmother && slave.pregKnown && slave.eggType === "human") {
			if (slave.assignment !== Job.DAIRY && V.dairyPregSetting <= 0) {
				const slaveID = "slave-" + slave.ID;
				const WL = slave.womb.length;
				const reservedNursery = WombReserveCount(slave, "nursery");
				const reservedIncubator = WombReserveCount(slave, "incubator");
				const pregWeek = slave.pregWeek;
				const slaveName = SlaveFullName(slave);

				r += `<div class="possible" @id="${slaveID}" @data-preg-count="${WL}" @data-reserved-spots="${reservedNursery}" @data-preg-week="${pregWeek}" @data-name="${slaveName}">`;

				r += `${App.UI.SlaveDescriptionDialog(slave)} is ${pregWeek} weeks pregnant with `;

				switch (slave.pregSource) {
					case 0:
						r += `someone's${slave.preg <= 5 ? `, though it is too early to tell whose,` : ``}`;
						break;
					case -1:
						r += `your`;
						break;
					case -2:
						r += `a citizen's`;
						break;
					case -3:
						r += `your Master's`;
						break;
					case -4:
						r += `another arcology owner's`;
						break;
					case -5:
						r += `your client's`;
						break;
					case -6:
						r += `the Societal Elite's`;
						break;
					case -7:
						r += `the lab's`;
						break;
					case -9:
						r += `the Futanari Sister's`;
						break;
					case -10:
						r += `your rapist`;
						break;
					default:
						if (slave.preg <= 5) {
							r += `someone's, though it is too early to tell whose,`;
						} else {
							let source = getSlave(slave.pregSource);
							if (source !== undefined) {
								r += `${source.slaveName}'s`;
							}
						}
						break;
				}
				r += ` ${WL > 1 ? `babies` : `baby`}. `;

				if (reservedNursery > 0) {
					nurseryHasReservedChildren = true;
					if (WL === 1) {
						r += `${His} child will be placed in ${V.nurseryName}. `;
					} else if (reservedNursery < WL) {
						r += `${reservedNursery} of ${his} children will be placed in ${V.nurseryName}. `;
					} else if (WL === 2) {
						r += `Both of ${his} children will be placed in ${V.nurseryName}. `;
					} else {
						r += `All ${reservedNursery} of ${his} children will be placed in ${V.nurseryName}. `;
					}

					if ((reservedIncubator + reservedNursery < WL) && (reservedChildrenNursery < freeCribs)) {
						r += `<br>    `;
						r += App.UI.passageLink("Keep another child", "Nursery", `${WombAddToGenericReserve(slave, "nursery", 1)}`);
						if (reservedNursery > 0) {
							r += ` | ${App.UI.passageLink("Keep one less child", "Nursery", `${WombCleanGenericReserve(slave, "nursery", 1)}`)}`;
						}
						if (reservedNursery > 1) {
							r += ` | ${App.UI.passageLink(`Keep none of ${his} children`, "Nursery", `${WombCleanGenericReserve(slave, "nursery", 9999)}`)}`;
						}
						if (reservedChildrenNursery + WL - reservedNursery <= freeCribs) {
							r += ` | ${App.UI.passageLink(`Keep the rest of ${his} children`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 9999)}`)}`;
						}
					} else if (reservedNursery === WL || reservedChildrenNursery === freeCribs || reservedIncubator + reservedNursery === WL) {
						r += `<br>    `;
						r += App.UI.passageLink("Keep one less child", "Nursery", `${WombCleanGenericReserve(slave, "nursery", 1)}`);
						if (reservedNursery > 1) {
							r += ` | ${App.UI.passageLink(`Keep none of ${his} children`, "Nursery", `${WombCleanGenericReserve(slave, "nursery", 9999)}`)}`;
						}
					}
				} else if (reservedChildrenNursery < freeCribs && freeCribs > WL) {
					if (WL - reservedIncubator === 0) {
						r += `<i>${His} children are already reserved for ${V.incubator.name}</i>`;
						r += `<br>    `;
						r += App.UI.passageLink(`Keep ${his} child${WL > 1 ? `ren` : ``} here instead`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 1)}`);
					} else {
						r += `You have ${freeCribs === 1 ? `an ` : ``}available room${freeCribs > 1 ? `s` : ``}. `;
						r += `<br>    `;
						r += App.UI.passageLink(`Keep ${WL > 1 ? `a` : `the`} child`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 1)}`);
						if (WL > 1 && (reservedChildrenNursery + WL - reservedNursery <= freeCribs)) {
							r += ` | ${App.UI.passageLink(`Keep all of ${his} children`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 9999)}`)}`;
						}
					}
				} else if (reservedChildrenNursery === freeCribs) {
					r += `<br>    `;
					r += `You have <span class="red">no room for ${his} offspring.</span> `;
				}

				eligibility = 1;
				r += `</div>`;
			}
		}
	}

	r += `</div>`;

	$('div#ql-nursery').ready(byPreviousSort);

	if (!eligibility) {
		r += `<br>`;
		r += `<i>You have no pregnant slave bearing eligible children</i>`;
	}

	if (PC.pregKnown && (!FutureSocieties.isActive('FSRestart', arcology) || V.eugenicsFullControl || (PC.pregSource !== -1 && PC.pregSource !== -6))) {
		const WL = PC.womb.length;

		let reservedIncubator = WombReserveCount(PC, "incubator");
		let reservedNursery = WombReserveCount(PC, "nursery");

		r += `<br><b><span class="pink">You're pregnant</span></b> and going to have ${WL === 1 ? `a baby. ` : pregNumberName(WL, 1)} `;

		if (reservedNursery > 0) {
			nurseryHasReservedChildren = true;
			if (WL === 1) {
				r += `Your child will be placed in ${V.nurseryName}.`;
			} else if (reservedNursery < WL) {
				r += `${reservedNursery} of your children will be placed in ${V.nurseryName}.`;
			} else if (WL === 2) {
				r += `Both of your children will be placed in ${V.nurseryName}.`;
			} else {
				r += `All ${reservedNursery} of your children will be placed in ${V.nurseryName}.`;
			}

			if (reservedNursery < WL && reservedChildrenNursery < freeCribs && reservedNursery - reservedIncubator > 0) {
				r += `<br>    `;
				r += App.UI.passageLink("Keep another child", "Nursery", `${reservedNursery += 1}, ${reservedChildrenNursery += 1}`);
				if (reservedNursery > 0) {
					r += ` | ${App.UI.passageLink("Keep one less child", "Nursery", `${reservedNursery -= 1}, ${reservedChildrenNursery -= 1}`)}`;
				}

				if (reservedNursery > 1) {
					r += ` | ${App.UI.passageLink("Keep none of your children", "Nursery", `${reservedChildrenNursery -= reservedNursery}, ${reservedChildrenNursery = 0}`)}`;
				}

				if (reservedChildrenNursery + WL - reservedNursery <= freeCribs) {
					r += ` | ${App.UI.passageLink("Keep the rest of your children", "Nursery", `${reservedChildrenNursery += (WL - reservedNursery)}, ${reservedNursery += (WL - reservedNursery)}`)}`;
				}
			} else if (reservedNursery === WL || reservedChildrenNursery === freeCribs || reservedNursery - reservedIncubator >= 0) {
				r += `<br>    `;
				r += App.UI.passageLink("Keep one less child", "Nursery", `${reservedNursery -= 1}, ${reservedChildrenNursery -= 1}`);
				if (reservedNursery > 1) {
					r += App.UI.passageLink("Keep none of your children", "Nursery", `${reservedChildrenNursery -= reservedNursery}, ${reservedNursery = 0}`);
				}
			}
		} else if (reservedChildrenNursery < freeCribs) {
			if (WL - reservedIncubator === 0) {
				r += `<i>Your child${WL > 1 ? `ren are` : ` is`} already reserved for ${V.incubator.name}</i>`;
				r += App.UI.passageLink(`Keep your child${WL > 1 ? `ren` : ``} here instead`, "Nursery", `${reservedNursery += WL}, ${reservedIncubator = 0}`);
			} else {
				r += `You have ${freeCribs === 1 ? `an ` : ``}available room${freeCribs > 1 ? `s` : ``}. `;
				r += `<br>    `;
				r += App.UI.passageLink(`Keep ${WL > 1 ? `a` : `your`} child`, "Nursery", `${reservedNursery += 1}, ${reservedChildrenNursery += 1}`);
				if (WL > 1 && (reservedChildrenNursery + WL - reservedNursery <= freeCribs)) {
					r += ` | ${App.UI.passageLink("Keep all of your children", "Nursery", `${reservedChildrenNursery += WL}, ${reservedNursery += WL}`)}`;
				}
			}
		} else if (reservedChildrenNursery === freeCribs) {
			r += `<br>    `;
			r += `You have <span class="red">no room for your offspring.</span> `;
		}
	}

	if (reservedChildrenNursery || nurseryHasReservedChildren) {
		r += `<br>`;
		r += App.UI.passageLink("Clear all reserved children", "Nursery", `${V.slaves.forEach((slave) => WombCleanGenericReserve(slave, "nursery", 9999))}, ${WombCleanGenericReserve(PC, "nursery", 9999)}`);
	}

	function byName() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-name');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byReservedSpots() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-reserved-spots');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byPregnancyWeek() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-preg-week');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byPregnancyCount() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-preg-count');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byPreviousSort() {
		let sort = V.sortNurseryList;
		if (sort !== 'unsorted') {
			if (sort === 'Name') {
				sortNurseryPossiblesByName();
			} else if (sort === 'Reserved Nursery Spots') {
				sortNurseryPossiblesByReservedSpots();
			} else if (sort === 'Pregnancy Week') {
				sortNurseryPossiblesByPregnancyWeek();
			} else if (sort === 'Number of Children') {
				sortNurseryPossiblesByPregnancyCount();
			}
		}
	}

	return r;
};


code:
App.UI.organFarm = function() {
	const node = new DocumentFragment();
	const PCSkillCheck = Math.min(V.upgradeMultiplierMedicine, V.HackingSkillMultiplier);

	App.UI.DOM.appendNewElement("h1", node, "The Organ Farm");

	const status = {
		1: "The organ farm is running smoothly. It can grow tailored organs for implantation in slaves. It can easily produce altered variants should you obtain the data necessary to create them.",
		2: "The organ farm is running smoothly. It can quickly grow tailored organs for implantation in slaves, though there will be side-effects. It can easily produce altered variants should you obtain the data necessary to create them.",
		3: "The organ farm is running smoothly. It can rapidly grow tailored organs for implantation in slaves. It can easily produce altered variants should you obtain the data necessary to create them."
	};

	App.UI.DOM.appendNewElement('div', node, App.Ratings.numeric(status, V.organFarmUpgrade), ['scene-intro']);

	/**
	 * @param {string} note
	 * @param {ParentNode} parentNode
	 */
	const appendNote = (note, parentNode) => {
		App.UI.DOM.appendNewElement("div", parentNode, note, "note");
	};

	/**
	 * @param {string} message
	 * @param {ParentNode} [parentNode]
	 */
	const upgradeImpossible = (message, parentNode) => {
		appendNote(message, parentNode ?? node);
	};

	/**
	 * @param {ParentNode} node
	 * @param {number} reputationReqBase
	 * @param {string} label
	 * @param {string[]} notes
	 * @param {number} costsBase
	 * @param {function(): void} handler
	 * @param {string} lackRepSubject
	 */
	const upgradeOption = (node, reputationReqBase, label, notes, costsBase, handler, lackRepSubject = '') => {
		if (V.rep < reputationReqBase * PCSkillCheck) {
			upgradeImpossible(`You lack the reputation to ${lackRepSubject}.`, node);
		} else {
			node.appendChild(makePurchase(label, costsBase * PCSkillCheck, "capEx", {
				notes,
				handler,
			}));
		}
	};

	if (V.organFarmUpgrade < 3 && V.rep <= 10000 * PCSkillCheck) {
		upgradeImpossible("You lack the reputation to access experimental organ farm parts.");
	} else if (V.dispensary === 0 && V.organFarmUpgrade === 2) {
		upgradeImpossible("An upgraded pharmaceutical fabricator is required by the perfected organ farm.");
	} else if (V.dispensary === 0 && V.organFarmUpgrade === 1) {
		upgradeImpossible("A pharmaceutical fabricator is required to produce the chemicals for the accelerated organ farm.");
	} else if (V.dispensaryUpgrade === 0 && V.organFarmUpgrade === 2) {
		upgradeImpossible("The pharmaceutical fabricator must be upgraded in order to produce the drugs required by the perfected organ farm.");
	} else if (V.organs.length > 0) {
		upgradeImpossible("The organ farm cannot be upgraded while it is use.");
	} else if (V.rep > 10000 * PCSkillCheck) {
		if (V.organFarmUpgrade === 2) {
			upgradeOption(node, 10_000, "Upgrade the organ farm to the cutting edge model",
				["will allow the organ farm to rapidly grow organs without risk to the implantee's health."],
				150_000, () => { V.organFarmUpgrade = 3; },
				""
			);
		} else if (V.organFarmUpgrade === 1) {
			upgradeOption(node, 10_000, "Upgrade the organ farm with an experimental growth accelerator",
				["will allow the organ farm to quickly grow organs. Implanted organs may cause health issues."],
				75_000, () => { V.organFarmUpgrade = 2; },
				""
			);
		}
	}

	if (V.youngerOvaries > 0) {
		App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing fertile ovaries for postmenopausal slaves.");
	} else {
		upgradeOption(node, 10_000, "Purchase designs for cloning fertile ovaries for menopausal slaves",
			["will allow the growth of younger, fertile ovaries for menopausal slaves. Restored fertility will only last for a couple years at most."],
			30_000, () => { V.youngerOvaries = 1; },
			"access designs for cloning fertile ovaries for menopausal slaves"
		);
	}

	if (V.immortalOvaries > 0) {
		App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing genetically modified ovaries that will never undergo menopause.");
	} else if (V.immortalityFormula > 0 && V.youngerOvaries > 0) {
		upgradeOption(node, 10_000, "Fund research into applying the immortality formula to ovaries",
			["will allow the growth of genetically modified ovaries that continually regenerate their ovarian follicles, thus never undergoing menopause. As long as the body remains young, it shall remain fertile."],
			1_000_000, () => { V.immortalOvaries = 1; },
			"fund additional fertility-focused research into the immortality project"
		);
	} else if (V.immortalityFormula > 0) {
		appendNote("You must acquire the designs to clone younger ovaries before you can research ovary immortality.", node);
	} // invisible without immortality formula

	if (V.asexualReproduction === 1) {
		App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing modified ovary pairs capable of self-fertilization.");
	}

	if (V.seePreg !== 0 && V.seeBestiality === 1 && V.experimental.animalOvaries === 1) {
		if (V.animalOvaries < 1) {
			appendNote("You lack the required designs for cloning animal ovaries for slaves.", node);
		} else {
			App.UI.DOM.appendNewElement('div', node, "The organ farm is capable of growing animal ovaries for slaves.");
		}

		if (V.animalTesticles < 1) {
			appendNote("You lack the required designs for cloning animal testicles for slaves.", node);
		} else {
			App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing animal testicles for slaves.");
		}

		if (V.arcologies[0].FSGenderRadicalistResearch === 1) {
			if (V.animalMpreg < 1) {
				appendNote("You lack the required designs for cloning animal anal wombs and ovaries for slaves.", node);
			} else {
				App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing animal anal wombs and ovaries for slaves.");
			}
		}
	}

	App.UI.DOM.appendNewElement("h2", node, "Organ Production");
	App.UI.DOM.appendNewElement("p", node, App.Medicine.OrganFarm.currentlyGrowing());

	App.UI.DOM.appendNewElement("h2", node, "Future Societies Research");

	if (V.seePreg !== 0) {
		if (V.arcologies[0].FSGenderRadicalistDecoration === 100) {
			if (V.arcologies[0].FSGenderRadicalistResearch === 0) {
				upgradeOption(node, 10_000, "Fund research into developing male pregnancy methods",
					["will allow cloning and production of anal uteri and ovaries."],
					50_000, () => { V.arcologies[0].FSGenderRadicalistResearch = 1; },
					"access the research necessary to develop anal uteri and ovaries"
				);
			} else {
				App.UI.DOM.appendNewElement("div", node, "The organ farm has been upgraded with schematics for modified uteri and ovaries.");
			}
		} else {
			appendNote("Gender Radicalist focused research unavailable.", node);
		}
	}
	return node;
};


code:
App.Facilities.HGSelect = function() {
	let div = document.createElement("div");
	const f = document.createDocumentFragment();
	let r = [];
	let links = [];

	App.UI.DOM.appendNewElement("h1", f, "Head Girl Management");

	if (S.HeadGirl) {
		const HGName = SlaveFullName(S.HeadGirl);
		const {
			His, He, he,
			his, him, himself
		} = getPronouns(S.HeadGirl);

		f.append(`${SlaveFullName(S.HeadGirl)} is working as your HeadGirl`);
		if (V.arcologies[0].FSEgyptianRevivalistLaw === 1) {
			f.append(`/Consort; serving and providing comfort, in addition to performing normal Head Girl duties`);
		}
		f.append(`. `);
		if (V.HGSuite) {
			f.append(`Currently living in ${capFirstChar(V.HGSuiteName)}. `);
		}
		f.append(App.UI.DOM.link("Remove HeadGirl", () => {
			removeJob(S.HeadGirl, Job.HEADGIRL);
		},
		[], "Main"
		));

		App.UI.DOM.appendNewElement("h2", f, `Slave training`);
		App.UI.DOM.appendNewElement("div", f, `${HGName} will prioritize enabled items in the following order`, "note");

		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsHealth"), " Health");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		div = document.createElement("div");
		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsParaphilias"), " Paraphilias");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		if (V.headGirlTrainsFlaws) {
			r.push(`${HGName} will remove flaws.`,);
		} else if (V.headGirlSoftensFlaws) {
			r.push(`${HGName} will soften flaws into quirks.`);
		} else if (V.headGirlOverridesQuirks) {
			r.push(`${HGName} will override quirks.`);
		} else {
			r.push(`${HGName} will ignore flaws.`);
		}

		links.push(App.UI.DOM.link("Override quirks", () => {
			V.headGirlTrainsFlaws = 0;
			V.headGirlSoftensFlaws = 0;
			V.headGirlOverridesQuirks = 1;
			App.UI.reload();
		}));
		links.push(App.UI.DOM.link("Soften flaws", () => {
			V.headGirlTrainsFlaws = 0;
			V.headGirlSoftensFlaws = 1;
			V.headGirlOverridesQuirks = 0;
			App.UI.reload();
		}));
		links.push(App.UI.DOM.link("Remove flaws", () => {
			V.headGirlTrainsFlaws = 1;
			V.headGirlSoftensFlaws = 0;
			V.headGirlOverridesQuirks = 0;
			App.UI.reload();
		}));

		links.push(App.UI.DOM.link("Ignore flaws", () => {
			V.headGirlTrainsFlaws = 0;
			V.headGirlSoftensFlaws = 0;
			V.headGirlOverridesQuirks = 0;
			App.UI.reload();
		}));

		r.push(App.UI.DOM.generateLinksStrip(links));
		App.Events.addNode(f, r, "div", "indent");

		div = document.createElement("div");
		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsObedience"), " Obedience");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		div = document.createElement("div");
		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsSkills"), " Skills");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		App.UI.DOM.appendNewElement("h2", f, "Training methods");

		r = [];
		if (V.HGSeverity === 1) {
			r.push(`${HGName} will be <span class="bold">aggressive</span> when punishing, with rape strongly encouraged.`);
			r.push(App.UI.DOM.link("Moderate", () => {
				V.HGSeverity = 0;
				App.UI.reload();
			}));
		} else if (V.HGSeverity === 0) {
			links = [];
			r.push(`${HGName} will be <span class="bold">moderate</span> when punishing, carefully selecting appropriate consequences.`);
			links.push(App.UI.DOM.link("Be aggressive", () => {
				V.HGSeverity = 1;
				App.UI.reload();
			}));
			links.push(App.UI.DOM.link(`Apply restrictions`, () => {
				V.HGSeverity = -1;
				App.UI.reload();
			}));
			r.push(App.UI.DOM.generateLinksStrip(links));
		} else if (V.HGSeverity === -1) {
			r.push(`${HGName} will be <span class="bold">respectful</span> when punishing, treating slaves decently.`);
			r.push(App.UI.DOM.link("Be stricter", () => {
				V.HGSeverity = 0;
				App.UI.reload();
			}));
		}
		App.Events.addNode(f, r, "div", "indent");

		r = [];
		if (V.HGPiercings === 1) {
			r.push(`${HGName} is <span class="bold">allowed</span> to use piercings as a tool to improve slaves' attitudes.`);
			r.push(App.UI.DOM.link("Disallow", () => {
				V.HGPiercings = 0;
				App.UI.reload();
			}));
		} else {
			r.push(`${HGName} is <span class="bold">not allowed</span> to use piercings as a tool to improve slaves' attitudes.`);
			r.push(App.UI.DOM.link("Allow", () => {
				V.HGPiercings = 1;
				App.UI.reload();
			}));
		}
		App.Events.addNode(f, r, "div", "indent");

		r = [];
		App.UI.DOM.appendNewElement("h2", f, "Behavior");
		if (V.HGFormality === 1) {
			r.push(`${HGName} will be <span class="bold">formal:</span> you will always be called ${getWrittenTitle(S.HeadGirl)}, just like any other slave.`);
			r.push(App.UI.DOM.link("Allow private informality", () => {
				V.HGFormality = 0;
				App.UI.reload();
			}));
		} else {
			r.push(`${HGName} is allowed to be <span class="bold">informal:</span> in private, you can be called ${properTitle()}.`);
			r.push(App.UI.DOM.link("Maintain complete formality", () => {
				V.HGFormality = 1;
				App.UI.reload();
			}));
		}
		App.Events.addNode(f, r, "div", "indent");

		r = [];
		if (V.seePreg !== 0) {
			if (V.universalRulesImpregnation === "HG") {
				App.UI.DOM.appendNewElement("div", f, `${HGName} is responsible for impregnating fertile slaves.`);
				if (canPenetrate(S.HeadGirl) && S.HeadGirl.pubertyXY === 1) {
					App.UI.DOM.appendNewElement("div", f, `To maximize the chances of impregnation, ${he} will fuck fertile pussies frequently during the week. ${S.HeadGirl.slaveName} can service ${resetHGCum(S.HeadGirl)} slaves this way.`);
					if (S.HeadGirl.devotion > 95) {
						App.UI.DOM.appendNewElement("div", f, `${He} loves you so much ${he}'ll fuck them until ${he}'s sore.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `If ${he} were more devoted to you, ${he} might be able to drive ${himself} to get hard and service one more.`);
					}
					if (S.HeadGirl.balls >= 120) {
						App.UI.DOM.appendNewElement("div", f, `${His} unreal balls produce nearly an endless supply of semen; ${his} ability to impregnate is almost limitless.`);
					} else if (S.HeadGirl.balls >= 80) {
						App.UI.DOM.appendNewElement("div", f, `${His} inhuman balls produce so much semen ${he} can easily impregnate twenty girls in one sitting.`);
					} else if (S.HeadGirl.balls >= 50) {
						App.UI.DOM.appendNewElement("div", f, `${His} giant balls produce so much semen ${he} can easily impregnate twelve girls in one sitting.`);
					} else if (S.HeadGirl.balls >= 25) {
						App.UI.DOM.appendNewElement("div", f, `${His} oversized balls produce so much semen ${he} can cum repeatedly in a single session.`);
					} else if (S.HeadGirl.balls >= 5) {
						App.UI.DOM.appendNewElement("div", f, `${His} big balls produce so much semen ${he} can cum more before ${he}'s drained.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `Bigger balls would let ${him} cum more before ${he}'s drained.`);
					}
					if (S.HeadGirl.health.condition > 95) {
						App.UI.DOM.appendNewElement("div", f, `${His} wonderful health lets ${him} get hard and stay hard all the time.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `If ${his} health were perfect, ${he} might be able to get hard more often.`);
					}
					if (S.HeadGirl.energy > 95) {
						App.UI.DOM.appendNewElement("div", f, `${His} nymphomania drives ${him} to go above and beyond in this.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `A more powerful sex drive could reduce ${his} refractory period.`);
					}
				} else {
					App.UI.DOM.appendNewElement("div", f, `However, ${S.HeadGirl.slaveName} cannot perform this duty.`);
				}
				r.push(App.UI.DOM.link(`Rescind ${his} impregnation responsibility`, () => {
					V.universalRulesImpregnation = "none";
					App.UI.reload();
				}));
				r.push(App.UI.DOM.link(`See to it yourself`, () => {
					V.universalRulesImpregnation = "PC";
					App.UI.reload();
				}));
				f.append(' ', App.UI.DOM.generateLinksStrip(r));
			} else {
				if (canPenetrate(S.HeadGirl) && S.HeadGirl.pubertyXY === 1) {
					App.UI.DOM.appendNewElement("div", f, `${HGName} is capable of impregnating slaves, but it's not part of ${his} responsibilities. `).append(
						App.UI.DOM.link(`Assign ${him} to impregnate`, () => {
							V.universalRulesImpregnation = "HG";
							App.UI.reload();
						}));
				}
			}
		}
	} else {
		f.append(`No HeadGirl assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.headGirlSuite, "Head Girl Select"));
	return f;
};


code:
App.Facilities.RecruiterSelect = function() {
	const f = document.createDocumentFragment();
	const recruiterCap = document.createDocumentFragment();
	let newLine = document.createElement("div");
	let r = [];

	App.UI.DOM.appendNewElement("h1", f, "Recruiter Management");
	if (S.Recruiter) {
		App.UI.DOM.appendNewElement("span", f, `${SlaveFullName(S.Recruiter)} is working as your Recruiter, currently ${V.recruiterTarget !== "other arcologies" ? 'recruiting girls. ' : 'acting as a sexual Ambassador'}`);
		if (V.recruiterTarget === "other arcologies") {
			const externalArcology = V.arcologies.find(s => s.direction === V.arcologies[0].influenceTarget);
			if (!externalArcology) {
				App.UI.DOM.appendNewElement("span", f, `. `);
				App.UI.DOM.appendNewElement("span", f, `Since you have not selected another arcology to influence, your recruiter's talents are going to waste. Select an influence target to apply them. `, "red");
			} else {
				App.UI.DOM.appendNewElement("span", f, ` to ${externalArcology.name}. `);
			}
		}
		f.append(App.UI.DOM.link("Remove Recruiter", () => {
			removeJob(S.Recruiter, Job.RECRUITER);
		},
		[], "Main"
		));

		App.UI.DOM.appendNewElement("p", f);
		f.append(`Your recruiter will target ${V.recruiterTarget}, `);
		if (V.recruiterTarget === "desperate whores") {
			f.append("they will be skilled but unhealthy. ");
		} else if (V.recruiterTarget === "young migrants") {
			f.append("they will be young and inexperienced but unhealthy. ");
		} else if (V.recruiterTarget === "recent divorcees") {
			f.append("they will be mature. ");
		} else if (V.recruiterTarget === "expectant mothers") {
			f.append("they will be pregnant and likely unhealthy. ");
		} else if (V.recruiterTarget === "dissolute sissies") {
			f.append("they will be born male and have some experience. ");
		} else if (V.recruiterTarget === "reassignment candidates") {
			f.append("they will be born male. ");
		} else if (V.recruiterTarget === "other arcologies") {
			f.append("they will appoint the Recruiter to be a sexual Ambassador. ");
		}

		r.push(App.UI.DOM.link(`Desperate whores`, () => {
			V.recruiterTarget = "desperate whores";
			App.UI.reload();
		}));
		r.push(App.UI.DOM.link("Young migrants", () => {
			V.recruiterTarget = "young migrants";
			App.UI.reload();
		}));
		r.push(App.UI.DOM.link("Recent divorcees", () => {
			V.recruiterTarget = "recent divorcees";
			App.UI.reload();
		}));

		if (V.seeDicks !== 100 && V.seePreg !== 0) {
			r.push(App.UI.DOM.link("Expectant mothers", () => {
				V.recruiterTarget = "expectant mothers";
				App.UI.reload();
			}));
		}
		if (V.seeDicks !== 0) {
			r.push(App.UI.DOM.link("Dissolute sissies", () => {
				V.recruiterTarget = "dissolute sissies";
				App.UI.reload();
			}));
			r.push(App.UI.DOM.link("Reassignment candidates", () => {
				V.recruiterTarget = "reassignment candidates";
				App.UI.reload();
			}));
		}
		if (V.arcologies.length > 1) {
			r.push(App.UI.DOM.link("Other arcologies' cultures", () => {
				V.oldRecruiterTarget = V.recruiterTarget;
				V.recruiterTarget = "other arcologies";
				App.UI.reload();
			}));
		}
		App.UI.DOM.appendNewElement("div", f, App.UI.DOM.generateLinksStrip(r));
		App.UI.DOM.appendNewElement("p", f);

		newLine.append(App.UI.DOM.makeCheckbox("recruiterEugenics"), App.UI.DOM.makeElement("span", " Target only individuals that can pass eugenics SMRs. This option will increase time it takes to recruit depending on how many eugenics SMR are active.", "note"));
		App.UI.DOM.appendNewElement("div", f, newLine);

		f.append("Suspend active recruiting and focus on publicity when: ");
		if (V.recruiterIdleRule === "number") {
			f.append(`${V.recruiterIdleNumber} sex slaves owned`);
		} else if (V.recruiterIdleRule === "facility") {
			const idleTarget = App.Utils.recruiterFacilitySpace();
			f.append(`match facility expansion, `);
			if (idleTarget > 20) {
				f.append(`${idleTarget} positions.`);
			} else {
				f.append("20 positions (rule minimum).");
			}
		} else {
			f.append("always recruit");
		}

		r = [];
		r.push(App.UI.DOM.link("Always recruit", () => {
			V.recruiterIdleRule = "always";
			App.UI.reload();
		}));
		r.push(App.UI.DOM.link("Facilities & leadership", () => {
			V.recruiterIdleRule = "facility";
			App.UI.reload();
		}));
		recruiterCap.append(App.UI.DOM.link("Set to this many slaves ", () => {
			V.recruiterIdleRule = "number";
			App.UI.reload();
		}));
		if (V.recruiterIdleRule === "number") {
			recruiterCap.append(App.UI.DOM.makeTextBox(V.recruiterIdleNumber, (v) => {
				V.recruiterIdleNumber = v;
				Engine.play(passage());
			}, true));
		}
		r.push(recruiterCap);
		App.UI.DOM.appendNewElement("div", f, App.UI.DOM.generateLinksStrip(r));
		App.UI.DOM.appendNewElement("div", f, "'Facilities' doesn't include training slots in cellblock, schoolroom, spa, clinic (but does include those leaders)");

		V.recruiterIdleNumber = Math.max(Math.trunc(Number(V.recruiterIdleNumber) || 20), 20);
	} else {
		f.append(`No Recruiter assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.penthouse, "Recruiter Select"));
	return f;
};