Index: binary-improvements/MapRendering/Web/WebPermissions.cs
===================================================================
--- binary-improvements/MapRendering/Web/WebPermissions.cs	(revision 325)
+++ binary-improvements/MapRendering/Web/WebPermissions.cs	(revision 326)
@@ -12,8 +12,8 @@
 			new Dictionary<string, WebModulePermission> ();
 
-		private Dictionary<string, AdminToken> admintokens;
+		private readonly Dictionary<string, AdminToken> admintokens = new CaseInsensitiveStringDictionary<AdminToken> ();
 		private FileSystemWatcher fileWatcher;
 
-		private Dictionary<string, WebModulePermission> modules;
+		private readonly Dictionary<string, WebModulePermission> modules = new CaseInsensitiveStringDictionary<WebModulePermission> ();
 
 		public WebPermissions () {
@@ -49,6 +49,7 @@
 
 		public WebModulePermission GetModulePermission (string _module) {
-			if (modules.ContainsKey (_module.ToLower ())) {
-				return modules [_module.ToLower ()];
+			WebModulePermission result;
+			if (modules.TryGetValue (_module, out result)) {
+				return result;
 			}
 
@@ -83,5 +84,5 @@
 		public AdminToken[] GetAdmins () {
 			AdminToken[] result = new AdminToken[admintokens.Count];
-			admintokens.Values.CopyTo (result, 0);
+			admintokens.CopyValuesTo (result);
 			return result;
 		}
@@ -90,5 +91,5 @@
 		// Commands
 		public void AddModulePermission (string _module, int _permissionLevel, bool _save = true) {
-			WebModulePermission p = new WebModulePermission (_module.ToLower (), _permissionLevel);
+			WebModulePermission p = new WebModulePermission (_module, _permissionLevel);
 			lock (this) {
 				modules [_module] = p;
@@ -100,13 +101,15 @@
 
 		public void AddKnownModule (string _module, int _defaultPermission) {
-			if (!string.IsNullOrEmpty (_module)) {
-				lock (this) {
-					if (!IsKnownModule (_module)) {
-						knownModules.Add (_module, new WebModulePermission (_module, _defaultPermission));
-					}
-
-					if (_defaultPermission > 0 && !modules.ContainsKey (_module.ToLower ())) {
-						AddModulePermission (_module, _defaultPermission);
-					}
+			if (string.IsNullOrEmpty (_module)) {
+				return;
+			}
+
+			lock (this) {
+				if (!IsKnownModule (_module)) {
+					knownModules.Add (_module, new WebModulePermission (_module, _defaultPermission));
+				}
+
+				if (_defaultPermission > 0 && !modules.ContainsKey (_module)) {
+					AddModulePermission (_module, _defaultPermission);
 				}
 			}
@@ -114,16 +117,17 @@
 
 		public bool IsKnownModule (string _module) {
-			if (!string.IsNullOrEmpty (_module)) {
-				lock (this) {
-					return knownModules.ContainsKey (_module);
-				}
-			}
-
-			return false;
+			if (string.IsNullOrEmpty (_module)) {
+				return false;
+			}
+
+			lock (this) {
+				return knownModules.ContainsKey (_module);
+			}
+
 		}
 
 		public void RemoveModulePermission (string _module, bool _save = true) {
 			lock (this) {
-				modules.Remove (_module.ToLower ());
+				modules.Remove (_module);
 				if (_save) {
 					Save ();
@@ -174,6 +178,6 @@
 
 		public void Load () {
-			admintokens = new Dictionary<string, AdminToken> ();
-			modules = new Dictionary<string, WebModulePermission> ();
+			admintokens.Clear ();
+			modules.Clear ();
 
 			if (!Utils.FileExists (GetFullPath ())) {
@@ -190,5 +194,5 @@
 				xmlDoc.Load (GetFullPath ());
 			} catch (XmlException e) {
-				Log.Error (string.Format ("Failed loading permissions file: {0}", e.Message));
+				Log.Error ("Failed loading permissions file: " + e.Message);
 				return;
 			}
@@ -196,4 +200,9 @@
 			XmlNode adminToolsNode = xmlDoc.DocumentElement;
 
+			if (adminToolsNode == null) {
+				Log.Error ("Failed loading permissions file: No DocumentElement found");
+				return;
+			}
+			
 			foreach (XmlNode childNode in adminToolsNode.ChildNodes) {
 				if (childNode.Name == "admintokens") {
@@ -230,5 +239,5 @@
 						string name = lineItem.GetAttribute ("name");
 						string token = lineItem.GetAttribute ("token");
-						int permissionLevel = 2000;
+						int permissionLevel;
 						if (!int.TryParse (lineItem.GetAttribute ("permission_level"), out permissionLevel)) {
 							Log.Warning (
@@ -267,5 +276,5 @@
 						}
 
-						int permissionLevel = 0;
+						int permissionLevel;
 						if (!int.TryParse (lineItem.GetAttribute ("permission_level"), out permissionLevel)) {
 							Log.Warning (
@@ -275,5 +284,5 @@
 						}
 
-						AddModulePermission (lineItem.GetAttribute ("module").ToLower (), permissionLevel, false);
+						AddModulePermission (lineItem.GetAttribute ("module"), permissionLevel, false);
 					}
 				}
