Index: applications/editors/josm/plugins/conflation/build.xml
===================================================================
--- applications/editors/josm/plugins/conflation/build.xml	(revision 27742)
+++ applications/editors/josm/plugins/conflation/build.xml	(revision 27751)
@@ -44,4 +44,5 @@
     <property name="plugin.dist.dir" value="../../dist"/>
     <property name="ant.build.javac.target" value="1.5"/>
+    <property name="ant.build.javac.source" value="1.5"/>
     <property name="plugin.dist.dir" value="../../dist"/>
     <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/>
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java	(revision 27742)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java	(revision 27751)
@@ -173,3 +173,7 @@
         selectedCandidate = c;
     }
+    
+    public ConflationCandidate getSelectedCandidate() {
+        return selectedCandidate;
+    }
 }
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form	(revision 27742)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form	(revision 27751)
@@ -12,5 +12,5 @@
     <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
     <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,4,0,0,2,-102"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,24,0,0,1,-80"/>
   </AuxValues>
 
@@ -30,37 +30,6 @@
           </Constraints>
 
-          <Layout>
-            <DimensionLayout dim="0">
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="102" attributes="0">
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="nonRefSetPanel" alignment="0" max="32767" attributes="0"/>
-                          <Component id="refSetPanel" alignment="0" max="32767" attributes="0"/>
-                          <Group type="102" alignment="1" attributes="0">
-                              <EmptySpace max="-2" attributes="0"/>
-                              <Component id="objectTabCancelButton" min="-2" max="-2" attributes="0"/>
-                              <EmptySpace min="-2" pref="81" max="-2" attributes="0"/>
-                              <Component id="objectTabNextButton" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                      </Group>
-                      <EmptySpace max="-2" attributes="0"/>
-                  </Group>
-              </Group>
-            </DimensionLayout>
-            <DimensionLayout dim="1">
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="102" attributes="0">
-                      <Component id="refSetPanel" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="nonRefSetPanel" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Group type="103" groupAlignment="3" attributes="0">
-                          <Component id="objectTabNextButton" alignment="3" min="-2" max="-2" attributes="0"/>
-                          <Component id="objectTabCancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
-                      </Group>
-                      <EmptySpace min="-2" pref="55" max="-2" attributes="0"/>
-                  </Group>
-              </Group>
-            </DimensionLayout>
+          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
+            <Property name="axis" type="int" value="3"/>
           </Layout>
           <SubComponents>
@@ -74,68 +43,5 @@
               </Properties>
 
-              <Layout>
-                <DimensionLayout dim="0">
-                  <Group type="103" groupAlignment="0" attributes="0">
-                      <Group type="102" attributes="0">
-                          <EmptySpace max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="0" attributes="0">
-                              <Group type="102" attributes="0">
-                                  <Component id="freezeMySetButton" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace pref="387" max="32767" attributes="0"/>
-                                  <Component id="restoreMySetButton" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <Group type="102" alignment="0" attributes="0">
-                                  <Group type="103" groupAlignment="0" attributes="0">
-                                      <Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                                  <Group type="103" groupAlignment="0" attributes="0">
-                                      <Component id="myLayerLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="myNodeCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="myWayCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="myRelationCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                              </Group>
-                          </Group>
-                          <EmptySpace max="-2" attributes="0"/>
-                      </Group>
-                  </Group>
-                </DimensionLayout>
-                <DimensionLayout dim="1">
-                  <Group type="103" groupAlignment="0" attributes="0">
-                      <Group type="102" alignment="0" attributes="0">
-                          <EmptySpace max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="freezeMySetButton" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="restoreMySetButton" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="myLayerLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="myNodeCountLabel" alignment="3" min="-2" pref="14" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="myWayCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="myRelationCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace pref="38" max="32767" attributes="0"/>
-                      </Group>
-                  </Group>
-                </DimensionLayout>
-              </Layout>
+              <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
               <SubComponents>
                 <Component class="javax.swing.JButton" name="freezeMySetButton">
@@ -147,4 +53,54 @@
                   </Events>
                 </Component>
+                <Container class="javax.swing.JPanel" name="jPanel3">
+
+                  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
+                    <Property name="columns" type="int" value="2"/>
+                    <Property name="horizontalGap" type="int" value="2"/>
+                    <Property name="rows" type="int" value="0"/>
+                  </Layout>
+                  <SubComponents>
+                    <Component class="javax.swing.JLabel" name="jLabel2">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Layer"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="myLayerLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="(invalid)"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="jLabel1">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Nodes"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="myNodeCountLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="0"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="jLabel3">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Ways"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="myWayCountLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="0"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="jLabel4">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Relations"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="myRelationCountLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="0"/>
+                      </Properties>
+                    </Component>
+                  </SubComponents>
+                </Container>
                 <Component class="javax.swing.JButton" name="restoreMySetButton">
                   <Properties>
@@ -154,44 +110,4 @@
                     <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="restoreMySetButtonActionPerformed"/>
                   </Events>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel1">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Nodes"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel2">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Layer"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel3">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Ways"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel4">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Relations"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="myRelationCountLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="0"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="myWayCountLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="0"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="myNodeCountLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="0"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="myLayerLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="(invalid)"/>
-                  </Properties>
                 </Component>
               </SubComponents>
@@ -206,68 +122,5 @@
               </Properties>
 
-              <Layout>
-                <DimensionLayout dim="0">
-                  <Group type="103" groupAlignment="0" attributes="0">
-                      <Group type="102" attributes="0">
-                          <EmptySpace max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="0" attributes="0">
-                              <Group type="102" alignment="1" attributes="0">
-                                  <Component id="freezeTheirSelectionButton" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace pref="387" max="32767" attributes="0"/>
-                                  <Component id="restoreTheirSetButton" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <Group type="102" alignment="0" attributes="0">
-                                  <Group type="103" groupAlignment="0" attributes="0">
-                                      <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="jLabel9" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="jLabel6" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                                  <Group type="103" groupAlignment="0" attributes="0">
-                                      <Component id="theirLayerLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="theirNodeCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="theirWayCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="theirRelationCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                              </Group>
-                          </Group>
-                          <EmptySpace max="-2" attributes="0"/>
-                      </Group>
-                  </Group>
-                </DimensionLayout>
-                <DimensionLayout dim="1">
-                  <Group type="103" groupAlignment="0" attributes="0">
-                      <Group type="102" alignment="0" attributes="0">
-                          <EmptySpace max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="freezeTheirSelectionButton" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="restoreTheirSetButton" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="theirLayerLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="theirNodeCountLabel" alignment="3" min="-2" pref="14" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="theirWayCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                          <Group type="103" groupAlignment="3" attributes="0">
-                              <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
-                              <Component id="theirRelationCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <EmptySpace pref="32" max="32767" attributes="0"/>
-                      </Group>
-                  </Group>
-                </DimensionLayout>
-              </Layout>
+              <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
               <SubComponents>
                 <Component class="javax.swing.JButton" name="freezeTheirSelectionButton">
@@ -279,4 +132,54 @@
                   </Events>
                 </Component>
+                <Container class="javax.swing.JPanel" name="jPanel4">
+
+                  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
+                    <Property name="columns" type="int" value="2"/>
+                    <Property name="horizontalGap" type="int" value="2"/>
+                    <Property name="rows" type="int" value="0"/>
+                  </Layout>
+                  <SubComponents>
+                    <Component class="javax.swing.JLabel" name="jLabel6">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Layer"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="theirLayerLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="(invalid)"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="jLabel7">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Nodes"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="theirNodeCountLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="0"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="jLabel9">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Ways"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="theirWayCountLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="0"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="jLabel5">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="Relations"/>
+                      </Properties>
+                    </Component>
+                    <Component class="javax.swing.JLabel" name="theirRelationCountLabel">
+                      <Properties>
+                        <Property name="text" type="java.lang.String" value="0"/>
+                      </Properties>
+                    </Component>
+                  </SubComponents>
+                </Container>
                 <Component class="javax.swing.JButton" name="restoreTheirSetButton">
                   <Properties>
@@ -286,44 +189,4 @@
                     <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="restoreTheirSetButtonActionPerformed"/>
                   </Events>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel5">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Relations"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel6">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Layer"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel7">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Nodes"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="jLabel9">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="Ways"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="theirNodeCountLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="0"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="theirLayerLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="(invalid)"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="theirWayCountLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="0"/>
-                  </Properties>
-                </Component>
-                <Component class="javax.swing.JLabel" name="theirRelationCountLabel">
-                  <Properties>
-                    <Property name="text" type="java.lang.String" value="0"/>
-                  </Properties>
                 </Component>
               </SubComponents>
@@ -357,45 +220,8 @@
           </Constraints>
 
-          <Layout>
-            <DimensionLayout dim="0">
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="102" attributes="0">
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Group type="102" alignment="1" attributes="0">
-                              <EmptySpace min="0" pref="568" max="32767" attributes="0"/>
-                              <Component id="criteriaTabConflateButton" min="-2" max="-2" attributes="0"/>
-                          </Group>
-                          <Group type="102" alignment="0" attributes="0">
-                              <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
-                              <EmptySpace min="0" pref="282" max="32767" attributes="0"/>
-                          </Group>
-                      </Group>
-                      <EmptySpace max="-2" attributes="0"/>
-                  </Group>
-              </Group>
-            </DimensionLayout>
-            <DimensionLayout dim="1">
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="102" alignment="1" attributes="0">
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace pref="217" max="32767" attributes="0"/>
-                      <Component id="criteriaTabConflateButton" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                  </Group>
-              </Group>
-            </DimensionLayout>
+          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
+            <Property name="axis" type="int" value="3"/>
           </Layout>
           <SubComponents>
-            <Component class="javax.swing.JButton" name="criteriaTabConflateButton">
-              <Properties>
-                <Property name="mnemonic" type="int" value="102"/>
-                <Property name="text" type="java.lang.String" value="Conflate"/>
-              </Properties>
-              <Events>
-                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="criteriaTabConflateButtonActionPerformed"/>
-              </Events>
-            </Component>
             <Container class="javax.swing.JPanel" name="jPanel2">
               <Properties>
@@ -410,8 +236,8 @@
                 <DimensionLayout dim="0">
                   <Group type="103" groupAlignment="0" attributes="0">
-                      <Group type="102" alignment="0" attributes="0">
+                      <Group type="102" attributes="0">
                           <EmptySpace max="-2" attributes="0"/>
                           <Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
-                          <EmptySpace pref="282" max="32767" attributes="0"/>
+                          <EmptySpace pref="350" max="32767" attributes="0"/>
                       </Group>
                   </Group>
@@ -422,5 +248,5 @@
                           <EmptySpace max="-2" attributes="0"/>
                           <Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
-                          <EmptySpace pref="192" max="32767" attributes="0"/>
+                          <EmptySpace pref="195" max="32767" attributes="0"/>
                       </Group>
                   </Group>
@@ -432,4 +258,5 @@
                     <Property name="selected" type="boolean" value="true"/>
                     <Property name="text" type="java.lang.String" value="Distance"/>
+                    <Property name="enabled" type="boolean" value="false"/>
                   </Properties>
                   <Events>
@@ -439,4 +266,13 @@
               </SubComponents>
             </Container>
+            <Component class="javax.swing.JButton" name="criteriaTabConflateButton">
+              <Properties>
+                <Property name="mnemonic" type="int" value="102"/>
+                <Property name="text" type="java.lang.String" value="Conflate"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="criteriaTabConflateButtonActionPerformed"/>
+              </Events>
+            </Component>
           </SubComponents>
         </Container>
@@ -500,5 +336,5 @@
                           <EmptySpace type="unrelated" max="-2" attributes="0"/>
                           <Component id="jButton1" min="-2" max="-2" attributes="0"/>
-                          <EmptySpace pref="252" max="32767" attributes="0"/>
+                          <EmptySpace pref="14" max="32767" attributes="0"/>
                       </Group>
                   </Group>
@@ -535,6 +371,9 @@
                 <Component class="javax.swing.JButton" name="useTheirTagsButton">
                   <Properties>
-                    <Property name="text" type="java.lang.String" value="Their Tags"/>
-                  </Properties>
+                    <Property name="text" type="java.lang.String" value="Merge tags"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="useTheirTagsButtonActionPerformed"/>
+                  </Events>
                 </Component>
                 <Component class="javax.swing.JButton" name="jButton1">
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java	(revision 27742)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java	(revision 27751)
@@ -33,9 +33,11 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.TagCollection;
+import org.openstreetmap.josm.data.osm.event.*;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
-import org.openstreetmap.josm.plugins.conflation.ConflationUtils.*;
+import utilsplugin2.dumbutils.ReplaceGeometryAction;
 
 /**
@@ -43,5 +45,5 @@
  * @author Josh
  */
-public class ConflationOptionsPanel extends javax.swing.JPanel implements IConflictListener {
+public class ConflationOptionsPanel extends javax.swing.JPanel implements DataSetListener {
     ConflationOptionsDialog dlg = null;
     ConflationLayer conflationLayer = null;
@@ -49,7 +51,7 @@
     DataSet sourceDataSet = null;
     ArrayList<OsmPrimitive> targetSelection = null;
-    ArrayList<OsmPrimitive> theirSelection = null;
+    ArrayList<OsmPrimitive> sourceSelection = null;
     OsmDataLayer targetLayer = null;
-    OsmDataLayer theirLayer = null;
+    OsmDataLayer sourceLayer = null;
     MatchTableModel tableModel;
     List<ConflationCandidate> candidates = null;
@@ -66,6 +68,7 @@
 
         // FIXME: doesn't work right now
-        ColorTableCellRenderer cr = new ColorTableCellRenderer("Tags");
-        resultsTable.getColumnModel().getColumn(4).setCellRenderer(cr);
+        resultsTable.getColumnModel().getColumn(0).setCellRenderer(new OsmPrimitivRenderer());
+        resultsTable.getColumnModel().getColumn(1).setCellRenderer(new OsmPrimitivRenderer());
+        resultsTable.getColumnModel().getColumn(4).setCellRenderer(new ColorTableCellRenderer("Tags"));
 
         this.dlg = dlg;
@@ -94,30 +97,32 @@
         refSetPanel = new javax.swing.JPanel();
         freezeMySetButton = new javax.swing.JButton();
-        restoreMySetButton = new javax.swing.JButton();
+        jPanel3 = new javax.swing.JPanel();
+        jLabel2 = new javax.swing.JLabel();
+        myLayerLabel = new javax.swing.JLabel();
         jLabel1 = new javax.swing.JLabel();
-        jLabel2 = new javax.swing.JLabel();
+        myNodeCountLabel = new javax.swing.JLabel();
         jLabel3 = new javax.swing.JLabel();
+        myWayCountLabel = new javax.swing.JLabel();
         jLabel4 = new javax.swing.JLabel();
         myRelationCountLabel = new javax.swing.JLabel();
-        myWayCountLabel = new javax.swing.JLabel();
-        myNodeCountLabel = new javax.swing.JLabel();
-        myLayerLabel = new javax.swing.JLabel();
+        restoreMySetButton = new javax.swing.JButton();
         nonRefSetPanel = new javax.swing.JPanel();
         freezeTheirSelectionButton = new javax.swing.JButton();
+        jPanel4 = new javax.swing.JPanel();
+        jLabel6 = new javax.swing.JLabel();
+        theirLayerLabel = new javax.swing.JLabel();
+        jLabel7 = new javax.swing.JLabel();
+        theirNodeCountLabel = new javax.swing.JLabel();
+        jLabel9 = new javax.swing.JLabel();
+        theirWayCountLabel = new javax.swing.JLabel();
+        jLabel5 = new javax.swing.JLabel();
+        theirRelationCountLabel = new javax.swing.JLabel();
         restoreTheirSetButton = new javax.swing.JButton();
-        jLabel5 = new javax.swing.JLabel();
-        jLabel6 = new javax.swing.JLabel();
-        jLabel7 = new javax.swing.JLabel();
-        jLabel9 = new javax.swing.JLabel();
-        theirNodeCountLabel = new javax.swing.JLabel();
-        theirLayerLabel = new javax.swing.JLabel();
-        theirWayCountLabel = new javax.swing.JLabel();
-        theirRelationCountLabel = new javax.swing.JLabel();
         objectTabCancelButton = new javax.swing.JButton();
         objectTabNextButton = new javax.swing.JButton();
         criteriaTabPanel = new javax.swing.JPanel();
-        criteriaTabConflateButton = new javax.swing.JButton();
         jPanel2 = new javax.swing.JPanel();
         jCheckBox1 = new javax.swing.JCheckBox();
+        criteriaTabConflateButton = new javax.swing.JButton();
         resultsPanel = new javax.swing.JPanel();
         jScrollPane1 = new javax.swing.JScrollPane();
@@ -132,5 +137,8 @@
         setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));
 
+        objectTabPanel.setLayout(new javax.swing.BoxLayout(objectTabPanel, javax.swing.BoxLayout.PAGE_AXIS));
+
         refSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Target Selection"));
+        refSetPanel.setLayout(new javax.swing.BoxLayout(refSetPanel, javax.swing.BoxLayout.LINE_AXIS));
 
         freezeMySetButton.setText("Freeze Selection");
@@ -140,4 +148,33 @@
             }
         });
+        refSetPanel.add(freezeMySetButton);
+
+        jPanel3.setLayout(new java.awt.GridLayout(0, 2, 2, 0));
+
+        jLabel2.setText("Layer");
+        jPanel3.add(jLabel2);
+
+        myLayerLabel.setText("(invalid)");
+        jPanel3.add(myLayerLabel);
+
+        jLabel1.setText("Nodes");
+        jPanel3.add(jLabel1);
+
+        myNodeCountLabel.setText("0");
+        jPanel3.add(myNodeCountLabel);
+
+        jLabel3.setText("Ways");
+        jPanel3.add(jLabel3);
+
+        myWayCountLabel.setText("0");
+        jPanel3.add(myWayCountLabel);
+
+        jLabel4.setText("Relations");
+        jPanel3.add(jLabel4);
+
+        myRelationCountLabel.setText("0");
+        jPanel3.add(myRelationCountLabel);
+
+        refSetPanel.add(jPanel3);
 
         restoreMySetButton.setText("Restore Selection");
@@ -147,73 +184,10 @@
             }
         });
-
-        jLabel1.setText("Nodes");
-
-        jLabel2.setText("Layer");
-
-        jLabel3.setText("Ways");
-
-        jLabel4.setText("Relations");
-
-        myRelationCountLabel.setText("0");
-
-        myWayCountLabel.setText("0");
-
-        myNodeCountLabel.setText("0");
-
-        myLayerLabel.setText("(invalid)");
-
-        javax.swing.GroupLayout refSetPanelLayout = new javax.swing.GroupLayout(refSetPanel);
-        refSetPanel.setLayout(refSetPanelLayout);
-        refSetPanelLayout.setHorizontalGroup(
-            refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(refSetPanelLayout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(refSetPanelLayout.createSequentialGroup()
-                        .addComponent(freezeMySetButton)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 392, Short.MAX_VALUE)
-                        .addComponent(restoreMySetButton))
-                    .addGroup(refSetPanelLayout.createSequentialGroup()
-                        .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(jLabel4)
-                            .addComponent(jLabel3)
-                            .addComponent(jLabel1)
-                            .addComponent(jLabel2))
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                        .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(myLayerLabel)
-                            .addComponent(myNodeCountLabel)
-                            .addComponent(myWayCountLabel)
-                            .addComponent(myRelationCountLabel))))
-                .addContainerGap())
-        );
-        refSetPanelLayout.setVerticalGroup(
-            refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(refSetPanelLayout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(freezeMySetButton)
-                    .addComponent(restoreMySetButton))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel2)
-                    .addComponent(myLayerLabel))
-                .addGap(11, 11, 11)
-                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel1)
-                    .addComponent(myNodeCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel3)
-                    .addComponent(myWayCountLabel))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel4)
-                    .addComponent(myRelationCountLabel))
-                .addContainerGap(38, Short.MAX_VALUE))
-        );
+        refSetPanel.add(restoreMySetButton);
+
+        objectTabPanel.add(refSetPanel);
 
         nonRefSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Source Selection"));
+        nonRefSetPanel.setLayout(new javax.swing.BoxLayout(nonRefSetPanel, javax.swing.BoxLayout.LINE_AXIS));
 
         freezeTheirSelectionButton.setText("Freeze Selection");
@@ -223,4 +197,33 @@
             }
         });
+        nonRefSetPanel.add(freezeTheirSelectionButton);
+
+        jPanel4.setLayout(new java.awt.GridLayout(0, 2, 2, 0));
+
+        jLabel6.setText("Layer");
+        jPanel4.add(jLabel6);
+
+        theirLayerLabel.setText("(invalid)");
+        jPanel4.add(theirLayerLabel);
+
+        jLabel7.setText("Nodes");
+        jPanel4.add(jLabel7);
+
+        theirNodeCountLabel.setText("0");
+        jPanel4.add(theirNodeCountLabel);
+
+        jLabel9.setText("Ways");
+        jPanel4.add(jLabel9);
+
+        theirWayCountLabel.setText("0");
+        jPanel4.add(theirWayCountLabel);
+
+        jLabel5.setText("Relations");
+        jPanel4.add(jLabel5);
+
+        theirRelationCountLabel.setText("0");
+        jPanel4.add(theirRelationCountLabel);
+
+        nonRefSetPanel.add(jPanel4);
 
         restoreTheirSetButton.setText("Restore Selection");
@@ -230,71 +233,7 @@
             }
         });
-
-        jLabel5.setText("Relations");
-
-        jLabel6.setText("Layer");
-
-        jLabel7.setText("Nodes");
-
-        jLabel9.setText("Ways");
-
-        theirNodeCountLabel.setText("0");
-
-        theirLayerLabel.setText("(invalid)");
-
-        theirWayCountLabel.setText("0");
-
-        theirRelationCountLabel.setText("0");
-
-        javax.swing.GroupLayout nonRefSetPanelLayout = new javax.swing.GroupLayout(nonRefSetPanel);
-        nonRefSetPanel.setLayout(nonRefSetPanelLayout);
-        nonRefSetPanelLayout.setHorizontalGroup(
-            nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(nonRefSetPanelLayout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, nonRefSetPanelLayout.createSequentialGroup()
-                        .addComponent(freezeTheirSelectionButton)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 392, Short.MAX_VALUE)
-                        .addComponent(restoreTheirSetButton))
-                    .addGroup(nonRefSetPanelLayout.createSequentialGroup()
-                        .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(jLabel5)
-                            .addComponent(jLabel9)
-                            .addComponent(jLabel7)
-                            .addComponent(jLabel6))
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                        .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(theirLayerLabel)
-                            .addComponent(theirNodeCountLabel)
-                            .addComponent(theirWayCountLabel)
-                            .addComponent(theirRelationCountLabel))))
-                .addContainerGap())
-        );
-        nonRefSetPanelLayout.setVerticalGroup(
-            nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(nonRefSetPanelLayout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(freezeTheirSelectionButton)
-                    .addComponent(restoreTheirSetButton))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel6)
-                    .addComponent(theirLayerLabel))
-                .addGap(11, 11, 11)
-                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel7)
-                    .addComponent(theirNodeCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel9)
-                    .addComponent(theirWayCountLabel))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel5)
-                    .addComponent(theirRelationCountLabel))
-                .addContainerGap(32, Short.MAX_VALUE))
-        );
+        nonRefSetPanel.add(restoreTheirSetButton);
+
+        objectTabPanel.add(nonRefSetPanel);
 
         objectTabCancelButton.setText("Cancel");
@@ -304,4 +243,5 @@
             }
         });
+        objectTabPanel.add(objectTabCancelButton);
 
         objectTabNextButton.setMnemonic('N');
@@ -312,42 +252,9 @@
             }
         });
-
-        javax.swing.GroupLayout objectTabPanelLayout = new javax.swing.GroupLayout(objectTabPanel);
-        objectTabPanel.setLayout(objectTabPanelLayout);
-        objectTabPanelLayout.setHorizontalGroup(
-            objectTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(objectTabPanelLayout.createSequentialGroup()
-                .addGroup(objectTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(nonRefSetPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                    .addComponent(refSetPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, objectTabPanelLayout.createSequentialGroup()
-                        .addContainerGap()
-                        .addComponent(objectTabCancelButton)
-                        .addGap(81, 81, 81)
-                        .addComponent(objectTabNextButton)))
-                .addContainerGap())
-        );
-        objectTabPanelLayout.setVerticalGroup(
-            objectTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(objectTabPanelLayout.createSequentialGroup()
-                .addComponent(refSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(nonRefSetPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(objectTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(objectTabNextButton)
-                    .addComponent(objectTabCancelButton))
-                .addGap(55, 55, 55))
-        );
+        objectTabPanel.add(objectTabNextButton);
 
         resultsTabPanel.addTab("Object selection", objectTabPanel);
 
-        criteriaTabConflateButton.setMnemonic('f');
-        criteriaTabConflateButton.setText("Conflate");
-        criteriaTabConflateButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                criteriaTabConflateButtonActionPerformed(evt);
-            }
-        });
+        criteriaTabPanel.setLayout(new javax.swing.BoxLayout(criteriaTabPanel, javax.swing.BoxLayout.PAGE_AXIS));
 
         jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
@@ -355,4 +262,5 @@
         jCheckBox1.setSelected(true);
         jCheckBox1.setText("Distance");
+        jCheckBox1.setEnabled(false);
         jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -368,5 +276,5 @@
                 .addContainerGap()
                 .addComponent(jCheckBox1)
-                .addContainerGap(282, Short.MAX_VALUE))
+                .addContainerGap(350, Short.MAX_VALUE))
         );
         jPanel2Layout.setVerticalGroup(
@@ -375,31 +283,17 @@
                 .addContainerGap()
                 .addComponent(jCheckBox1)
-                .addContainerGap(192, Short.MAX_VALUE))
+                .addContainerGap(195, Short.MAX_VALUE))
         );
 
-        javax.swing.GroupLayout criteriaTabPanelLayout = new javax.swing.GroupLayout(criteriaTabPanel);
-        criteriaTabPanel.setLayout(criteriaTabPanelLayout);
-        criteriaTabPanelLayout.setHorizontalGroup(
-            criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(criteriaTabPanelLayout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, criteriaTabPanelLayout.createSequentialGroup()
-                        .addGap(0, 568, Short.MAX_VALUE)
-                        .addComponent(criteriaTabConflateButton))
-                    .addGroup(criteriaTabPanelLayout.createSequentialGroup()
-                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                        .addGap(0, 282, Short.MAX_VALUE)))
-                .addContainerGap())
-        );
-        criteriaTabPanelLayout.setVerticalGroup(
-            criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, criteriaTabPanelLayout.createSequentialGroup()
-                .addContainerGap()
-                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 217, Short.MAX_VALUE)
-                .addComponent(criteriaTabConflateButton)
-                .addContainerGap())
-        );
+        criteriaTabPanel.add(jPanel2);
+
+        criteriaTabConflateButton.setMnemonic('f');
+        criteriaTabConflateButton.setText("Conflate");
+        criteriaTabConflateButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                criteriaTabConflateButtonActionPerformed(evt);
+            }
+        });
+        criteriaTabPanel.add(criteriaTabConflateButton);
 
         resultsTabPanel.addTab("Matching criteria", criteriaTabPanel);
@@ -434,5 +328,10 @@
         jLabel8.setText("Resolve using:");
 
-        useTheirTagsButton.setText("Their Tags");
+        useTheirTagsButton.setText("Merge tags");
+        useTheirTagsButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                useTheirTagsButtonActionPerformed(evt);
+            }
+        });
 
         jButton1.setText("Not a match");
@@ -452,5 +351,5 @@
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                 .addComponent(jButton1)
-                .addContainerGap(252, Short.MAX_VALUE))
+                .addContainerGap(14, Short.MAX_VALUE))
         );
         jPanel1Layout.setVerticalGroup(
@@ -490,5 +389,5 @@
         // some initialization
         int n = targetSelection.size();
-        int m = theirSelection.size();
+        int m = sourceSelection.size();
         int maxLen = Math.max(n, m);
         double cost[][] = new double[maxLen][maxLen];
@@ -497,5 +396,5 @@
         for (int i = 0; i < n; i++) {
             for (int j = 0; j < m; j++) {
-                cost[i][j] = calcCost(targetSelection.get(i), theirSelection.get(j));
+                cost[i][j] = calcCost(targetSelection.get(i), sourceSelection.get(j));
             }
         }
@@ -506,10 +405,12 @@
         candidates = new LinkedList<ConflationCandidate>();
         for (int i = 0; i < maxLen; i++) {
-            if (assignment[i][0] < n)
-                target = targetSelection.get(assignment[i][0]);
+            int tgtIdx = assignment[i][0];
+            int srcIdx = assignment[i][1];
+            if (tgtIdx < n)
+                target = targetSelection.get(tgtIdx);
             else
                 target = null;
-            if (assignment[i][1] < m)
-                source = theirSelection.get(assignment[i][1]);
+            if (srcIdx < m)
+                source = sourceSelection.get(srcIdx);
             else
                 source = null;
@@ -517,5 +418,5 @@
             if (target != null && source != null) {
                 // TODO: do something!
-                candidates.add(new ConflationCandidate(source, target));
+                candidates.add(new ConflationCandidate(source, target, cost[tgtIdx][srcIdx]));
             }
         }
@@ -534,4 +435,7 @@
         // print list of matched pairsalong with distance
         // upon selection of one pair, highlight them and draw arrow
+        
+        if (resultsPanel != null)
+            resultsTabPanel.setSelectedComponent(resultsPanel);
     }//GEN-LAST:event_criteriaTabConflateButtonActionPerformed
 
@@ -550,13 +454,17 @@
 
     private void restoreTheirSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restoreTheirSetButtonActionPerformed
-        if (theirLayer != null && sourceDataSet != null && theirSelection != null && !theirSelection.isEmpty()) {
-            Main.map.mapView.setActiveLayer(theirLayer);
-            theirLayer.setVisible(true);
-            sourceDataSet.setSelected(theirSelection);
+        if (sourceLayer != null && sourceDataSet != null && sourceSelection != null && !sourceSelection.isEmpty()) {
+            Main.map.mapView.setActiveLayer(sourceLayer);
+            sourceLayer.setVisible(true);
+            sourceDataSet.setSelected(sourceSelection);
         }
     }//GEN-LAST:event_restoreTheirSetButtonActionPerformed
 
     private void freezeTargetSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeTargetSelectionActionPerformed
+        if (targetDataSet != null && targetDataSet == Main.main.getCurrentDataSet()) {
+            targetDataSet.removeDataSetListener(this);
+        }
         targetDataSet = Main.main.getCurrentDataSet();
+        targetDataSet.addDataSetListener(this);
         targetLayer = Main.main.getEditLayer();
         if (targetDataSet == null || targetLayer == null) {
@@ -590,13 +498,17 @@
 
     private void freezeSourceSelectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeSourceSelectionActionPerformed
+        if (sourceDataSet != null && sourceDataSet == Main.main.getCurrentDataSet()) {
+            sourceDataSet.removeDataSetListener(this);
+        }
         sourceDataSet = Main.main.getCurrentDataSet();
-        theirLayer = Main.main.getEditLayer();
-        if (sourceDataSet == null || theirLayer == null) {
+        sourceDataSet.addDataSetListener(this);
+        sourceLayer = Main.main.getEditLayer();
+        if (sourceDataSet == null || sourceLayer == null) {
             JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."),
                     tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
             return;
         }
-        theirSelection = new ArrayList<OsmPrimitive>(sourceDataSet.getSelected());
-        if (theirSelection.isEmpty()) {
+        sourceSelection = new ArrayList<OsmPrimitive>(sourceDataSet.getSelected());
+        if (sourceSelection.isEmpty()) {
             JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."),
                     tr("Empty selection"), JOptionPane.ERROR_MESSAGE);
@@ -607,5 +519,5 @@
         int numWays = 0;
         int numRelations = 0;
-        for (OsmPrimitive p: theirSelection) {
+        for (OsmPrimitive p: sourceSelection) {
             switch(p.getType()) {
             case NODE: numNodes++; break;
@@ -615,5 +527,5 @@
         }
 
-        theirLayerLabel.setText(theirLayer.getName());
+        theirLayerLabel.setText(sourceLayer.getName());
         theirNodeCountLabel.setText(Integer.toString(numNodes));
         theirWayCountLabel.setText(Integer.toString(numWays));
@@ -631,6 +543,12 @@
 
     private void replaceGeometryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceGeometryButtonActionPerformed
-        
+        ReplaceGeometryAction rg = new ReplaceGeometryAction();
+        ConflationCandidate c = conflationLayer.getSelectedCandidate();
+        rg.replace(c.getSource(), c.getTarget());
     }//GEN-LAST:event_replaceGeometryButtonActionPerformed
+
+    private void useTheirTagsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useTheirTagsButtonActionPerformed
+        // TODO add your handling code here:
+    }//GEN-LAST:event_useTheirTagsButtonActionPerformed
 
     static public class LayerListCellRenderer extends DefaultListCellRenderer {
@@ -659,11 +577,11 @@
      * now, later we can also use dissimilarity between tags.
      *
-     * @param   refPrim      the reference <code>OsmPrimitive</code>.
-     * @param   nonRefPrim   the non-reference <code>OsmPrimitive</code>.
+     * @param   source      the reference <code>OsmPrimitive</code>.
+     * @param   target   the non-reference <code>OsmPrimitive</code>.
      */
-    public double calcCost(OsmPrimitive refPrim, OsmPrimitive nonRefPrim) {
+    public double calcCost(OsmPrimitive source, OsmPrimitive target) {
         double dist;
         try {
-            dist = getCenter(refPrim).distance(getCenter(nonRefPrim));
+            dist = getCenter(source).distance(getCenter(target));
         } catch (Exception e) {
             dist = 1000; // FIXME: what number to use?
@@ -692,12 +610,17 @@
 
         public Object getValueAt(int row, int col) {
+            ConflationCandidate c = candidates.get(row);
             if (col == 0)
-                return candidates.get(row).getSource();
-            if (col == 1)
-                return candidates.get(row).getTarget();
+                return c.getSource();
+            else if (col == 1)
+                return c.getTarget();
+            else if (col == 2)
+                return c.getDistance();
+            else if (col == 3)
+                return c.getCost();
             if (col == 4) {
                 HashSet<OsmPrimitive> set = new HashSet<OsmPrimitive>();
-                set.add(candidates.get(row).getSource());
-                set.add(candidates.get(row).getTarget());
+                set.add(c.getSource());
+                set.add(c.getTarget());
                 TagCollection tags = TagCollection.unionOfAllPrimitives(set);
                 Set<String> keys = tags.getKeysWithMultipleValues();
@@ -761,5 +684,5 @@
 
             // only one item selected, show tags and zoom/center map
-            if (!lsm.isSelectionEmpty() && firstIndex == lastIndex) {
+            if (!lsm.isSelectionEmpty() && firstIndex == lastIndex && firstIndex < candidates.size()) {
                 ConflationCandidate c = candidates.get(firstIndex);
                 
@@ -789,18 +712,47 @@
     }
 
-    public void onConflictsAdded(ConflictCollection conflicts) {
+    @Override
+    public void primitivesAdded(PrimitivesAddedEvent event) {
+    }
+
+    @Override
+    public void primitivesRemoved(PrimitivesRemovedEvent event) {
+        List<? extends OsmPrimitive> prims = event.getPrimitives();
+        for (OsmPrimitive p : prims) {
+            for (ConflationCandidate c : candidates) {
+                if (c.getSource().equals(p) || c.getTarget().equals(p)) {
+                    candidates.remove(c);
+                    break;
+                }
+            }
+        }
         refreshView();
     }
-
-    public void onConflictsRemoved(ConflictCollection conflicts) {
-        System.err.println("1 conflict has been resolved.");
-        refreshView();
-    }
     
+    @Override
+    public void tagsChanged(TagsChangedEvent event) {}
+    
+    @Override
+    public void nodeMoved(NodeMovedEvent event) {}
+        
+    @Override
+    public void wayNodesChanged(WayNodesChangedEvent event) {}
+
+    @Override
+    public void relationMembersChanged(RelationMembersChangedEvent event) {}
+
+    @Override
+    public void otherDatasetChange(AbstractDatasetChangedEvent event) {}
+
+    @Override
+    public void dataChanged(DataChangedEvent event) {}
+
     public class ConflationCandidate {
         protected OsmPrimitive source;
         protected OsmPrimitive target;
+        protected double cost;
+        protected double distance;
         
-        public ConflationCandidate(OsmPrimitive source, OsmPrimitive target) {
+        public ConflationCandidate(OsmPrimitive source, OsmPrimitive target, double cost) {
             if (source == null || target == null) {
                 throw new IllegalArgumentException("Invalid source or target");
@@ -808,4 +760,7 @@
             this.source = source;
             this.target = target;
+            this.cost = cost;
+            // TODO: use distance calculated in cost function, and make sure it's in meters?
+            this.distance = getCenter(source).distance(getCenter(target));
         }
         
@@ -816,4 +771,12 @@
         public OsmPrimitive getTarget() {
             return target;
+        }
+
+        private Object getCost() {
+            return cost;
+        }
+
+        private Object getDistance() {
+            return distance;
         }
     }
@@ -837,4 +800,6 @@
     private javax.swing.JPanel jPanel1;
     private javax.swing.JPanel jPanel2;
+    private javax.swing.JPanel jPanel3;
+    private javax.swing.JPanel jPanel4;
     private javax.swing.JScrollPane jScrollPane1;
     private javax.swing.JLabel myLayerLabel;
