diff --git a/Source/Core/Controls/Scripting/ScriptEditorPanel.cs b/Source/Core/Controls/Scripting/ScriptEditorPanel.cs
index 1448dba3291ef35c8d8a682bfa30354b7493e630..5186b98c5795ec6c4d88ab4b1305d68bc552fd88 100644
--- a/Source/Core/Controls/Scripting/ScriptEditorPanel.cs
+++ b/Source/Core/Controls/Scripting/ScriptEditorPanel.cs
@@ -628,12 +628,35 @@ namespace CodeImp.DoomBuilder.Controls
 		{
 			// Resource exists?
 			DataReader dr = null;
-			foreach(DataReader reader in General.Map.Data.Containers)
+
+			// Resource is a temporary file?
+			if(item.ResourceLocation.StartsWith(General.Map.TempPath))
 			{
-				if(reader.Location.location == item.ResourceLocation)
+				// Search in PK3-embedded wads only
+				foreach(DataReader reader in General.Map.Data.Containers)
 				{
-					dr = reader;
-					break;
+					if(!(reader is PK3Reader)) continue;
+					PK3Reader pkr = (PK3Reader)reader;
+					foreach(WADReader wadreader in pkr.Wads)
+					{
+						if(wadreader.Location.location == item.ResourceLocation)
+						{
+							dr = wadreader;
+							break;
+						}
+					}
+				}
+			}
+			else
+			{
+				// Search among resources
+				foreach(DataReader reader in General.Map.Data.Containers)
+				{
+					if(reader.Location.location == item.ResourceLocation)
+					{
+						dr = reader;
+						break;
+					}
 				}
 			}
 
@@ -643,9 +666,14 @@ namespace CodeImp.DoomBuilder.Controls
 			TextResourceData trd = new TextResourceData(dr, dr.LoadFile(item.LumpName, item.LumpIndex), item.LumpName, item.LumpIndex, false);
 			var targettab = OpenResource(new ScriptResource(trd, item.ScriptType));
 
-			// Go to error line
-			if(targettab != null && item.LineNumber != CompilerError.NO_LINE_NUMBER)
-				targettab.MoveToLine(item.LineNumber);
+			if(targettab != null)
+			{
+				// Go to error line
+				if(item.LineNumber != CompilerError.NO_LINE_NUMBER) targettab.MoveToLine(item.LineNumber);
+
+				// Show in resources tree
+				scriptresources.SelectItem(item.ResourceLocation, item.LumpName, item.LumpIndex, item.ScriptType);
+			}
 		}
 
 		//mxd
diff --git a/Source/Core/Controls/Scripting/ScriptResourcesControl.cs b/Source/Core/Controls/Scripting/ScriptResourcesControl.cs
index c68b6db4e80f119ce31d7ec3ffac41b590c0fcb2..ef5d52e5e04708b49884a627fc115f76607f37ea 100644
--- a/Source/Core/Controls/Scripting/ScriptResourcesControl.cs
+++ b/Source/Core/Controls/Scripting/ScriptResourcesControl.cs
@@ -185,6 +185,41 @@ namespace CodeImp.DoomBuilder.Controls
 
 		#region ================== Methods
 
+		public void SelectItem(string resourcelocation, string lumpname, int lumpindex, ScriptType scripttype)
+		{
+			TreeNode target = FindItem(projecttree.Nodes, resourcelocation, lumpname, lumpindex, scripttype);
+			if(target != null)
+			{
+				projecttree.SelectedNode = target;
+			}
+		}
+
+		private static TreeNode FindItem(TreeNodeCollection nodes, string resourcelocation, string lumpname, int lumpindex, ScriptType scripttype)
+		{
+			foreach(TreeNode node in nodes)
+			{
+				// Is this the item we are looking for?
+				TextResourceNodeData data = (TextResourceNodeData)node.Tag;
+
+				if(data.NodeType == TextResourceNodeType.NODE && data.ResourceLocation == resourcelocation 
+					&& data.ScriptType == scripttype && data.Resource.Filename == lumpname && data.Resource.LumpIndex == lumpindex)
+				{
+					// Found it!
+					return node;
+				}
+				
+				// Try children...
+				if(node.Nodes.Count > 0)
+				{
+					TreeNode item = FindItem(node.Nodes, resourcelocation, lumpname, lumpindex, scripttype);
+					if(item != null) return item;
+				}
+			}
+
+			// No dice...
+			return null;
+		}
+
 		private void UpdateResourcesTree()
 		{
 			ScriptType targettype = (filterbytype.SelectedIndex > -1 ? ((ScriptTypeItem)filterbytype.SelectedItem).Type : ScriptType.UNKNOWN);
@@ -352,6 +387,7 @@ namespace CodeImp.DoomBuilder.Controls
 															LocationInResource = path, 
 															NodeType = TextResourceNodeType.NODE, 
 															Resource = res,
+															ScriptType = res.ScriptType,
 							                            };
 							string includepath = (res.ScriptType == ScriptType.ACS ? "\nInclude path: \"" + res.Filename + "\"" : "");
 							TreeNode scriptnode = new TreeNode(res.ToString(), iconindex, iconindex) { Tag = data, ToolTipText = data + includepath };
diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs
index b0f93af92a935102010504e0873cf56207b362f2..94bf214a18a07d6b1f30fb9fa4ddf39b3c68cab2 100644
--- a/Source/Core/Data/DataManager.cs
+++ b/Source/Core/Data/DataManager.cs
@@ -1831,8 +1831,7 @@ namespace CodeImp.DoomBuilder.Data
 						if(decorate.HasError)
 						{
 							decorate.LogError();
-							currentreader = null;
-							return counter;
+							break;
 						}
 					}
 				}
@@ -2022,6 +2021,11 @@ namespace CodeImp.DoomBuilder.Data
 						}
 					}
 				}
+				else
+				{
+					// Return after adding parsed resources
+					return counter;
+				}
 			}
 			
 			// Output info
@@ -2375,6 +2379,8 @@ namespace CodeImp.DoomBuilder.Data
 			// Load gldefs from resources
 			foreach(DataReader dr in containers) 
 			{
+				if(parser.HasError) break;
+
 				currentreader = dr;
 				parser.ClearIncludesList();
 				IEnumerable<TextResourceData> streams = dr.GetGldefsData(General.Map.Config.BaseGame);
@@ -2387,8 +2393,7 @@ namespace CodeImp.DoomBuilder.Data
 					if(parser.HasError)
 					{
 						parser.LogError();
-						currentreader = null;
-						return;
+						break;
 					}
 				}
 			}
@@ -2397,6 +2402,9 @@ namespace CodeImp.DoomBuilder.Data
 			scriptresources[parser.ScriptType] = new HashSet<ScriptResource>(parser.ScriptResources.Values);
 			currentreader = null;
 
+			//mxd. Abort on errors, but after adding parsed text resources
+			if(parser.HasError) return;
+
 			// Create Gldefs Entries dictionary
 			foreach(KeyValuePair<string, string> e in parser.Objects) //<ClassName, Light name>
 			{
diff --git a/Source/Core/IO/WAD.cs b/Source/Core/IO/WAD.cs
index 8d7427d7f69098bdbb0bfbdf0d38774c28a7f075..b6923d42417af1bcf30e4bec8ff3beba574e3f17 100644
--- a/Source/Core/IO/WAD.cs
+++ b/Source/Core/IO/WAD.cs
@@ -508,12 +508,12 @@ namespace CodeImp.DoomBuilder.IO
 		// This finds a lump by name, returns -1 when not found
 		public int FindLumpIndex(string name, int start, int end)
 		{
-			if(name.Length > 8 || lumps.Count == 0)	return -1; //mxd. Can't be here. Go away!
+			if(name.Length > 8 || lumps.Count == 0 || start > lumps.Count - 1) return -1; //mxd. Can't be here. Go away!
 			
 			long longname = Lump.MakeLongName(name);
 			
 			// Fix start/end when they exceed safe bounds
-			start = General.Clamp(start, 0, lumps.Count - 1);
+			start = Math.Max(start, 0);
 			end = General.Clamp(end, 0, lumps.Count - 1);
 
 			// Loop through the lumps
diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs
index 189cc3470ed2b1e88e0dadbfa9e0f912bb6e1564..c24e8378bd1d8299aaa814707231aecf51bed3d4 100644
--- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs
@@ -213,15 +213,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
 						int brightness = level.brightnessbelow;
 
 						//mxd. Apply lightfloor value
+						// According to Graf, this is incorrect behaviour...
 						// TECH: In (G)ZDoom, this is ignored when ceiling texture is sky or a thing is below a 3D floor
 						// It's probably more involved than this, but for now let's do it only when there are no 3d floors in Thing.Sector...
-						if(General.Map.UDMF && sd.LightLevels.Count == 2 && Thing.Sector.CeilTexture != General.Map.Config.SkyFlatName)
+						/*if(General.Map.UDMF && sd.LightLevels.Count == 2 && Thing.Sector.CeilTexture != General.Map.Config.SkyFlatName)
 						{
 							if(sd.Sector.Fields.GetValue("lightfloorabsolute", false))
 								brightness = UniFields.GetInteger(sd.Sector.Fields, "lightfloor");
 							else
 								brightness += UniFields.GetInteger(sd.Sector.Fields, "lightfloor");
-						}
+						}*/
 
 						// Level is glowing
 						if(level.affectedbyglow && level.type == SectorLevelType.Floor)
diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs
index 4ce5e72976aab523712e7102b3a55283c107160f..49197d5ad260b130e01d694a70fc32d01cea76ea 100644
--- a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs
@@ -218,20 +218,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
 				foreach(Sidedef side in level.sector.Sidedefs)
 				{
 					VisualSidedefParts parts = Sector.GetSidedefParts(side);
-					if(parts.upper != null) parts.upper.UpdateSkyRenderFlag();
-					else if(parts.middlesingle != null) parts.middlesingle.UpdateSkyRenderFlag();
-
-					// On the other side as well...
-					if(side.Other != null && side.Other.Sector != null &&
-					   side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName)
+					if(parts.upper != null)
 					{
-						BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
-						if(other != null && other.Sides != null)
+						parts.upper.UpdateSkyRenderFlag();
+
+						// On the other side as well...
+						if(side.Other != null && side.Other.Sector != null &&
+						   (side.Other.HighTexture == "-" || side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName))
 						{
-							parts = other.GetSidedefParts(side.Other);
-							if(parts.upper != null) parts.upper.UpdateSkyRenderFlag();
+							BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
+							if(other != null && other.Sides != null)
+							{
+								parts = other.GetSidedefParts(side.Other);
+								if(parts.upper != null) parts.upper.UpdateSkyRenderFlag();
+							}
 						}
 					}
+					else if(parts.middlesingle != null)
+					{
+						parts.middlesingle.UpdateSkyRenderFlag();
+					}
 				}
 			}
 		}
diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs
index 376b0bf5f29687478fd25e75091724d36de9f1b6..5ca68f4905eb071039803448652f891f74c96927 100644
--- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs
@@ -198,11 +198,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
 			renderassky = (level.sector.FloorTexture == General.Map.Config.SkyFlatName || level.sector.LongFloorTexture == MapSet.EmptyLongName);
 			if(isrenderedassky != renderassky && Sector.Sides != null)
 			{
-				// Middle geometry may need updating...
+				// Middle/Lower geometry may need updating...
 				foreach(Sidedef side in level.sector.Sidedefs)
 				{
 					VisualSidedefParts parts = Sector.GetSidedefParts(side);
-					if(parts.middlesingle != null) parts.middlesingle.UpdateSkyRenderFlag();
+					if(parts.lower != null)
+					{
+						parts.lower.UpdateSkyRenderFlag();
+						
+						// On the other side as well...
+						if(side.Other != null && side.Other.Sector != null &&
+						   (side.Other.LowTexture == "-" || side.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName))
+						{
+							BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector);
+							if(other != null && other.Sides != null)
+							{
+								parts = other.GetSidedefParts(side.Other);
+								if(parts.lower != null) parts.lower.UpdateSkyRenderFlag();
+							}
+						}
+					}
+					else if(parts.middlesingle != null)
+					{
+						parts.middlesingle.UpdateSkyRenderFlag();
+					}
 				}
 			}
 		}
diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs
index 755e7026353026e25e696c8a6c07a60f3df5823b..dbb01223626785b8819bf42c69b1ac91bd5107b5 100644
--- a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs
@@ -62,6 +62,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
 		{
 			Vector2D vl, vr;
 
+			//mxd. Apply sky hack?
+			UpdateSkyRenderFlag();
+
 			//mxd. lightfog flag support
 			int lightvalue;
 			bool lightabsolute;
@@ -206,6 +209,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
 			base.SetVertices(null); //mxd
 			return false;
 		}
+
+		//mxd
+		internal void UpdateSkyRenderFlag()
+		{
+			bool isdoublesided = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null);
+
+			//TECH: when a side part has no texture, sky hack will be applied when either front or back sectors' floor uses SkyFlatName texture
+			//TECH: this glitches in both ZDoom and GZDoom when only lower sector's floor has SkyFlatName
+			if(Sidedef.LowTexture == "-")
+			{
+				renderassky = (isdoublesided
+					&& (Sidedef.Sector.FloorTexture == General.Map.Config.SkyFlatName
+					|| Sidedef.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName));
+			}
+			//TECH: otherwise, sky hack will be applied when both front and back sector floors use SkyFlatName texture
+			else
+			{
+				renderassky = (isdoublesided
+					&& Sidedef.Sector.FloorTexture == General.Map.Config.SkyFlatName
+					&& Sidedef.Other.Sector.FloorTexture == General.Map.Config.SkyFlatName);
+			}
+		}
 		
 		#endregion
 
diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs
index f2447194df11aa7b30c1bbe172a9e786773446a8..93fea6db716f5701549bef1f300b50f56b0c6118 100644
--- a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs
@@ -204,9 +204,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
 		//mxd
 		internal void UpdateSkyRenderFlag()
 		{
-			renderassky = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null &&
-						   Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName &&
-						   Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName);
+			bool isdoublesided = (Sidedef.Other != null && Sidedef.Sector != null && Sidedef.Other.Sector != null);
+			
+			//TECH: when a side part has no texture, sky hack will be applied when either front or back sectors' ceiling uses SkyFlatName texture
+			//TECH: this glitches in both ZDoom and GZDoom when only higher sector's ceiling has SkyFlatName
+			if(Sidedef.HighTexture == "-")
+			{
+				renderassky = (isdoublesided
+					&& (Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName 
+					|| Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName));
+			}
+			//TECH: otherwise, sky hack will be applied when both front and back sector ceilings use SkyFlatName texture
+			else
+			{
+				renderassky = (isdoublesided 
+					&& Sidedef.Sector.CeilTexture == General.Map.Config.SkyFlatName 
+					&& Sidedef.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName);
+			}
 		}
 		
 		#endregion