Index: /applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.core.prefs	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.core.prefs	(revision 32211)
@@ -112,2 +112,3 @@
 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
 org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
Index: /applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.ui.prefs	(revision 32211)
+++ /applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.ui.prefs	(revision 32211)
@@ -0,0 +1,61 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_settings_version=12
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+sp_cleanup.use_type_arguments=false
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java	(revision 32211)
@@ -14,8 +14,6 @@
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
+import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -63,5 +61,5 @@
 import org.openstreetmap.josm.tools.Shortcut;
 
-public class Address extends MapMode implements MouseListener, MouseMotionListener, ActionListener {
+public class Address extends MapMode {
 
     // perhaps make all these tags configurable in the future
@@ -76,16 +74,16 @@
     private String relationMemberHouse = "house";
 
-    private JRadioButton plus_one = new JRadioButton("+1", false);
-    private JRadioButton plus_two = new JRadioButton("+2", true); // enable this by default
-    private JRadioButton minus_one = new JRadioButton("-1", false);
-    private JRadioButton minus_two = new JRadioButton("-2", false);
+    private JRadioButton plusOne = new JRadioButton("+1", false);
+    private JRadioButton plusTwo = new JRadioButton("+2", true); // enable this by default
+    private JRadioButton minusOne = new JRadioButton("-1", false);
+    private JRadioButton minusTwo = new JRadioButton("-2", false);
     final JCheckBox tagPolygon = new JCheckBox(tr("on polygon"));
 
-    JDialog dialog = null;
-    JButton clearButton = null;
+    JDialog dialog;
+    JButton clearButton;
     final JTextField inputNumber = new JTextField();
     final JTextField inputStreet = new JTextField();
     JLabel link = new JLabel();
-    private Way selectedWay;
+    private transient Way selectedWay;
     private boolean shift;
     private boolean ctrl;
@@ -114,6 +112,5 @@
 //        dialog.setVisible(false);
         // kill the window completely to fix an issue on some linux distro and full screen mode.
-        if(dialog != null)
-        {
+        if(dialog != null) {
             dialog.dispose();
             dialog = null;
@@ -131,5 +128,4 @@
         List<Way> mouseOnExistingWays = new ArrayList<>();
         List<Way> mouseOnExistingBuildingWays = new ArrayList<>();
-        mouseOnExistingWays = new ArrayList<>();
         Node currentMouseNode = mv.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate);
         if (currentMouseNode != null) {
@@ -140,5 +136,5 @@
                     && currentMouseNode.get(tagHouseStreet) == null
                     && findWayInRelationAddr(currentMouseNode) == null
-                    && !inputStreet.getText().equals("")) {
+                    && !inputStreet.getText().isEmpty()) {
                 // house number already present but not linked to a street
                 Collection<Command> cmds = new LinkedList<>();
@@ -199,7 +195,7 @@
                 inputNumber.setText("");
                 setNewSelection(mouseOnExistingWays.get(0));
-            } else if (mouseOnExistingWays.size() == 0) {
+            } else if (mouseOnExistingWays.isEmpty()) {
                 // clicked a non highway and not a node => add the new address
-                if (inputStreet.getText().equals("") || inputNumber.getText().equals("")) {
+                if (inputStreet.getText().isEmpty() || inputNumber.getText().isEmpty()) {
                     Toolkit.getDefaultToolkit().beep();
                 } else {
@@ -217,5 +213,4 @@
             }
         }
-
     }
 
@@ -297,5 +292,5 @@
     }
 
-    private Node createNewNode(MouseEvent e, Collection<Command> cmds) {
+    private static Node createNewNode(MouseEvent e, Collection<Command> cmds) {
         // DrawAction.mouseReleased() but without key modifiers
         Node n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY()));
@@ -398,6 +393,4 @@
 
     private static void pruneSuccsAndReverse(List<Integer> is) {
-        //if (is.size() < 2) return;
-
         HashSet<Integer> is2 = new HashSet<>();
         for (int i : is) {
@@ -415,5 +408,6 @@
         try {
             return ImageProvider.getCursor("crosshair", null);
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
+            Main.warn(e);
         }
         return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
@@ -422,11 +416,11 @@
     private void applyInputNumberChange() {
         Integer num = Integer.parseInt(inputNumber.getText());
-        if (plus_one.isSelected())
+        if (plusOne.isSelected())
             num = num + 1;
-        if (plus_two.isSelected())
+        if (plusTwo.isSelected())
             num = num + 2;
-        if (minus_one.isSelected() && num > 1)
+        if (minusOne.isSelected() && num > 1)
             num = num - 1;
-        if (minus_two.isSelected() && num > 2)
+        if (minusTwo.isSelected() && num > 2)
             num = num - 2;
         inputNumber.setText(num.toString());
@@ -435,11 +429,11 @@
     private void revertInputNumberChange() {
         Integer num = Integer.parseInt(inputNumber.getText());
-        if (plus_one.isSelected())
+        if (plusOne.isSelected())
             num = num - 1;
-        if (plus_two.isSelected())
+        if (plusTwo.isSelected())
             num = num - 2;
-        if (minus_one.isSelected() && num > 1)
+        if (minusOne.isSelected() && num > 1)
             num = num + 1;
-        if (minus_two.isSelected() && num > 2)
+        if (minusTwo.isSelected() && num > 2)
             num = num + 2;
         inputNumber.setText(num.toString());
@@ -471,11 +465,10 @@
         });
         ButtonGroup bgIncremental = new ButtonGroup();
-        bgIncremental.add(plus_one);
-        bgIncremental.add(plus_two);
-        bgIncremental.add(minus_one);
-        bgIncremental.add(minus_two);
-        p.add(minus_one, GBC.std().insets(10, 0, 10, 0));
-//        p.add(plus_one, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 0, 0, 0));
-        p.add(plus_one, GBC.std().insets(0, 0, 10, 0));
+        bgIncremental.add(plusOne);
+        bgIncremental.add(plusTwo);
+        bgIncremental.add(minusOne);
+        bgIncremental.add(minusTwo);
+        p.add(minusOne, GBC.std().insets(10, 0, 10, 0));
+        p.add(plusOne, GBC.std().insets(0, 0, 10, 0));
         tagPolygon.setSelected(Main.pref.getBoolean("cadastrewms.addr.onBuilding", false));
         tagPolygon.addChangeListener(new ChangeListener() {
@@ -486,6 +479,6 @@
         });
         p.add(tagPolygon, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 0));
-        p.add(minus_two, GBC.std().insets(10, 0, 10, 0));
-        p.add(plus_two, GBC.std().insets(0, 0, 10, 0));
+        p.add(minusTwo, GBC.std().insets(10, 0, 10, 0));
+        p.add(plusTwo, GBC.std().insets(0, 0, 10, 0));
         p.add(clearButton, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 0));
 
@@ -508,22 +501,10 @@
             }
         });
-        dialog.addWindowListener(new WindowListener() {
+        dialog.addWindowListener(new WindowAdapter() {
             @Override
-            public void windowClosing(WindowEvent arg0) {
+            public void windowClosing(WindowEvent arg) {
                 exitMode();
                 Main.map.selectMapMode((MapMode)Main.map.getDefaultButtonAction());
             }
-            @Override
-            public void windowClosed(WindowEvent e) {}
-            @Override
-            public void windowActivated(WindowEvent arg0) {}
-            @Override
-            public void windowDeactivated(WindowEvent arg0) {}
-            @Override
-            public void windowDeiconified(WindowEvent arg0) {}
-            @Override
-            public void windowIconified(WindowEvent arg0) {}
-            @Override
-            public void windowOpened(WindowEvent arg0) {}
         });
         String bounds = Main.pref.get("cadastrewms.addr.bounds",null);
@@ -544,5 +525,5 @@
     }
 
-    private void setNewSelection(OsmPrimitive osm) {
+    private static void setNewSelection(OsmPrimitive osm) {
         Collection<OsmPrimitive> newSelection = new LinkedList<>(Main.main.getCurrentDataSet().getSelected());
         newSelection.clear();
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java	(revision 32211)
@@ -13,4 +13,5 @@
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.concurrent.Callable;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -33,9 +34,9 @@
 public class CacheControl implements Runnable {
 
-    public static final String cLambertCC9Z = "CC";
-
-    public static final String cUTM20N = "UTM";
-
-    public class ObjectOutputStreamAppend extends ObjectOutputStream {
+    public static final String C_LAMBERT_CC_9Z = "CC";
+
+    public static final String C_UTM20N = "UTM";
+
+    public static class ObjectOutputStreamAppend extends ObjectOutputStream {
         public ObjectOutputStreamAppend(OutputStream out) throws IOException {
             super(out);
@@ -51,5 +52,5 @@
     public static int cacheSize = 500;
 
-    public WMSLayer wmsLayer = null;
+    public WMSLayer wmsLayer;
 
     private ArrayList<GeorefImage> imagesToSave = new ArrayList<>();
@@ -79,5 +80,5 @@
     }
 
-    private void checkDirSize(File path) {
+    private static void checkDirSize(File path) {
         if (cacheSize != 0) {
             long size = 0;
@@ -105,27 +106,28 @@
             CadastrePlugin.askToChangeProjection();
         }
-        try {
-            File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension());
-            if (file.exists()) {
-                JOptionPane pane = new JOptionPane(
-                        tr("Location \"{0}\" found in cache.\n"+
-                        "Load cache first ?\n"+
-                        "(No = new cache)", wmsLayer.getName()),
-                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null);
-                // this below is a temporary workaround to fix the "always on top" issue
-                JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille"));
-                CadastrePlugin.prepareDialog(dialog);
-                dialog.setVisible(true);
-                int reply = (Integer)pane.getValue();
-                // till here
-
-                if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) {
-                    return true;
-                } else {
-                    delete(file);
-                }
-            }
-        } catch (Exception e) {
-            Main.error(e);
+        File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension());
+        if (file.exists()) {
+            int reply = GuiHelper.runInEDTAndWaitAndReturn(new Callable<Integer>() {
+                @Override
+                public Integer call() throws Exception {
+                    JOptionPane pane = new JOptionPane(
+                            tr("Location \"{0}\" found in cache.\n"+
+                            "Load cache first ?\n"+
+                            "(No = new cache)", wmsLayer.getName()),
+                            JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null);
+                    // this below is a temporary workaround to fix the "always on top" issue
+                    JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille"));
+                    CadastrePlugin.prepareDialog(dialog);
+                    dialog.setVisible(true);
+                    return (Integer)pane.getValue();
+                    // till here
+                }
+            });
+
+            if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) {
+                return true;
+            } else {
+                delete(file);
+            }
         }
         return false;
@@ -133,12 +135,8 @@
 
     public void deleteCacheFile() {
-        try {
-            delete(new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension()));
-        } catch (Exception e) {
-            Main.error(e);
-        }
-    }
-
-    private void delete(File file) {
+        delete(new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension()));
+    }
+
+    private static void delete(File file) {
         Main.info("Delete file "+file);
         if (file.exists())
@@ -155,5 +153,5 @@
         ) {
             successfulRead = wmsLayer.read(file, ois, currentLambertZone);
-        } catch (Exception ex) {
+        } catch (IOException | ClassNotFoundException ex) {
             Main.error(ex);
             GuiHelper.runInEDTAndWait(new Runnable() {
@@ -176,5 +174,5 @@
         imagesLock.lock();
         this.imagesToSave.add(image);
-        this.notify();
+        this.notifyAll();
         imagesLock.unlock();
     }
@@ -224,9 +222,9 @@
 
     private String WMSFileExtension() {
-        String ext = String.valueOf((wmsLayer.getLambertZone() + 1));
+        String ext = String.valueOf(wmsLayer.getLambertZone() + 1);
         if (CadastrePlugin.isLambert_cc9())
-            ext = cLambertCC9Z + ext;
+            ext = C_LAMBERT_CC_9Z + ext;
         else if (CadastrePlugin.isUtm_france_dom())
-            ext = cUTM20N + ext;
+            ext = C_UTM20N + ext;
         return ext;
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileLambert4ZoneFilter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileLambert4ZoneFilter.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileLambert4ZoneFilter.java	(revision 32211)
@@ -3,8 +3,11 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
 import java.io.File;
+import java.util.Locale;
+
 import javax.swing.filechooser.FileFilter;
 
-public class CacheFileLambert4ZoneFilter extends FileFilter {
+public final class CacheFileLambert4ZoneFilter extends FileFilter {
 
     /**
@@ -14,5 +17,5 @@
     private final String description;
 
-    public static CacheFileLambert4ZoneFilter[] filters = {
+    static final CacheFileLambert4ZoneFilter[] filters = {
         new CacheFileLambert4ZoneFilter("1", tr("Lambert Zone {0} cache file (.{0})", 1)),
         new CacheFileLambert4ZoneFilter("2", tr("Lambert Zone {0} cache file (.{0})", 2)),
@@ -31,5 +34,5 @@
 
     public boolean acceptName(String filename) {
-        String name = filename.toLowerCase();
+        String name = filename.toLowerCase(Locale.FRANCE);
         for (String ext : extension.split(","))
             if (name.endsWith("." + ext))
@@ -49,4 +52,3 @@
         return description;
     }
-
 }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java	(revision 32211)
@@ -43,8 +43,8 @@
     }
 
-    private URL getURLRaster(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
+    private static URL getURLRaster(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
         // GET /scpc/wms?version=1.1&request=GetMap&layers=CDIF:PMC@QH4480001701&format=image/png&bbox=-1186,0,13555,8830&width=576&height=345&exception=application/vnd.ogc.se_inimage&styles= HTTP/1.1
         final int cRasterX = CadastrePlugin.imageWidth; // keep width constant and adjust width to original image proportions
-        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
+        String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap";
         str += "&layers=CDIF:PMC@";
         str += wmsLayer.getCodeCommune();
@@ -60,11 +60,10 @@
     }
 
-    private URL buildURLVector(String layers, String styles,
+    private static URL buildURLVector(String layers, String styles,
             int width, int height,
             EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
-        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
+        String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap";
         str += "&layers="+ layers;
         str += "&format=image/png";
-        //str += "&format=image/jpeg";
         str += "&bbox="+lambertMin.east()+",";
         str += lambertMin.north() + ",";
@@ -78,5 +77,5 @@
     }
 
-    private URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
+    private static URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
         return buildURLVector(CadastrePlugin.grabLayers, CadastrePlugin.grabStyles,
                 CadastrePlugin.imageWidth, CadastrePlugin.imageHeight,
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 32211)
@@ -12,6 +12,8 @@
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.Date;
-import java.util.Vector;
+import java.util.List;
 
 import javax.swing.JComboBox;
@@ -26,14 +28,14 @@
 
 public class CadastreInterface {
-    public boolean downloadCanceled = false;
-    public HttpURLConnection urlConn = null;
+    public boolean downloadCanceled;
+    public HttpURLConnection urlConn;
 
     private String cookie;
-    private String interfaceRef = null;
-    private String lastWMSLayerName = null;
+    private String interfaceRef;
+    private String lastWMSLayerName;
     private URL searchFormURL;
-    private Vector<String> listOfCommunes = new Vector<>();
-    private Vector<String> listOfTA = new Vector<>();
-    class PlanImage {
+    private List<String> listOfCommunes = new ArrayList<>();
+    private List<String> listOfTA = new ArrayList<>();
+    static class PlanImage {
         String name;
         String ref;
@@ -43,30 +45,30 @@
         }
     }
-    private Vector<PlanImage> listOfFeuilles = new Vector<>();
+    private List<PlanImage> listOfFeuilles = new ArrayList<>();
     private long cookieTimestamp;
 
-    final String baseURL = "http://www.cadastre.gouv.fr";
-    final String cImageFormat = "Cette commune est au format ";
-    final String cCommuneListStart = "<select name=\"codeCommune\"";
-    final String cCommuneListEnd = "</select>";
-    final String c0ptionListStart = "<option value=\"";
-    final String cOptionListEnd = "</option>";
-    final String cBBoxCommunStart = "new GeoBox(";
-    final String cBBoxCommunEnd = ")";
-
-    final String cInterfaceVector = "afficherCarteCommune.do";
-    final String cInterfaceRasterTA = "afficherCarteTa.do";
-    final String cInterfaceRasterFeuille = "afficherCarteFeuille.do";
-    final String cImageLinkStart = "<a href=\"#\" class=\"raster\" onClick=\"popup('afficherCarteFeuille.do?f=";
-    final String cTAImageLinkStart = "<a href=\"#\" class=\"raster\" onClick=\"popup('afficherCarteTa.do?f=";
-    final String cImageNameStart = ">Feuille ";
-    final String cTAImageNameStart = "Tableau d'assemblage <strong>";
-
-    final static long cCookieExpiration = 30 * 60 * 1000; // 30 minutes expressed in milliseconds
-
-    final  int cRetriesGetCookie = 10; // 10 times every 3 seconds means 30 seconds trying to get a cookie
+    static final String BASE_URL = "http://www.cadastre.gouv.fr";
+    static final String C_IMAGE_FORMAT = "Cette commune est au format ";
+    static final String C_COMMUNE_LIST_START = "<select name=\"codeCommune\"";
+    static final String C_COMMUNE_LIST_END = "</select>";
+    static final String C_OPTION_LIST_START = "<option value=\"";
+    static final String C_OPTION_LIST_END = "</option>";
+    static final String C_BBOX_COMMUN_START = "new GeoBox(";
+    static final String C_BBOX_COMMUN_END = ")";
+
+    static final String C_INTERFACE_VECTOR = "afficherCarteCommune.do";
+    static final String C_INTERFACE_RASTER_TA = "afficherCarteTa.do";
+    static final String C_INTERFACE_RASTER_FEUILLE = "afficherCarteFeuille.do";
+    static final String C_IMAGE_LINK_START = "<a href=\"#\" class=\"raster\" onClick=\"popup('afficherCarteFeuille.do?f=";
+    static final String C_TA_IMAGE_LINK_START = "<a href=\"#\" class=\"raster\" onClick=\"popup('afficherCarteTa.do?f=";
+    static final String C_IMAGE_NAME_START = ">Feuille ";
+    static final String C_TA_IMAGE_NAME_START = "Tableau d'assemblage <strong>";
+
+    static final long COOKIE_EXPIRATION = 30 * 60 * 1000L; // 30 minutes expressed in milliseconds
+
+    static final int RETRIES_GET_COOKIE = 10; // 10 times every 3 seconds means 30 seconds trying to get a cookie
 
     public boolean retrieveInterface(WMSLayer wmsLayer) throws DuplicateLayerException, WMSException {
-        if (wmsLayer.getName().equals(""))
+        if (wmsLayer.getName().isEmpty())
             return false;
         boolean isCookieExpired = isCookieExpired();
@@ -90,4 +92,5 @@
             openInterface();
         } catch (IOException e) {
+            Main.error(e);
             JOptionPane.showMessageDialog(Main.parent,
                     tr("Town/city {0} not found or not available\n" +
@@ -105,9 +108,9 @@
      */
     private void getCookie() throws IOException {
-        boolean sucess = false;
-        int retries = cRetriesGetCookie;
+        boolean success = false;
+        int retries = RETRIES_GET_COOKIE;
         try {
-            searchFormURL = new URL(baseURL + "/scpc/accueil.do");
-            while (sucess == false && retries > 0) {
+            searchFormURL = new URL(BASE_URL + "/scpc/accueil.do");
+            while (!success && retries > 0) {
                 urlConn = (HttpURLConnection)searchFormURL.openConnection();
                 urlConn.setRequestProperty("Connection", "close");
@@ -116,7 +119,9 @@
                 if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                     Main.info("GET "+searchFormURL);
-                    BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
-                    while(in.readLine() != null) {}  // read the buffer otherwise we sent POST too early
-                    sucess = true;
+                    BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8));
+                    while(in.readLine() != null) {
+                        // read the buffer otherwise we sent POST too early
+                    }
+                    success = true;
                     String headerName;
                     for (int i=1; (headerName = urlConn.getHeaderFieldKey(i))!=null; i++) {
@@ -155,5 +160,5 @@
     public boolean isCookieExpired() {
         long now = new Date().getTime();
-        if ((now - cookieTimestamp) > cCookieExpiration) {
+        if ((now - cookieTimestamp) > COOKIE_EXPIRATION) {
             Main.info("cookie received at "+new Date(cookieTimestamp)+" expired (now is "+new Date(now)+")");
             return true;
@@ -182,15 +187,14 @@
         // second attempt either from known codeCommune (e.g. from cache) or from ComboBox
         if (interfaceRef == null) {
-            if (!wmsLayer.getCodeCommune().equals("")) {
+            if (!wmsLayer.getCodeCommune().isEmpty()) {
                 // codeCommune is already known (from previous request or from cache on disk)
                 interfaceRef = postForm(wmsLayer, wmsLayer.getCodeCommune());
             } else {
                 if (listOfCommunes.size() > 1) {
-                    // commune unknown, prompt the list of communes from
-                    // server and try with codeCommune
-                    String selected = selectMunicipalityDialog(wmsLayer);
+                    // commune unknown, prompt the list of communes from server and try with codeCommune
+                    String selected = selectMunicipalityDialog();
                     if (selected != null) {
-                        String newCodeCommune = selected.substring(1, selected.indexOf(">")-2);
-                        String newLocation = selected.substring(selected.indexOf(">")+1, selected.lastIndexOf(" - "));
+                        String newCodeCommune = selected.substring(1, selected.indexOf('>') - 2);
+                        String newLocation = selected.substring(selected.indexOf('>') + 1, selected.lastIndexOf(" - "));
                         wmsLayer.setCodeCommune(newCodeCommune);
                         wmsLayer.setLocation(newLocation);
@@ -205,5 +209,5 @@
                     int res = selectFeuilleDialog();
                     if (res != -1) {
-                        wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name);
+                        wmsLayer.setCodeCommune(listOfFeuilles.get(res).name);
                         checkLayerDuplicates(wmsLayer);
                         interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune());
@@ -220,7 +224,5 @@
         try {
             // finally, open the interface on server side giving access to the wms server
-            String lines = null;
-            String ln = null;
-            URL interfaceURL = new URL(baseURL + "/scpc/"+interfaceRef);
+            URL interfaceURL = new URL(BASE_URL + "/scpc/"+interfaceRef);
             urlConn = (HttpURLConnection)interfaceURL.openConnection();
             urlConn.setRequestMethod("GET");
@@ -231,11 +233,15 @@
             }
             Main.info("GET "+interfaceURL);
-            BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
+            BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8));
             // read the buffer otherwise we sent POST too early
+            StringBuilder lines = new StringBuilder();
+            String ln;
             while ((ln = in.readLine()) != null) {
-                lines += ln;
+                if (Main.isDebugEnabled()) {
+                    lines.append(ln);
+                }
             }
             if (Main.isDebugEnabled()) {
-                Main.debug(lines);
+                Main.debug(lines.toString());
             }
         } catch (MalformedURLException e) {
@@ -267,6 +273,4 @@
     private String postForm(WMSLayer wmsLayer, String codeCommune) throws IOException {
         try {
-            String ln = null;
-            String lines = null;
             listOfCommunes.clear();
             listOfTA.clear();
@@ -276,6 +280,6 @@
             content += "&nomvoie=";
             content += "&lieuDit=";
-            if (codeCommune == "") {
-                content += "&ville=" + new String(java.net.URLEncoder.encode(wmsLayer.getLocation(), "UTF-8"));
+            if (codeCommune.isEmpty()) {
+                content += "&ville=" + java.net.URLEncoder.encode(wmsLayer.getLocation(), "UTF-8");
                 content += "&codePostal=";
             } else {
@@ -286,5 +290,5 @@
             content += "&nbResultatParPage=10";
             content += "&x=0&y=0";
-            searchFormURL = new URL(baseURL + "/scpc/rechercherPlan.do");
+            searchFormURL = new URL(BASE_URL + "/scpc/rechercherPlan.do");
             urlConn = (HttpURLConnection)searchFormURL.openConnection();
             urlConn.setRequestMethod("POST");
@@ -293,39 +297,42 @@
             setCookie();
             try (OutputStream wr = urlConn.getOutputStream()) {
-                wr.write(content.getBytes());
+                wr.write(content.getBytes(StandardCharsets.UTF_8));
                 Main.info("POST "+content);
                 wr.flush();
             }
-            try (BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream()))) {
+            String ln;
+            StringBuilder sb = new StringBuilder();
+            try (BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8))) {
                 while ((ln = rd.readLine()) != null) {
-                    lines += ln;
-                }
-            }
+                    sb.append(ln);
+                }
+            }
+            String lines = sb.toString();
             urlConn.disconnect();
             if (lines != null) {
-                if (lines.indexOf(cImageFormat) != -1) {
-                    int i = lines.indexOf(cImageFormat);
-                    int j = lines.indexOf(".", i);
-                    wmsLayer.setRaster(lines.substring(i+cImageFormat.length(), j).equals("image"));
-                }
-                if (!wmsLayer.isRaster() && lines.indexOf(cInterfaceVector) != -1) {  // "afficherCarteCommune.do"
+                if (lines.indexOf(C_IMAGE_FORMAT) != -1) {
+                    int i = lines.indexOf(C_IMAGE_FORMAT);
+                    int j = lines.indexOf('.', i);
+                    wmsLayer.setRaster("image".equals(lines.substring(i+C_IMAGE_FORMAT.length(), j)));
+                }
+                if (!wmsLayer.isRaster() && lines.indexOf(C_INTERFACE_VECTOR) != -1) {  // "afficherCarteCommune.do"
                     // shall be something like: interfaceRef = "afficherCarteCommune.do?c=X2269";
-                    lines = lines.substring(lines.indexOf(cInterfaceVector),lines.length());
-                    lines = lines.substring(0, lines.indexOf("'"));
+                    lines = lines.substring(lines.indexOf(C_INTERFACE_VECTOR),lines.length());
+                    lines = lines.substring(0, lines.indexOf('\''));
                     Main.info("interface ref.:"+lines);
                     return lines;
-                } else if (wmsLayer.isRaster() && lines.indexOf(cInterfaceRasterTA) != -1) { // "afficherCarteTa.do"
+                } else if (wmsLayer.isRaster() && lines.indexOf(C_INTERFACE_RASTER_TA) != -1) { // "afficherCarteTa.do"
                     // list of values parsed in listOfFeuilles (list all non-georeferenced images)
                     lines = getFeuillesList();
                     if (!downloadCanceled) {
                         parseFeuillesList(lines);
-                        if (listOfFeuilles.size() > 0) {
+                        if (!listOfFeuilles.isEmpty()) {
                             int res = selectFeuilleDialog();
                             if (res != -1) {
-                                wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name);
+                                wmsLayer.setCodeCommune(listOfFeuilles.get(res).name);
                                 checkLayerDuplicates(wmsLayer);
                                 interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune());
-                                wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).ref);
-                                lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.elementAt(res).ref);
+                                wmsLayer.setCodeCommune(listOfFeuilles.get(res).ref);
+                                lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.get(res).ref);
                                 Main.info("interface ref.:"+lines);
                                 return lines;
@@ -334,16 +341,15 @@
                     }
                     return null;
-                } else if (lines.indexOf(cCommuneListStart) != -1 && lines.indexOf(cCommuneListEnd) != -1) {
+                } else if (lines.indexOf(C_COMMUNE_LIST_START) != -1 && lines.indexOf(C_COMMUNE_LIST_END) != -1) {
                     // list of values parsed in listOfCommunes
-                    int i = lines.indexOf(cCommuneListStart);
-                    int j = lines.indexOf(cCommuneListEnd, i);
+                    int i = lines.indexOf(C_COMMUNE_LIST_START);
+                    int j = lines.indexOf(C_COMMUNE_LIST_END, i);
                     parseCommuneList(lines.substring(i, j));
                 }
             }
         } catch (MalformedURLException e) {
-            throw (IOException) new IOException(
-                "Illegal url.").initCause(e);
-        } catch (Exception e){
-            e.printStackTrace();
+            throw (IOException) new IOException("Illegal url.").initCause(e);
+        } catch (DuplicateLayerException e){
+            Main.error(e);
         }
         return null;
@@ -351,12 +357,12 @@
 
     private void parseCommuneList(String input) {
-        if (input.indexOf(c0ptionListStart) != -1) {
+        if (input.indexOf(C_OPTION_LIST_START) != -1) {
             while (input.indexOf("<option value=\"") != -1) {
-                int i = input.indexOf(c0ptionListStart);
-                int j = input.indexOf(cOptionListEnd, i+c0ptionListStart.length());
-                int k = input.indexOf("\"", i+c0ptionListStart.length());
-                if (j != -1 && k > (i + c0ptionListStart.length())) {
-                    String lov = new String(input.substring(i+c0ptionListStart.length()-1, j));
-                    if (lov.indexOf(">") != -1) {
+                int i = input.indexOf(C_OPTION_LIST_START);
+                int j = input.indexOf(C_OPTION_LIST_END, i+C_OPTION_LIST_START.length());
+                int k = input.indexOf('"', i+C_OPTION_LIST_START.length());
+                if (j != -1 && k > (i + C_OPTION_LIST_START.length())) {
+                    String lov = input.substring(i+C_OPTION_LIST_START.length()-1, j);
+                    if (lov.indexOf('>') != -1) {
                         Main.info("parse "+lov);
                         listOfCommunes.add(lov);
@@ -364,5 +370,5 @@
                         Main.error("unable to parse commune string:"+lov);
                 }
-                input = input.substring(j+cOptionListEnd.length());
+                input = input.substring(j+C_OPTION_LIST_END.length());
             }
         }
@@ -372,15 +378,15 @@
         // get all images in one html page
         String ln = null;
-        String lines = null;
+        StringBuilder lines = new StringBuilder();
         HttpURLConnection urlConn2 = null;
         try {
-            URL getAllImagesURL = new URL(baseURL + "/scpc/listerFeuillesParcommune.do?keepVolatileSession=&offset=2000");
+            URL getAllImagesURL = new URL(BASE_URL + "/scpc/listerFeuillesParcommune.do?keepVolatileSession=&offset=2000");
             urlConn2 = (HttpURLConnection)getAllImagesURL.openConnection();
             setCookie(urlConn2);
             urlConn2.connect();
             Main.info("GET "+getAllImagesURL);
-            try (BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn2.getInputStream()))) {
+            try (BufferedReader rd = new BufferedReader(new InputStreamReader(urlConn2.getInputStream(), StandardCharsets.UTF_8))) {
                 while ((ln = rd.readLine()) != null) {
-                    lines += ln;
+                    lines.append(ln);
                 }
             }
@@ -390,5 +396,5 @@
             Main.error(e);
         }
-        return lines;
+        return lines.toString();
     }
 
@@ -398,18 +404,18 @@
         String inputTA = input;
         if (Main.pref.getBoolean("cadastrewms.useTA", false)) {
-            while (inputTA.indexOf(cTAImageLinkStart) != -1) {
-                inputTA = inputTA.substring(inputTA.indexOf(cTAImageLinkStart) + cTAImageLinkStart.length());
-                String refTA = inputTA.substring(0, inputTA.indexOf("'"));
-                String nameTA = inputTA.substring(inputTA.indexOf(cTAImageNameStart) + cTAImageNameStart.length());
-                nameTA = nameTA.substring(0, nameTA.indexOf("<"));
+            while (inputTA.indexOf(C_TA_IMAGE_LINK_START) != -1) {
+                inputTA = inputTA.substring(inputTA.indexOf(C_TA_IMAGE_LINK_START) + C_TA_IMAGE_LINK_START.length());
+                String refTA = inputTA.substring(0, inputTA.indexOf('\''));
+                String nameTA = inputTA.substring(inputTA.indexOf(C_TA_IMAGE_NAME_START) + C_TA_IMAGE_NAME_START.length());
+                nameTA = nameTA.substring(0, nameTA.indexOf('<'));
                 listOfFeuilles.add(new PlanImage(nameTA, refTA));
             }
         }
         // get "Feuilles"
-        while (input.indexOf(cImageLinkStart) != -1) {
-            input = input.substring(input.indexOf(cImageLinkStart)+cImageLinkStart.length());
-            String refFeuille = input.substring(0, input.indexOf("'"));
+        while (input.indexOf(C_IMAGE_LINK_START) != -1) {
+            input = input.substring(input.indexOf(C_IMAGE_LINK_START)+C_IMAGE_LINK_START.length());
+            String refFeuille = input.substring(0, input.indexOf('\''));
             String nameFeuille = input.substring(
-                    input.indexOf(cImageNameStart)+cImageNameStart.length(),
+                    input.indexOf(C_IMAGE_NAME_START)+C_IMAGE_NAME_START.length(),
                     input.indexOf(" -"));
             listOfFeuilles.add(new PlanImage(nameFeuille, refFeuille));
@@ -417,15 +423,14 @@
     }
 
-    private String selectMunicipalityDialog(WMSLayer wmsLayer) {
+    private String selectMunicipalityDialog() {
         JPanel p = new JPanel(new GridBagLayout());
         String[] communeList = new String[listOfCommunes.size() + 1];
         communeList[0] = tr("Choose from...");
         for (int i = 0; i < listOfCommunes.size(); i++) {
-            communeList[i + 1] = listOfCommunes.elementAt(i).substring(listOfCommunes.elementAt(i).indexOf(">")+1);
+            communeList[i + 1] = listOfCommunes.get(i).substring(listOfCommunes.get(i).indexOf('>')+1);
         }
         JComboBox<String> inputCommuneList = new JComboBox<>(communeList);
         p.add(inputCommuneList, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 0, 0, 0));
         JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null);
-        //pane.createDialog(Main.parent, tr("Select commune")).setVisible(true);
         // this below is a temporary workaround to fix the "always on top" issue
         JDialog dialog = pane.createDialog(Main.parent, tr("Select commune"));
@@ -435,17 +440,16 @@
         if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue()))
             return null;
-        return listOfCommunes.elementAt(inputCommuneList.getSelectedIndex()-1);
+        return listOfCommunes.get(inputCommuneList.getSelectedIndex()-1);
     }
 
     private int selectFeuilleDialog() {
         JPanel p = new JPanel(new GridBagLayout());
-        Vector<String> imageNames = new Vector<>();
+        List<String> imageNames = new ArrayList<>();
         for (PlanImage src : listOfFeuilles) {
             imageNames.add(src.name);
         }
-        JComboBox<String> inputFeuilleList = new JComboBox<>(imageNames);
+        JComboBox<String> inputFeuilleList = new JComboBox<>(imageNames.toArray(new String[]{}));
         p.add(inputFeuilleList, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 0, 0, 0));
         JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null);
-        //pane.createDialog(Main.parent, tr("Select Feuille")).setVisible(true);
         // this below is a temporary workaround to fix the "always on top" issue
         JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille"));
@@ -455,10 +459,9 @@
         if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue()))
             return -1;
-        int result = inputFeuilleList.getSelectedIndex();
-        return result;
-    }
-
-    private String buildRasterFeuilleInterfaceRef(String codeCommune) {
-        return cInterfaceRasterFeuille + "?f=" + codeCommune;
+        return inputFeuilleList.getSelectedIndex();
+    }
+
+    private static String buildRasterFeuilleInterfaceRef(String codeCommune) {
+        return C_INTERFACE_RASTER_FEUILLE + "?f=" + codeCommune;
     }
 
@@ -474,8 +477,6 @@
         if (interfaceRef == null)
             return;
-        String ln = null;
-        String line = null;
         // send GET opening normally the small window with the commune overview
-        String content = baseURL + "/scpc/" + interfaceRef;
+        String content = BASE_URL + "/scpc/" + interfaceRef;
         content += "&dontSaveLastForward&keepVolatileSession=";
         searchFormURL = new URL(content);
@@ -488,10 +489,13 @@
         }
         Main.info("GET "+searchFormURL);
-        try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()))) {
+        String ln;
+        StringBuilder sb = new StringBuilder();
+        try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8))) {
             while ((ln = in.readLine()) != null) {
-                line += ln;
+                sb.append(ln);
             }
         }
         urlConn.disconnect();
+        String line = sb.toString();
         parseBBoxCommune(wmsLayer, line);
         if (wmsLayer.isRaster() && !wmsLayer.isAlreadyGeoreferenced()) {
@@ -500,14 +504,14 @@
     }
 
-    private void parseBBoxCommune(WMSLayer wmsLayer, String input) {
-        if (input.indexOf(cBBoxCommunStart) != -1) {
-            input = input.substring(input.indexOf(cBBoxCommunStart));
-            int i = input.indexOf(",");
-            double minx = Double.parseDouble(input.substring(cBBoxCommunStart.length(), i));
-            int j = input.indexOf(",", i+1);
+    private static void parseBBoxCommune(WMSLayer wmsLayer, String input) {
+        if (input.indexOf(C_BBOX_COMMUN_START) != -1) {
+            input = input.substring(input.indexOf(C_BBOX_COMMUN_START));
+            int i = input.indexOf(',');
+            double minx = Double.parseDouble(input.substring(C_BBOX_COMMUN_START.length(), i));
+            int j = input.indexOf(',', i+1);
             double miny = Double.parseDouble(input.substring(i+1, j));
-            int k = input.indexOf(",", j+1);
+            int k = input.indexOf(',', j+1);
             double maxx = Double.parseDouble(input.substring(j+1, k));
-            int l = input.indexOf(cBBoxCommunEnd, k+1);
+            int l = input.indexOf(C_BBOX_COMMUN_END, k+1);
             double maxy = Double.parseDouble(input.substring(k+1, l));
             wmsLayer.setCommuneBBox( new EastNorthBound(new EastNorth(minx,miny), new EastNorth(maxx,maxy)));
@@ -515,5 +519,5 @@
     }
 
-    private void parseGeoreferences(WMSLayer wmsLayer, String input) {
+    private static void parseGeoreferences(WMSLayer wmsLayer, String input) {
         /* commented since cadastre WMS changes mid july 2013
          * until new GeoBox coordinates parsing is solved */
@@ -547,13 +551,12 @@
 //                wmsLayer.Y0 = Y0;
 //            }
-//            Main.info("parse georef:"+unknown_yet+","+angle+","+scale_origin+","+dpi+","+fX+","+
-//                    fY+","+X0+","+Y0);
+//            Main.info("parse georef:"+unknown_yet+","+angle+","+scale_origin+","+dpi+","+fX+","+fY+","+X0+","+Y0);
 //        }
     }
 
-    private void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
+    private static void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
         if (Main.map != null) {
             for (Layer l : Main.map.mapView.getAllLayers()) {
-                if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (l != wmsLayer)) {
+                if (l instanceof WMSLayer && l.getName().equals(wmsLayer.getName()) && (!l.equals(wmsLayer))) {
                     Main.info("Try to grab into a new layer when "+wmsLayer.getName()+" is already opened.");
                     // remove the duplicated layer
@@ -569,5 +572,4 @@
             urlConn.setConnectTimeout(1);
             urlConn.setReadTimeout(1);
-            //urlConn.disconnect();
         }
         downloadCanceled = true;
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java	(revision 32211)
@@ -41,10 +41,10 @@
             fileStr = URLDecoder.decode(fileStr, "UTF-8");
             fileStr = fileStr.substring(fileStr.indexOf(":/")+2);
-            String filename = fileStr.substring(fileStr.lastIndexOf("/")+1,fileStr.length());
-            String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length());
+            String filename = fileStr.substring(fileStr.lastIndexOf('/')+1,fileStr.length());
+            String ext = (filename.lastIndexOf('.')==-1)?"":filename.substring(filename.lastIndexOf('.')+1,filename.length());
             // create layer and load cache
-            if (ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z))
+            if (ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z))
                 ext = ext.substring(2);
-            else if (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N))
+            else if (ext.length() == 4 && ext.substring(0, CacheControl.C_UTM20N.length()).equals(CacheControl.C_UTM20N))
                 ext = ext.substring(3);
             else if (ext.length() == 2 || ext.length() > 4)
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java	(revision 32211)
@@ -14,4 +14,5 @@
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -38,7 +39,7 @@
     private WMSLayer wmsLayer;
     private CadastreInterface wmsInterface;
-    private String svg = null;
-    private static EastNorthBound currentView = null;
-    private EastNorthBound viewBox = null;
+    private String svg;
+    private static EastNorthBound currentView;
+    private EastNorthBound viewBox;
     private static String errorMessage;
 
@@ -82,4 +83,5 @@
     @Override
     protected void finish() {
+        // Do nothing
     }
 
@@ -119,5 +121,5 @@
                 // check if new node is not already created by another new path
                 Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.getNodes());
-                if (nearestNewNode == nodeToAdd)
+                if (nodeToAdd.equals(nearestNewNode))
                     svgDataSet.addPrimitive(nearestNewNode);
                 wayToAdd.addNode(nearestNewNode); // either a new node or an existing one
@@ -175,5 +177,5 @@
         double dy = Double.parseDouble(coor[2]);
         for (int i=3; i<coor.length; i+=2){
-            if (coor[i].equals("")) {
+            if (coor[i].isEmpty()) {
                 eastNorth.clear(); // some paths are just artifacts
                 return;
@@ -197,5 +199,5 @@
      * @return the already existing node (if any), otherwise the new node candidate.
      */
-    private Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) {
+    private static Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) {
         double epsilon = 0.05; // smallest distance considering duplicate node
         for (Node n : nodes) {
@@ -220,6 +222,6 @@
     }
 
-    private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
-        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
+    private static URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
+        String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap";
         str += "&layers=";
         str += "CDIF:LS2";
@@ -243,15 +245,15 @@
         wmsInterface.setCookie();
         File file = new File(CadastrePlugin.cacheDir + "building.svg");
-        String svg = new String();
+        String svg = "";
         try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
             if (file.exists())
                 file.delete();
             try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
-                 InputStreamReader isr = new InputStreamReader(is);
+                 InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
                  BufferedReader br = new BufferedReader(isr)) {
-                String line="";
+                String line;
                 while ( null!=(line=br.readLine())){
                     line += "\n";
-                    bos.write(line.getBytes());
+                    bos.write(line.getBytes(StandardCharsets.UTF_8));
                     svg += line;
                 }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java	(revision 32211)
@@ -14,4 +14,5 @@
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -43,6 +44,6 @@
     private WMSLayer wmsLayer;
     private CadastreInterface wmsInterface;
-    private String svg = null;
-    private EastNorthBound viewBox = null;
+    private String svg;
+    private EastNorthBound viewBox;
     private static String errorMessage;
 
@@ -88,4 +89,5 @@
     @Override
     protected void finish() {
+        // Do nothing
     }
 
@@ -168,7 +170,5 @@
     private String grabBoundary(EastNorthBound bbox) throws IOException, OsmTransferException {
         try {
-            URL url = null;
-            url = getURLsvg(bbox);
-            return grabSVG(url);
+            return grabSVG(getURLsvg(bbox));
         } catch (MalformedURLException e) {
             throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
@@ -176,6 +176,6 @@
     }
 
-    private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
-        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
+    private static URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
+        String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap";
         str += "&layers=";
         str += "CDIF:COMMUNE";
@@ -198,5 +198,5 @@
         wmsInterface.setCookie();
         File file = new File(CadastrePlugin.cacheDir + "boundary.svg");
-        String svg = new String();
+        String svg = "";
         try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
             if (file.exists())
@@ -205,8 +205,8 @@
                  InputStreamReader isr =new InputStreamReader(is);
                  BufferedReader br = new BufferedReader(isr)) {
-                String line="";
+                String line;
                 while ( null!=(line=br.readLine())){
                     line += "\n";
-                    bos.write(line.getBytes());
+                    bos.write(line.getBytes(StandardCharsets.UTF_8));
                     svg += line;
                 }
@@ -219,5 +219,5 @@
 
     public static void download(WMSLayer wmsLayer) {
-        if (CadastrePlugin.autoSourcing == false) {
+        if (!CadastrePlugin.autoSourcing) {
             JOptionPane.showMessageDialog(Main.parent,
                     tr("Please, enable auto-sourcing and check cadastre millesime."));
@@ -228,4 +228,3 @@
             JOptionPane.showMessageDialog(Main.parent, errorMessage);
     }
-
 }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java	(revision 32211)
@@ -18,6 +18,9 @@
     private static final long serialVersionUID = 1L;
 
-    public static String name = marktr("Load layer from cache");
+    public static final String name = marktr("Load layer from cache");
 
+    /**
+     * Constructs a new {@code MenuActionLoadFromCache}.
+     */
     public MenuActionLoadFromCache() {
         super(tr(name), "cadastre_small", tr("Load location from cache (only if cache is enabled)"), null, false, "cadastrefr/loadfromcache", true);
@@ -36,8 +39,8 @@
             if (file.exists()) {
                 String filename = file.getName();
-                String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length());
-                if ((ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z) &&
+                String ext = (filename.lastIndexOf('.')==-1)?"":filename.substring(filename.lastIndexOf('.')+1,filename.length());
+                if ((ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z) &&
                     !(CadastrePlugin.isLambert_cc9()))
-                    || (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N) &&
+                    || (ext.length() == 4 && ext.substring(0, CacheControl.C_UTM20N.length()).equals(CacheControl.C_UTM20N) &&
                             !(CadastrePlugin.isUtm_france_dom()))
                     || (ext.length() == 1) && !(CadastrePlugin.isLambert())) {
@@ -45,8 +48,8 @@
                         continue;
                 } else {
-                    String location = filename.substring(0, filename.lastIndexOf("."));
-                    if (ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z))
+                    String location = filename.substring(0, filename.lastIndexOf('.'));
+                    if (ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z))
                         ext = ext.substring(2);
-                    else if (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N))
+                    else if (ext.length() == 4 && ext.substring(0, CacheControl.C_UTM20N.length()).equals(CacheControl.C_UTM20N))
                         ext = ext.substring(3);
                     // check the extension and its compatibility with current projection
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 32210)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 32211)
@@ -21,4 +21,5 @@
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Vector;
 import java.util.concurrent.locks.Lock;
@@ -39,4 +40,5 @@
 import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 
 /**
@@ -77,6 +79,6 @@
     public EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0));
 
-    private boolean isRaster = false;
-    private boolean isAlreadyGeoreferenced = false;
+    private boolean isRaster;
+    private boolean isAlreadyGeoreferenced;
     public double X0, Y0, angle, fX, fY;
 
@@ -87,6 +89,6 @@
 
     // offset for vector images temporarily shifted (correcting Cadastre artifacts), in pixels
-    public double deltaEast=0;
-    public double deltaNorth=0;
+    public double deltaEast;
+    public double deltaNorth;
 
     private Action saveAsPng;
@@ -107,5 +109,4 @@
             Main.map.mapView.repaint();
         }
-
     }
 
@@ -114,4 +115,7 @@
     public GrabThread grabThread;
 
+    /**
+     * Constructs a new {@code WMSLayer}.
+     */
     public WMSLayer() {
         this(tr("Blank Layer"), "", -1);
@@ -142,6 +146,6 @@
 
     private static String buildName(String location, String codeCommune) {
-        String ret = location.toUpperCase();
-        if (codeCommune != null && !codeCommune.equals(""))
+        String ret = location.toUpperCase(Locale.FRANCE);
+        if (codeCommune != null && !codeCommune.isEmpty())
             ret += "(" + codeCommune + ")";
         return  ret;
@@ -149,5 +153,5 @@
 
     private String rebuildName() {
-        return buildName(this.location.toUpperCase(), this.codeCommune);
+        return buildName(this.location.toUpperCase(Locale.FRANCE), this.codeCommune);
     }
 
@@ -157,14 +161,19 @@
         // if it is the first layer, use the communeBBox as grab bbox (and not divided)
         if (Main.map.mapView.getAllLayers().size() == 1 ) {
-            b = this.getCommuneBBox().toBounds();
-            Main.map.mapView.zoomTo(b);
-            divideBbox(b, 1);
+            final Bounds bounds = this.getCommuneBBox().toBounds();
+            GuiHelper.runInEDTAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    Main.map.mapView.zoomTo(bounds);
+                }
+            });
+            divideBbox(bounds, 1);
         } else {
             if (isRaster) {
-                b = new Bounds(Main.getProjection().eastNorth2latlon(rasterMin), Main.getProjection().eastNorth2latlon(rasterMax));
-                divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider",
-                        CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)));
+                divideBbox(new Bounds(Main.getProjection().eastNorth2latlon(rasterMin), Main.getProjection().eastNorth2latlon(rasterMax)),
+                        Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)));
             } else
-                divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.scale", CadastrePreferenceSetting.DEFAULT_GRAB_MULTIPLIER)));
+                divideBbox(b, 
+                        Integer.parseInt(Main.pref.get("cadastrewms.scale", CadastrePreferenceSetting.DEFAULT_GRAB_MULTIPLIER)));
         }
         grabThread.addImages(dividedBbox);
@@ -223,5 +232,5 @@
                     j = 0;
                     currDir = (currDir+1)%4;
-                } else if (currDir >= 0 && j >= (currDir == 0 || currDir == 2 ? x-1 : y-1)) {
+                } else if (currDir >= 0 && j >= (currDir == 0 || currDir == 2 ? (x-1) : (y-1))) {
                     // the overall is a rectangle, not a square. Jump to the other side to grab next square.
                     k++;
@@ -251,9 +260,10 @@
             str += "\n"+tr("Is not vectorized.");
             str += "\n"+tr("Bounding box: {0}", communeBBox);
-            if(images.size()>0)
+            if(!images.isEmpty())
                 str += "\n"+tr("Image size (px): {0}/{1}", images.get(0).image.getWidth(), images.get(0).image.getHeight());
-        } else
+        } else {
             str += "\n"+tr("Is vectorized.");
             str += "\n"+tr("Commune bbox: {0}", communeBBox);
+        }
         return str;
     }
@@ -266,4 +276,5 @@
     @Override
     public void mergeFrom(Layer from) {
+        // Do nothing
     }
 
@@ -318,5 +329,5 @@
         refineGeoRef.setEnabled(isRaster && grabThread.getImagesToGrabSize() == 0);
         Action resetOffset = new ResetOffsetActionMenu();
-        resetOffset.setEnabled(!isRaster && images.size() > 0 && (deltaEast!=0.0 || deltaNorth!=0.0));
+        resetOffset.setEnabled(!isRaster && !images.isEmpty() && (deltaEast!=0.0 || deltaNorth!=0.0));
         return new Action[] {
                 LayerListDialog.getInstance().createShowHideLayerAction(),
@@ -328,5 +339,4 @@
                 resetOffset,
                 new LayerListPopup.InfoAction(this),
-
         };
     }
@@ -368,5 +378,4 @@
         return minX+","+minY+","+maxX+","+maxY;
     }
-
 
     public String getLocation() {
@@ -548,6 +557,6 @@
             int newWidth = oldImgWidth*lx.size();
             int newHeight = oldImgHeight*ly.size();
-            BufferedImage new_img = new BufferedImage(newWidth, newHeight, images.get(0).image.getType()/*BufferedImage.TYPE_INT_ARGB*/);
-            Graphics g = new_img.getGraphics();
+            BufferedImage newImg = new BufferedImage(newWidth, newHeight, images.get(0).image.getType()/*BufferedImage.TYPE_INT_ARGB*/);
+            Graphics g = newImg.getGraphics();
             // Coordinate (0,0) is on top,left corner where images are grabbed from bottom left
             int rasterDivider = (int)Math.sqrt(images.size());
@@ -562,5 +571,5 @@
             synchronized(this) {
                 images.clear();
-                images.add(new GeorefImage(new_img, min, max, this));
+                images.add(new GeorefImage(newImg, min, max, this));
             }
         }
@@ -586,5 +595,7 @@
         rasterMin = adj1;
         rasterMax = adj2;
-        setCommuneBBox(new EastNorthBound(new EastNorth(0,0), new EastNorth(images.get(0).image.getWidth()-1,images.get(0).image.getHeight()-1)));
+        setCommuneBBox(new EastNorthBound(
+                new EastNorth(0,0), 
+                new EastNorth(images.get(0).image.getWidth()-1,images.get(0).image.getHeight()-1)));
         rasterRatio = (rasterMax.getX()-rasterMin.getX())/(communeBBox.max.getX() - communeBBox.min.getX());
     }
@@ -598,16 +609,15 @@
             return communeBBox;
         }
-        double min_x = Double.MAX_VALUE;
-        double max_x = Double.MIN_VALUE;
-        double min_y = Double.MAX_VALUE;
-        double max_y = Double.MIN_VALUE;
+        double minX = Double.MAX_VALUE;
+        double maxX = Double.MIN_VALUE;
+        double minY = Double.MAX_VALUE;
+        double maxY = Double.MIN_VALUE;
         for (GeorefImage image:images){
-            min_x = image.min.east() < min_x ? image.min.east() : min_x;
-            max_x = image.max.east() > max_x ? image.max.east() : max_x;
-            min_y = image.min.north() < min_y ? image.min.north() : min_y;
-            max_y = image.max.north() > max_y ? image.max.north() : max_y;
-        }
-        EastNorthBound maxGrabbedBBox = new EastNorthBound(new EastNorth(min_x, min_y), new EastNorth(max_x, max_y));
-        return maxGrabbedBBox;
+            minX = image.min.east() < minX ? image.min.east() : minX;
+            maxX = image.max.east() > maxX ? image.max.east() : maxX;
+            minY = image.min.north() < minY ? image.min.north() : minY;
+            maxY = image.max.north() > maxY ? image.max.north() : maxY;
+        }
+        return new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY));
     }
 
@@ -653,5 +663,4 @@
         this.rasterMin = rasterMin.rotate(rasterCenter, angle);
         this.rasterMax = rasterMax.rotate(rasterCenter, angle);
-//        double proportion = dst1.distance(dst2)/org1.distance(org2);
         images.get(0).rotate(rasterCenter, angle);
         this.angle += angle;
@@ -718,4 +727,3 @@
         imagesLock.unlock();
     }
-
 }
