Index: binary-improvements/MapRendering/Web/API/GetLandClaims.cs
===================================================================
--- binary-improvements/MapRendering/Web/API/GetLandClaims.cs	(revision 251)
+++ binary-improvements/MapRendering/Web/API/GetLandClaims.cs	(revision 253)
@@ -7,14 +7,12 @@
 namespace AllocsFixes.NetConnections.Servers.Web.API
 {
-	public class GetLandClaims : WebAPI
-	{
-		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel)
-		{
-			string ViewersSteamID = string.Empty;
-            ulong lViewersSteamID = 0L;
+	public class GetLandClaims : WebAPI {
+		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) {
+			string requestedSteamID = string.Empty;
 
 			if (req.QueryString ["steamid"] != null) {
-				ViewersSteamID = req.QueryString ["steamid"];
-                if (ViewersSteamID.Length != 17 || !ulong.TryParse (ViewersSteamID, out lViewersSteamID)) {
+				ulong lViewersSteamID;
+				requestedSteamID = req.QueryString ["steamid"];
+				if (requestedSteamID.Length != 17 || !ulong.TryParse (requestedSteamID, out lViewersSteamID)) {
 					resp.StatusCode = (int)HttpStatusCode.BadRequest;
 					Web.SetResponseTextContent (resp, "Invalid SteamID given");
@@ -23,8 +21,8 @@
 			}
 
-            // default user, cheap way to avoid 'null reference exception'
-            try { user = user ?? new WebConnection ("", "", 0L); } catch { }
+			// default user, cheap way to avoid 'null reference exception'
+			user = user ?? new WebConnection ("", "", 0L);
 
-            bool bViewAll = false; try { bViewAll = user.CanViewAllClaims (permissionLevel); } catch { }
+			bool bViewAll = WebConnection.CanViewAllClaims (permissionLevel);
             
 			JSONObject result = new JSONObject ();
@@ -34,55 +32,48 @@
 			result.Add ("claimowners", claimOwners);
 
-			Dictionary<Vector3i, PersistentPlayerData> d = GameManager.Instance.GetPersistentPlayerList ().m_lpBlockMap;
-			if (d != null) {
-				World w = GameManager.Instance.World;
-				Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>> ();
+			LandClaimList.OwnerFilter[] ownerFilters = null;
+			if (!string.IsNullOrEmpty (requestedSteamID) || !bViewAll) {
+				if (!string.IsNullOrEmpty (requestedSteamID) && !bViewAll) {
+					ownerFilters = new LandClaimList.OwnerFilter[] {
+						LandClaimList.SteamIdFilter (user.SteamID.ToString ()),
+						LandClaimList.SteamIdFilter (requestedSteamID)
+					};
+				} else if (!bViewAll) {
+					ownerFilters = new LandClaimList.OwnerFilter[] { LandClaimList.SteamIdFilter (user.SteamID.ToString ()) };
+				} else {
+					ownerFilters = new LandClaimList.OwnerFilter[] { LandClaimList.SteamIdFilter (requestedSteamID) };
+				}
+			}
+			LandClaimList.PositionFilter[] posFilters = null;
 
-                // Add all owners to this temporary list regardless of permissions
-				foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) {
-					if (kvp.Value.PlayerId.Equals (ViewersSteamID)) {
-						if (!owners.ContainsKey (kvp.Value)) {
-							owners.Add (kvp.Value, new List<Vector3i> ());
-						}
-						owners [kvp.Value].Add (kvp.Key);
+			Dictionary<PersistentData.Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (ownerFilters, posFilters);
+
+			foreach (KeyValuePair<PersistentData.Player, List<Vector3i>> kvp in claims) {
+
+				try {
+					JSONObject owner = new JSONObject ();
+					claimOwners.Add (owner);
+
+					owner.Add ("steamid", new JSONString (kvp.Key.SteamID));
+					owner.Add ("claimactive", new JSONBoolean (kvp.Key.LandProtectionActive));
+
+					if (kvp.Key.Name.Length > 0) {
+						owner.Add ("playername", new JSONString (kvp.Key.Name));
+					} else {
+						owner.Add ("playername", new JSONNull ());
 					}
-				}
 
-                // Loop through all claim owners...
-				foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) {
-                    try
-                    {
-                        // ... but only show us claims that are from the current web user or if the current web user can see all claims regardless of ownership
-                        if (kvp.Key.PlayerId.Equals (ViewersSteamID) || bViewAll)
-                        {
-                            string currentSteamID = kvp.Key.PlayerId;
-                            bool isActive = w.IsLandProtectionValidForPlayer (kvp.Key);
+					JSONArray claimsJson = new JSONArray ();
+					owner.Add ("claims", claimsJson);
 
-                            JSONObject owner = new JSONObject ();
-                            claimOwners.Add (owner);
+					foreach (Vector3i v in kvp.Value) {
+						JSONObject claim = new JSONObject ();
+						claim.Add ("x", new JSONNumber (v.x));
+						claim.Add ("y", new JSONNumber (v.y));
+						claim.Add ("z", new JSONNumber (v.z));
 
-                            owner.Add("steamid", new JSONString (currentSteamID));
-                            owner.Add("claimactive", new JSONBoolean (isActive));
-
-                            if (PersistentContainer.Instance.Players [currentSteamID, false] != null) {
-                                owner.Add("playername", new JSONString (PersistentContainer.Instance.Players [currentSteamID, false].Name));
-                            } else {
-                                owner.Add("playername", new JSONNull ());
-                            }
-
-                            JSONArray claims = new JSONArray ();
-                            owner.Add ("claims", claims);
-
-                            foreach (Vector3i v in kvp.Value) {
-                                JSONObject claim = new JSONObject ();
-                                claim.Add ("x", new JSONNumber (v.x));
-                                claim.Add ("y", new JSONNumber (v.y));
-                                claim.Add ("z", new JSONNumber (v.z));
-
-                                claims.Add (claim);
-                            }
-                        }
-                    }
-                    catch { }
+						claimsJson.Add (claim);
+					}
+				} catch {
 				}
 			}
Index: binary-improvements/MapRendering/Web/API/GetLog.cs
===================================================================
--- binary-improvements/MapRendering/Web/API/GetLog.cs	(revision 251)
+++ binary-improvements/MapRendering/Web/API/GetLog.cs	(revision 253)
@@ -15,11 +15,7 @@
 			}
 
-			if (req.QueryString ["lastLine"] == null || !int.TryParse (req.QueryString ["lastLine"], out lastLine)) {
-				lastLine = -1;
-			}
-
 			JSONObject result = new JSONObject ();
 
-			List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, ref lastLine);
+			List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, 50, out lastLine);
 
 			JSONArray entries = new JSONArray ();
Index: binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs
===================================================================
--- binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs	(revision 251)
+++ binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs	(revision 253)
@@ -8,4 +8,5 @@
 {
 	public class GetPlayerInventory : WebAPI {
+
 		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) {
 			if (req.QueryString ["steamid"] == null) {
@@ -38,18 +39,17 @@
 			DoInventory (bag, inv.bag);
 
-			AddEquipment (equipment, "head", inv.equipment, XMLData.Item.EnumEquipmentSlot.Head, NGuiInvGridEquipment.EnumClothingLayer.Middle);
-			AddEquipment (equipment, "eyes", inv.equipment, XMLData.Item.EnumEquipmentSlot.Eyes, NGuiInvGridEquipment.EnumClothingLayer.Middle);
-			AddEquipment (equipment, "face", inv.equipment, XMLData.Item.EnumEquipmentSlot.Face, NGuiInvGridEquipment.EnumClothingLayer.Middle);
+			AddEquipment (equipment, "head", inv.equipment, EquipmentSlots.Headgear);
+			AddEquipment (equipment, "eyes", inv.equipment, EquipmentSlots.Eyewear);
+			AddEquipment (equipment, "face", inv.equipment, EquipmentSlots.Face);
 
-			AddEquipment (equipment, "armor", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Outer);
-			AddEquipment (equipment, "jacket", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Middle);
-			AddEquipment (equipment, "shirt", inv.equipment, XMLData.Item.EnumEquipmentSlot.Chest, NGuiInvGridEquipment.EnumClothingLayer.Inner);
+			AddEquipment (equipment, "armor", inv.equipment, EquipmentSlots.ChestArmor);
+			AddEquipment (equipment, "jacket", inv.equipment, EquipmentSlots.Jacket);
+			AddEquipment (equipment, "shirt", inv.equipment, EquipmentSlots.Shirt);
 
-			AddEquipment (equipment, "legarmor", inv.equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Outer);
-			AddEquipment (equipment, "pants", inv.equipment, XMLData.Item.EnumEquipmentSlot.Legs, NGuiInvGridEquipment.EnumClothingLayer.Inner);
-			AddEquipment (equipment, "boots", inv.equipment, XMLData.Item.EnumEquipmentSlot.Feet, NGuiInvGridEquipment.EnumClothingLayer.Inner);
+			AddEquipment (equipment, "legarmor", inv.equipment, EquipmentSlots.LegArmor);
+			AddEquipment (equipment, "pants", inv.equipment, EquipmentSlots.Legs);
+			AddEquipment (equipment, "boots", inv.equipment, EquipmentSlots.Feet);
 
-			AddEquipment (equipment, "gloves", inv.equipment, XMLData.Item.EnumEquipmentSlot.Hands, NGuiInvGridEquipment.EnumClothingLayer.Inner);
-			AddEquipment (equipment, "backpack", inv.equipment, XMLData.Item.EnumEquipmentSlot.Back, NGuiInvGridEquipment.EnumClothingLayer.Outer);
+			AddEquipment (equipment, "gloves", inv.equipment, EquipmentSlots.Hands);
 
 			WriteJSON (resp, result);
@@ -62,11 +62,16 @@
 		}
 
-		private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, XMLData.Item.EnumEquipmentSlot _slot, NGuiInvGridEquipment.EnumClothingLayer _layer) {
-			int index = (int)_slot + (int)_layer * (int)XMLData.Item.EnumEquipmentSlot.Count;
-			if (_items != null) {
-				_eq.Add (_slotname, GetJsonForItem (_items [index]));
-			} else {
-				_eq.Add (_slotname, new JSONNull ());
+		private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, EquipmentSlots _slot) {
+			int[] slotindices = XUiM_PlayerEquipment.GetSlotIndicesByEquipmentSlot (_slot);
+
+			for (int i = 0; i < slotindices.Length; i++) {
+				if (_items != null && _items [slotindices [i]] != null) {
+					InvItem item = _items [slotindices [i]];
+					_eq.Add (_slotname, GetJsonForItem (item));
+					return;
+				}
 			}
+
+			_eq.Add (_slotname, new JSONNull ());
 		}
 
@@ -75,8 +80,8 @@
 				JSONObject jsonItem = new JSONObject ();
 				jsonItem.Add ("count", new JSONNumber (_item.count));
-                jsonItem.Add ("name", new JSONString (_item.itemName));
-                jsonItem.Add ("icon", new JSONString (_item.icon));
-                jsonItem.Add ("iconcolor", new JSONString ((string.IsNullOrEmpty (_item.iconcolor) || _item.iconcolor == "FFFFFF" ? "" : _item.iconcolor)));
-                jsonItem.Add ("quality", new JSONNumber(_item.quality));
+				jsonItem.Add ("name", new JSONString (_item.itemName));
+				jsonItem.Add ("icon", new JSONString (_item.icon));
+				jsonItem.Add ("iconcolor", new JSONString (_item.iconcolor));
+				jsonItem.Add ("quality", new JSONNumber (_item.quality));
 				if (_item.quality >= 0) {
 					jsonItem.Add ("qualitycolor", new JSONString (QualityInfo.GetQualityColorHex (_item.quality)));
Index: binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs
===================================================================
--- binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs	(revision 251)
+++ binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs	(revision 253)
@@ -11,10 +11,8 @@
 		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel)
 		{
-            AdminTools admTools = null;
+            AdminTools admTools = GameManager.Instance.adminTools;
+            user = user ?? new WebConnection ("", "", 0L);
 
-            try { admTools = GameManager.Instance.adminTools; } catch { }
-            try { user = user ?? new WebConnection ("", "", 0L); } catch { } // default user, cheap way to avoid 'null reference exception'
-
-            bool bViewAll = false; try { bViewAll = user.CanViewAllPlayers (permissionLevel); } catch { }
+            bool bViewAll = WebConnection.CanViewAllPlayers (permissionLevel);
 
             JSONArray playersJsResult = new JSONArray ();
@@ -23,36 +21,29 @@
 
 			foreach (string sid in playersList.SteamIDs) {
-                try {
-                    if ((admTools != null) && (PetesUtils.ValidText (sid)))
-                        if (admTools.IsBanned (sid))
-                            continue;
+                if (admTools != null)
+                    if (admTools.IsBanned (sid))
+                        continue;
+
+                Player p = playersList [sid, false];
+
+                ulong player_steam_ID = 0L;
+                if (!ulong.TryParse (sid, out player_steam_ID))
+                    player_steam_ID = 0L;
+
+                if ((player_steam_ID == user.SteamID) || bViewAll) {
+                    JSONObject pos = new JSONObject ();
+                    pos.Add("x", new JSONNumber (p.LastPosition.x));
+                    pos.Add("y", new JSONNumber (p.LastPosition.y));
+                    pos.Add("z", new JSONNumber (p.LastPosition.z));
+
+                    JSONObject pJson = new JSONObject ();
+                    pJson.Add("steamid", new JSONString (sid));
+                    pJson.Add("ip", new JSONString (p.IP));
+                    pJson.Add("name", new JSONString (p.Name));
+                    pJson.Add("online", new JSONBoolean (p.IsOnline));
+                    pJson.Add("position", pos);
+
+                    playersJsResult.Add (pJson);
                 }
-                catch { }
-
-                try
-                {
-                    Player p = playersList [sid, false];
-
-                    ulong player_steam_ID = 0L;
-                    if (!ulong.TryParse (sid, out player_steam_ID))
-                        player_steam_ID = 0L;
-
-                    if ((player_steam_ID == user.SteamID) || bViewAll) {
-                        JSONObject pos = new JSONObject ();
-                        pos.Add("x", new JSONNumber (p.LastPosition.x));
-                        pos.Add("y", new JSONNumber (p.LastPosition.y));
-                        pos.Add("z", new JSONNumber (p.LastPosition.z));
-
-                        JSONObject pJson = new JSONObject ();
-                        pJson.Add("steamid", new JSONString (sid));
-                        pJson.Add("ip", new JSONString (p.IP));
-                        pJson.Add("name", new JSONString (p.Name));
-                        pJson.Add("online", new JSONBoolean (p.IsOnline));
-                        pJson.Add("position", pos);
-
-                        playersJsResult.Add (pJson);
-                    }
-                }
-                catch { }
             }
 
Index: binary-improvements/MapRendering/Web/API/GetRawEntitiesList.cs
===================================================================
--- binary-improvements/MapRendering/Web/API/GetRawEntitiesList.cs	(revision 251)
+++ 	(revision )
@@ -1,174 +1,0 @@
-﻿using AllocsFixes.JSON;
-using System;
-using System.Collections.Generic;
-using System.Net;
-
-namespace AllocsFixes.NetConnections.Servers.Web.API
-{
-    class GetRawEntitiesList : WebAPI
-    {
-        public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel)
-        {
-            JSONArray entitiesJsResult = new JSONArray ();
-
-            // Yes: hardcoded... even hacking the web interface won't show this data.  You -must- be an admin.
-            if (permissionLevel != 0) {
-                try {
-                    foreach (object base_entity in GameManager.Instance.World.Entities.list) {
-                        try {
-                            Entity entity = (Entity)base_entity;
-
-                            if ((entity.entityType == EntityType.Animal) || (base_entity.GetType () == typeof(EntityAnimal)) || (base_entity.GetType ().ToString ().ToLower ().Contains ("animal")))
-                            {
-                                EntityAnimal ea = (EntityAnimal)entity;
-
-                                Vector3i position = new Vector3i (entity.GetPosition ());
-
-                                JSONObject jsonPOS = new JSONObject ();
-                                jsonPOS.Add("x", new JSONNumber (position.x));
-                                jsonPOS.Add("y", new JSONNumber (position.y));
-                                jsonPOS.Add("z", new JSONNumber (position.z));
-
-                                JSONObject pJson = new JSONObject ();
-                                pJson.Add ("id", new JSONNumber (entity.entityId));
-                                pJson.Add ("type", new JSONString ("animal"));
-                                pJson.Add ("tag", new JSONString (entity.tag ?? ""));
-                                pJson.Add ("model", new JSONString ((entity.emodel == null) ? "?" : entity.emodel.name ?? "?"));
-                                pJson.Add ("alive", new JSONBoolean (ea.IsAlive ()));
-                                pJson.Add ("health", new JSONNumber (ea.Health));
-
-                                if (PetesUtils.ValidText (ea.EntityName))
-                                    pJson.Add ("name", new JSONString (ea.EntityName));
-                                else
-                                    pJson.Add ("name", new JSONString ("animal class #" + entity.entityClass.ToString ()));
-
-                                pJson.Add ("position", jsonPOS);
-
-                                entitiesJsResult.Add (pJson);
-                            }
-                            else if ((entity.entityType == EntityType.Zombie) || (base_entity.GetType () == typeof(EntityEnemy))) {
-                                EntityEnemy ee = (EntityEnemy)entity;
-
-                                Vector3i position = new Vector3i (entity.GetPosition ());
-
-                                JSONObject jsonPOS = new JSONObject ();
-                                jsonPOS.Add ("x", new JSONNumber (position.x));
-                                jsonPOS.Add ("y", new JSONNumber (position.y));
-                                jsonPOS.Add ("z", new JSONNumber (position.z));
-
-                                JSONObject pJson = new JSONObject ();
-                                pJson.Add ("id", new JSONNumber (entity.entityId));
-                                pJson.Add ("type", new JSONString ("enemy"));
-                                pJson.Add ("tag", new JSONString (entity.tag ?? ""));
-                                pJson.Add ("model", new JSONString ((entity.emodel == null) ? "?" : entity.emodel.name ?? "?"));
-                                pJson.Add ("alive", new JSONBoolean (ee.IsAlive ()));
-                                pJson.Add ("health", new JSONNumber (ee.Health));
-
-                                if (PetesUtils.ValidText (ee.EntityName))
-                                    pJson.Add ("name", new JSONString (ee.EntityName));
-                                else
-                                    pJson.Add ("name", new JSONString ("enemy class #" + entity.entityClass.ToString ()));
-
-                                pJson.Add ("position", jsonPOS);
-
-                                entitiesJsResult.Add (pJson);
-                            }
-                            else if ((entity.entityType == EntityType.Player) || (base_entity.GetType () == typeof(EntityPlayer))) {
-                                EntityPlayer ep = (EntityPlayer)entity;
-
-                                Vector3i position = new Vector3i (entity.GetPosition ());
-
-                                JSONObject jsonPOS = new JSONObject ();
-                                jsonPOS.Add ("x", new JSONNumber (position.x));
-                                jsonPOS.Add ("y", new JSONNumber (position.y));
-                                jsonPOS.Add ("z", new JSONNumber (position.z));
-
-                                JSONObject pJson = new JSONObject ();
-                                pJson.Add ("id", new JSONNumber (entity.entityId));
-                                pJson.Add ("type", new JSONString ("player"));
-                                pJson.Add ("tag", new JSONString (entity.tag ?? ""));
-                                pJson.Add ("model", new JSONString ((entity.emodel == null) ? "?" : entity.emodel.name ?? "?"));
-                                pJson.Add ("alive", new JSONBoolean (ep.IsAlive ()));
-                                pJson.Add ("score", new JSONNumber (ep.Score));
-                                pJson.Add ("health", new JSONNumber (ep.Health));
-                                pJson.Add ("zombiekills", new JSONNumber (ep.KilledZombies));
-                                pJson.Add ("stamina", new JSONNumber (ep.Stamina));
-
-                                if (PetesUtils.ValidText (ep.EntityName))
-                                    pJson.Add ("name", new JSONString (ep.EntityName));
-                                else
-                                    pJson.Add ("name", new JSONString ("player class #" + entity.entityClass.ToString ()));
-
-                                pJson.Add("position", jsonPOS);
-
-                                entitiesJsResult.Add(pJson);
-                            }
-                            else { // note: animals are an EntityAnimal but are being generated with the wrong entityType ID, so get caught here
-                                Vector3i position = new Vector3i (entity.GetPosition ());
-
-                                JSONObject jsonPOS = new JSONObject ();
-                                jsonPOS.Add ("x", new JSONNumber (position.x));
-                                jsonPOS.Add ("y", new JSONNumber (position.y));
-                                jsonPOS.Add ("z", new JSONNumber (position.z));
-
-                                JSONObject pJson = new JSONObject ();
-                                pJson.Add ("id", new JSONNumber (entity.entityId));
-                                pJson.Add ("type", new JSONString ("unknown #" + ((int)entity.entityType).ToString ()));
-                                pJson.Add ("tag", new JSONString (entity.tag ?? ""));
-
-                                string true_name = entity.name;
-                                
-                                try {
-                                    int iTries = 0;
-                                    UnityEngine.GameObject go = entity.gameObject;
-
-                                    while (true_name == "GameObject") {
-                                        true_name = go.name;
-                                        go = go.gameObject;
-
-                                        if (++iTries > 10)
-                                            break;
-                                    }
-                                }
-                                catch { }
-
-                                string true_emodel = (entity.emodel == null) ? "?" : entity.emodel.name;
-
-                                try {
-                                    int iTries = 0;
-                                    UnityEngine.GameObject go = entity.emodel.gameObject;
-
-                                    while (true_emodel == "GameObject") {
-                                        true_emodel = go.name;
-                                        go = go.gameObject;
-
-                                        if (++iTries > 10)
-                                            break;
-                                    }
-                                }
-                                catch { }
-
-                                pJson.Add ("model", new JSONString (true_emodel));
-
-                                if (PetesUtils.ValidText (true_name))
-                                    pJson.Add("name", new JSONString (base_entity.GetType ().ToString () + ": " + true_name));
-                                else
-                                    pJson.Add("name", new JSONString (base_entity.GetType ().ToString () + " class #" + entity.entityClass.ToString ()));
-
-                                pJson.Add ("position", jsonPOS);
-
-                                entitiesJsResult.Add (pJson);
-                            }
-                        }
-                        catch { }
-                    }
-                }
-                catch (Exception ex) {
-                    entitiesJsResult.Add (new JSONString ("Error: " + ex.GetType ().ToString () + " - " + ex.Message + "\r\n" + ex.StackTrace));
-                }
-            }
-
-            WriteJSON (resp, entitiesJsResult);
-        }
-    }
-}
