Index: binaries/data/mods/public/simulation/components/GarrisonHolder.js
===================================================================
--- binaries/data/mods/public/simulation/components/GarrisonHolder.js	(revision 18527)
+++ binaries/data/mods/public/simulation/components/GarrisonHolder.js	(working copy)
@@ -65,16 +65,13 @@
 	this.allowGarrisoning = {};
 	this.visibleGarrisonPoints = [];
 	if (this.template.VisibleGarrisonPoints)
-	{
-		for each (var offset in this.template.VisibleGarrisonPoints)
-		{
-			var o = {};
-			o.x = +offset.X;
-			o.y = +offset.Y;
-			o.z = +offset.Z;
-			this.visibleGarrisonPoints.push({"offset":o, "entity": null});
-		}
-	}
+		for (let name in this.template.VisibleGarrisonPoints)
+			this.visibleGarrisonPoints.push({ 
+				"offset": { 
+					"x": this.template.VisibleGarrisonPoints[name].X, 
+					"y": this.template.VisibleGarrisonPoints[name].Y, 
+					"z": this.template.VisibleGarrisonPoints[name].Z 
+					}, "entity": null });
 };
 
 /**
@@ -163,11 +160,10 @@
  */
 GarrisonHolder.prototype.IsGarrisoningAllowed = function()
 {
-	for each (var allow in this.allowGarrisoning)
-	{
-		if (!allow)
+	for (let allow in this.allowGarrisoning)
+		if (!this.allowGarrisoning[allow])
 			return false;
-	}
+
 	return true;
 };
 
@@ -177,10 +173,10 @@
 GarrisonHolder.prototype.GetGarrisonedEntitiesCount = function()
 {
 	var count = 0;
-	for each (var ent in this.entities)
+	for (let entity in this.entities)
 	{
-		count++;
-		var cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder);
+		++count;
+		let cmpGarrisonHolder = Engine.QueryInterface(this.entities[entity], IID_GarrisonHolder);
 		if (cmpGarrisonHolder)
 			count += cmpGarrisonHolder.GetGarrisonedEntitiesCount();
 	}
@@ -263,7 +259,7 @@
 
 	if (!this.timer && this.GetHealRate() > 0)
 	{
- 		var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
+		var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
 		this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {});
 	}
 
@@ -282,7 +278,7 @@
 
 	var cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
 	if (cmpUnitAI && cmpUnitAI.IsUnderAlert())
-		Engine.PostMessage(cmpUnitAI.GetAlertRaiser(), MT_UnitGarrisonedAfterAlert, {"holder": this.entity, "unit": entity});
+		Engine.PostMessage(cmpUnitAI.GetAlertRaiser(), MT_UnitGarrisonedAfterAlert, { "holder": this.entity, "unit": entity });
 
 	return true;
 };
@@ -305,10 +301,9 @@
 	var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
 	// If the garrisonHolder is a sinking ship, restrict the location to the intersection of both passabilities
 	// TODO: should use passability classes to be more generic
-	if ((!cmpHealth || cmpHealth.GetHitpoints() == 0) && cmpIdentity && cmpIdentity.HasClass("Ship"))
-		var pos = cmpFootprint.PickSpawnPointBothPass(entity);
-	else
-		var pos = cmpFootprint.PickSpawnPoint(entity);
+	let pos = (!cmpHealth || cmpHealth.GetHitpoints() === 0) && cmpIdentity && cmpIdentity.HasClass("Ship") ?
+		cmpFootprint.PickSpawnPointBothPass(entity) :
+		cmpFootprint.PickSpawnPoint(entity);
 
 	if (pos.y < 0)
 	{
@@ -332,7 +327,7 @@
 		if (vgp.entity != entity)
 			continue;
 		cmpNewPosition.SetTurretParent(INVALID_ENTITY, new Vector3D());
-		var cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
+		let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
 		if (cmpUnitAI)
 			cmpUnitAI.ResetTurretStance();
 		vgp.entity = null;
@@ -377,10 +372,8 @@
 			// ignore the rally point if it is autogarrison
 			if (commands[0].type == "garrison" && commands[0].target == this.entity)
 				return;
-			for each (var com in commands)
-			{
-				ProcessCommand(cmpOwnership.GetOwner(), com);
-			}
+			for (let command of commands)
+				ProcessCommand(cmpOwnership.GetOwner(), command);
 		}
 	}
 };
@@ -411,8 +404,8 @@
 
 		if (this.Eject(entity, forced))
 		{
-			var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
-			var cmpEntOwnership = Engine.QueryInterface(entity, IID_Ownership);
+			let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
+			let cmpEntOwnership = Engine.QueryInterface(entity, IID_Ownership);
 			if (cmpOwnership && cmpEntOwnership && cmpOwnership.GetOwner() == cmpEntOwnership.GetOwner())
 				ejectedEntities.push(entity);
 		}
@@ -423,7 +416,7 @@
 				failedRadius = Math.min(failedRadius, radius);
 			else
 			{
-				var cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction);
+				let cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction);
 				failedRadius = cmpObstruction ? cmpObstruction.GetUnitRadius() : 0;
 			}
 		}
@@ -463,13 +456,12 @@
 
 	var entities = [];
 	var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
-	for each (var entity in this.entities)
+	for (let entity of this.entities)
 	{
 		var cmpIdentity = Engine.QueryInterface(entity, IID_Identity);
 
 		// Units with multiple ranks are grouped together.
-		var name = cmpIdentity.GetSelectionGroupName()
-		           || cmpTemplateManager.GetCurrentTemplateName(entity);
+		let name = cmpIdentity.GetSelectionGroupName() || cmpTemplateManager.GetCurrentTemplateName(entity);
 
 		if (name != template)
 			continue;
@@ -541,7 +533,8 @@
  */
 GarrisonHolder.prototype.HealTimeout = function(data)
 {
-	if (this.entities.length == 0)
+	let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
+	if (this.entities.length)
 	{
 		var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
 		cmpTimer.CancelTimer(this.timer);
@@ -549,7 +542,7 @@
 	}
 	else
 	{
-		for each (var entity in this.entities)
+		for (let entity of this.entities)
 		{
 			var cmpHealth = Engine.QueryInterface(entity, IID_Health);
 			if (cmpHealth)
@@ -559,7 +552,7 @@
 					cmpHealth.Increase(this.GetHealRate());
 			}
 		}
-		var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
+		cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
 		this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {});
 	}
 };
@@ -612,7 +605,7 @@
 	{
 		// If the entity is dead, remove it directly instead of ejecting the corpse
 		var cmpHealth = Engine.QueryInterface(msg.entity, IID_Health);
-		if (cmpHealth && cmpHealth.GetHitpoints() == 0)
+		if (cmpHealth && cmpHealth.GetHitpoints() === 0)
 		{
 			this.entities.splice(entityIndex, 1);
 			Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added" : [], "removed": [msg.entity] });
@@ -694,7 +687,7 @@
 
 	// And destroy all remaining entities
 	var killedEntities = [];
-	for each (var entity in entities)
+	for (let entity of entities)
 	{
 		var entityIndex = this.entities.indexOf(entity);
 		if (entityIndex == -1)
@@ -719,9 +712,8 @@
 	var ejectableClasses = this.template.EjectClassesOnDestroy._string;
 	ejectableClasses = ejectableClasses ? ejectableClasses.split(/\s+/) : [];
 	var entityClasses = (Engine.QueryInterface(entity, IID_Identity)).GetClassesList();
-	for each (var ejectableClass in ejectableClasses)
-		if (entityClasses.indexOf(ejectableClass) != -1)
-			return true;
+	if (ejectableClasses.some(ejectableClass => entityClasses.indexOf(ejectableClass) != -1))
+		return true;
 
 	return false;
 };
@@ -743,5 +735,4 @@
 	this.initGarrison = undefined;
 };
 
-Engine.RegisterComponentType(IID_GarrisonHolder, "GarrisonHolder", GarrisonHolder);
-
+Engine.RegisterComponentType(IID_GarrisonHolder, "GarrisonHolder", GarrisonHolder);
\ No newline at end of file
