Index: src/org/openstreetmap/josm/gui/mappaint/Environment.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/Environment.java	(revision 6111)
+++ src/org/openstreetmap/josm/gui/mappaint/Environment.java	(working copy)
@@ -77,12 +77,29 @@
         return e;
     }
 
+    public Environment withParentAndIndexAndLinkContext(OsmPrimitive parent, int index) {
+        Environment e = new Environment(this);
+        e.parent = parent;
+        e.index = index;
+        e.context = Context.LINK;
+        return e;
+    }
+
     public Environment withChild(OsmPrimitive child) {
         Environment e = new Environment(this);
         e.child = child;
         return e;
     }
 
+
+    public Environment withChildAndIndexAndLinkContext(OsmPrimitive child, int index) {
+        Environment e = new Environment(this);
+        e.child = child;
+        e.index = index;
+        e.context = Context.LINK;
+        return e;
+    }
+
     public Environment withIndex(int index) {
         Environment e = new Environment(this);
         e.index = index;
Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java	(revision 6111)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java	(working copy)
@@ -166,8 +166,7 @@
                     if (sub == null) {
                         sub = "default";
                     }
-
-                    if (sub.equals("*")) {
+                    else if ("*".equals(sub)) {
                         for (Entry<String, Cascade> entry : mc.getLayers()) {
                             env.layer = entry.getKey();
                             if (Utils.equal(env.layer, "*")) {
@@ -176,6 +175,7 @@
                             r.execute(env);
                         }
                     }
+
                     env.layer = sub;
                     r.execute(env);
                 }
Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 6111)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(working copy)
@@ -107,7 +107,7 @@
                 for (int i=0; i<w.getNodesCount(); i++) {
                     Node n = w.getNode(i);
                     if (n.equals(e.osm)) {
-                        if (link.matches(e.withParent(w).withIndex(i).withLinkContext())) {
+                        if (link.matches(e.withParentAndIndexAndLinkContext(w, i))) {
                             e.parent = w;
                             e.index = i;
                             return;
@@ -129,7 +129,7 @@
                 for (int i=0; i < r.getMembersCount(); i++) {
                     RelationMember m = r.getMember(i);
                     if (m.getMember().equals(e.osm)) {
-                        if (link.matches(e.withParent(r).withIndex(i).withLinkContext())) {
+                        if (link.matches(e.withParentAndIndexAndLinkContext(r, i))) {
                             e.parent = r;
                             e.index = i;
                             return;
@@ -155,7 +155,7 @@
                     for (int i=0; i<wayNodes.size(); i++) {
                         Node n = wayNodes.get(i);
                         if (left.matches(e.withPrimitive(n))) {
-                            if (link.matches(e.withChild(n).withIndex(i).withLinkContext())) {
+                            if (link.matches(e.withChildAndIndexAndLinkContext(n, i))) {
                                 e.child = n;
                                 e.index = i;
                                 return true;
@@ -168,7 +168,7 @@
                     for (int i=0; i<members.size(); i++) {
                         OsmPrimitive member = members.get(i).getMember();
                         if (left.matches(e.withPrimitive(member))) {
-                            if (link.matches(e.withChild(member).withIndex(i).withLinkContext())) {
+                            if (link.matches(e.withChildAndIndexAndLinkContext(member, i))) {
                                 e.child = member;
                                 e.index = i;
                                 return true;
