diff --git a/Source/Core/Map/Linedef.cs b/Source/Core/Map/Linedef.cs
index b6c92154e419c876fb12de5ea3e72fd188942efa..98dcc8a3b1f487b2bba82931cad690ab84108060 100644
--- a/Source/Core/Map/Linedef.cs
+++ b/Source/Core/Map/Linedef.cs
@@ -784,6 +784,15 @@ namespace CodeImp.DoomBuilder.Map
 		{
 			return new Dictionary<string, bool>(flags);
 		}
+
+		//mxd. This returns enabled flags
+		public HashSet<string> GetEnabledFlags()
+		{
+			HashSet<string> result = new HashSet<string>();
+			foreach(KeyValuePair<string, bool> group in flags)
+				if(group.Value) result.Add(group.Key);
+			return result;
+		}
 		
 		// This clears all flags
 		public void ClearFlags()
diff --git a/Source/Core/Map/Sector.cs b/Source/Core/Map/Sector.cs
index 0c75b669036c82e13bb3362b43013acf4fa73c80..9c9b0095df296c1fd17aa74cfc2f18209cacde7e 100644
--- a/Source/Core/Map/Sector.cs
+++ b/Source/Core/Map/Sector.cs
@@ -516,6 +516,15 @@ namespace CodeImp.DoomBuilder.Map
 			return new Dictionary<string, bool>(flags);
 		}
 
+		//mxd. This returns enabled flags
+		public HashSet<string> GetEnabledFlags()
+		{
+			HashSet<string> result = new HashSet<string>();
+			foreach(KeyValuePair<string, bool> group in flags)
+				if(group.Value) result.Add(group.Key);
+			return result;
+		} 
+
 		// This clears all flags
 		public void ClearFlags() 
 		{
diff --git a/Source/Core/Map/Sidedef.cs b/Source/Core/Map/Sidedef.cs
index b8fff9b9963116e59fd7cd6a7c9465583fdc4065..9664a3ae505c6f52f790847cb46239ed3417d9e4 100644
--- a/Source/Core/Map/Sidedef.cs
+++ b/Source/Core/Map/Sidedef.cs
@@ -323,6 +323,15 @@ namespace CodeImp.DoomBuilder.Map
 			return new Dictionary<string, bool>(flags);
 		}
 
+		//mxd. This returns enabled flags
+		public HashSet<string> GetEnabledFlags()
+		{
+			HashSet<string> result = new HashSet<string>();
+			foreach(KeyValuePair<string, bool> group in flags)
+				if(group.Value) result.Add(group.Key);
+			return result;
+		} 
+
 		// This clears all flags
 		public void ClearFlags() 
 		{
diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs
index 583fae647cc328bd25c72082fb59d1cc0bb995d2..efb2b9d4c9a191d3800c85fcc8534784a06ca913 100644
--- a/Source/Core/Map/Thing.cs
+++ b/Source/Core/Map/Thing.cs
@@ -603,6 +603,15 @@ namespace CodeImp.DoomBuilder.Map
 			return new Dictionary<string,bool>(flags);
 		}
 
+		//mxd. This returns enabled flags
+		public HashSet<string> GetEnabledFlags()
+		{
+			HashSet<string> result = new HashSet<string>();
+			foreach(KeyValuePair<string, bool> group in flags)
+				if(group.Value) result.Add(group.Key);
+			return result;
+		} 
+
 		// This clears all flags
 		public void ClearFlags()
 		{
diff --git a/Source/Plugins/BuilderModes/General/CopyStructures.cs b/Source/Plugins/BuilderModes/General/CopyStructures.cs
index 83dd9db7a29acbe24bd3aa0e643d4a301c55c60a..ceae71a0c65bbebfc0da8ee7cf677573212dd694 100644
--- a/Source/Plugins/BuilderModes/General/CopyStructures.cs
+++ b/Source/Plugins/BuilderModes/General/CopyStructures.cs
@@ -802,7 +802,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
 			if(flags.CeilingTexture && source.CeilTexture != target.CeilTexture) return false;
 			if(flags.Brightness && source.Brightness != target.Brightness) return false;
 			if(flags.Tag && !TagsMatch(source.Tags, target.Tags)) return false;
-			if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
+			if(flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
 
 			// Generalized effects require more tender loving care...
 			if(flags.Special && source.Effect != target.Effect)
@@ -869,7 +869,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
 					if(!UniFields.ValuesMatch("arg4str", source, target)) return false;
 				}
 			}
-			if(linedefflags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
+			if(linedefflags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
 
 			if(General.Map.UDMF)
 			{
@@ -905,7 +905,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
 			if(!General.Map.UDMF) return true;
 
 			// UDMF-specific properties
-			if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
+			if(flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
 
 			// UI fields
 			if(flags.UpperTextureScale && !UniFields.ValuesMatch("scalex_top", "scaley_top", source, target)) return false;
@@ -947,7 +947,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
 				}
 			}
 			if(flags.Tag && source.Tag != target.Tag) return false;
-			if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
+			if(flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) return false;
 			if(!General.Map.UDMF) return true;
 
 			// UDMF-specific properties
@@ -971,11 +971,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
 
 		#endregion
 
-		private static bool FlagsMatch(Dictionary<string, bool> flags1, Dictionary<string, bool> flags2) 
+		private static bool FlagsMatch(HashSet<string> flags1, HashSet<string> flags2)
 		{
 			if(flags1.Count != flags2.Count) return false;
-			foreach(KeyValuePair<string, bool> group in flags1)
-				if(!flags2.ContainsKey(group.Key) || flags2[group.Key] != flags1[group.Key]) return false;
+			foreach(string flag in flags1)
+			{
+				if(!flags2.Contains(flag)) return false;
+			}
+
 			return true;
 		}