Index: applications/editors/josm/plugins/merge-overlap/src/mergeoverlap/MergeOverlapAction.java
===================================================================
--- applications/editors/josm/plugins/merge-overlap/src/mergeoverlap/MergeOverlapAction.java	(revision 35583)
+++ applications/editors/josm/plugins/merge-overlap/src/mergeoverlap/MergeOverlapAction.java	(revision 36132)
@@ -34,4 +34,5 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Pair;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -80,8 +81,5 @@
                 Way way = (Way) osm;
                 ways.add(way);
-                List<Relation> rels = new ArrayList<>();
-                for (Relation r : Utils.filteredCollection(way.getReferrers(), Relation.class)) {
-                    rels.add(r);
-                }
+                List<Relation> rels = new ArrayList<>(Utils.filteredCollection(way.getReferrers(), Relation.class));
                 relations.put(way, rels);
             }
@@ -208,4 +206,5 @@
                     combineResult = combineWaysWorker(combine);
                 } catch (UserCancelException ex) {
+                    Logging.trace(ex);
                     return;
                 }
@@ -215,6 +214,6 @@
         }
 
-        for (Relation old : newRelations.keySet()) {
-            cmds.add(new ChangeCommand(old, newRelations.get(old)));
+        for (Map.Entry<Relation, Relation> entry : newRelations.entrySet()) {
+            cmds.add(new ChangeCommand(entry.getKey(), entry.getValue()));
         }
 
@@ -226,5 +225,5 @@
         }
         if (!del.isEmpty()) {
-            cmds.add(new DeleteCommand(del));
+            cmds.add(DeleteCommand.delete(del));
         }
 
@@ -258,5 +257,5 @@
     }
 
-    private boolean addNodes(NodePos start, NodePos end, Way way,
+    private static boolean addNodes(NodePos start, NodePos end, Way way,
             Set<Node> nodes, boolean hasFirst) {
         if (way.isClosed() || (start.node != way.getNode(0) && start.node != way.getNode(way.getNodesCount() - 1))) {
@@ -274,5 +273,5 @@
     }
 
-    private boolean follows(Way way1, Way way2, NodePos np1, NodePos np2,
+    private static boolean follows(Way way1, Way way2, NodePos np1, NodePos np2,
             int incr) {
         if (way2.isClosed() && incr == 1 && np1.opositPos == way2.getNodesCount() - 2) {
@@ -290,8 +289,8 @@
 
     /**
-     * @param ways
+     * @param ways The ways to be combined
      * @return null if ways cannot be combined. Otherwise returns the combined
      *         ways and the commands to combine
-     * @throws UserCancelException
+     * @throws UserCancelException If the user cancelled the operation
      */
     private Pair<Way, List<Command>> combineWaysWorker(Collection<Way> ways) throws UserCancelException {
@@ -434,13 +433,13 @@
      */
     private boolean duplicateParentRelations(Collection<Way> ways) {
-        Set<Relation> relations = new HashSet<>();
+        Set<Relation> duplicateRelations = new HashSet<>();
         for (Way w : ways) {
             List<Relation> rs = getParentRelations(w);
             for (Relation r : rs) {
-                if (relations.contains(r)) {
+                if (duplicateRelations.contains(r)) {
                     return true;
                 }
             }
-            relations.addAll(rs);
+            duplicateRelations.addAll(rs);
         }
         return false;
@@ -455,9 +454,5 @@
         List<Relation> rels = new ArrayList<>();
         for (Relation r : relations.get(way)) {
-            if (newRelations.containsKey(r)) {
-                rels.add(newRelations.get(r));
-            } else {
-                rels.add(r);
-            }
+            rels.add(newRelations.getOrDefault(r, r));
         }
         return rels;
@@ -479,9 +474,5 @@
 
     public static Way getOld(Way w, Map<Way, Way> oldWays) {
-        if (oldWays.containsKey(w)) {
-            return oldWays.get(w);
-        } else {
-            return w;
-        }
+        return oldWays.getOrDefault(w, w);
     }
 
