Index: trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 11492)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 11493)
@@ -463,4 +463,13 @@
 
     /**
+     * remove a style source; only accessed from MapPaintStyles
+     * @param style style source to remove
+     * @return {@code true} if this list contained the specified element
+     */
+    boolean remove(StyleSource style) {
+        return styleSources.remove(style);
+    }
+
+    /**
      * set the style sources; only accessed from MapPaintStyles
      * @param sources new style sources
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java	(revision 11492)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java	(revision 11493)
@@ -290,4 +290,7 @@
 
     private static StyleSource fromSourceEntry(SourceEntry entry) {
+        if (entry.url == null && entry instanceof MapCSSStyleSource) {
+            return (MapCSSStyleSource) entry;
+        }
         Set<String> mimes = new HashSet<>(Arrays.asList(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES.split(", ")));
         try (CachedFile cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes))) {
@@ -419,4 +422,21 @@
         styles.add(source);
         loadStyleForFirstTime(source);
+        refreshStyles();
+        return source;
+    }
+
+    /**
+     * Remove a map paint style.
+     * @param entry map paint style
+     * @since 11493
+     */
+    public static void removeStyle(SourceEntry entry) {
+        StyleSource source = fromSourceEntry(entry);
+        if (styles.remove(source)) {
+            refreshStyles();
+        }
+    }
+
+    private static void refreshStyles() {
         MapPaintPrefHelper.INSTANCE.put(styles.getStyleSources());
         fireMapPaintSylesUpdated();
@@ -425,5 +445,4 @@
             Main.map.mapView.repaint();
         }
-        return source;
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java	(revision 11492)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java	(revision 11493)
@@ -272,5 +272,5 @@
         public Map<String, String> serialize(SourceEntry entry) {
             Map<String, String> res = new HashMap<>();
-            res.put("url", entry.url);
+            res.put("url", entry.url == null ? "" : entry.url);
             res.put("title", entry.title == null ? "" : entry.title);
             res.put("active", Boolean.toString(entry.active));
Index: trunk/src/org/openstreetmap/josm/io/CachedFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 11492)
+++ trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 11493)
@@ -207,5 +207,5 @@
         File file = getFile();
         if (file == null) {
-            if (name.startsWith("resource://")) {
+            if (name != null && name.startsWith("resource://")) {
                 InputStream is = getClass().getResourceAsStream(
                         name.substring("resource:/".length()));
@@ -273,5 +273,5 @@
             }
         } catch (MalformedURLException e) {
-            if (name.startsWith("resource://")) {
+            if (name == null || name.startsWith("resource://")) {
                 return null;
             } else if (name.startsWith("josmdir://")) {
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 11492)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 11493)
@@ -1166,5 +1166,5 @@
      */
     public static boolean isLocalUrl(String url) {
-        if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("resource://"))
+        if (url == null || url.startsWith("http://") || url.startsWith("https://") || url.startsWith("resource://"))
             return false;
         return true;
Index: trunk/test/data/regress/12627/overlapping.osm
===================================================================
--- trunk/test/data/regress/12627/overlapping.osm	(revision 11493)
+++ trunk/test/data/regress/12627/overlapping.osm	(revision 11493)
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' upload='true' generator='JOSM'>
+  <node id='-25' action='modify' visible='true' lat='-22.58401175177' lon='-47.41447678914' />
+  <node id='-28' action='modify' visible='true' lat='-22.58366442745' lon='-47.41407254727' />
+  <node id='-32' action='modify' visible='true' lat='-22.58386141747' lon='-47.4137890165' />
+  <node id='-34' action='modify' visible='true' lat='-22.5841698618' lon='-47.41412588474' />
+  <node id='-43' visible='true' lat='-22.58433963548' lon='-47.41448661447' />
+  <node id='-44' visible='true' lat='-22.583992312' lon='-47.41408237259' />
+  <node id='-45' visible='true' lat='-22.58418930154' lon='-47.41379884183' />
+  <node id='-46' visible='true' lat='-22.58449774514' lon='-47.41413571006' />
+  <way id='-29' action='modify' visible='true'>
+    <nd ref='-25' />
+    <nd ref='-28' />
+    <nd ref='-32' />
+    <nd ref='-34' />
+    <nd ref='-25' />
+    <tag k='natural' v='wood' />
+  </way>
+  <way id='-42' action='modify' visible='true'>
+    <nd ref='-43' />
+    <nd ref='-44' />
+    <nd ref='-45' />
+    <nd ref='-46' />
+    <nd ref='-43' />
+    <tag k='natural' v='wood' />
+  </way>
+</osm>
Index: trunk/test/data/regress/14289/example2.osm
===================================================================
--- trunk/test/data/regress/14289/example2.osm	(revision 11493)
+++ trunk/test/data/regress/14289/example2.osm	(revision 11493)
@@ -0,0 +1,42 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' upload='true' generator='JOSM'>
+  <node id='-30485' action='modify' visible='true' lat='-23.2277275943' lon='-51.12651457665' />
+  <node id='-30487' action='modify' visible='true' lat='-23.22434907439' lon='-51.12226912293' />
+  <node id='-30489' action='modify' visible='true' lat='-23.22804935364' lon='-51.12318824177' />
+  <node id='-30491' action='modify' visible='true' lat='-23.22274022534' lon='-51.11793613408' />
+  <node id='-30493' action='modify' visible='true' lat='-23.22652098986' lon='-51.11854887998' />
+  <node id='-30495' action='modify' visible='true' lat='-23.22648076952' lon='-51.12296940395' />
+  <node id='-30497' action='modify' visible='true' lat='-23.2288537486' lon='-51.12467633895' />
+  <node id='-30499' action='modify' visible='true' lat='-23.23014077046' lon='-51.11929292857' />
+  <node id='-30664' action='modify' visible='true' lat='-23.22448675761' lon='-51.12075882171' />
+  <node id='-30665' action='modify' visible='true' lat='-23.22758893344' lon='-51.1210246296' />
+  <node id='-30667' action='modify' visible='true' lat='-23.22773549114' lon='-51.11932345911' />
+  <node id='-30669' action='modify' visible='true' lat='-23.22368066863' lon='-51.11932345911' />
+  <way id='-30509' action='modify' visible='true'>
+    <nd ref='-30487' />
+    <nd ref='-30485' />
+    <nd ref='-30489' />
+    <nd ref='-30491' />
+    <nd ref='-30487' />
+    <tag k='name' v='A' />
+    <tag k='natural' v='wood' />
+  </way>
+  <way id='-30511' action='modify' visible='true'>
+    <nd ref='-30493' />
+    <nd ref='-30495' />
+    <nd ref='-30497' />
+    <nd ref='-30499' />
+    <nd ref='-30493' />
+    <tag k='name' v='B' />
+    <tag k='natural' v='wood' />
+  </way>
+  <way id='-30666' action='modify' visible='true'>
+    <nd ref='-30664' />
+    <nd ref='-30665' />
+    <nd ref='-30667' />
+    <nd ref='-30669' />
+    <nd ref='-30664' />
+    <tag k='name' v='C' />
+    <tag k='natural' v='wood' />
+  </way>
+</osm>
Index: trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java	(revision 11492)
+++ trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java	(revision 11493)
@@ -10,4 +10,5 @@
 import java.io.StringReader;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
@@ -32,4 +33,6 @@
 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.TagCheck;
+import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
+import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
 import org.openstreetmap.josm.io.OsmReader;
@@ -48,5 +51,5 @@
     @Rule
     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
-    public JOSMTestRules test = new JOSMTestRules().projection();
+    public JOSMTestRules test = new JOSMTestRules().projection().platform();
 
     static MapCSSTagChecker buildTagChecker(String css) throws ParseException {
@@ -216,3 +219,47 @@
         }
     }
+
+    private void doTestNaturalWood(int ticket, String filename, int errorsCount, int setsCount) throws Exception {
+        final MapCSSTagChecker test = buildTagChecker(
+                "area:closed:areaStyle[tag(\"natural\") = parent_tag(\"natural\")] ⧉ area:closed:areaStyle[natural] {" +
+                "  throwWarning: tr(\"Overlapping Identical Natural Areas\");" +
+                "}");
+        final MapCSSStyleSource style = new MapCSSStyleSource(
+                "area[natural=wood] {" +
+                "    fill-color: woodarea#008000;" +
+                "}");
+        MapPaintStyles.addStyle(style);
+        try (InputStream is = TestUtils.getRegressionDataStream(ticket, filename)) {
+            test.visit(OsmReader.parseDataSet(is, null).allPrimitives());
+            List<TestError> errors = test.getErrors();
+            assertEquals(errorsCount, errors.size());
+            Set<Set<OsmPrimitive>> primitives = new HashSet<>();
+            for (TestError e : errors) {
+                primitives.add(new HashSet<>(e.getPrimitives()));
+            }
+            assertEquals(setsCount, primitives.size());
+        } finally {
+            MapPaintStyles.removeStyle(style);
+        }
+    }
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/12627">Bug #12627</a>.
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Ignore("not fixed yet")
+    public void testTicket12627() throws Exception {
+        doTestNaturalWood(12627, "overlapping.osm", 1, 1);
+    }
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14289">Bug #14289</a>.
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Ignore("not fixed yet")
+    public void testTicket14289() throws Exception {
+        doTestNaturalWood(14289, "example2.osm", 3, 3);
+    }
 }
