Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java	(revision 15582)
@@ -31,9 +31,11 @@
 import org.openstreetmap.josm.plugins.czechaddress.actions.FactoryAction;
 import org.openstreetmap.josm.plugins.czechaddress.actions.HelpAction;
-import org.openstreetmap.josm.plugins.czechaddress.actions.ModifierAction;
+import org.openstreetmap.josm.plugins.czechaddress.actions.ManagerAction;
 import org.openstreetmap.josm.plugins.czechaddress.actions.SplitAreaByEmptyWayAction;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Street;
 import org.openstreetmap.josm.plugins.czechaddress.gui.ConflictResolver;
 import org.openstreetmap.josm.plugins.czechaddress.gui.FactoryDialog;
 import org.openstreetmap.josm.plugins.czechaddress.gui.LocationSelector;
+import org.openstreetmap.josm.plugins.czechaddress.gui.ManagerDialog;
 import org.openstreetmap.josm.plugins.czechaddress.intelligence.Reasoner;
 import org.openstreetmap.josm.plugins.czechaddress.intelligence.SelectionMonitor;
@@ -82,9 +84,12 @@
         addStatusListener(this);
         
-        Reasoner.getInstance();
         ConflictResolver.getInstance();
         SelectionMonitor.getInstance();
+        FactoryDialog.getInstance();
+        Reasoner.getInstance();
 
-        initLoggers();
+        boolean assertionsEnabled = false;
+        assert assertionsEnabled = true;
+        if (assertionsEnabled) initLoggers();
         
         MainMenu.add(Main.main.menu.toolsMenu, new SplitAreaByEmptyWayAction());
@@ -94,6 +99,4 @@
         parser.setTargetDatabase(Database.getInstance());
         parser.setStorageDir(getPluginDir());
-
-        parser.setFilter("HUSTOPEČE", "HUSTOPEČE", null, null);
 
         // Fill the database in separate thread.
@@ -130,20 +133,19 @@
             reasoner.reset();
             reasoner.openTransaction();
-            //Reasoner.logger.setLevel(Level.OFF);
             for (House house : location.getAllHouses())
-                reasoner.consider(house);
+                reasoner.update(house);
+
+            for (Street street : location.getAllStreets())
+                reasoner.update(street);
+
             for (OsmPrimitive prim : Main.ds.allPrimitives()) {
-                boolean include = false;
-                for (String key : prim.keySet())
-                    if (key.startsWith("addr:")) {
-                        include = true;
-                        break;
-                    }
-                if (include)
-                    reasoner.consider(prim);
+                if (House.isMatchable(prim) || Street.isMatchable(prim))
+                    reasoner.update(prim);
             }
-            //Reasoner.logger.setLevel(Level.ALL);
             reasoner.closeTransaction();
         }
+        ManagerDialog dialog = new ManagerDialog();
+        if (dialog.countAutomaticRenameProposals() > 0)
+            dialog.setVisible(true);
     }
 
@@ -178,5 +180,5 @@
             menuItems.add(MainMenu.add(czechMenu, new GroupManipulatorAction()));
             menuItems.add(MainMenu.add(czechMenu, new ConflictResolveAction()));
-            menuItems.add(MainMenu.add(czechMenu, new ModifierAction()));
+            menuItems.add(MainMenu.add(czechMenu, new ManagerAction()));
             menuItems.add(MainMenu.add(czechMenu, new HelpAction()));
             return;
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/PrimUtils.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/PrimUtils.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/PrimUtils.java	(revision 15582)
@@ -7,8 +7,5 @@
 
 import java.util.Comparator;
-import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Way;
 
 /**
@@ -16,5 +13,8 @@
  * @author Radomír Černoch, radomir.cernoch@gmail.com
  */
-public class PrimUtils implements Comparator<OsmPrimitive> {
+public class PrimUtils {
+
+    public static final String KEY_HIGHWAY      = "highway";
+    public static final String KEY_PLACE        = "place";
 
     public static final String KEY_ADDR_CP      = "addr:alternatenumber";
@@ -28,34 +28,43 @@
 
     private static final String[] keysToCompare = new String[]
-        {KEY_ADDR_COUNTRY, KEY_ADDR_CITY, KEY_IS_IN,
-         KEY_ADDR_STREET, KEY_ADDR_CO, KEY_ADDR_CP, KEY_NAME };
+        {KEY_PLACE, KEY_NAME, KEY_ADDR_COUNTRY, KEY_ADDR_CITY, KEY_IS_IN,
+         KEY_ADDR_STREET, KEY_ADDR_CO, KEY_ADDR_CP };
 
-    public int compare(OsmPrimitive o1, OsmPrimitive o2) {
+    public static final Comparator<OsmPrimitive> comparator =
+        new Comparator<OsmPrimitive>() {
 
-        for (String key : keysToCompare) {
-            if (o1.get(key) == null) continue;
-            if (o2.get(key) == null) continue;
+        public int compare(OsmPrimitive o1, OsmPrimitive o2) {
 
-            int val = o1.get(key).compareTo(o2.get(key));
-            if (val != 0) return val;
-        }
+            for (String key : keysToCompare) {
+                if (o1.get(key) == null) {
+                    continue;
+                }
+                if (o2.get(key) == null) {
+                    continue;
+                }
 
+                int val = o1.get(key).compareTo(o2.get(key));
+                if (val != 0) {
+                    return val;
+                }
+            }
 
-        return o1.toString().compareTo(o2.toString());
+            return o1.toString().compareTo(o2.toString());
 
-        /*LatLon pos1 = null;
-        LatLon pos2 = null;
-        if (o1 instanceof Node) pos1 = ((Node) o1).coor;
-        if (o1 instanceof Way)  pos1 = ((Way)  o1).lastNode().coor;
-        if (o2 instanceof Node) pos1 = ((Node) o2).coor;
-        if (o2 instanceof Way)  pos1 = ((Way)  o2).lastNode().coor;
+            /*LatLon pos1 = null;
+            LatLon pos2 = null;
+            if (o1 instanceof Node) pos1 = ((Node) o1).coor;
+            if (o1 instanceof Way)  pos1 = ((Way)  o1).lastNode().coor;
+            if (o2 instanceof Node) pos1 = ((Node) o2).coor;
+            if (o2 instanceof Way)  pos1 = ((Way)  o2).lastNode().coor;
 
-        if (pos1 != null && pos2 != null) {
+            if (pos1 != null && pos2 != null) {
             if (pos1.lat() < pos2.lat()) return -1;
             if (pos1.lat() > pos2.lat()) return  1;
             if (pos1.lon() < pos2.lon()) return -1;
             if (pos1.lon() > pos2.lon()) return  1;
-        }*/
-    }
+            }*/
+        }
+    };
 
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StringUtils.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StringUtils.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StringUtils.java	(revision 15582)
@@ -1,4 +1,5 @@
 package org.openstreetmap.josm.plugins.czechaddress;
 
+import java.text.Normalizer;
 import org.openstreetmap.josm.data.coor.LatLon;
 
@@ -50,12 +51,12 @@
 
     /**
-     * String matcher with abbreviations
+     * String matcher with abbreviations and regardless of diacritics.
      *
-     * <p>Returns {@code true} even if s1="Nám. Svobody" and
+     * <p>Returns {@code true} even if s1="Nam. Svobody" and
      * s2="Náměstí Svobody".</p>
      */
     public static boolean matchAbbrev(String s1, String s2) {
-        String[] parts1 = s1.split(" +");
-        String[] parts2 = s2.split(" +");
+        String[] parts1 = anglicize(s1).split(" +");
+        String[] parts2 = anglicize(s2).split(" +");
 
         if (parts1.length != parts2.length)
@@ -110,5 +111,5 @@
         }
 
-        String[] noCapitalize = { "Nad", "Pod", "U", "Na" };
+        String[] noCapitalize = { "Nad", "Pod", "U", "Na", "Z" };
         for (String noc : noCapitalize)
             result = result.replaceAll(" "+noc+" ", " "+noc.toLowerCase()+" ");
@@ -116,3 +117,23 @@
         return result;
     }
+
+    /**
+     * Remove diacritics from the string.
+     *
+     * <p>This method was posted on the
+     * <a href='http://forums.sun.com/thread.jspa?messageID=10190825#10190825'>
+     * SUN forum</a> by
+     * <a href='http://forums.sun.com/profile.jspa?userID=43408'>
+     * <i>Alan Moore</i></a>.</p>
+     */
+    public static String anglicize(String str) {
+        String strNFD = Normalizer.normalize(str, Normalizer.Form.NFD);
+        StringBuilder sb = new StringBuilder();
+        for (char ch : strNFD.toCharArray()) {
+            if (Character.getType(ch) != Character.NON_SPACING_MARK) {
+                sb.append(ch);
+            }
+        }
+        return sb.toString();
+    }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/FactoryAction.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/FactoryAction.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/FactoryAction.java	(revision 15582)
@@ -9,5 +9,4 @@
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.gui.MapFrame;
-import org.openstreetmap.josm.plugins.czechaddress.CzechAddressPlugin;
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
 import org.openstreetmap.josm.plugins.czechaddress.intelligence.Reasoner;
@@ -99,9 +98,10 @@
             r.closeTransaction();
         }
+        
+        FactoryDialog.getInstance().selectionListenerActivated = false;
         FactoryDialog.getInstance().selectNextUnmatchedHouseByCheckBox();
-
-        // And make the new node selected.
-        Main.ds.addPrimitive(newNode);
+        Main.ds.addPrimitive(newNode);        
         Main.ds.setSelected(newNode);
+        FactoryDialog.getInstance().selectionListenerActivated = true;
     }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/ManagerAction.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/ManagerAction.java	(revision 15582)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/ManagerAction.java	(revision 15582)
@@ -0,0 +1,28 @@
+package org.openstreetmap.josm.plugins.czechaddress.actions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.plugins.czechaddress.gui.ManagerDialog;
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ *
+ * @author Radomír Černoch, radomir.cernoch@gmail.com
+ */
+public class ManagerAction extends JosmAction {
+
+    public ManagerAction() {
+        super("Upravit databázi",
+              null,//"envelope-closed-big.png",
+              "Upravit jména elemntů dle mapy",
+              Shortcut.registerShortcut("address:assignaddress",
+                        "Adresy: Přiřadit adresy",
+                        KeyEvent.VK_P, Shortcut.GROUP_DIRECT, Shortcut.SHIFT_DEFAULT),
+              true);
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        (new ManagerDialog()).setVisible(true);
+    }
+}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/ModifierAction.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/ModifierAction.java	(revision 15558)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.openstreetmap.josm.plugins.czechaddress.actions;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.plugins.czechaddress.gui.Renamer;
-import org.openstreetmap.josm.tools.Shortcut;
-
-/**
- *
- * @author Radomír Černoch, radomir.cernoch@gmail.com
- */
-public class ModifierAction extends JosmAction {
-
-    public ModifierAction() {
-        super("Upravit databázi",
-              null,//"envelope-closed-big.png",
-              "Upravit jména elemntů dle mapy",
-              Shortcut.registerShortcut("address:assignaddress",
-                        "Adresy: Přiřadit adresy",
-                        KeyEvent.VK_P, Shortcut.GROUP_DIRECT, Shortcut.SHIFT_DEFAULT),
-              true);
-    }
-
-    public void actionPerformed(ActionEvent e) {
-        (new Renamer()).setVisible(true);
-    }
-}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java	(revision 15582)
@@ -6,5 +6,5 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.plugins.czechaddress.StringUtils;
-import org.openstreetmap.josm.plugins.czechaddress.intelligence.Match;
+import org.openstreetmap.josm.plugins.czechaddress.intelligence.Reasoner;
 import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal;
 
@@ -206,4 +206,8 @@
     }
 
+    protected int[] getAdditionalFieldMatchList(OsmPrimitive primitive) {
+        int[] result = {0};
+        return result;
+    }
 
     public List<Proposal> getDiff(OsmPrimitive prim) {
@@ -211,5 +215,5 @@
     }
 
-    public int getMatchQuality(OsmPrimitive primitive) {
+    public int getQ(OsmPrimitive primitive) {
         
         // Firstly get integers representing a match of every matchable field.
@@ -234,5 +238,5 @@
         // has nothing to do with our field.
         if (maxVal <= 0)
-            return Match.MATCH_NOMATCH;
+            return Reasoner.MATCH_NOMATCH;
         
         // If all fields are 1    --> ROCKSOLID MATCH
@@ -240,36 +244,10 @@
         // If some are 1, some -1 --> CONFLICT
         switch (minVal * maxVal) {
-            case -1 : return Match.MATCH_CONFLICT;
-            case  0 : return Match.MATCH_PARTIAL;
-            case +1 : return Match.MATCH_ROCKSOLID;   
+            case -1 : return Reasoner.MATCH_CONFLICT;
+            case  0 : return Reasoner.MATCH_PARTIAL;
+            case +1 : return Reasoner.MATCH_ROCKSOLID;
         }
         
         return 0; // <-- just to make compilers happy. We cannot get here.
-    }
-
-
-
-    public String getIsIn() {
-        return getIsIn(null);
-    }
-
-    protected String getIsInName() {
-        return getName();
-    }
-
-    private String getIsIn(String childString) {
-
-        String result = "";
-
-        if (getIsInName() != null  &&  !getIsInName().equals(childString)) {
-            result += getIsInName() + ", ";
-        }
-
-        if (parent != null)
-            result += parent.getIsIn(getIsInName());
-        else
-            result += "CZ";
-        
-        return result;
     }
 
@@ -282,5 +260,5 @@
         if (retVal != 0) return retVal;
 
-        return getName().compareTo(((AddressElement) elem).getName());
+        return toString().compareTo(((AddressElement) elem).toString());
     }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithHouses.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithHouses.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithHouses.java	(revision 15582)
@@ -9,5 +9,5 @@
  * @author Radomir Cernoch radomir.cernoch@gmail.com
  */
-abstract public class ElementWithHouses extends AddressElement {
+public abstract class ElementWithHouses extends AddressElement {
 
     /**
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithStreets.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithStreets.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithStreets.java	(revision 15582)
@@ -16,5 +16,5 @@
  * @author Radomir Cernoch radomir.cernoch@gmail.com
  */
-abstract public class ElementWithStreets extends ElementWithHouses {
+public abstract class ElementWithStreets extends ElementWithHouses {
 
     private ArrayList<Street> streets = new ArrayList<Street>();
@@ -60,4 +60,9 @@
     }
 
+    public List<Street> getAllStreets() {
+        return getStreets();
+    }
+
+
     public Street findStreet(String streetName) {
 
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/House.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/House.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/House.java	(revision 15582)
@@ -5,5 +5,4 @@
 import org.openstreetmap.josm.plugins.czechaddress.NotNullList;
 import org.openstreetmap.josm.plugins.czechaddress.PrimUtils;
-import org.openstreetmap.josm.plugins.czechaddress.StringUtils;
 import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal;
 
@@ -133,5 +132,5 @@
      * {@link AddressElement}{@code .getFieldMatchList()}.</p>
      *
-     * <p>First elemtn of the returned array corresponds to the CP
+     * <p>First element of the returned array corresponds to the CP
      * (číslo popisné), the second one to the combination of Street+CO.</p>
      */
@@ -139,5 +138,6 @@
     protected int[] getFieldMatchList(OsmPrimitive prim) {
         int[] result = {0, 0};
-                
+        if (!isMatchable(prim)) return result;
+
         // First field is the AlternateNubmer
         result[0] = matchField(this.cp, prim.get(PrimUtils.KEY_ADDR_CP));
@@ -150,5 +150,17 @@
         return result;
     }
+
+    @Override
+    protected int[] getAdditionalFieldMatchList(OsmPrimitive prim) {
+        int[] result = {0};
+        if (!isMatchable(prim)) return result;
+
+        ParentResolver resolver = new ParentResolver(this);
+        result[0] = matchField(resolver.getIsIn(), prim.get(PrimUtils.KEY_IS_IN));
+        return result;
+    }
+
     
+
     /**
      * Gives all proposals to make the primitive be an address primitive.
@@ -161,5 +173,5 @@
         
         List<Proposal> props = new NotNullList<Proposal>();
-        ParentResolver pr = new ParentResolver(this);
+        ParentResolver resolver = new ParentResolver(this);
 
         props.add(getStringFieldDiff(PrimUtils.KEY_ADDR_CP, prim.get(PrimUtils.KEY_ADDR_CP), getCP()));
@@ -169,13 +181,15 @@
                             prim.get(PrimUtils.KEY_ADDR_COUNTRY), "CZ"));
 
-        if (pr.parentStreet != null)
+        if (resolver.parentStreet != null)
             props.add(getStringFieldDiff(PrimUtils.KEY_ADDR_STREET,
                                 prim.get(PrimUtils.KEY_ADDR_STREET),
-                                pr.parentStreet.getName()));
-
-        if (parent.parent != null) // For sure our parent is a ElemWithStreets
+                                resolver.parentStreet.getName()));
+
+        AddressElement isInElem = parent;
+        if (isInElem instanceof Street) isInElem = parent.parent;
+        if (isInElem != null) // For sure our parent is a ElemWithStreets
             props.add(getStringFieldDiff(PrimUtils.KEY_IS_IN,
                                 prim.get(PrimUtils.KEY_IS_IN),
-                                parent.parent.getIsIn()));
+                                resolver.getIsIn()));
 
         // If we have added any proposal so far, add the source info as well.
@@ -187,10 +201,7 @@
 
     public static boolean isMatchable(OsmPrimitive prim) {
-        
-        for (String key : prim.keySet()) {
-            String value = prim.get(key);
-            if (value != null && value.startsWith("addr:"))
+        for (String key : prim.keySet())
+            if (key.startsWith("addr:"))
                 return true;
-        }
         return false;
     }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ParentResolver.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ParentResolver.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ParentResolver.java	(revision 15582)
@@ -40,4 +40,27 @@
     }
 
+    public String getIsIn() {
+        String result = "";
+        String last = "";
+
+        if (parentSuburb != null && !last.equals(parentSuburb.getName())) {
+            result += parentSuburb.getName() + ", ";
+            last = parentSuburb.getName();
+        }
+
+        if (parentViToCi != null && !last.equals(parentViToCi.getName())) {
+            result += parentViToCi.getName() + ", ";
+            last = parentViToCi.getName();
+        }
+
+        if (parentRegion != null && parentRegion.getNuts3Name() != null &&
+                                    !last.equals(parentRegion.getNuts3Name())) {
+            result += parentRegion.getNuts3Name() + " kraj, ";
+            last = parentRegion.getNuts3Name();
+        }
+
+        return result + "CZ";
+    }
+
     public int compareTo(ParentResolver o) {
         int val = 0;
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Region.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Region.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Region.java	(revision 15582)
@@ -95,15 +95,3 @@
         return thisString;
     }
-
-    @Override
-    protected String getIsInName() {
-
-        if (nuts3name != null)
-            return nuts3name + " kraj";
-
-        if (nuts4name != null)
-            return nuts3name + " okres";
-
-        return null;
-    }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Street.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Street.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Street.java	(revision 15582)
@@ -1,5 +1,11 @@
 package org.openstreetmap.josm.plugins.czechaddress.addressdatabase;
 
+import java.util.List;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.plugins.czechaddress.NotNullList;
+import org.openstreetmap.josm.plugins.czechaddress.PrimUtils;
+import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal;
+
+import static org.openstreetmap.josm.plugins.czechaddress.proposal.ProposalFactory.getStringFieldDiff;
 
 /**
@@ -29,20 +35,21 @@
     protected int[] getFieldMatchList(OsmPrimitive primitive) {
         int[] result = {0};
+        if (!isMatchable(primitive)) return result;
         
-        if (primitive.get("highway") == null)
-            return result;
-        
-        result[0] = matchField(name, primitive.get("name"));
-
-        if (primitive.get("name") != null) {
-            String[] parts1 = primitive.get("name").split("\\.* +");
-            String[] parts2 =                  name.split("\\.* +");
-            for (String p : parts1)
-                System.out.println("X: " + p);
-            for (String p : parts2)
-                System.out.println("Y: " + p);
-        }
-
+        result[0] = matchFieldAbbrev(name, primitive.get("name"));
         return result;
     }
+
+    @Override
+    public List<Proposal> getDiff(OsmPrimitive prim) {
+        List<Proposal> props = new NotNullList<Proposal>();
+        
+        props.add(getStringFieldDiff(PrimUtils.KEY_NAME, prim.get(PrimUtils.KEY_NAME), getName()));
+        return props;
+    }
+
+    public static boolean isMatchable(OsmPrimitive prim) {
+        return (prim.get(PrimUtils.KEY_HIGHWAY) != null);
+    }
+
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Suburb.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Suburb.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Suburb.java	(revision 15582)
@@ -1,3 +1,6 @@
 package org.openstreetmap.josm.plugins.czechaddress.addressdatabase;
+
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.plugins.czechaddress.PrimUtils;
 
 /**
@@ -11,3 +14,10 @@
         super(name);
     }
+
+    public static boolean isMatchable(OsmPrimitive prim) {
+        for (String key : prim.keySet())
+            if (key.equals(PrimUtils.KEY_PLACE))
+                return true;
+        return false;
+    }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ViToCi.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ViToCi.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ViToCi.java	(revision 15582)
@@ -3,5 +3,4 @@
 import java.util.List;
 import java.util.ArrayList;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
 
 /**
@@ -56,3 +55,19 @@
         return null;
     }
+
+    @Override
+    public List<Street> getAllStreets() {
+        List<Street> result = super.getAllStreets();
+        for (Suburb suburb : suburbs)
+            result.addAll(suburb.getAllStreets());
+        return result;
+    }
+
+    @Override
+    public List<House> getAllHouses() {
+        List<House> result = super.getAllHouses();
+        for (Suburb suburb : suburbs)
+            result.addAll(suburb.getAllHouses());
+        return result;
+    }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.form
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.form	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.form	(revision 15582)
@@ -156,4 +156,7 @@
             <Property name="enabled" type="boolean" value="false"/>
           </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="candPickButtonActionPerformed"/>
+          </Events>
         </Component>
         <Component class="javax.swing.JButton" name="mainPickButton">
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.java	(revision 15582)
@@ -24,4 +24,5 @@
 import org.openstreetmap.josm.plugins.czechaddress.PrimUtils;
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.ElementWithHouses;
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Street;
@@ -134,4 +135,9 @@
         candPickButton.setText("     ");
         candPickButton.setEnabled(false);
+        candPickButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                candPickButtonActionPerformed(evt);
+            }
+        });
 
         mainPickButton.setText("     ");
@@ -212,4 +218,13 @@
     }
 
+    public void focusElement(AddressElement elem) {
+        int index = Collections.binarySearch(conflictModel.elements, elem);
+        if (index >= 0) {
+            mainField.setSelectedIndex(index);
+            mainField.repaint();
+            setVisible(true);
+        }
+    }
+
     private void reassignButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reassignButtonActionPerformed
 
@@ -258,6 +273,12 @@
 
     private void mainPickButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mainPickButtonActionPerformed
-        // TODO add your handling code here:
+        if (mainField.getSelectedItem() instanceof House)
+            FactoryDialog.getInstance().setSelectedHouse((House) mainField.getSelectedItem());
     }//GEN-LAST:event_mainPickButtonActionPerformed
+
+    private void candPickButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_candPickButtonActionPerformed
+        if (candField.getSelectedItem() instanceof House)
+            FactoryDialog.getInstance().setSelectedHouse((House) candField.getSelectedItem());
+    }//GEN-LAST:event_candPickButtonActionPerformed
 
     // Variables declaration - do not modify//GEN-BEGIN:variables
@@ -279,6 +300,6 @@
 
         public void elementChanged(AddressElement elem) {
-            String delStr = Reasoner.getInstance().inConflict(elem) ? " in conflict" : " no conflict";
-            logger.log(Level.FINER, "hook: element changed", elem.getName() + delStr);
+            if (!(elem instanceof House)) return;
+            logger.log(Level.FINER, "hook: element changed", elem.getName());
 
             if (Reasoner.getInstance().inConflict(elem))
@@ -289,6 +310,6 @@
 
         public void primitiveChanged(OsmPrimitive prim) {
-            String delStr = Reasoner.getInstance().inConflict(prim) ? " in conflict" : " no conflict";
-            logger.log(Level.FINER, "hook: primitive changed", AddressElement.getName(prim) + delStr);
+            if (!House.isMatchable(prim)) return;
+            logger.log(Level.FINER, "hook: primitive changed", AddressElement.getName(prim));
 
             if (Reasoner.getInstance().inConflict(prim))
@@ -333,9 +354,9 @@
 
         public void put(OsmPrimitive prim) {
-            int index = Collections.binarySearch(primitives, prim, new PrimUtils());
+            int index = Collections.binarySearch(primitives, prim, PrimUtils.comparator);
             if (index < 0) {
                 logger.log(Level.FINE, "conflicts: adding primitive",
-                                        "[" + String.valueOf(-index-1) + "]=„"
-                                        + AddressElement.getName(prim) + "“");
+                                       "["+String.valueOf(-index-1)+"]=„"
+                                        +AddressElement.getName(prim) + "“");
                 primitives.add(-index-1, prim);
                 
@@ -452,5 +473,5 @@
             List<OsmPrimitive> conflPrims = new NotNullList<OsmPrimitive>();
             conflPrims.addAll(Reasoner.getInstance().getCandidates(selElem));
-            Collections.sort(conflPrims, new PrimUtils());
+            Collections.sort(conflPrims, PrimUtils.comparator);
             candField.setModel(new CandidatesModel<OsmPrimitive>(conflPrims));
 
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/FactoryDialog.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/FactoryDialog.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/FactoryDialog.java	(revision 15582)
@@ -96,14 +96,22 @@
             keepOddityCheckBox.setEnabled(true);
             return;
-        }
-        
-/*      if (message == MESSAGE_REASONER_REASONED) {
-            ensureConsistencyButton.setEnabled(true);
-        }
-        
-        if (message == MESSAGE_MATCHES_CHANGED || message == MESSAGE_CONFLICT_CHANGED) {
-            houseModel.notifyAllListeners();
-            return;
-        }*/
+        }        
+    }
+
+    public void setSelectedHouse(House house) {
+
+        for (int i=0; i<streetModel.getSize(); i++)
+            if (streetModel.getElementAt(i) == house.getParent()) {
+                streetComboBox.setSelectedIndex(i);
+                streetComboBox.repaint();
+                break;
+            }
+
+        for (int i=0; i<houseModel.getSize(); i++)
+            if (houseModel.getHouseAt(i) == house) {
+                houseList.setSelectedIndex(i);
+                houseList.ensureIndexIsVisible(i);
+                break;
+            }
     }
 
@@ -111,6 +119,5 @@
         if (houseList.getSelectedValue() instanceof House)
             return (House) houseList.getSelectedValue();
-        else
-            return null;
+        return null;
     }
 
@@ -138,8 +145,8 @@
         int index = houseList.getSelectedIndex();
 
-        index++;
-        Object current;
-        while ( (current = houseModel.getElementAt(index)) != null
-              && Reasoner.getInstance().translate((House) current) != null)
+        index++; // Initial kick to do at least one move.
+        House current;
+        while ( (current = houseModel.getHouseAt(index))  != null
+             && Reasoner.getInstance().translate(current) != null)
             index++;
 
@@ -171,6 +178,6 @@
                 newNum = Integer.valueOf(newStr);
 
-            } while ( (oldNum + newNum) % 2 == 1 &&
-                      houseList.getSelectedIndex() != 0 );
+            } while ((oldNum + newNum) % 2 == 1 &&
+                     houseList.getSelectedIndex() != 0);
             
         } catch (Exception exp) {}
@@ -184,10 +191,11 @@
     }
 
+    public boolean selectionListenerActivated = true;
     public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
 
+        if (!selectionListenerActivated) return;
         if (newSelection.size() != 1) return;
 
         OsmPrimitive selectedPrim = (OsmPrimitive) newSelection.toArray()[0];
-
         String streetName;
 
@@ -215,5 +223,5 @@
         for (House currHouse : selectedStreet.getHouses()) {
 
-            int currQuality = currHouse.getMatchQuality(selectedPrim);
+            int currQuality = currHouse.getQ(selectedPrim);
 
             if (currQuality > bestQuality) {
@@ -225,4 +233,5 @@
         if (bestHouse == null) return;
         houseList.setSelectedValue(bestHouse, true);
+        houseList.ensureIndexIsVisible(houseList.getSelectedIndex());
         houseModel.notifyAllListeners();
     }
@@ -313,19 +322,8 @@
             Reasoner r = Reasoner.getInstance();
 
-            if (r.translate(getSelectedHouse()) != null) {
+            if (r.translate(getSelectedHouse()) != null)
                 MapUtils.zoomTo(r.translate(getSelectedHouse()));
-                return;
-            }
-
-            // TODO: The following code does not work... for some reason.
-/*            List<Match> getConflicts = r.getConflictsForElement(getSelectegetConflicts if (getConflicts != null) {
-                List<OsmPrimitive> toZoom
-                        = new ArrayList<OsmPrimitive>(getConflicts.size());
-                for (Match conflict : getConflicts)
-                    toZoom.add(conflict.prim);
-
-                MapUtils.zoomToMany(toZoom);
-                return;
-*/
+            else
+                ConflictResolver.getInstance().focusElement(getSelectedHouse());
         }
     }//GEN-LAST:event_houseListClicked
@@ -344,35 +342,28 @@
         houseModel.notifyAllListeners();
     }
-
     public void primitiveChanged(OsmPrimitive prim) {}
-
-    public void resonerReseted() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
+    public void resonerReseted() {}
+
+//==============================================================================
 
     private class StreetListRenderer extends DefaultListCellRenderer {
-
-        Font plainFont = null;
-        Font boldFont = null;
-
         @Override
         public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
             Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 
-            if (plainFont == null) plainFont = getFont().deriveFont(Font.PLAIN);
-            if (boldFont  == null)  boldFont = getFont().deriveFont(Font.BOLD);
-
             if (value instanceof Street) {
-                setFont(plainFont);
+                setFont(getFont().deriveFont(Font.PLAIN));
                 setText(((Street) value).getName());
                 
             } else if (value instanceof ElementWithHouses) {
-                setFont(boldFont);
+                setFont(getFont().deriveFont(Font.BOLD));
                 setText("[" + ((ElementWithHouses) value).getName() + "]");
             }
-
+            
             return c;
         }
     }
+
+//==============================================================================
 
     private class HouseListRenderer extends DefaultListCellRenderer {
@@ -392,6 +383,4 @@
             if (boldFont == null) boldFont = getFont().deriveFont(Font.BOLD);
 
-            Reasoner r = Reasoner.getInstance();
-
             if (value instanceof House) {
                 House house = (House) value;
@@ -400,8 +389,8 @@
                 setFont(plainFont);
 
-                if (r.inConflict(house))
+                if (Reasoner.getInstance().inConflict(house))
                     setIcon(envelopeExclIcon);
 
-                else if (r.translate(house) == null) {
+                else if (Reasoner.getInstance().translate(house) == null) {
                     setIcon(envelopeStarIcon);
                     setFont(boldFont);
@@ -414,4 +403,6 @@
     }
 
+//==============================================================================
+
     private class AllStreetProvider extends ElementWithHouses {
         public AllStreetProvider() {
@@ -431,15 +422,5 @@
             super("nepřiřazené domy");
             Reasoner.getInstance().addListener(this);
-            rebuild();
-        }
-
-        @Override
-        public void setHouses(List<House> houses) {
-            this.houses = houses;
-        }
-
-
-        public void rebuild() {
-            houses.clear();
+
             for (AddressElement house : Reasoner.getInstance().getUnassignedElements())
                 if (house instanceof House)
@@ -452,18 +433,19 @@
         public void primitiveChanged(OsmPrimitive prim) {}
         public void elementChanged(AddressElement elem) {
-            if (!(elem instanceof House))
-                return;
+            if (!(elem instanceof House)) return;
             House house = (House) elem;
+            int index = Collections.binarySearch(houses, house);
             
-            if (Reasoner.getInstance().translate(house) != null)
-                houses.remove(house);
-            else if (!houses.contains(house)) {
-                houses.add(house);
-                Collections.sort(houses);
-            }
-        }
-
-
-    }
+            if (Reasoner.getInstance().translate(house) != null) {
+                if (index >= 0) houses.remove(index);
+            } else {
+                if (index < 0)  houses.add(-index-1, house);
+            }
+            
+            houseModel.notifyAllListeners();
+        }
+    }
+
+//==============================================================================
 
     private class StreetListModel extends HalfCookedComboBoxModel {
@@ -481,6 +463,4 @@
         }
 
-
-
         public int getSize() {
             if (parent == null) return 0;
@@ -491,8 +471,8 @@
             if (parent == null) return;
 
-            selected = parent;
-            this.parent = parent;
+            this.selected = parent;
+            this.parent   = parent;
+            
             metaElem.set(0, parent);
-
             metaElem.get(1).setHouses(parent.getAllHouses());
             notifyAllListeners();
@@ -500,7 +480,5 @@
 
         public Object getElementAt(int index) {
-
             if (parent == null) return null;
-            if (index <  0) return null;
 
             if (index < metaElem.size())
@@ -508,5 +486,5 @@
 
             index -= metaElem.size();
-            // Now the index points to the list of streets
+
             if (index < parent.getStreets().size())
                 return parent.getStreets().get(index);
@@ -526,5 +504,12 @@
     }
 
-    private class HouseListModel extends HalfCookedListModel {
+//==============================================================================
+
+    private class HouseListModel extends HalfCookedListModel
+                                 implements ReasonerListener {
+
+        public HouseListModel() {
+            Reasoner.getInstance().addListener(this);
+        }
 
         public int getSize() {
@@ -549,4 +534,13 @@
             return getHouseAt(index);
         }
+
+        public void primitiveChanged(OsmPrimitive prim) {}
+        public void elementChanged(AddressElement elem) {
+            notifyAllListeners();
+        }
+
+        public void resonerReseted() {
+            notifyAllListeners();
+        }
     }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/GroupManipulatorDialog.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/GroupManipulatorDialog.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/GroupManipulatorDialog.java	(revision 15582)
@@ -1,4 +1,7 @@
 package org.openstreetmap.josm.plugins.czechaddress.gui;
 
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
+import org.openstreetmap.josm.plugins.czechaddress.gui.utils.UniversalTreeRenderer;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -9,4 +12,5 @@
 import org.openstreetmap.josm.plugins.czechaddress.StatusListener;
 import org.openstreetmap.josm.plugins.czechaddress.intelligence.Reasoner;
+import org.openstreetmap.josm.plugins.czechaddress.intelligence.ReasonerListener;
 import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal;
 import org.openstreetmap.josm.plugins.czechaddress.proposal.ProposalContainer;
@@ -25,5 +29,5 @@
  * @see ConflictDatabase
  */
-public class GroupManipulatorDialog extends ExtendedDialog implements StatusListener {
+public class GroupManipulatorDialog extends ExtendedDialog implements ReasonerListener {
 
     private static GroupManipulatorDialog singleton = null;
@@ -33,4 +37,6 @@
         return singleton;
     }
+
+    private ProposalDatabase database = null;
 
     /**
@@ -52,7 +58,4 @@
         setAlwaysOnTop(false);
 
-        // Start receiving plugin-wide messages.
-        CzechAddressPlugin.addStatusListener(this);
-
         // TODO: Why does it always crash if the modality is set in constructor?
         setModal(false);
@@ -63,38 +66,24 @@
         super.buttonAction(evt);
         if (getValue() == 1)
-            ((ProposalDatabase) proposalTree.getModel()).applyAll();
-    }
-
-    public void pluginStatusChanged(int message) {
-        /*if (message == StatusListener.MESSAGE_MATCHES_CHANGED) {
-            int retval = (new ExtendedDialog(Main.parent, "Změna umístění",
-                    "Došlo ke změně v přiřazení databáze.\n" +
-                    "Přejete si znovu načíst seznam navrhovaných změn?",
-                    new String[] {"Ano", "Ne"},
-                    new String[] {"ok.png", "cancel.png"})).getValue();
-
-            if (retval == 1)
-                recreateProposals();
-        }*/
+            database.applyAll();
     }
 
     @Override
-    public void setVisible(boolean b) {
-        if (!isVisible() && b)
+    public void setVisible(boolean visible) {
+
+        if (!isVisible() && visible) {
+            Reasoner.getInstance().addListener(this);
             recreateProposals();
-
-        if (b)
-            CzechAddressPlugin.addStatusListener(this);
-        else
-            CzechAddressPlugin.removeStatusListener(this);
-
-        super.setVisible(b);
+        } else
+            Reasoner.getInstance().removeListener(this);
+
+        super.setVisible(visible);
     }
 
     public void recreateProposals() {
-/*        locationTextField.setText(CzechAddressPlugin.getLocation().toString());
+        locationTextField.setText(CzechAddressPlugin.getLocation().toString());
         
-        Reasoner r = CzechAddressPlugin.getReasoner();
-        proposalTree.setModel(r.getProposals());*/
+        database = Reasoner.getInstance().getProposals();
+        proposalTree.setModel(database);
     }
 
@@ -210,3 +199,25 @@
     // End of variables declaration//GEN-END:variables
 
+    public void elementChanged(AddressElement elem) {
+        for (ProposalContainer container : database.getContainers()) {
+            if (Reasoner.getInstance().translate(elem) == container.getTarget()) {
+                recreateProposals();
+                break;
+            }
+        }
+    }
+
+    public void primitiveChanged(OsmPrimitive prim) {
+        for (ProposalContainer container : database.getContainers()) {
+            if (container.getTarget() == prim) {
+                recreateProposals();
+                break;
+            }
+        }
+    }
+
+    public void resonerReseted() {
+        recreateProposals();
+    }
+
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Inspector.form
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Inspector.form	(revision 15558)
+++ 	(revision )
@@ -1,56 +1,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="2"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-  </SyntheticProperties>
-  <AuxValues>
-    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
-    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-  </AuxValues>
-
-  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
-    <Property name="columns" type="int" value="0"/>
-    <Property name="rows" type="int" value="1"/>
-  </Layout>
-  <SubComponents>
-    <Container class="javax.swing.JPanel" name="mainPanel">
-
-      <Layout>
-        <DimensionLayout dim="0">
-          <Group type="103" groupAlignment="0" attributes="0">
-              <Component id="jScrollPane1" min="-2" pref="400" max="-2" attributes="0"/>
-          </Group>
-        </DimensionLayout>
-        <DimensionLayout dim="1">
-          <Group type="103" groupAlignment="0" attributes="0">
-              <Component id="jScrollPane1" min="-2" pref="300" max="-2" attributes="0"/>
-          </Group>
-        </DimensionLayout>
-      </Layout>
-      <SubComponents>
-        <Container class="javax.swing.JScrollPane" name="jScrollPane1">
-          <AuxValues>
-            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-          </AuxValues>
-
-          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
-          <SubComponents>
-            <Component class="javax.swing.JTree" name="tree">
-            </Component>
-          </SubComponents>
-        </Container>
-      </SubComponents>
-    </Container>
-  </SubComponents>
-</Form>
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Inspector.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Inspector.java	(revision 15558)
+++ 	(revision )
@@ -1,174 +1,0 @@
-package org.openstreetmap.josm.plugins.czechaddress.gui;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.gui.ExtendedDialog;
-import org.openstreetmap.josm.plugins.czechaddress.CzechAddressPlugin;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Database;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Region;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Street;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Suburb;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.ViToCi;
-
-public class Inspector extends ExtendedDialog {
-
-    /** Creates new form Inspector */
-    public Inspector() {
-        super(Main.parent, "Inspektor databáze", new String[] {}, true);
-        initComponents();
-
-        //tree.setModel(new Model());
-        tree.setCellRenderer(new UniversalTreeRenderer());
-
-        // And finalize initializing the form.
-        setupDialog(mainPanel, new String[] {});
-    }
-
-    /*private class Model extends HalfCookedTreeModel {
-
-        @Override
-        public Object getRoot() {
-            return CzechAddressPlugin.database;
-        }
-
-        public Object getChild(Object parent, int index) {
-
-            if (parent instanceof House)
-                return null;
-
-            if (parent instanceof Street)
-                return ((Street) parent).getHouses().get(index);
-
-            if (parent instanceof Suburb) {
-                Suburb suburb = (Suburb) parent;
-
-                if (index< suburb.getHouses().size())
-                    return suburb.getHouses().get(index);
-                else
-                    index -= suburb.getHouses().size();
-
-                if (index< suburb.getStreets().size())
-                    return suburb.getStreets().get(index);
-                else
-                    return null;
-            }
-
-            if (parent instanceof ViToCi) {
-                ViToCi vitoci = (ViToCi) parent;
-
-                if (index< vitoci.getHouses().size())
-                    return vitoci.getHouses().get(index);
-                else
-                    index -= vitoci.getHouses().size();
-
-                if (index< vitoci.getStreets().size())
-                    return vitoci.getStreets().get(index);
-                else
-                    index -= vitoci.getStreets().size();
-
-                if (index< vitoci.getSuburbs().size())
-                    return vitoci.getSuburbs().get(index);
-                else
-                    return null;
-            }
-
-            if (parent instanceof Region) {
-                Region region = (Region) parent;
-
-                if (index< region.getHouses().size())
-                    return region.getHouses().get(index);
-                else
-                    index -= region.getHouses().size();
-
-                if (index< region.getStreets().size())
-                    return region.getStreets().get(index);
-                else
-                    index -= region.getStreets().size();
-
-                if (index< region.getViToCis().size())
-                    return region.getViToCis().get(index);
-                else
-                    return null;
-            }
-
-            if (parent instanceof Database)
-                return ((Database) parent).regions.get(index);
-
-            return null;
-        }
-
-        public int getChildCount(Object parent) {
-
-            if (parent instanceof House)
-                return 0;
-
-            if (parent instanceof Street)
-                return ((Street) parent).getHouses().size();
-
-            if (parent instanceof Suburb)
-                return ((Suburb) parent).getHouses().size() +
-                       ((Suburb) parent).getStreets().size();
-
-            if (parent instanceof ViToCi)
-                return ((ViToCi) parent).getHouses().size() +
-                       ((ViToCi) parent).getStreets().size() +
-                       ((ViToCi) parent).getSuburbs().size();
-
-            if (parent instanceof Region)
-                return ((Region) parent).getHouses().size() +
-                       ((Region) parent).getStreets().size() +
-                       ((Region) parent).getViToCis().size();
-
-            if (parent instanceof Database)
-                return ((Database) parent).regions.size();
-
-            return 0;
-        }
-
-        public int getIndexOfChild(Object parent, Object child) {
-            return 0;
-        }
-        
-    }*/
-
-    /** This method is called from within the constructor to
-     * initialize the form.
-     * WARNING: Do NOT modify this code. The content of this method is
-     * always regenerated by the Form Editor.
-     */
-    @SuppressWarnings("unchecked")
-    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-    private void initComponents() {
-
-        mainPanel = new javax.swing.JPanel();
-        jScrollPane1 = new javax.swing.JScrollPane();
-        tree = new javax.swing.JTree();
-
-        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-        getContentPane().setLayout(new java.awt.GridLayout());
-
-        jScrollPane1.setViewportView(tree);
-
-        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
-        mainPanel.setLayout(mainPanelLayout);
-        mainPanelLayout.setHorizontalGroup(
-            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
-        );
-        mainPanelLayout.setVerticalGroup(
-            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
-        );
-
-        getContentPane().add(mainPanel);
-
-        pack();
-    }// </editor-fold>//GEN-END:initComponents
-
-    // Variables declaration - do not modify//GEN-BEGIN:variables
-    private javax.swing.JScrollPane jScrollPane1;
-    private javax.swing.JPanel mainPanel;
-    private javax.swing.JTree tree;
-    // End of variables declaration//GEN-END:variables
-
-}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.form
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.form	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.form	(revision 15582)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
-<Form version="1.3" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
   <Properties>
     <Property name="title" type="java.lang.String" value="V&#xfd;b&#x11b;r um&#xed;st&#x11b;n&#xed;"/>
     <Property name="modal" type="boolean" value="true"/>
-    <Property name="name" type="java.lang.String" value="locationSelector"/>
+    <Property name="name" type="java.lang.String" value="locationSelector" noResource="true"/>
   </Properties>
   <SyntheticProperties>
@@ -41,7 +41,7 @@
                   <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="1" attributes="0">
-                      <Component id="castObceComboBox" pref="340" max="32767" attributes="0"/>
-                      <Component id="obecComboBox" pref="340" max="32767" attributes="0"/>
-                      <Component id="oblastComboBox" pref="340" max="32767" attributes="0"/>
+                      <Component id="suburbComboBox" pref="341" max="32767" attributes="0"/>
+                      <Component id="vitociComboBox" pref="341" max="32767" attributes="0"/>
+                      <Component id="oblastComboBox" pref="341" max="32767" attributes="0"/>
                   </Group>
               </Group>
@@ -58,10 +58,10 @@
                   <Group type="103" groupAlignment="3" attributes="0">
                       <Component id="obecLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                      <Component id="obecComboBox" alignment="3" min="-2" pref="25" max="-2" attributes="0"/>
+                      <Component id="vitociComboBox" alignment="3" min="-2" pref="25" max="-2" attributes="0"/>
                   </Group>
                   <EmptySpace max="-2" attributes="0"/>
                   <Group type="103" groupAlignment="3" attributes="0">
                       <Component id="castObceLabel" alignment="3" min="-2" max="-2" attributes="0"/>
-                      <Component id="castObceComboBox" alignment="3" min="-2" pref="25" max="-2" attributes="0"/>
+                      <Component id="suburbComboBox" alignment="3" min="-2" pref="25" max="-2" attributes="0"/>
                   </Group>
                   <EmptySpace max="32767" attributes="0"/>
@@ -81,5 +81,5 @@
           </Events>
         </Component>
-        <Component class="javax.swing.JComboBox" name="castObceComboBox">
+        <Component class="javax.swing.JComboBox" name="suburbComboBox">
           <Properties>
             <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
@@ -88,8 +88,8 @@
           </Properties>
           <Events>
-            <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="castObceComboBoxItemStateChanged"/>
+            <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="suburbComboBoxItemStateChanged"/>
           </Events>
         </Component>
-        <Component class="javax.swing.JComboBox" name="obecComboBox">
+        <Component class="javax.swing.JComboBox" name="vitociComboBox">
           <Properties>
             <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
@@ -98,5 +98,5 @@
           </Properties>
           <Events>
-            <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="obecComboBoxItemStateChanged"/>
+            <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="vitociComboBoxItemStateChanged"/>
           </Events>
         </Component>
@@ -113,5 +113,5 @@
         <Component class="javax.swing.JLabel" name="oblastLabel">
           <Properties>
-            <Property name="text" type="java.lang.String" value="Oblast:"/>
+            <Property name="text" type="java.lang.String" value="ORP:"/>
           </Properties>
         </Component>
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java	(revision 15582)
@@ -1,6 +1,6 @@
 package org.openstreetmap.josm.plugins.czechaddress.gui;
 
-import org.openstreetmap.josm.plugins.czechaddress.*;
 import java.awt.Component;
+import java.awt.Font;
 import java.util.ArrayList;
 
@@ -55,6 +55,6 @@
 
         oblastComboBox.setRenderer(new AddressElementRenderer());
-        obecComboBox.setRenderer(new AddressElementRenderer());
-        castObceComboBox.setRenderer(new AddressElementRenderer());
+        vitociComboBox.setRenderer(new AddressElementRenderer());
+        suburbComboBox.setRenderer(new SuburbRenderer());
 
         oblastComboBox.setModel(new DefaultComboBoxModel(
@@ -146,8 +146,8 @@
                         if (obec.getName().toUpperCase().equals(bestFit.get("name").toUpperCase())) {
                             oblastComboBox.setSelectedItem(oblast);
-                            obecComboBox.setSelectedItem(obec);
+                            vitociComboBox.setSelectedItem(obec);
                             for (Suburb castObce : obec.getSuburbs()) {
                                 if (castObce.getName().toUpperCase().equals(bestFit.get("name").toUpperCase())) {
-                                    castObceComboBox.setSelectedItem(castObce);
+                                    suburbComboBox.setSelectedItem(castObce);
                                     break;
                                 }
@@ -159,6 +159,6 @@
                             if (castObce.getName().toUpperCase().equals(bestFit.get("name").toUpperCase())) {
                                 oblastComboBox.setSelectedItem(oblast);
-                                obecComboBox.setSelectedItem(obec);
-                                castObceComboBox.setSelectedItem(castObce);
+                                vitociComboBox.setSelectedItem(obec);
+                                suburbComboBox.setSelectedItem(castObce);
                                 break;
                             }
@@ -176,19 +176,20 @@
      */
     @SuppressWarnings("unchecked")
-    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
     private void initComponents() {
+
         mainPanel = new javax.swing.JPanel();
         oblastComboBox = new javax.swing.JComboBox();
-        castObceComboBox = new javax.swing.JComboBox();
-        obecComboBox = new javax.swing.JComboBox();
+        suburbComboBox = new javax.swing.JComboBox();
+        vitociComboBox = new javax.swing.JComboBox();
         obecLabel = new javax.swing.JLabel();
         castObceLabel = new javax.swing.JLabel();
         oblastLabel = new javax.swing.JLabel();
 
+        setTitle("Výběr umístění");
+        setModal(true);
+        setName("locationSelector"); // NOI18N
         getContentPane().setLayout(new java.awt.GridLayout(1, 0));
 
-        setTitle("V\u00fdb\u011br um\u00edst\u011bn\u00ed");
-        setModal(true);
-        setName("locationSelector");
         oblastComboBox.addItemListener(new java.awt.event.ItemListener() {
             public void itemStateChanged(java.awt.event.ItemEvent evt) {
@@ -197,13 +198,13 @@
         });
 
-        castObceComboBox.addItemListener(new java.awt.event.ItemListener() {
+        suburbComboBox.addItemListener(new java.awt.event.ItemListener() {
             public void itemStateChanged(java.awt.event.ItemEvent evt) {
-                castObceComboBoxItemStateChanged(evt);
+                suburbComboBoxItemStateChanged(evt);
             }
         });
 
-        obecComboBox.addItemListener(new java.awt.event.ItemListener() {
+        vitociComboBox.addItemListener(new java.awt.event.ItemListener() {
             public void itemStateChanged(java.awt.event.ItemEvent evt) {
-                obecComboBoxItemStateChanged(evt);
+                vitociComboBoxItemStateChanged(evt);
             }
         });
@@ -211,7 +212,7 @@
         obecLabel.setText("Obec:");
 
-        castObceLabel.setText("\u010c\u00e1st obce:");
-
-        oblastLabel.setText("Oblast:");
+        castObceLabel.setText("Část obce:");
+
+        oblastLabel.setText("ORP:");
 
         javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
@@ -226,7 +227,7 @@
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
-                    .addComponent(castObceComboBox, 0, 340, Short.MAX_VALUE)
-                    .addComponent(obecComboBox, 0, 340, Short.MAX_VALUE)
-                    .addComponent(oblastComboBox, 0, 340, Short.MAX_VALUE)))
+                    .addComponent(suburbComboBox, 0, 341, Short.MAX_VALUE)
+                    .addComponent(vitociComboBox, 0, 341, Short.MAX_VALUE)
+                    .addComponent(oblastComboBox, 0, 341, Short.MAX_VALUE)))
         );
         mainPanelLayout.setVerticalGroup(
@@ -239,13 +240,13 @@
                 .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(obecLabel)
-                    .addComponent(obecComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(vitociComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(castObceLabel)
-                    .addComponent(castObceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(suburbComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
+
         getContentPane().add(mainPanel);
-
     }// </editor-fold>//GEN-END:initComponents
 
@@ -278,22 +279,28 @@
         if (oblast == null) return;
 
-        obecComboBox.setModel(new DefaultComboBoxModel(oblast.getViToCis().toArray()));
-        obecComboBox.setEnabled(obecComboBox.getModel().getSize() > 1);
-
-        obecComboBoxItemStateChanged(null);
+        vitociComboBox.setModel(new DefaultComboBoxModel(oblast.getViToCis().toArray()));
+        vitociComboBox.setEnabled(vitociComboBox.getModel().getSize() > 1);
+        vitociComboBoxItemStateChanged(null);
     }//GEN-LAST:event_oblastComboBoxItemStateChanged
 
-    private void obecComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_obecComboBoxItemStateChanged
-
-        ViToCi obec = (ViToCi) obecComboBox.getSelectedItem();
+    private void vitociComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vitociComboBoxItemStateChanged
+
+        ViToCi obec = (ViToCi) vitociComboBox.getSelectedItem();
         if (obec == null) return;
 
-        castObceComboBox.setModel(new DefaultComboBoxModel(obec.getSuburbs().toArray()));
-        castObceComboBox.setEnabled(castObceComboBox.getModel().getSize() > 1);
-
-        castObceComboBoxItemStateChanged(null);
-    }//GEN-LAST:event_obecComboBoxItemStateChanged
-
-        private void castObceComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_castObceComboBoxItemStateChanged
+        if (obec.getSuburbs().size() > 0) {
+            Object[] suburbs = new Object[obec.getSuburbs().size() + 1];
+            suburbs[0] = obec;
+            for (int i=0; i<obec.getSuburbs().size(); i++)
+                suburbs[i+1] = obec.getSuburbs().get(i);
+            suburbComboBox.setModel(new DefaultComboBoxModel(suburbs));
+        } else
+            suburbComboBox.setModel(new DefaultComboBoxModel());
+
+        suburbComboBox.setEnabled(suburbComboBox.getModel().getSize() > 1);
+        suburbComboBoxItemStateChanged(null);
+    }//GEN-LAST:event_vitociComboBoxItemStateChanged
+
+        private void suburbComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_suburbComboBoxItemStateChanged
 
         /*if (castObceComboBox.getSelectedItem() != null)
@@ -306,27 +313,26 @@
             checkSetSelected((ElementWithStreets) oblastComboBox.getSelectedItem());*/
 
-        if (castObceComboBox.getSelectedItem() != null)
-            selectedElement = ((ElementWithStreets) castObceComboBox.getSelectedItem());
-
-        else if (obecComboBox.getSelectedItem() != null)
-            selectedElement = ((ElementWithStreets) obecComboBox.getSelectedItem());
+        if (suburbComboBox.getSelectedItem() != null)
+            selectedElement = ((ElementWithStreets) suburbComboBox.getSelectedItem());
+
+        else if (vitociComboBox.getSelectedItem() != null)
+            selectedElement = ((ElementWithStreets) vitociComboBox.getSelectedItem());
 
         else if (oblastComboBox.getSelectedItem() != null)
             selectedElement = ((ElementWithStreets) oblastComboBox.getSelectedItem());
         
-        }//GEN-LAST:event_castObceComboBoxItemStateChanged
+        }//GEN-LAST:event_suburbComboBoxItemStateChanged
 
     // Variables declaration - do not modify//GEN-BEGIN:variables
-    private javax.swing.JComboBox castObceComboBox;
     private javax.swing.JLabel castObceLabel;
     private javax.swing.JPanel mainPanel;
-    private javax.swing.JComboBox obecComboBox;
     private javax.swing.JLabel obecLabel;
     private javax.swing.JComboBox oblastComboBox;
     private javax.swing.JLabel oblastLabel;
+    private javax.swing.JComboBox suburbComboBox;
+    private javax.swing.JComboBox vitociComboBox;
     // End of variables declaration//GEN-END:variables
 
     private class AddressElementRenderer extends DefaultListCellRenderer {
-
         @Override
         public Component getListCellRendererComponent(
@@ -334,5 +340,6 @@
                     boolean isSelected, boolean cellHasFocus) {
 
-            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+            Component c = super.getListCellRendererComponent(list, value, index,
+                                                      isSelected, cellHasFocus);
 
             if (value instanceof AddressElement && !(value instanceof Region))
@@ -342,3 +349,20 @@
         }
     }
+
+    private class SuburbRenderer extends AddressElementRenderer {
+        @Override
+        public Component getListCellRendererComponent(JList list, Object value,
+                          int index, boolean isSelected, boolean cellHasFocus) {
+            Component c = super.getListCellRendererComponent(list, value,
+                                               index, isSelected, cellHasFocus);
+
+            if (value instanceof ViToCi) {
+                setFont(getFont().deriveFont(Font.BOLD));
+                setText(((ViToCi) value).getName() + ", všechny části obce");
+            } else
+                setFont(getFont().deriveFont(Font.PLAIN));
+
+            return c;
+        }
+    }
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.form
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.form	(revision 15582)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.form	(revision 15582)
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <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,1,-84,0,0,1,-74"/>
+  </AuxValues>
+
+  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
+    <Property name="columns" type="int" value="0"/>
+    <Property name="rows" type="int" value="1"/>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="mainPanel">
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
+        <Property name="columns" type="int" value="0"/>
+        <Property name="rows" type="int" value="1"/>
+      </Layout>
+      <SubComponents>
+        <Container class="javax.swing.JTabbedPane" name="tabbedPane">
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
+          <SubComponents>
+            <Container class="javax.swing.JPanel" name="jPanel1">
+              <Constraints>
+                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
+                  <JTabbedPaneConstraints tabName="N&#xe1;vrhy na p&#x159;ejmenov&#xe1;n&#xed;">
+                    <Property name="tabTitle" type="java.lang.String" value="N&#xe1;vrhy na p&#x159;ejmenov&#xe1;n&#xed;"/>
+                  </JTabbedPaneConstraints>
+                </Constraint>
+              </Constraints>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="1" attributes="0">
+                          <EmptySpace pref="253" max="32767" attributes="0"/>
+                          <Component id="renamerButton" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                      </Group>
+                      <Component id="streetScrollPane" alignment="0" pref="426" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="1" attributes="0">
+                          <Component id="streetScrollPane" pref="342" max="32767" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="renamerButton" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Container class="javax.swing.JScrollPane" name="streetScrollPane">
+                  <AuxValues>
+                    <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+                  </AuxValues>
+
+                  <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+                  <SubComponents>
+                    <Component class="javax.swing.JTable" name="renameTable">
+                      <Properties>
+                        <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+                          <Table columnCount="2" rowCount="4">
+                            <Column editable="false" title="P&#x16f;vodn&#xed; n&#xe1;zev" type="java.lang.Object"/>
+                            <Column editable="true" title="N&#xe1;vrh z mapy" type="java.lang.String"/>
+                          </Table>
+                        </Property>
+                        <Property name="columnSelectionAllowed" type="boolean" value="true"/>
+                        <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
+                          <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
+                        </Property>
+                      </Properties>
+                    </Component>
+                  </SubComponents>
+                </Container>
+                <Component class="javax.swing.JButton" name="renamerButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Pou&#x17e;&#xed;t navr&#x17e;en&#xe9; zm&#x11b;ny"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="renamerButtonActionPerformed"/>
+                  </Events>
+                </Component>
+              </SubComponents>
+            </Container>
+            <Container class="javax.swing.JPanel" name="jPanel2">
+              <Constraints>
+                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
+                  <JTabbedPaneConstraints tabName="Inspektor datab&#xe1;ze">
+                    <Property name="tabTitle" type="java.lang.String" value="Inspektor datab&#xe1;ze"/>
+                  </JTabbedPaneConstraints>
+                </Constraint>
+              </Constraints>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="jScrollPane1" alignment="0" pref="426" max="32767" attributes="0"/>
+                      <Group type="102" alignment="1" attributes="0">
+                          <EmptySpace pref="356" max="32767" attributes="0"/>
+                          <Component id="dbEditButton" min="-2" max="-2" attributes="0"/>
+                          <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">
+                          <Component id="jScrollPane1" pref="342" max="32767" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="dbEditButton" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+                  <AuxValues>
+                    <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+                  </AuxValues>
+
+                  <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+                  <SubComponents>
+                    <Component class="javax.swing.JTree" name="dbTree">
+                      <Events>
+                        <EventHandler event="valueChanged" listener="javax.swing.event.TreeSelectionListener" parameters="javax.swing.event.TreeSelectionEvent" handler="dbTreeValueChanged"/>
+                      </Events>
+                    </Component>
+                  </SubComponents>
+                </Container>
+                <Component class="javax.swing.JButton" name="dbEditButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Upravit"/>
+                    <Property name="enabled" type="boolean" value="false"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="dbEditButtonActionPerformed"/>
+                  </Events>
+                </Component>
+              </SubComponents>
+            </Container>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.java	(revision 15582)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ManagerDialog.java	(revision 15582)
@@ -0,0 +1,410 @@
+package org.openstreetmap.josm.plugins.czechaddress.gui;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableModel;
+import org.openstreetmap.josm.plugins.czechaddress.gui.utils.UniversalTreeRenderer;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.plugins.czechaddress.CzechAddressPlugin;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Database;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Region;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Street;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Suburb;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.ViToCi;
+import org.openstreetmap.josm.plugins.czechaddress.gui.databaseeditors.StreetEditor;
+import org.openstreetmap.josm.plugins.czechaddress.intelligence.Capitalizator;
+import org.openstreetmap.josm.plugins.czechaddress.intelligence.Reasoner;
+
+public class ManagerDialog extends ExtendedDialog {
+
+    RenameModel<Street> streetModel = new RenameModel<Street>();
+
+    public ManagerDialog() {
+        super(Main.parent, "Inspektor databáze", new String[] {}, true);
+        initComponents();
+
+        dbTree.setModel(new DatabaseModel());
+        dbTree.setCellRenderer(new UniversalTreeRenderer());
+
+        Capitalizator cap = new Capitalizator(
+                                Main.ds.allPrimitives(),
+                                CzechAddressPlugin.getLocation().getStreets());
+
+        for (Street capStreet : cap.getCapitalised()) {
+            assert cap.translate(capStreet).get("name") != null : capStreet;
+
+            String elemName = capStreet.getName();
+            String primName = cap.translate(capStreet).get("name");
+
+            if (!elemName.equals(primName)) {
+                streetModel.elems.add(capStreet);
+                streetModel.names.add(primName);
+            }
+        }
+
+        renameTable.setModel(streetModel);
+        renameTable.setDefaultRenderer( AddressElement.class,
+                                        new AddressElementRenderer());
+        renameTable.setDefaultRenderer( String.class,
+                                        new AddressElementRenderer());
+
+        // And finalize initializing the form.
+        setupDialog(mainPanel, new String[] {});
+    }
+
+    public int countAutomaticRenameProposals() {
+        return streetModel.getRowCount();
+    }
+
+    private class DatabaseModel extends HalfCookedTreeModel {
+
+        @Override
+        public Object getRoot() {
+            return CzechAddressPlugin.getLocation();
+        }
+
+        public Object getChild(Object parent, int index) {
+
+            if (parent instanceof House)
+                return null;
+
+            if (parent instanceof Street)
+                return ((Street) parent).getHouses().get(index);
+
+            if (parent instanceof Suburb) {
+                Suburb suburb = (Suburb) parent;
+
+                if (index< suburb.getHouses().size())
+                    return suburb.getHouses().get(index);
+                else
+                    index -= suburb.getHouses().size();
+
+                if (index< suburb.getStreets().size())
+                    return suburb.getStreets().get(index);
+                else
+                    return null;
+            }
+
+            if (parent instanceof ViToCi) {
+                ViToCi vitoci = (ViToCi) parent;
+
+                if (index< vitoci.getHouses().size())
+                    return vitoci.getHouses().get(index);
+                else
+                    index -= vitoci.getHouses().size();
+
+                if (index< vitoci.getStreets().size())
+                    return vitoci.getStreets().get(index);
+                else
+                    index -= vitoci.getStreets().size();
+
+                if (index< vitoci.getSuburbs().size())
+                    return vitoci.getSuburbs().get(index);
+                else
+                    return null;
+            }
+
+            if (parent instanceof Region) {
+                Region region = (Region) parent;
+
+                if (index< region.getHouses().size())
+                    return region.getHouses().get(index);
+                else
+                    index -= region.getHouses().size();
+
+                if (index< region.getStreets().size())
+                    return region.getStreets().get(index);
+                else
+                    index -= region.getStreets().size();
+
+                if (index< region.getViToCis().size())
+                    return region.getViToCis().get(index);
+                else
+                    return null;
+            }
+
+            if (parent instanceof Database)
+                return ((Database) parent).regions.get(index);
+
+            return null;
+        }
+
+        public int getChildCount(Object parent) {
+
+            if (parent instanceof House)
+                return 0;
+
+            if (parent instanceof Street)
+                return ((Street) parent).getHouses().size();
+
+            if (parent instanceof Suburb)
+                return ((Suburb) parent).getHouses().size() +
+                       ((Suburb) parent).getStreets().size();
+
+            if (parent instanceof ViToCi)
+                return ((ViToCi) parent).getHouses().size() +
+                       ((ViToCi) parent).getStreets().size() +
+                       ((ViToCi) parent).getSuburbs().size();
+
+            if (parent instanceof Region)
+                return ((Region) parent).getHouses().size() +
+                       ((Region) parent).getStreets().size() +
+                       ((Region) parent).getViToCis().size();
+
+            if (parent instanceof Database)
+                return ((Database) parent).regions.size();
+
+            return 0;
+        }
+
+        public int getIndexOfChild(Object parent, Object child) {
+            return 0;
+        }
+        
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        mainPanel = new javax.swing.JPanel();
+        tabbedPane = new javax.swing.JTabbedPane();
+        jPanel1 = new javax.swing.JPanel();
+        streetScrollPane = new javax.swing.JScrollPane();
+        renameTable = new javax.swing.JTable();
+        renamerButton = new javax.swing.JButton();
+        jPanel2 = new javax.swing.JPanel();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        dbTree = new javax.swing.JTree();
+        dbEditButton = new javax.swing.JButton();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        getContentPane().setLayout(new java.awt.GridLayout(1, 0));
+
+        mainPanel.setLayout(new java.awt.GridLayout(1, 0));
+
+        renameTable.setModel(new javax.swing.table.DefaultTableModel(
+            new Object [][] {
+                {null, null},
+                {null, null},
+                {null, null},
+                {null, null}
+            },
+            new String [] {
+                "Původní název", "Návrh z mapy"
+            }
+        ) {
+            Class[] types = new Class [] {
+                java.lang.Object.class, java.lang.String.class
+            };
+            boolean[] canEdit = new boolean [] {
+                false, true
+            };
+
+            public Class getColumnClass(int columnIndex) {
+                return types [columnIndex];
+            }
+
+            public boolean isCellEditable(int rowIndex, int columnIndex) {
+                return canEdit [columnIndex];
+            }
+        });
+        renameTable.setColumnSelectionAllowed(true);
+        streetScrollPane.setViewportView(renameTable);
+
+        renamerButton.setText("Použít navržené změny");
+        renamerButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                renamerButtonActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+        jPanel1.setLayout(jPanel1Layout);
+        jPanel1Layout.setHorizontalGroup(
+            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+                .addContainerGap(253, Short.MAX_VALUE)
+                .addComponent(renamerButton)
+                .addContainerGap())
+            .addComponent(streetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
+        );
+        jPanel1Layout.setVerticalGroup(
+            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+                .addComponent(streetScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(renamerButton)
+                .addContainerGap())
+        );
+
+        tabbedPane.addTab("Návrhy na přejmenování", jPanel1);
+
+        dbTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
+            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
+                dbTreeValueChanged(evt);
+            }
+        });
+        jScrollPane1.setViewportView(dbTree);
+
+        dbEditButton.setText("Upravit");
+        dbEditButton.setEnabled(false);
+        dbEditButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                dbEditButtonActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+        jPanel2.setLayout(jPanel2Layout);
+        jPanel2Layout.setHorizontalGroup(
+            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
+                .addContainerGap(356, Short.MAX_VALUE)
+                .addComponent(dbEditButton)
+                .addContainerGap())
+        );
+        jPanel2Layout.setVerticalGroup(
+            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
+                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(dbEditButton)
+                .addContainerGap())
+        );
+
+        tabbedPane.addTab("Inspektor databáze", jPanel2);
+
+        mainPanel.add(tabbedPane);
+
+        getContentPane().add(mainPanel);
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void renamerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_renamerButtonActionPerformed
+        assert streetModel.elems.size() == streetModel.names.size();
+        Reasoner r = Reasoner.getInstance();
+
+        synchronized (r) {
+            r.openTransaction();
+            for(int i=0; i<streetModel.elems.size(); i++) {
+                streetModel.elems.get(i).setName(streetModel.names.get(i));
+                r.update(streetModel.elems.get(i));
+            }
+            r.closeTransaction();
+        }
+
+        streetModel.elems.clear();
+        streetModel.names.clear();
+        jPanel1.setVisible(false);
+    }//GEN-LAST:event_renamerButtonActionPerformed
+
+    private AddressElement dbTreeValue = null;
+
+    private void dbTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_dbTreeValueChanged
+        dbTreeValue = (AddressElement) dbTree.getSelectionPath().getLastPathComponent();
+        dbEditButton.setEnabled(dbTreeValue instanceof Street);
+    }//GEN-LAST:event_dbTreeValueChanged
+
+    private void dbEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbEditButtonActionPerformed
+        if (dbTreeValue instanceof Street)
+            if (StreetEditor.editStreet((Street) dbTreeValue))
+                dbTree.repaint();
+    }//GEN-LAST:event_dbEditButtonActionPerformed
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton dbEditButton;
+    private javax.swing.JTree dbTree;
+    private javax.swing.JPanel jPanel1;
+    private javax.swing.JPanel jPanel2;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JPanel mainPanel;
+    private javax.swing.JTable renameTable;
+    private javax.swing.JButton renamerButton;
+    private javax.swing.JScrollPane streetScrollPane;
+    private javax.swing.JTabbedPane tabbedPane;
+    // End of variables declaration//GEN-END:variables
+
+    private class AddressElementRenderer extends DefaultTableCellRenderer {
+
+        public AddressElementRenderer() {}
+
+        @Override
+        protected void setValue(Object value) {
+            super.setValue(value);
+
+            if (value instanceof AddressElement)
+                setText(((AddressElement) value).getName() );
+        }
+    }
+
+    private class RenameModel<Element> implements TableModel {
+
+        List<Element> elems = new ArrayList<Element>();
+        List<String>  names = new ArrayList<String>();
+
+        public int getRowCount() {
+            assert elems.size() == names.size();
+            return elems.size();
+        }
+
+        public int getColumnCount() {
+            return 2;
+        }
+
+        public String getColumnName(int columnIndex) {
+            if (columnIndex == 0) return "Původní název";
+            if (columnIndex == 1) return "Navržený název";
+            assert false : columnIndex;
+            return null;
+        }
+
+        public Class<?> getColumnClass(int columnIndex) {
+            if (columnIndex == 0) return AddressElement.class;
+            if (columnIndex == 1) return String.class;
+            assert false : columnIndex;
+            return null;
+        }
+
+        public boolean isCellEditable(int rowIndex, int columnIndex) {
+            return columnIndex == 1;
+        }
+
+        public Object getValueAt(int rowIndex, int columnIndex) {
+            if (columnIndex == 0) return elems.get(rowIndex);
+            if (columnIndex == 1) return names.get(rowIndex);
+            assert false : columnIndex;
+            return null;
+        }
+
+        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+            assert columnIndex == 1;
+            names.set(rowIndex, (String) aValue);
+        }
+
+        public void addTableModelListener(TableModelListener l) {
+
+        }
+
+        public void removeTableModelListener(TableModelListener l) {
+
+        }
+    }
+}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.form
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.form	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.form	(revision 15582)
@@ -22,5 +22,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,1,11,0,0,1,-79"/>
+    <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,21,0,0,1,-79"/>
   </AuxValues>
 
@@ -49,12 +49,9 @@
                       </Group>
                       <Component id="alternateNumberEdit" alignment="0" pref="293" max="32767" attributes="0"/>
-                      <Group type="102" alignment="1" attributes="0">
-                          <Component id="matchesComboBox" pref="186" max="32767" attributes="0"/>
-                          <EmptySpace max="-2" attributes="0"/>
-                          <Component id="ensureConsistencyButton" min="-2" max="-2" attributes="0"/>
-                      </Group>
+                      <Component id="matchesComboBox" alignment="0" pref="293" max="32767" attributes="0"/>
                   </Group>
               </Group>
-              <Component id="jScrollPane1" alignment="1" pref="433" max="32767" attributes="0"/>
+              <Component id="statusLabel" alignment="0" pref="433" max="32767" attributes="0"/>
+              <Component id="jScrollPane1" alignment="0" pref="433" max="32767" attributes="0"/>
           </Group>
         </DimensionLayout>
@@ -76,11 +73,9 @@
                       <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
                       <Component id="matchesComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
-                      <Component id="ensureConsistencyButton" alignment="3" min="-2" max="-2" attributes="0"/>
                   </Group>
-                  <EmptySpace pref="176" max="32767" attributes="0"/>
-              </Group>
-              <Group type="102" alignment="0" attributes="0">
-                  <EmptySpace min="-2" pref="92" max="-2" attributes="0"/>
-                  <Component id="jScrollPane1" pref="175" max="32767" attributes="0"/>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="jScrollPane1" pref="161" max="32767" attributes="0"/>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="statusLabel" min="-2" max="-2" attributes="0"/>
               </Group>
           </Group>
@@ -154,17 +149,8 @@
           </Properties>
         </Component>
-        <Component class="javax.swing.JButton" name="ensureConsistencyButton">
+        <Component class="javax.swing.JLabel" name="statusLabel">
           <Properties>
-            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
-              <Connection code="ImageProvider.get(&quot;actions&quot;, &quot;refresh-small.png&quot;)" type="code"/>
-            </Property>
-            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
-              <Connection code="&quot;&quot;" type="code"/>
-            </Property>
-            <Property name="toolTipText" type="java.lang.String" value="Provede nov&#xe9; p&#x159;i&#x159;azen&#xed; prvk&#x16f; mapy na elementy datab&#xe1;ze.&#xa;Touto volbou se zru&#x161;&#xed; v&#x161;echny manu&#xe1;ln&#x11b; vy&#x159;e&#x161;en&#xe9; konflikty."/>
+            <Property name="text" type="java.lang.String" value=" "/>
           </Properties>
-          <Events>
-            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ensureConsistencyButtonActionPerformed"/>
-          </Events>
         </Component>
       </SubComponents>
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.java	(revision 15582)
@@ -1,14 +1,10 @@
 package org.openstreetmap.josm.plugins.czechaddress.gui;
 
-import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.util.List;
 import java.util.Map;
-import javax.swing.JList;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.ImageIcon;
 import javax.swing.Timer;
 import org.openstreetmap.josm.Main;
@@ -21,9 +17,8 @@
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
-import org.openstreetmap.josm.plugins.czechaddress.intelligence.Match;
+import org.openstreetmap.josm.plugins.czechaddress.gui.utils.UniversalListRenderer;
 import org.openstreetmap.josm.plugins.czechaddress.intelligence.Reasoner;
 import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal;
 import org.openstreetmap.josm.plugins.czechaddress.proposal.ProposalContainer;
-import org.openstreetmap.josm.plugins.czechaddress.proposal.ProposalListPainter;
 import org.openstreetmap.josm.tools.ImageProvider;
 
@@ -55,5 +50,4 @@
         // Create action for delaying the database query...
         updateMatchesAction = new AbstractAction() {
-            boolean shouldDraw = false;
             public void actionPerformed(ActionEvent e) {
                 updateMatches();
@@ -68,9 +62,9 @@
         proposalContainer = new ProposalContainer(primitive);
         proposalList.setModel(proposalContainer);
-        proposalList.setCellRenderer(new ProposalListPainter());
+        proposalList.setCellRenderer(new UniversalListRenderer());
 
         // Init the "match" combobox.
         matchesComboBox.setModel(new MatchesComboBoxModel());
-        matchesComboBox.setRenderer(new MatchesComboBoxPainter());
+        matchesComboBox.setRenderer(new UniversalListRenderer());
 
         if (primitive.get("addr:alternatenumber") != null) {
@@ -91,5 +85,5 @@
     protected void buttonAction(ActionEvent evt) {
         super.buttonAction(evt);
-/*        if (getValue() == 1) {
+        if (getValue() == 1) {
             
             if (updateMatchesTimer.isRunning()) {
@@ -103,10 +97,14 @@
             Main.ds.setSelected(proposalContainer.getTarget());
             
-            Reasoner r = CzechAddressPlugin.getReasoner();
-            Match    m = (Match) matchesComboBox.getSelectedItem();
-            if (m != null) {
-                r.overwriteMatch(m.elem, m.prim);
-            }
-        }*/
+            AddressElement elem = (AddressElement) matchesComboBox.getSelectedItem();
+            if (elem != null) {
+                Reasoner r = Reasoner.getInstance();
+                synchronized (r) {
+                    r.openTransaction();
+                    r.doOverwrite(proposalContainer.getTarget(), elem);
+                    r.closeTransaction();
+                }
+            }
+        }
 
         CzechAddressPlugin.removeStatusListener(this);
@@ -125,26 +123,27 @@
     public void updateMatches() {
         
-/*        if (proposalContainer.getTarget().deleted) {
+        if (proposalContainer.getTarget().deleted)
             setVisible(false);
+        OsmPrimitive prim = this.proposalContainer.getTarget();
+        Reasoner r = Reasoner.getInstance();
+        List<AddressElement> elems = new NotNullList<AddressElement>();
+
+        synchronized (r) {
+            Map<String,String> backup = prim.keys;
+            r.openTransaction();
+            prim.keys = null;
+            prim.put("addr:alternatenumber", alternateNumberEdit.getText());
+            r.update(prim);
+            elems.addAll(r.getCandidates(prim));
+            prim.keys = backup;
+            r.update(prim);
+            r.closeTransaction();
         }
         
-        OsmPrimitive prim = this.proposalContainer.getTarget();
-        
-        Map<String,String> backup = prim.keys; 
-        prim.keys = null;
-        prim.put("addr:alternatenumber", alternateNumberEdit.getText());
-        
-        Reasoner r = CzechAddressPlugin.getReasoner();
-        NotNullList<Match> matches = r.getMatchesForPrimitive(prim);
-
-        prim.keys = backup;
-        
-        // TODO: Here we should sort matches according to their quality.
-
         MatchesComboBoxModel matchesModel =
                 ((MatchesComboBoxModel) matchesComboBox.getModel());
 
         // Fill the combobox with suitable houses.
-        matchesModel.setMatches(matches);
+        matchesModel.setElements(elems);
         if (matchesModel.getSize() > 0) {
             matchesComboBox.setSelectedIndex(0);
@@ -156,5 +155,5 @@
         fakeHouse.setParent(CzechAddressPlugin.getLocation());
         proposalContainer.setProposals(
-                fakeHouse.getDiff(proposalContainer.getTarget()));*/
+                fakeHouse.getDiff(proposalContainer.getTarget()));
     }
 
@@ -162,13 +161,8 @@
 
         // If location changes, we block the dialog until reasoning is done.
-/*        if (message == MESSAGE_LOCATION_CHANGED) {
+        if (message == MESSAGE_LOCATION_CHANGED) {
             updateLocation();
             mainPanel.setEnabled(false);
-
-        // When reasoning is done, dialog gets enabled and new proposals are added.
-        } else if (message == MESSAGE_MATCHES_CHANGED) {
-            updateMatches();
-            mainPanel.setEnabled(true);
-        }*/
+        }
     }
 
@@ -195,5 +189,5 @@
         matchesComboBox = new javax.swing.JComboBox();
         jLabel6 = new javax.swing.JLabel();
-        ensureConsistencyButton = new javax.swing.JButton();
+        statusLabel = new javax.swing.JLabel();
 
         jLabel4.setText("jLabel4");
@@ -238,12 +232,5 @@
         jLabel6.setText("Zaznam v databazi:");
 
-        ensureConsistencyButton.setIcon(ImageProvider.get("actions", "refresh-small.png"));
-        ensureConsistencyButton.setText("");
-        ensureConsistencyButton.setToolTipText("Provede nové přiřazení prvků mapy na elementy databáze.\nTouto volbou se zruší všechny manuálně vyřešené konflikty."); // NOI18N
-        ensureConsistencyButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                ensureConsistencyButtonActionPerformed(evt);
-            }
-        });
+        statusLabel.setText(" ");
 
         javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
@@ -259,14 +246,11 @@
                 .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
-                        .addComponent(locationEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
+                        .addComponent(locationEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                         .addComponent(changeLocationButton))
-                    .addComponent(alternateNumberEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
-                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
-                        .addComponent(matchesComboBox, 0, 208, Short.MAX_VALUE)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(ensureConsistencyButton))))
-            .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE))
+                    .addComponent(alternateNumberEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
+                    .addComponent(matchesComboBox, 0, 293, Short.MAX_VALUE)))
+            .addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
+            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
         );
         mainPanelLayout.setVerticalGroup(
@@ -284,11 +268,9 @@
                 .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jLabel6)
-                    .addComponent(matchesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addComponent(ensureConsistencyButton))
-                .addContainerGap(179, Short.MAX_VALUE))
-            .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                .addGroup(mainPanelLayout.createSequentialGroup()
-                    .addGap(92, 92, 92)
-                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)))
+                    .addComponent(matchesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(statusLabel))
         );
 
@@ -319,13 +301,10 @@
 
         if (matchesComboBox.getSelectedItem() == null) return;        
-        Match match = (Match) matchesComboBox.getSelectedItem();
-
-        proposalContainer.setProposals(match.elem.getDiff(
+        AddressElement selectedElement
+                           = (AddressElement) matchesComboBox.getSelectedItem();
+
+        proposalContainer.setProposals(selectedElement.getDiff(
                                                 proposalContainer.getTarget()));
     }//GEN-LAST:event_matchChanged
-
-    private void ensureConsistencyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ensureConsistencyButtonActionPerformed
-//        CzechAddressPlugin.getReasoner().ensureConsistency();
-    }//GEN-LAST:event_ensureConsistencyButtonActionPerformed
 
 
@@ -333,5 +312,4 @@
     private javax.swing.JTextField alternateNumberEdit;
     private javax.swing.JButton changeLocationButton;
-    private javax.swing.JButton ensureConsistencyButton;
     private javax.swing.JLabel jLabel1;
     private javax.swing.JLabel jLabel4;
@@ -343,51 +321,18 @@
     private javax.swing.JComboBox matchesComboBox;
     private javax.swing.JList proposalList;
+    private javax.swing.JLabel statusLabel;
     // End of variables declaration//GEN-END:variables
 
     /**
-     * Painter for adding icons to the {@code matchesComboBox}.
-     */
-    private class MatchesComboBoxPainter extends DefaultListCellRenderer {
-
-        ImageIcon envelopeNormIcon = ImageProvider.get("envelope-closed-small.png");
-        ImageIcon envelopeStarIcon = ImageProvider.get("envelope-closed-star-small.png");
-        ImageIcon envelopeExclIcon = ImageProvider.get("envelope-closed-exclamation-small.png");
-
-        @Override
-        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
-            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-
-/*            Reasoner r = CzechAddressPlugin.getReasoner();
-            setIcon(null);
-
-            if (value instanceof Match) {
-                Match match = (Match) value;
-
-                setText(AddressElement.getName(match.elem));
-
-                if (match.elem instanceof House) {
-                    setIcon(envelopeStarIcon);
-                    if ( r.conflicts(match.elem) != null )
-                        setIcon(envelopeExclIcon);
-                    else if ( r.translate(match.elem) != null)
-                        setIcon(envelopeNormIcon);
-                }
-            }*/
-
-            return c;
-        }
-    }
-
-    /**
      * Container for all Houses, which match the given 'alternatenumber'.
      */
     private class MatchesComboBoxModel extends HalfCookedComboBoxModel {
 
-        private List<Match> matches = null;
-        int selectedIndex = -1;
-
-        public void setMatches(List<Match> matches) {
-            this.matches = matches;
-            selectedIndex = -1;
+        private List<AddressElement> matches = null;
+        AddressElement selected = null;
+
+        public void setElements(List<AddressElement> elements) {
+            this.matches = elements;
+            selected = null;
             notifyAllListeners();
         }
@@ -395,9 +340,14 @@
         public void setSelectedItem(Object anItem) {
             if (matches == null) return;
-            selectedIndex = matches.indexOf(anItem);
+            selected = (AddressElement) anItem;
+            if (Reasoner.getInstance().translate(selected) != proposalContainer.getTarget())
+                statusLabel.setText("Vybraná adresa už v mapě existuje."+
+                                    " Potvrzením vznikne konflikt.");
+            else
+                statusLabel.setText(" ");
         }
 
         public Object getSelectedItem() {
-            return getElementAt(selectedIndex);
+            return selected;
         }
 
@@ -409,5 +359,5 @@
         public Object getElementAt(int index) {
             if (matches == null) return null;
-            if ((index < 0) || (index >= matches.size())) return null;
+            if (index >= matches.size()) return null;
             return matches.get(index);
         }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Renamer.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Renamer.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/Renamer.java	(revision 15582)
@@ -12,9 +12,7 @@
 package org.openstreetmap.josm.plugins.czechaddress.gui;
 
-import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
 import java.util.List;
-import javax.swing.JTable;
 import javax.swing.event.TableModelListener;
 import javax.swing.table.DefaultTableCellRenderer;
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/UniversalTreeRenderer.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/UniversalTreeRenderer.java	(revision 15558)
+++ 	(revision )
@@ -1,31 +1,0 @@
-package org.openstreetmap.josm.plugins.czechaddress.gui;
-
-import java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
-import org.openstreetmap.josm.plugins.czechaddress.gui.utils.UniversalRenderer;
-
-/**
- * Renderer for rendering trees with {@link OsmPrimitive}s and
- * {@link AddressElement}s.
- *
- * @author Radomír Černoch, radomir.cernoch@gmail.com
- */
-public class UniversalTreeRenderer extends DefaultTreeCellRenderer {
-
-    @Override
-    public Component getTreeCellRendererComponent(
-            JTree tree, Object value, boolean sel,
-            boolean expanded, boolean leaf, int row, boolean hasFocus) {
-
-        Component c = super.getTreeCellRendererComponent(tree, value, sel,
-                expanded, leaf, row, hasFocus);
-
-        setIcon(UniversalRenderer.getIcon(value));
-        setText(UniversalRenderer.getText(value));
-
-        return c;
-    }
-}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/utils/UniversalTreeRenderer.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/utils/UniversalTreeRenderer.java	(revision 15582)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/utils/UniversalTreeRenderer.java	(revision 15582)
@@ -0,0 +1,31 @@
+package org.openstreetmap.josm.plugins.czechaddress.gui.utils;
+
+import java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
+import org.openstreetmap.josm.plugins.czechaddress.gui.utils.UniversalRenderer;
+
+/**
+ * Renderer for rendering trees with {@link OsmPrimitive}s and
+ * {@link AddressElement}s.
+ *
+ * @author Radomír Černoch, radomir.cernoch@gmail.com
+ */
+public class UniversalTreeRenderer extends DefaultTreeCellRenderer {
+
+    @Override
+    public Component getTreeCellRendererComponent(
+            JTree tree, Object value, boolean sel,
+            boolean expanded, boolean leaf, int row, boolean hasFocus) {
+
+        Component c = super.getTreeCellRendererComponent(tree, value, sel,
+                expanded, leaf, row, hasFocus);
+
+        setIcon(UniversalRenderer.getIcon(value));
+        setText(UniversalRenderer.getText(value));
+
+        return c;
+    }
+}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/Match.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/Match.java	(revision 15558)
+++ 	(revision )
@@ -1,88 +1,0 @@
-package org.openstreetmap.josm.plugins.czechaddress.intelligence;
-
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
-import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal;
-
-/**
- * Match is a relation between {@link OsmPrimitive} and {@link AddressElement}.
- *
- * @author Radomír Cernoch radomir.cernoch@gmail.com
- */
-public class Match {
-    
-    public static final int MATCH_OVERWRITE = 4;
-    public static final int MATCH_ROCKSOLID = 3;
-    public static final int MATCH_PARTIAL   = 2;
-    public static final int MATCH_CONFLICT  = 1;
-    public static final int MATCH_NOMATCH   = 0;
-    
-    public int qVal;
-    public OsmPrimitive prim;
-    public AddressElement elem;
-
-    public String checkSum;
-    public static Logger logger = Logger.getLogger("Match");
-
-    public Match(AddressElement element, OsmPrimitive primitive,
-                 int qualityFactor) {
-        
-        assert primitive != null;
-        assert element   != null;
-        assert !primitive.deleted;
-
-        prim = primitive;
-        elem = element;
-        qVal = qualityFactor;
-    }
-
-    public List<Proposal> getDiff() {
-        return this.elem.getDiff(this.prim);
-    }
-
-    public static Match createMatch(AddressElement element,
-                                    OsmPrimitive primitive) {
-
-        int quality = element.getMatchQuality(primitive);
-
-        logger.log(Level.FINE, "asked to create match",
-                               new Object[] {element, primitive, quality});
-
-        if (quality > MATCH_NOMATCH)
-            return new Match(element, primitive, quality);
-
-        return null;
-    }
-/*
-    public boolean setQ(int desiredQ) {
-        int oldQ = evalQ();
-        qVal = desiredQ;
-        int newQ = evalQ();
-
-        if (oldQ != newQ)
-            logger.log(Level.INFO, "changing match value: " + oldQ + " --> " + newQ
-                                 + " (desired value is " + desiredQ + ")", this);
-        return oldQ != evalQ();
-    }
-*/
-    public static int evalQ(OsmPrimitive prim, AddressElement elem, Integer oldQ) {
-        
-        if (prim.deleted)
-            return MATCH_NOMATCH;
-
-        if (oldQ == MATCH_OVERWRITE)
-            return MATCH_OVERWRITE;
-
-        return elem.getMatchQuality(prim);
-    }
-
-    @Override
-    public String toString() {
-        return "{Match: q=" + String.valueOf(qVal)
-                   + "; elem='" + elem.toString()
-                   +"'; prim='" + AddressElement.getName(prim) + "'}";
-    }
-}
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/Reasoner.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/Reasoner.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/Reasoner.java	(revision 15582)
@@ -1,4 +1,5 @@
 package org.openstreetmap.josm.plugins.czechaddress.intelligence;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -7,26 +8,28 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.crypto.Mac;
-import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.AddressElement;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
-import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Street;
+import org.openstreetmap.josm.plugins.czechaddress.proposal.ProposalContainer;
+import org.openstreetmap.josm.plugins.czechaddress.proposal.ProposalDatabase;
 
 /**
  * Intended to concentrate all intelligence of
- * {@link House}-{@link OsmPrimitive} matching.
+ * {@link AddressElement}-{@link OsmPrimitive} matching.
  *
- * <p>HouseReasoner holds the relations between House and OsmPrimitive
- * and also tries to keep it consistent with the state of the map.
- * Firstly it is initialised by {@code initReasoner()} and subsequently and
- * change done to the map should be reflected in HouseReasoner by calling
- * {@code addPrimitive} or {@code removePrimitive}.</p>
+ * <p>Reasoner holds the relations between AddressElement and OsmPrimitive
+ * and also tries to keep it consistent with the state of the map.</p>
+ *
+ * <p>You can imagine data model as a big matrix, whose rows consist of
+ * {@code AddressElement}s and columns are {@code OsmPrimitive}s. The cell
+ * of this matrix is a so-called "quality", which says how well the primitive
+ * and element fit together (see {@code MATCH_*} for details).
+ * Through the documentation we will use <tt><b>Q(prim, elem)</b></tt> notation
+ * for this matrix. The reasoner is memory-efficient iff most of the Q values
+ * are equal to {@code MATCH_NOMATCH}.</p>
  *
  * <p><b>NOTE:</b> Currently there is no known way of adding a hook into JOSM
- * to detect changed or deleted elements. Therefore every call of
- * {@code ensureConsistency()} checks for deleted elements, which is rather
- * inefficient. Moreover there is a listener for selectionChanged, which
- * checks deselcted items for their change. Again, inefficient.</p>
+ * to detect changed or deleted elements. Therefore there is a
+ * {@link SelectionMonitor}, which passes every selected primitive to
+ * the reasoner.</p>
  *
  * @author Radomír Černoch radomir.cernoch@gmail.com
@@ -34,5 +37,9 @@
 public class Reasoner {
 
-    /* A list of {@link OsmPrimitive}s, for which there was no suitable match.*/
+    public static final int MATCH_OVERWRITE = 4;
+    public static final int MATCH_ROCKSOLID = 3;
+    public static final int MATCH_PARTIAL   = 2;
+    public static final int MATCH_CONFLICT  = 1;
+    public static final int MATCH_NOMATCH   = 0;
 
     private     Map<OsmPrimitive, AddressElement> primBestIndex
@@ -59,4 +66,11 @@
     }
 
+//==============================================================================
+// INPUT METHODS
+//==============================================================================
+
+    /**
+     * Brings the reasoner to the initial state
+     */
     public void reset() {
         primToUpdate.clear();
@@ -68,94 +82,48 @@
         primBestIndex.clear();
 
+        transactionOpened = false;
+
         for (ReasonerListener listener : listeners)
             listener.resonerReseted();
     }
-    
-    public Set<AddressElement> getCandidates(OsmPrimitive prim) {
-
-        int best = Match.MATCH_NOMATCH;
-        for (AddressElement elem : primMatchIndex.get(prim).keySet()) {
-            int cand = primMatchIndex.get(prim).get(elem);
-            if (best < cand)
-                best = cand;
-        }
-
-        Set<AddressElement> result = new HashSet<AddressElement>();
-
-        for (AddressElement elem : primMatchIndex.get(prim).keySet()) {
-            int cand = primMatchIndex.get(prim).get(elem);
-            if (best == cand)
-                result.add(elem);
-        }
-        return result;
-    }
-
-    public Set<OsmPrimitive> getCandidates(AddressElement elem) {
-
-        int best = Match.MATCH_NOMATCH;
-        for (OsmPrimitive prim : elemMatchIndex.get(elem).keySet()) {
-            int cand = elemMatchIndex.get(elem).get(prim);
-            if (best < cand)
-                best = cand;
-        }
-
-        Set<OsmPrimitive> result = new HashSet<OsmPrimitive>();
-        
-        for (OsmPrimitive prim : elemMatchIndex.get(elem).keySet()) {
-            int cand = elemMatchIndex.get(elem).get(prim);
-            if (best == cand)
-                result.add(prim);
-        }
-        return result;
-    }
-
-    public AddressElement getStrictlyBest(OsmPrimitive prim) {
-
-        Map<AddressElement, Integer> matches = primMatchIndex.get(prim);
-        //if (matches == null) return null;
-
-        AddressElement bestE = null;
-        int bestQ = Match.MATCH_NOMATCH;
-
-        for (AddressElement elem : matches.keySet()) {
-            if (matches.get(elem) == bestQ)
-                bestE = null;
-
-            if (matches.get(elem) > bestQ) {
-                bestQ = matches.get(elem);
-                bestE = elem;
-            }
-        }
-
-        return bestE;
-    }
-
-    public OsmPrimitive getStrictlyBest(AddressElement prim) {
-
-        Map<OsmPrimitive, Integer> matches = elemMatchIndex.get(prim);
-        //if (matches == null) return null;
-
-        OsmPrimitive bestE = null;
-        int bestQ = Match.MATCH_NOMATCH;
-
-        for (OsmPrimitive elem : matches.keySet()) {
-            if (matches.get(elem) == bestQ)
-                bestE = null;
-
-            if (matches.get(elem) > bestQ) {
-                bestQ = matches.get(elem);
-                bestE = elem;
-            }
-        }
-
-        return bestE;
-    }
-
+
+    /**
+     * Indicates whether there is currently an open transaction
+     */
+    private boolean transactionOpened = false;
+
+    /**
+     * Prepares reasoner to modify its data.
+     *
+     * <p>This method must be called before <u>any</u> method, which might
+     * modify the data in the reasoner.
+     * The only exception is {@code reset()}.</p>
+     * 
+     * <p>When there's an open transaction, the result of most output methods
+     * undefined. Exceptions to this rules are indicated.</p>
+     *
+     * <p><b>Transactions:</b> This method requires a closed transaction.</p>
+     */
     public void openTransaction() {
         assert primToUpdate.size() == 0;
         assert elemToUpdate.size() == 0;
-    }
-
+        assert !transactionOpened;
+
+        primToUpdate.clear();
+        elemToUpdate.clear();
+        transactionOpened = true;
+    }
+
+    /**
+     * Turns the reasoner back into consistent state.
+     *
+     * <p>Recreates {@code *BestIndex} indexes, sends notification to
+     * all listeners about changed elements/primitives and closes
+     * the transaction.</p>
+     *
+     * <p><b>Transactions:</b> This method requires an open transaction.</p>
+     */
     public void closeTransaction() {
+        assert transactionOpened;
 
         Set<AddressElement> elemChanges = new HashSet<AddressElement>();
@@ -168,5 +136,5 @@
                 if (bestMatch == null) {
                     logger.log(Level.FINE, "primitive has no longer best match",
-                            AddressElement.getName(prim));
+                                           AddressElement.getName(prim));
                     primBestIndex.remove(prim);
                 } else {
@@ -200,4 +168,5 @@
         elemToUpdate.addAll(elemChanges);
         primToUpdate.addAll(primChanges);
+        transactionOpened = false;
 
         for (ReasonerListener listener : listeners) {
@@ -205,20 +174,77 @@
                 if (elem != null)
                     listener.elementChanged(elem);
-            
+
             for (OsmPrimitive prim : primToUpdate)
                 if (prim != null)
                     listener.primitiveChanged(prim);
         }
-        
+
         primToUpdate.clear();
         elemToUpdate.clear();
     }
 
-    private Set<ReasonerListener> listeners = new HashSet<ReasonerListener>();
-
-    public void reconsider(OsmPrimitive prim, AddressElement elem) {
+    /**
+     * Update all relations of the given primitive.
+     *
+     * <p>If the primitive is unknown to the reasoner, it's added.
+     * Then it updates all cells in the Q matrix's column, which corresponds
+     * to the provided primitive. In the Q-matrix analogy is roughly equivalent
+     * to doing an update
+     * <center>∀ elem. Q(elem, prim) ← elem.getQ(prim).</center>
+     * Hence its time complexity is linear.</p>
+     *
+     * <p><b>Transactions:</b> This method requires an open transaction.</p>
+     */
+    public void update(OsmPrimitive prim) {
+        logger.log(Level.FINER, "considering primitive", AddressElement.getName(prim));
+        assert transactionOpened;
+
+
+        Map<AddressElement, Integer> matches = primMatchIndex.get(prim);
+        if (matches == null) {
+            logger.log(Level.FINE, "new primitive detected", AddressElement.getName(prim));
+            matches = new HashMap<AddressElement, Integer>();
+            primMatchIndex.put(prim, matches);
+        }
+
+        for (AddressElement elem : elemMatchIndex.keySet())
+            reconsider(prim, elem);
+    }
+
+    /**
+     * Update all relations of the given element
+     *
+     * <p>If the primitive is unknown to the reasoner, it's added.
+     * Then it updates all cells in the Q matrix's row, which corresponds
+     * to the provided element.In the Q-matrix analogy is roughly equivalent
+     * to doing an update
+     * <center>∀ prim. Q(elem, prim) ← elem.getQ(prim).</center>
+     * Hence its time complexity is linear.</p>
+     *
+     * <p><b>Transactions:</b> This method requires an open transaction.</p>
+     */
+    public void update(AddressElement elem) {
+        logger.log(Level.FINER, "considering element", elem);
+        assert transactionOpened;
+
+        Map<OsmPrimitive, Integer> matches = elemMatchIndex.get(elem);
+        if (matches == null) {
+            logger.log(Level.FINE, "new element detected", elem);
+            matches = new HashMap<OsmPrimitive, Integer>();
+            elemMatchIndex.put(elem, matches);
+        }
+
+        for (OsmPrimitive prim : primMatchIndex.keySet())
+            reconsider(prim, elem);
+    }
+
+    /**
+     * Internal method for doing the actual Q value update.
+     */
+    private void reconsider(OsmPrimitive prim, AddressElement elem) {
+        assert transactionOpened;
 
         int oldQ = getQ(prim, elem);
-        int newQ = Match.evalQ(prim, elem, oldQ);
+        int newQ = evalQ(prim, elem, oldQ);
 
         if (oldQ != newQ) {
@@ -237,33 +263,53 @@
     }
 
-    public void consider(OsmPrimitive prim) {
-        logger.log(Level.FINER, "considering primitive", AddressElement.getName(prim));
-
-        Map<AddressElement, Integer> matches = primMatchIndex.get(prim);
-        if (matches == null) {
-            logger.log(Level.FINE, "new primitive detected", AddressElement.getName(prim));
-            matches = new HashMap<AddressElement, Integer>();
-            primMatchIndex.put(prim, matches);
-        }
-
-        for (AddressElement elem : elemMatchIndex.keySet())
-            reconsider(prim, elem);
-    }
-
-    public void consider(AddressElement elem) {
-        logger.log(Level.FINER, "considering element", elem);
-
-        Map<OsmPrimitive, Integer> matches = elemMatchIndex.get(elem);
-        if (matches == null) {
-            logger.log(Level.FINE, "new element detected", elem);
-            matches = new HashMap<OsmPrimitive, Integer>();
-            elemMatchIndex.put(elem, matches);
-        }
-
-        for (OsmPrimitive prim : primMatchIndex.keySet())
-            reconsider(prim, elem);
-    }
-
-    public int getQ(OsmPrimitive prim, AddressElement elem) {
+    /**
+     * Sets the relation's Q value to highest possible.
+     *
+     * <p>Regardless of how well the primitive and element pair fits
+     * together, it assings their Q value to {@code MATCH_OVERWRITE}.</p>
+     *
+     * <p><b>Transactions:</b> This method requires an open transaction.</p>
+     */
+    public void doOverwrite(OsmPrimitive prim, AddressElement elem) {
+        logger.log(Level.FINER, "overwriting match",
+                    "elem=„" + elem + "“; " +
+                    "prim=„" + AddressElement.getName(prim) + "“");
+        assert transactionOpened;
+
+        update(prim);
+        update(elem);
+        putQ(prim, elem, MATCH_OVERWRITE);
+
+        primToUpdate.add(prim);
+        elemToUpdate.add(elem);
+    }
+
+    /**
+     * Sets the relation to its original Q value.
+     *
+     * <p>If the element-primitive pair was previously edited by
+     * {@code doOverwrite()} method, this returns their Q to the
+     * original value, which is determined by {@code evalQ()}.</p>
+     *
+     * <p><b>Transactions:</b> This method requires an open transaction.</p>
+     */
+    public void unOverwrite(OsmPrimitive prim, AddressElement elem) {
+        logger.log(Level.FINER, "unoverwriting match",
+                    "elem=„" + elem + "“; " +
+                    "prim=„" + AddressElement.getName(prim) + "“");
+        assert transactionOpened;
+
+        update(prim);
+        update(elem);
+        putQ(prim, elem, evalQ(prim, elem, MATCH_NOMATCH));
+
+        primToUpdate.add(prim);
+        elemToUpdate.add(elem);
+    }
+
+    /**
+     * Returns the Q value of the given primitive-element relation.
+     */
+    private int getQ(OsmPrimitive prim, AddressElement elem) {
         assert primMatchIndex.get(prim).get(elem)
             == elemMatchIndex.get(elem).get(prim);
@@ -275,7 +321,10 @@
     }
 
-    public void putQ(OsmPrimitive prim, AddressElement elem, int qVal) {
-        
-        if (qVal == Match.MATCH_NOMATCH) {
+    /**
+     * Sets the Q value of the given primitive-element relation.
+     */
+    private void putQ(OsmPrimitive prim, AddressElement elem, int qVal) {
+
+        if (qVal == MATCH_NOMATCH) {
             primMatchIndex.get(prim).remove(elem);
             elemMatchIndex.get(elem).remove(prim);
@@ -286,154 +335,350 @@
     }
 
+    /**
+     * Evaluates the Q value between the given primitive and element.
+     *
+     * <p>If {@code oldQ} is {@code MATCH_OVERWRITE}, it is preserved.</p>
+     */
+    private int evalQ(OsmPrimitive prim, AddressElement elem, Integer oldQ) {
+
+        if (prim.deleted)
+            return MATCH_NOMATCH;
+
+        if (oldQ == MATCH_OVERWRITE)
+            return MATCH_OVERWRITE;
+
+        return elem.getQ(prim);
+    }
+
+//==============================================================================
+// OUTPUT METHODS
+//==============================================================================
+
+    /**
+     * Returns the primitive, which is a unique counterpart of the element.
+     *
+     * <p>This method is probably the single most used method of the reasoner.
+     * It allows the unique translation between map and the database.</p>
+     *
+     * <p>An element <i>elem</i> and primitive <i>prim</i> can be translated
+     * between each other iff
+     * <center>[∄ <i>prim'</i>. Q(elem, prim') ≥ Q(elem, prim)] ∧
+     *         [∄ <i>elem'</i>. Q(elem', prim) ≥ Q(elem, prim)].</center>
+     * In other words, the cell at Q(elem, prim) is the strictly greatest one
+     * in both its row and the column of the Q matrix.</p>
+     *
+     * <p>This method depends on {@code getStrictlyBest()}, which induces its
+     * complexity properties.</p>
+     *
+     * <p><b>Transactions:</b> Can be called regardless of transaction state.
+     * However if the transaction is closed, its time-complexity reduces to
+     * constant thanks to using indexes.</p>
+     */
     public AddressElement translate(OsmPrimitive prim) {
         if (prim == null) return null;
 
-        AddressElement elem = primBestIndex.get(prim);
-        if (elemBestIndex.get(elem) == prim)
+        AddressElement elem = getStrictlyBest(prim);
+        if (getStrictlyBest(elem) == prim)
             return elem;
+        
         return null;
     }
 
+    /**
+     * Returns the element, which is a unique counterpart of the primitive.
+     *
+     * <p>This method is probably the single most used method of the reasoner.
+     * It allows the unique translation between map and the database.</p>
+     *
+     * <p>An element <i>elem</i> and primitive <i>prim</i> can be translated
+     * between each other iff
+     * <center>[∄ <i>prim'</i>. Q(elem, prim') ≥ Q(elem, prim)] ∧
+     *         [∄ <i>elem'</i>. Q(elem', prim) ≥ Q(elem, prim)].</center>
+     * In other words, the cell at Q(elem, prim) is the strictly greatest one
+     * in both its row and the column of the Q matrix.</p>
+     *
+     * <p>This method depends on {@code getStrictlyBest()}, which induces its
+     * complexity properties.</p>
+     *
+     * <p><b>Transactions:</b> Can be called regardless of transaction state.
+     * However if the transaction is closed, its time-complexity reduces to
+     * constant thanks to using indexes.</p>
+     */
     public OsmPrimitive translate(AddressElement elem) {
         if (elem == null) return null;
 
-        OsmPrimitive prim = elemBestIndex.get(elem);
-        if (primBestIndex.get(prim) == elem)
+        OsmPrimitive prim = getStrictlyBest(elem);
+        if (getStrictlyBest(prim) == elem)
             return prim;
+        
         return null;
     }
 
-    public Set<AddressElement> getConflicts(OsmPrimitive prim) {
-
-        Set<AddressElement> result = getCandidates(prim);
-        AddressElement match = translate(prim);
-        if (match != null)
-            result.remove(match);
-
-        return result;
-    }
-
-    public Set<OsmPrimitive> getConflicts(AddressElement elem) {
-
-        Set<OsmPrimitive> result = getCandidates(elem);
-        OsmPrimitive match = translate(elem);
-        if (match != null)
-            result.remove(match);
-
-        return result;
-    }
-
-    public void addListener(ReasonerListener listener) {
-        listeners.add(listener);
-    }
-
-    public void removeListener(ReasonerListener listener) {
-        listeners.remove(listener);
-    }
-
-    public static void main(String[] args) {
-        try {
-
-            Reasoner r = Reasoner.getInstance();
-            Reasoner.logger.setLevel(Level.ALL);
-            
-            Street s1 = new Street("Jarní");
-            Street s2 = new Street("Letní");
-
-            House h1 = new House("240", "1"); s1.addHouse(h1); r.consider(h1);
-            House h2 = new House("241", "2"); s1.addHouse(h2); r.consider(h2);
-            House h3 = new House("241", "3"); s1.addHouse(h3); r.consider(h3);
-            House h4 = new House("242", "4"); s1.addHouse(h4); r.consider(h4);
-
-            House i1 = new House("42",  "1"); s2.addHouse(i1); r.consider(i1);
-            House i2 = new House("45",  "2"); s2.addHouse(i2); r.consider(i2);
-            House i3 = new House("61",  "3"); s2.addHouse(i3); r.consider(i3);
-            House i4 = new House("240", "4"); s2.addHouse(i4); r.consider(i4);
-
-
-            
-            Node n1 = new Node(1);
-            n1.put("addr:street", "Jarní");
-            n1.put("addr:alternatenumber", "242");
-
-            r.openTransaction();
-            r.consider(n1);
-            r.closeTransaction();
-            assert r.translate(n1) == h4;
-            assert r.getConflicts(n1).size() == 0;
-
-
-
-            Node n2 = new Node(2);
-            n2.put("addr:alternatenumber", "240");
-            r.openTransaction();
-            r.consider(n2);
-            r.closeTransaction();
-            assert r.translate(n2) == null;
-            assert r.getConflicts(n2).contains(h1);
-            assert r.getConflicts(n2).contains(i4);
-
-            n2.put("addr:street", "Letní");
-            n2.put("addr:housenumber", "4");
-            r.openTransaction();
-            r.consider(n2);
-            r.closeTransaction();
-            assert r.translate(n2) == i4;
-
-
-            n2.deleted = true;
-            r.openTransaction();
-            r.consider(n2);
-            r.closeTransaction();
-            assert r.translate(n2) == null;
-            
-        } catch (Exception ex) {
-            
-            ex.printStackTrace();
-        }
-    }
-
-    public void doOverwrite(OsmPrimitive prim, AddressElement elem) {
-        logger.log(Level.FINER, "overwriting match",
-                    "elem=„" + elem + "“; " +
-                    "prim=„" + AddressElement.getName(prim) + "“");
-
-        consider(prim);
-        consider(elem);
-        putQ(prim, elem, Match.MATCH_OVERWRITE);
-
-        primToUpdate.add(prim);
-        elemToUpdate.add(elem);
-    }
-
-    public void unOverwrite(OsmPrimitive prim, AddressElement elem) {
-        logger.log(Level.FINER, "unoverwriting match",
-                    "elem=„" + elem + "“; " +
-                    "prim=„" + AddressElement.getName(prim) + "“");
-
-        consider(prim);
-        consider(elem);
-        putQ(prim, elem, Match.evalQ(prim, elem, Match.MATCH_NOMATCH));
-
-        primToUpdate.add(prim);
-        elemToUpdate.add(elem);
-    }
-
+    /**
+     * Says whether the given primitive has a conflict.
+     *
+     * <p>There are two conditions for a primitive to be in a conflict. It must
+     * be at least partially fitting to some element, but it cannot be
+     * uniquely translatable.
+     * <center> [∃ elem. Q(elem, prim) > NO_MATCH] ∧
+     *          ]∄ elem. elem = translate(prim)] ,</center>
+     * which is equivalent to saying that
+     * <center>|getCandidates(prim)| ≥ 2</center></p>
+     */
     public boolean inConflict(OsmPrimitive prim) {
+        if (primMatchIndex.get(prim) == null) return false;
         return primMatchIndex.get(prim).size() > 0
             && translate(translate(prim)) != prim;
     }
 
+    /**
+     * Says whether the given element has a conflict.
+     *
+     * <p>There are two conditions for a element to be in a conflict. It must
+     * be at least partially fitting to some primitive, but it cannot be
+     * uniquely translatable.
+     * <center> [∃ prim. Q(elem, prim) > NO_MATCH] ∧
+     *          [∄ prim. prim = translate(elem)] ,</center>
+     * which is equivalent to saying that
+     * <center>|getCandidates(prim)| ≥ 2</center></p>
+     */
     public boolean inConflict(AddressElement elem) {
+        if (elemMatchIndex.get(elem) == null) return false;
         return elemMatchIndex.get(elem).size() > 0
             && translate(translate(elem)) != elem;
     }
 
+
+    /**
+     * Returns elements having the best quality for the given primitive.
+     *
+     * <p>It searches among all Q values corresponding to the given primitive
+     * and returns a set of all elements, whose relation has the greatest
+     * Q value. Formally we can write that the output is a set
+     * <center>{elem |   Q(elem, prim) > MATCH_NOMATCH
+     *                 ∧ ∀ elem'. Q(elem, prim) ≥ Q(elem', prim)}.</center></p>
+     *
+     * <p><b>Transactions:</b> Can be called regardless of transaction state.</p>
+     *
+     * @return A new set, which can be freely manipulated. Changes are not
+     * reflected in the reasoner.
+     */
+    public Set<AddressElement> getCandidates(OsmPrimitive prim) {
+
+        int best = MATCH_NOMATCH;
+        for (AddressElement elem : primMatchIndex.get(prim).keySet()) {
+            int cand = primMatchIndex.get(prim).get(elem);
+            if (best < cand)
+                best = cand;
+        }
+
+        Set<AddressElement> result = new HashSet<AddressElement>();
+
+        for (AddressElement elem : primMatchIndex.get(prim).keySet()) {
+            int cand = primMatchIndex.get(prim).get(elem);
+            if (best == cand)
+                result.add(elem);
+        }
+        return result;
+    }
+
+    /**
+     * Returns primitives having the best quality for the given element.
+     *
+     * <p>It searches among all Q values corresponding to the given element
+     * and returns a set of all primitives, whose relation has the greatest
+     * Q value. Formally we can write that the output is a set
+     * <center>{prim |   Q(elem, prim) > MATCH_NOMATCH
+     *                 ∧ ∀ prim'. Q(elem, prim) ≥ Q(elem, prim')}.</center></p>
+     *
+     * <p><b>Transactions:</b> Can be called regardless of transaction state.</p>
+     *
+     * @return A new set, which can be freely manipulated. Changes are not
+     * reflected in the reasoner.
+     */
+    public Set<OsmPrimitive> getCandidates(AddressElement elem) {
+
+        int best = MATCH_NOMATCH;
+        for (OsmPrimitive prim : elemMatchIndex.get(elem).keySet()) {
+            int cand = elemMatchIndex.get(elem).get(prim);
+            if (best < cand)
+                best = cand;
+        }
+
+        Set<OsmPrimitive> result = new HashSet<OsmPrimitive>();
+        
+        for (OsmPrimitive prim : elemMatchIndex.get(elem).keySet()) {
+            int cand = elemMatchIndex.get(elem).get(prim);
+            if (best == cand)
+                result.add(prim);
+        }
+        return result;
+    }
+
+    /**
+     * Returns the element having the best quality for the given primitive.
+     *
+     * <p>It searches among all Q values corresponding to the given primitive
+     * and returns such an element, whose relation has the greatest
+     * Q value. If there are more of them, {@code null} is returned.
+     * Formally we can write that the output is a primitive
+     * <center>elem: Q(elem, prim) > MATCH_NOMATCH
+     *             ∧ ∀ elem'. Q(elem, prim) > Q(elem', prim)}.</center></p>
+     *
+     * <p>If {@code getCandidates(prim)} returns exactly one element,
+     * this method should return the same one. Otherwise {@code null}.</p>
+     *
+     * <p><b>Transactions:</b> Can be called regardless of transaction state.
+     * However if the transaction is closed, its time-complexity reduces to
+     * constant thanks to using indexes.</p>
+     */
+    public AddressElement getStrictlyBest(OsmPrimitive prim) {
+
+        if (!transactionOpened)
+            return primBestIndex.get(prim);
+
+        Map<AddressElement, Integer> matches = primMatchIndex.get(prim);
+        AddressElement bestE = null;
+        int bestQ = MATCH_NOMATCH;
+
+        for (AddressElement elem : matches.keySet()) {
+            if (matches.get(elem) == bestQ)
+                bestE = null;
+
+            if (matches.get(elem) > bestQ) {
+                bestQ = matches.get(elem);
+                bestE = elem;
+            }
+        }
+
+        return bestE;
+    }
+
+    /**
+     * Returns the primitive having the best quality for the given element.
+     *
+     * <p>It searches among all Q values corresponding to the given element
+     * and returns sucha  primitive, whose relation has the greatest
+     * Q value. If there are more of them, {@code null} is returned.
+     * Formally we can write that the output is a primitive
+     * <center>prim: Q(elem, prim) > MATCH_NOMATCH
+     *             ∧ ∀ prim'. Q(elem, prim) > Q(elem', prim)}.</center></p>
+     *
+     * <p>If {@code getCandidates(elem)} returns exactly one primitive,
+     * this method should return the same one. Otherwise {@code null}.</p>
+     *
+     * <p><b>Transactions:</b> Can be called regardless of transaction state.
+     * However if the transaction is closed, its time-complexity reduces to
+     * constant thanks to using indexes.</p>
+     */
+    public OsmPrimitive getStrictlyBest(AddressElement elem) {
+
+        if (!transactionOpened)
+            return elemBestIndex.get(elem);
+
+        Map<OsmPrimitive, Integer> matches = elemMatchIndex.get(elem);
+        OsmPrimitive bestE = null;
+        int bestQ = MATCH_NOMATCH;
+
+        for (OsmPrimitive prim : matches.keySet()) {
+            if (matches.get(prim) == bestQ)
+                bestE = null;
+
+            if (matches.get(prim) > bestQ) {
+                bestQ = matches.get(prim);
+                bestE = prim;
+            }
+        }
+
+        return bestE;
+    }
+
+    /**
+     * Returns all elements which are not translatable.
+     */
     public Set<AddressElement> getUnassignedElements() {
         Set<AddressElement> result = new HashSet<AddressElement>();
         for (AddressElement elem : elemMatchIndex.keySet())
-            if (elemMatchIndex.get(elem).size() == 0)
+            if (translate(elem) == null)
                 result.add(elem);
         return result;
     }
+
+    /**
+     * Returns all primitives which are not translatable.
+     */
+    public Set<OsmPrimitive> getUnassignedPrimitives() {
+        Set<OsmPrimitive> result = new HashSet<OsmPrimitive>();
+        for (OsmPrimitive prim : primMatchIndex.keySet())
+            if (translate(prim) == null)
+                result.add(prim);
+        return result;
+    }
+
+    /**
+     * Returns all elements, which were {@code update}d from
+     * the last {@code reset}.
+     */
+    public Set<AddressElement> getAllElements() {
+        Set<AddressElement> result = new HashSet<AddressElement>();
+        result.addAll(elemMatchIndex.keySet());
+        return result;
+    }
+
+    /**
+     * Returns all elements, which were {@code update}d from
+     * the last {@code reset}.
+     */
+    public Set<OsmPrimitive> getAllPrimitives() {
+        Set<OsmPrimitive> result = new HashSet<OsmPrimitive>();
+        result.addAll(primMatchIndex.keySet());
+        return result;
+    }
+
+//==============================================================================
+// MISC METHODS
+//==============================================================================
+
+    /**
+     * Returns proposals to fit all translatable primitives to their elements.
+     */
+    public ProposalDatabase getProposals() {
+        ProposalDatabase database = new ProposalDatabase();
+
+        // We can go only over primBestIndex to save some iterations.
+        // A primitive cannot be translated unless contained in primBestIndex.
+        for (OsmPrimitive prim : primBestIndex.keySet()) {
+            AddressElement elem = translate(prim);
+            if (elem == null) continue;
+
+            ProposalContainer container = new ProposalContainer(prim);
+            container.addProposals(elem.getDiff(prim));
+            
+            if (container.getProposals().size() > 0)
+                database.addContainer(container);
+        }
+
+        Collections.sort(database.getContainers());
+        return database;
+    }
+
+    /**
+     * Set of listeners currently hooked to changes in this reasoner.
+     */
+    private Set<ReasonerListener> listeners = new HashSet<ReasonerListener>();
+
+    /**
+     * Adds a new listener to receive reasoner's status changes.
+     */
+    public void addListener(ReasonerListener listener) {
+        listeners.add(listener);
+    }
+
+    /**
+     * Stops the listener to receive reasoner's status changes.
+     */
+    public void removeListener(ReasonerListener listener) {
+        listeners.remove(listener);
+    }
+
 }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/SelectionMonitor.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/SelectionMonitor.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/SelectionMonitor.java	(revision 15582)
@@ -6,4 +6,6 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.plugins.czechaddress.NotNullList;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.House;
+import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Street;
 
 /**
@@ -37,7 +39,9 @@
             r.openTransaction();
             for (OsmPrimitive selectedPrim :newSelection)
-                r.consider(selectedPrim);
+                if (House.isMatchable(selectedPrim) || Street.isMatchable(selectedPrim))
+                    r.update(selectedPrim);
             for (OsmPrimitive selectedPrim :lastSelection)
-                r.consider(selectedPrim);
+                if (House.isMatchable(selectedPrim) || Street.isMatchable(selectedPrim))
+                    r.update(selectedPrim);
             r.closeTransaction();
         }
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java	(revision 15582)
@@ -108,5 +108,5 @@
 
             int total = 0, count;
-            byte[] buffer = new byte[1024*128];
+            byte[] buffer = new byte[1024*512];
             while ((count = con.getInputStream().read(buffer)) >= 0) {
                 bos.write(buffer, 0, count);
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java	(revision 15582)
@@ -44,6 +44,11 @@
 
             // If the region filter is on, apply it!
-            if (filRegion != null && !attributes.getValue("nazev").equals(filRegion))
-                return;
+            if (filRegion != null && !attributes.getValue("nazev").equals(filRegion)) {
+                curRegion = null;
+                curViToCi = null;
+                curSuburb = null;
+                curStreet = null;
+                return;
+            }
 
             /*curRegion = target.findRegion(
@@ -70,6 +75,10 @@
 
             // If the viToCi filter is on, apply it!
-            if (filViToCi != null && !attributes.getValue("nazev").equals(filViToCi))
-                return;
+            if (filViToCi != null && !attributes.getValue("nazev").equals(filViToCi)) {
+                curViToCi = null;
+                curSuburb = null;
+                curStreet = null;
+                return;
+            }
 
             //curViToCi = curRegion.findViToCi(attributes.getValue("nazev"));
@@ -87,6 +96,9 @@
 
             // If the suburb filter is on, apply it!
-            if (filSuburb != null && !attributes.getValue("nazev").equals(filSuburb))
-                return;
+            if (filSuburb != null && !attributes.getValue("nazev").equals(filSuburb)) {
+                curSuburb = null;
+                curStreet = null;
+                return;
+            }
 
             //curSuburb = curViToCi.findSuburb(attributes.getValue("nazev"));
@@ -102,6 +114,8 @@
 
             // If the street filter is on, apply it!
-            if (filStreet != null && !attributes.getValue("nazev").equals(filStreet))
-                return;
+            if (filStreet != null && !attributes.getValue("nazev").equals(filStreet)) {
+                curStreet = null;
+                return;
+            }
 
             ElementWithStreets   topElem = curSuburb;
Index: applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/proposal/ProposalContainer.java
===================================================================
--- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/proposal/ProposalContainer.java	(revision 15558)
+++ applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/proposal/ProposalContainer.java	(revision 15582)
@@ -9,4 +9,5 @@
 import javax.swing.event.ListDataListener;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.plugins.czechaddress.PrimUtils;
 
 /**
@@ -22,5 +23,5 @@
  * @see Proposal
  */
-public class ProposalContainer implements ListModel {
+public class ProposalContainer implements ListModel, Comparable<ProposalContainer> {
 
 
@@ -216,3 +217,7 @@
     }
 
+    public int compareTo(ProposalContainer o) {
+        return PrimUtils.comparator.compare(this.target, o.target);
+    }
+
 }
