Index: binaries/data/mods/public/gui/session/unit_actions.js
===================================================================
--- binaries/data/mods/public/gui/session/unit_actions.js	(revision 16565)
+++ binaries/data/mods/public/gui/session/unit_actions.js	(working copy)
@@ -222,7 +222,7 @@
 				return false;
 			if (getActionInfo("repair", target).possible)
 				return {"type": "repair", "cursor": "action-repair", "target": target};
-			return {"type": "none", "cursor": "action-repair-disabled", "target": undefined};
+			return {"type": "none", "cursor": "action-repair-disabled", "target": null};
 		},
 		"actionCheck": function(target)
 		{
@@ -295,7 +295,7 @@
 	{
 		"execute": function(target, action, selection, queued)
 		{
-			Engine.PostNetworkCommand({"type": "setup-trade-route", "entities": selection, "target": action.target, "source": undefined, "route": undefined, "queued": queued});
+			Engine.PostNetworkCommand({"type": "setup-trade-route", "entities": selection, "target": action.target, "source": null, "route": null, "queued": queued});
 			Engine.GuiInterfaceCall("PlaySound", { "name": "order_trade", "entity": selection[0] });
 			return true;
 		},
@@ -390,7 +390,7 @@
 			var actionInfo =  getActionInfo("garrison", target);
 			if (actionInfo.possible)
 				return {"type": "garrison", "cursor": "action-garrison", "tooltip": actionInfo.tooltip, "target": target};
-			return {"type": "none", "cursor": "action-garrison-disabled", "target": undefined};
+			return {"type": "none", "cursor": "action-garrison-disabled", "target": null};
 		},
 		"hotkeyActionCheck": function(target)
 		{
@@ -428,7 +428,7 @@
 				return false;
 			if (getActionInfo("guard", target).possible)
 				return {"type": "guard", "cursor": "action-guard", "target": target};
-			return {"type": "none", "cursor": "action-guard-disabled", "target": undefined};
+			return {"type": "none", "cursor": "action-guard-disabled", "target": null};
 		},
 		"hotkeyActionCheck": function(target)
 		{
Index: binaries/data/mods/public/simulation/components/GuiInterface.js
===================================================================
--- binaries/data/mods/public/simulation/components/GuiInterface.js	(revision 16565)
+++ binaries/data/mods/public/simulation/components/GuiInterface.js	(working copy)
@@ -267,17 +267,12 @@
 		ret.needsRepair = cmpMirage.NeedsRepair();
 	}
 
-	var cmpCapturable = Engine.QueryInterface(ent, IID_Capturable);
+	var cmpCapturable = QueryMiragedInterface(ent, IID_Capturable);
 	if (cmpCapturable)
 	{
 		ret.capturePoints = cmpCapturable.GetCapturePoints();
 		ret.maxCapturePoints = cmpCapturable.GetMaxCapturePoints();
 	}
-	if (cmpMirage && cmpMirage.Capturable())
-	{
-		ret.capturePoints = cmpMirage.GetCapturePoints();
-		ret.maxCapturePoints = cmpMirage.GetMaxCapturePoints();
-	}
 
 	var cmpBuilder = Engine.QueryInterface(ent, IID_Builder);
 	if (cmpBuilder)
@@ -1716,12 +1711,7 @@
 
 	var owner = QueryOwnerInterface(data.entity).GetPlayerID();
 
-	var cmp = Engine.QueryInterface(data.target, IID_Mirage);
-	if (cmp && !cmp.Capturable())
-		return false
-	else if (!cmp)
-		var cmp = Engine.QueryInterface(data.target, IID_Capturable);
-
+	var cmpCapturale = QueryMiragedInterface(data.target, IID_Capturable);
 	if (cmp && cmp.CanCapture(owner) && cmpAttack.GetAttackTypes().indexOf("Capture") != -1)
 		return cmpAttack.CanAttack(data.target);
 
Index: binaries/data/mods/public/simulation/components/Mirage.js
===================================================================
--- binaries/data/mods/public/simulation/components/Mirage.js	(revision 16565)
+++ binaries/data/mods/public/simulation/components/Mirage.js	(working copy)
@@ -47,6 +47,23 @@
 	this.player = player;
 };
 
+Mirage.prototype.Mirages = function(iid)
+{
+	switch (iid)
+	{
+	case IID_Foundation:
+		return this.foundation;
+	case IID_Health:
+		return this.health;
+	case IID_Capturable:
+		return this.capturable;
+	case IID_ResourceSupply:
+		return this.resourceSupply;
+	default:
+		return false;
+	}
+};
+
 // ============================
 // Parent entity data
 
@@ -58,11 +75,6 @@
 	this.buildPercentage = buildPercentage;
 };
 
-Mirage.prototype.Foundation = function()
-{
-	return this.foundation;
-};
-
 Mirage.prototype.GetBuildPercentage = function()
 {
 	return this.buildPercentage;
@@ -78,11 +90,6 @@
 	this.needsRepair = needsRepair;
 };
 
-Mirage.prototype.Health = function()
-{
-	return this.health;
-};
-
 Mirage.prototype.GetMaxHitpoints = function()
 {
 	return this.maxHitpoints;
@@ -107,11 +114,6 @@
 	this.maxCapturePoints = maxCapturePoints;
 };
 
-Mirage.prototype.Capturable = function()
-{
-	return this.capturable;
-};
-
 Mirage.prototype.GetMaxCapturePoints = function()
 {
 	return this.maxCapturePoints;
@@ -135,11 +137,6 @@
 	this.isInfinite = isInfinite;
 };
 
-Mirage.prototype.ResourceSupply = function()
-{
-	return this.resourceSupply;
-};
-
 Mirage.prototype.GetMaxAmount = function()
 {
 	return this.maxAmount;
Index: binaries/data/mods/public/simulation/helpers/Player.js
===================================================================
--- binaries/data/mods/public/simulation/helpers/Player.js	(revision 16565)
+++ binaries/data/mods/public/simulation/helpers/Player.js	(working copy)
@@ -223,6 +223,21 @@
 }
 
 /**
+ * Similar to Engine.QueryInterface but first checks if the entity
+ * mirages the interface.
+ */
+function QueryMiragedInterface(ent, iid)
+{
+	var cmp = Engine.QueryInterface(ent, IID_Mirage);
+	if (cmp && !cmp.Mirages(iid))
+		return null;
+	else if (!cmp)
+		cmp = Engine.QueryInterface(ent, iid);
+
+	return cmp;
+}
+
+/**
  * Returns true if the entity 'target' is owned by an ally of
  * the owner of 'entity'.
  */
@@ -379,6 +394,7 @@
 Engine.RegisterGlobal("LoadPlayerSettings", LoadPlayerSettings);
 Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface);
 Engine.RegisterGlobal("QueryPlayerIDInterface", QueryPlayerIDInterface);
+Engine.RegisterGlobal("QueryMiragedInterface", QueryMiragedInterface);
 Engine.RegisterGlobal("IsOwnedByAllyOfEntity", IsOwnedByAllyOfEntity);
 Engine.RegisterGlobal("IsOwnedByMutualAllyOfEntity", IsOwnedByMutualAllyOfEntity);
 Engine.RegisterGlobal("IsOwnedByPlayer", IsOwnedByPlayer);

