Index: binary-improvements/MapRendering/Web/API/GetLog.cs
===================================================================
--- binary-improvements/MapRendering/Web/API/GetLog.cs	(revision 349)
+++ binary-improvements/MapRendering/Web/API/GetLog.cs	(revision 350)
@@ -5,15 +5,37 @@
 namespace AllocsFixes.NetConnections.Servers.Web.API {
 	public class GetLog : WebAPI {
-		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user,
-			int permissionLevel) {
-			int firstLine, lastLine;
+		private const int MAX_COUNT = 1000;
+		
+		public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
+			int _permissionLevel) {
+			int count, firstLine, lastLine;
 
-			if (req.QueryString ["firstLine"] == null || !int.TryParse (req.QueryString ["firstLine"], out firstLine)) {
-				firstLine = LogBuffer.Instance.OldestLine;
+			if (_req.QueryString ["count"] == null || !int.TryParse (_req.QueryString ["count"], out count)) {
+				count = 50;
+			}
+
+			if (count == 0) {
+				count = 1;
+			}
+
+			if (count > MAX_COUNT) {
+				count = MAX_COUNT;
+			}
+
+			if (count < -MAX_COUNT) {
+				count = -MAX_COUNT;
+			}
+
+			if (_req.QueryString ["firstLine"] == null || !int.TryParse (_req.QueryString ["firstLine"], out firstLine)) {
+				if (count > 0) {
+					firstLine = LogBuffer.Instance.OldestLine;
+				} else {
+					firstLine = LogBuffer.Instance.LatestLine;
+				}
 			}
 
 			JSONObject result = new JSONObject ();
 
-			List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, 50, out lastLine);
+			List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, count, out lastLine);
 
 			JSONArray entries = new JSONArray ();
@@ -25,5 +47,5 @@
 				entry.Add ("msg", new JSONString (logEntry.message));
 				entry.Add ("trace", new JSONString (logEntry.trace));
-				entry.Add ("type", new JSONString (logEntry.type.ToString ()));
+				entry.Add ("type", new JSONString (logEntry.type.ToStringCached ()));
 				entries.Add (entry);
 			}
@@ -33,5 +55,5 @@
 			result.Add ("entries", entries);
 
-			WriteJSON (resp, result);
+			WriteJSON (_resp, result);
 		}
 	}
