Index: trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java	(revision 6174)
+++ trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java	(revision 6175)
@@ -37,9 +37,16 @@
     private CopyOnWriteArrayList<IConflictListener> listeners;
 
+    /**
+     * Constructs a new {@code ConflictCollection}.
+     */
     public ConflictCollection() {
-        conflicts = new ArrayList<Conflict<?>>();
+        conflicts = new ArrayList<Conflict<? extends OsmPrimitive>>();
         listeners = new CopyOnWriteArrayList<IConflictListener>();
     }
 
+    /**
+     * Adds the specified conflict listener, if not already present.
+     * @param listener The conflict listener to add
+     */
     public void addConflictListener(IConflictListener listener) {
         if (listener != null) {
@@ -48,4 +55,8 @@
     }
 
+    /**
+     * Removes the specified conflict listener.
+     * @param listener The conflict listener to remove
+     */
     public void removeConflictListener(IConflictListener listener) {
         listeners.remove(listener);
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 6174)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 6175)
@@ -236,4 +236,5 @@
                         if (s.isProperLineStyle() || s instanceof AreaElemStyle) {
                             hasIndependentElemStyle = true;
+                            break;
                         }
                     }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java	(revision 6174)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java	(revision 6175)
@@ -23,8 +23,9 @@
 
     /**
-     * If not null, this is the matching parent object if an condition or an expression
+     * If not null, this is the matching parent object if a condition or an expression
      * is evaluated in a {@link LinkSelector} (within a child selector)
      */
     public OsmPrimitive parent;
+    
     /**
      * The same for parent selector. Only one of the 2 fields (parent or child) is not null in any environment.
@@ -38,8 +39,11 @@
 
     /**
-     * Creates a new uninitialized environment
+     * Creates a new uninitialized environment.
      */
     public Environment() {}
 
+    /**
+     * Creates a new environment.
+     */
     public Environment(OsmPrimitive osm, MultiCascade mc, String layer, StyleSource source) {
         this.osm = osm;
@@ -50,9 +54,10 @@
 
     /**
-     * Creates a clone of the environment {@code other}
+     * Creates a clone of the environment {@code other}.
      *
      * @param other the other environment. Must not be null.
-     */
-    public Environment(Environment other) throws IllegalArgumentException{
+     * @throws IllegalArgumentException if {@code param} is {@code null}
+     */
+    public Environment(Environment other) throws IllegalArgumentException {
         CheckParameterUtil.ensureParameterNotNull(other);
         this.osm = other.osm;
@@ -66,4 +71,9 @@
     }
 
+    /**
+     * Creates a clone of this environment, with the specified primitive.
+     * @return A clone of this environment, with the specified primitive
+     * @see #osm
+     */
     public Environment withPrimitive(OsmPrimitive osm) {
         Environment e = new Environment(this);
@@ -72,4 +82,10 @@
     }
 
+    /**
+     * Creates a clone of this environment, with the specified parent.
+     * @param parent the matching parent object
+     * @return A clone of this environment, with the specified parent
+     * @see #parent
+     */
     public Environment withParent(OsmPrimitive parent) {
         Environment e = new Environment(this);
@@ -78,4 +94,27 @@
     }
 
+    /**
+     * Creates a clone of this environment, with the specified parent, index, and context set to {@link Context#LINK}.
+     * @param parent the matching parent object
+     * @param index index of node in parent way or member in parent relation
+     * @return A clone of this environment, with the specified parent, index, and context set to {@link Context#LINK}
+     * @since 6175
+     * @see #parent
+     * @see #index
+     */
+    public Environment withParentAndIndexAndLinkContext(OsmPrimitive parent, int index) {
+        Environment e = new Environment(this);
+        e.parent = parent;
+        e.index = index;
+        e.context = Context.LINK;
+        return e;
+    }
+
+    /**
+     * Creates a clone of this environment, with the specified child.
+     * @param child the matching child object
+     * @return A clone of this environment, with the specified child
+     * @see #child
+     */
     public Environment withChild(OsmPrimitive child) {
         Environment e = new Environment(this);
@@ -84,4 +123,27 @@
     }
 
+    /**
+     * Creates a clone of this environment, with the specified child, index, and context set to {@link Context#LINK}.
+     * @param child the matching child object
+     * @param index index of node in parent way or member in parent relation
+     * @return A clone of this environment, with the specified child, index, and context set to {@code Context#LINK}
+     * @since 6175
+     * @see #child
+     * @see #index
+     */
+    public Environment withChildAndIndexAndLinkContext(OsmPrimitive child, int index) {
+        Environment e = new Environment(this);
+        e.child = child;
+        e.index = index;
+        e.context = Context.LINK;
+        return e;
+    }
+
+    /**
+     * Creates a clone of this environment, with the specified index.
+     * @param index index of node in parent way or member in parent relation
+     * @return A clone of this environment, with the specified index
+     * @see #index
+     */
     public Environment withIndex(int index) {
         Environment e = new Environment(this);
@@ -90,4 +152,8 @@
     }
 
+    /**
+     * Creates a clone of this environment, with the specified {@link Context}.
+     * @return A clone of this environment, with the specified {@code Context}
+     */
     public Environment withContext(Context context) {
         Environment e = new Environment(this);
@@ -96,4 +162,8 @@
     }
 
+    /**
+     * Creates a clone of this environment, with context set to {@link Context#LINK}.
+     * @return A clone of this environment, with context set to {@code Context#LINK}
+     */
     public Environment withLinkContext() {
         Environment e = new Environment(this);
@@ -102,8 +172,17 @@
     }
 
+    /**
+     * Determines if the context of this environment is {@link Context#LINK}.
+     * @return {@code true} if the context of this environment is {@code Context#LINK}, {@code false} otherwise
+     */
     public boolean isLinkContext() {
         return Context.LINK.equals(context);
     }
 
+    /**
+     * Determines if this environment has a relation as parent.
+     * @return {@code true} if this environment has a relation as parent, {@code false} otherwise
+     * @see #parent
+     */
     public boolean hasParentRelation() {
         return parent instanceof Relation;
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java	(revision 6174)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java	(revision 6175)
@@ -173,6 +173,5 @@
                         sub = "default";
                     }
-
-                    if (sub.equals("*")) {
+                    else if ("*".equals(sub)) {
                         for (Entry<String, Cascade> entry : mc.getLayers()) {
                             env.layer = entry.getKey();
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 6174)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 6175)
@@ -108,5 +108,5 @@
                     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;
@@ -130,5 +130,5 @@
                     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;
@@ -156,5 +156,5 @@
                         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;
@@ -169,5 +169,5 @@
                         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;
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 6174)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 6175)
@@ -401,4 +401,6 @@
     }
 
+    private static final char[] HEX_ARRAY = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+
     /**
      * Converts a byte array to a string of hexadecimal characters.
@@ -409,10 +411,19 @@
      */
     public static String toHexString(byte[] bytes) {
-        char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
-        char[] hexChars = new char[bytes.length * 2];
-        for (int j=0; j<bytes.length; j++) {
-            int v = bytes[j] & 0xFF;
-            hexChars[j*2] = hexArray[v/16];
-            hexChars[j*2 + 1] = hexArray[v%16];
+
+        if (bytes == null) {
+            return "";
+        }
+
+        final int len = bytes.length;
+        if (len == 0) {
+            return "";
+        }
+
+        char[] hexChars = new char[len * 2];
+        for (int i = 0, j = 0; i < len; i++) {
+            final int v = bytes[i];
+            hexChars[j++] = HEX_ARRAY[(v & 0xf0) >> 4];
+            hexChars[j++] = HEX_ARRAY[v & 0xf];
         }
         return new String(hexChars);
