Index: /applications/editors/josm/plugins/cadastre-fr/build.xml
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/build.xml	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/build.xml	(revision 36385)
@@ -16,5 +16,5 @@
     <property name="plugin.stage" value="60"/>
     <property name="plugin.requires" value="apache-commons;ejml;jts;geotools"/>
-    <property name="plugin.minimum.java.version" value="11"/>
+    <property name="plugin.minimum.java.version" value="17"/>
 
     <!-- ** include targets that all plugins have in common ** -->
Index: /applications/editors/josm/plugins/cadastre-fr/pom.xml
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/pom.xml	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/pom.xml	(revision 36385)
@@ -29,5 +29,6 @@
         <plugin.stage>60</plugin.stage>
         <plugin.requires>apache-commons;ejml;jts;geotools</plugin.requires>
-        <plugin.minimum.java.version>11</plugin.minimum.java.version>
+        <java.lang.version>17</java.lang.version>
+        <plugin.minimum.java.version>${java.lang.version}</plugin.minimum.java.version>
     </properties>
     <dependencies>
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/CadastrePlugin.java	(revision 36385)
@@ -7,6 +7,4 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.io.File;
@@ -22,4 +20,5 @@
 import javax.swing.JOptionPane;
 import javax.swing.KeyStroke;
+import javax.swing.WindowConstants;
 
 import org.openstreetmap.josm.actions.ExtensionFileFilter;
@@ -178,24 +177,26 @@
 
     // true if the checkbox "auto-sourcing" is set in the plugin menu
-    public static boolean autoSourcing = false;
+    public static boolean autoSourcing;
 
     // true when the plugin is first used, e.g. grab from WMS or download cache file
-    public static boolean pluginUsed = false;
-
-    public static String cacheDir = null;
-
-    public static boolean alterColors = false;
-
-    public static boolean backgroundTransparent = false;
+    public static boolean pluginUsed;
+
+    public static String cacheDir;
+
+    public static boolean alterColors;
+
+    public static boolean backgroundTransparent;
 
     public static float transparency = 1.0f;
 
-    public static boolean drawBoundaries = false;
-
-    public static int imageWidth, imageHeight;
-
-    public static String grabLayers, grabStyles = null;
-
-    private static boolean menuEnabled = false;
+    public static boolean drawBoundaries;
+
+    public static int imageWidth;
+    public static int imageHeight;
+
+    public static String grabLayers;
+    public static String grabStyles;
+
+    private static boolean menuEnabled;
 
     private static final String LAYER_BULDINGS = "CDIF:BATIMENT,CDIF:LS2";
@@ -224,5 +225,5 @@
     public CadastrePlugin(PluginInformation info) {
         super(info);
-        Logging.info("Pluging cadastre-fr v"+VERSION+" started...");
+        Logging.info("Plugin cadastre-fr v"+VERSION+" started...");
         initCacheDir();
 
@@ -265,10 +266,7 @@
             final JCheckBoxMenuItem menuSource = new JCheckBoxMenuItem(tr("Auto sourcing"));
             menuSource.setSelected(autoSourcing);
-            menuSource.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent ev) {
-                    Config.getPref().putBoolean("cadastrewms.autosourcing", menuSource.isSelected());
-                    autoSourcing = menuSource.isSelected();
-                }
+            menuSource.addActionListener(ev -> {
+                Config.getPref().putBoolean("cadastrewms.autosourcing", menuSource.isSelected());
+                autoSourcing = menuSource.isSelected();
             });
 
@@ -296,4 +294,7 @@
     }
 
+    /**
+     * Update the configuration values
+     */
     public static void refreshConfiguration() {
         source = checkSourceMillesime();
@@ -309,7 +310,7 @@
         }
         String currentResolution = Config.getPref().get("cadastrewms.resolution", "high");
-        if (currentResolution.equals("high")) {
+        if ("high".equals(currentResolution)) {
             imageWidth = 1000; imageHeight = 800;
-        } else if (currentResolution.equals("medium")) {
+        } else if ("medium".equals(currentResolution)) {
             imageWidth = 800; imageHeight = 600;
         } else {
@@ -466,4 +467,5 @@
         } catch (InterruptedException e) {
             Logging.debug(e);
+            Thread.currentThread().interrupt();
         }
     }
@@ -477,9 +479,10 @@
             } catch (SecurityException e) {
                 Logging.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString()));
+                Logging.trace(e);
             }
         }
         dialog.setModal(true);
         dialog.toFront();
-        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+        dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     }
 
@@ -508,5 +511,5 @@
         int currentYear = Calendar.getInstance().get(Calendar.YEAR);
         String src = Config.getPref().get("cadastrewms.source",
-            "cadastre-dgi-fr source : Direction G\u00e9n\u00e9rale des Imp\u00f4ts - Cadastre. Mise \u00e0 jour : AAAA");
+            "cadastre-dgi-fr source : Direction Générale des Impôts - Cadastre. Mise à jour : AAAA");
         String srcYear = src.substring(src.lastIndexOf(" ")+1);
         Integer year = null;
@@ -516,5 +519,5 @@
             Logging.debug(e);
         }
-        if (srcYear.equals("AAAA") || (year != null && year < currentYear)) {
+        if ("AAAA".equals(srcYear) || (year != null && year < currentYear)) {
             Logging.info("Replace source year "+srcYear+" by current year "+currentYear);
             src = src.substring(0, src.lastIndexOf(" ")+1)+currentYear;
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionBoundaries.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionBoundaries.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionBoundaries.java	(revision 36385)
@@ -22,5 +22,4 @@
 
     private static final long serialVersionUID = 1L;
-    private WMSLayer wmsLayer = null;
 
     /**
@@ -33,5 +32,5 @@
     @Override
     public void actionPerformed(ActionEvent arg0) {
-        wmsLayer = WMSDownloadAction.getLayer();
+        WMSLayer wmsLayer = WMSDownloadAction.getLayer();
         if (wmsLayer != null) {
             if (wmsLayer.isRaster()) {
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionCancelGrab.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionCancelGrab.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionCancelGrab.java	(revision 36385)
@@ -17,5 +17,5 @@
     private static final String NAME = marktr("Cancel current grab");
 
-    private WMSLayer wmsLayer;
+    private final transient WMSLayer wmsLayer;
 
     /**
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionGrabPlanImage.java	(revision 36385)
@@ -30,7 +30,7 @@
     public static final String NAME = marktr("Georeference an image");
 
-    private DownloadWMSPlanImage downloadWMSPlanImage;
-    private WMSLayer wmsLayer;
-    private RasterImageGeoreferencer rasterImageGeoreferencer;
+    private transient DownloadWMSPlanImage downloadWMSPlanImage;
+    private transient WMSLayer wmsLayer;
+    private transient RasterImageGeoreferencer rasterImageGeoreferencer;
 
     /**
@@ -56,5 +56,5 @@
         if (MainApplication.getMap() != null) {
             if (CadastrePlugin.isCadastreProjection()) {
-                wmsLayer = new MenuActionNewLocation().addNewLayer(new ArrayList<WMSLayer>());
+                wmsLayer = new MenuActionNewLocation().addNewLayer(new ArrayList<>());
                 if (wmsLayer == null) return;
                 downloadWMSPlanImage = new DownloadWMSPlanImage();
@@ -74,5 +74,5 @@
         if (loadedFromCache) {
             wmsLayer.invalidate();
-        } else if (wmsLayer.getImages().size() == 0) {
+        } else if (wmsLayer.getImages().isEmpty()) {
             // action canceled or image loaded from cache (and already georeferenced)
             rasterImageGeoreferencer.actionInterrupted();
@@ -90,5 +90,5 @@
             } else {
                 rasterImageGeoreferencer.addListener();
-                if (Config.getPref().getBoolean("cadastrewms.noImageCropping", false) == false)
+                if (!Config.getPref().getBoolean("cadastrewms.noImageCropping", false))
                     rasterImageGeoreferencer.startCropping(wmsLayer);
                 else
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionLoadFromCache.java	(revision 36385)
@@ -27,6 +27,7 @@
 public class MenuActionLoadFromCache extends JosmAction {
     private static final long serialVersionUID = 1L;
+    private static final String ERROR = marktr("Error");
 
-    private static final String name = marktr("Load layer from cache");
+    private static final String ACTION_NAME = marktr("Load layer from cache");
 
     /**
@@ -34,5 +35,5 @@
      */
     public MenuActionLoadFromCache() {
-        super(tr(name), "cadastre_small",
+        super(tr(ACTION_NAME), "cadastre_small",
                 tr("Load location from cache (only if cache is enabled)"), null, false, "cadastrefr/loadfromcache", true);
     }
@@ -46,61 +47,79 @@
         File[] files = fc.getSelectedFiles();
         int layoutZone = CadastrePlugin.getCadastreProjectionLayoutZone();
-        nextFile:
         for (File file : files) {
             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.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z) &&
-                    !CadastrePlugin.isLambert_cc9())
-                    || (ext.length() == 4 && ext.substring(0, CacheControl.C_UTM20N.length()).equals(CacheControl.C_UTM20N) &&
-                            !CadastrePlugin.isUtm_france_dom())
+                String ext = getExtension(filename);
+                if ((extIsLambertCC9Z(ext) && !CadastrePlugin.isLambert_cc9())
+                    || (extIsUTM20N(ext) && !CadastrePlugin.isUtm_france_dom())
                     || (ext.length() == 1 && !CadastrePlugin.isLambert())) {
                         JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
                                 tr("{0} not allowed with the current projection", filename),
                                 tr("Error"), JOptionPane.ERROR_MESSAGE);
-                        continue;
                 } else {
-                    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.C_UTM20N.length()).equals(CacheControl.C_UTM20N))
-                        ext = ext.substring(3);
-                    // check the extension and its compatibility with current projection
-                    try {
-                        int cacheZone = Integer.parseInt(ext) - 1;
-                        if (cacheZone >= 0 && cacheZone <= 9) {
-                            if (cacheZone != layoutZone) {
-                                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
-                                        tr("Cannot load cache {0} which is not compatible with current projection zone", filename),
-                                        tr("Error"), JOptionPane.ERROR_MESSAGE);
-                                continue nextFile;
-                            } else
-                                Logging.info("Load cache " + filename);
-                        }
-                    } catch (NumberFormatException ex) {
-                        JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
-                                tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename),
-                                tr("Error"), JOptionPane.ERROR_MESSAGE);
-                        continue nextFile;
-                    }
-                    // check if the selected cache is not already displayed
-                    if (MainApplication.getMap() != null) {
-                        for (Layer l : MainApplication.getLayerManager().getLayers()) {
-                            if (l instanceof WMSLayer && l.getName().equals(location)) {
-                                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
-                                        tr("The location {0} is already on screen. Cache not loaded.", filename),
-                                        tr("Error"), JOptionPane.ERROR_MESSAGE);
-                                continue nextFile;
-                            }
-                        }
-                    }
-                    // create layer and load cache
-                    WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1);
-                    if (wmsLayer.grabThread.getCacheControl().loadCache(file, layoutZone)) {
-                        CadastrePlugin.addWMSLayer(wmsLayer);
-                    }
+                    actionPerformed(file, filename, ext, layoutZone);
                 }
             }
         }
+    }
+
+    private static String getExtension(String filename) {
+        return (filename.lastIndexOf('.') == -1) ? "" : filename.substring(filename.lastIndexOf('.')+1);
+    }
+
+    private static String simplifyExtension(String ext) {
+        if (extIsLambertCC9Z(ext))
+            return ext.substring(2);
+        else if (extIsUTM20N(ext))
+            return ext.substring(3);
+        return ext;
+    }
+
+    private static void actionPerformed(File file, String filename, String ext, int layoutZone) {
+        String location = filename.substring(0, filename.lastIndexOf('.'));
+        // check the extension and its compatibility with current projection
+        ext = simplifyExtension(ext);
+        try {
+            int cacheZone = Integer.parseInt(ext) - 1;
+            if (cacheZone >= 0 && cacheZone <= 9) {
+                if (cacheZone != layoutZone) {
+                    JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
+                            tr("Cannot load cache {0} which is not compatible with current projection zone", filename),
+                            tr(ERROR), JOptionPane.ERROR_MESSAGE);
+                    return;
+                } else {
+                    Logging.info("Load cache " + filename);
+                }
+            }
+        } catch (NumberFormatException ex) {
+            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
+                    tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename),
+                    tr(ERROR), JOptionPane.ERROR_MESSAGE);
+            return;
+        }
+        // check if the selected cache is not already displayed
+        if (MainApplication.getMap() != null) {
+            for (Layer l : MainApplication.getLayerManager().getLayers()) {
+                if (l instanceof WMSLayer && l.getName().equals(location)) {
+                    JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
+                            tr("The location {0} is already on screen. Cache not loaded.", filename),
+                            tr(ERROR), JOptionPane.ERROR_MESSAGE);
+                    return;
+                }
+            }
+        }
+        // create layer and load cache
+        WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1);
+        if (wmsLayer.grabThread.getCacheControl().loadCache(file, layoutZone)) {
+            CadastrePlugin.addWMSLayer(wmsLayer);
+        }
+    }
+
+    private static boolean extIsLambertCC9Z(String ext) {
+        return ext.length() == 3 && ext.startsWith(CacheControl.C_LAMBERT_CC_9Z);
+    }
+
+    private static boolean extIsUTM20N(String ext) {
+        return ext.length() == 4 && ext.startsWith(CacheControl.C_UTM20N);
     }
 
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionNewLocation.java	(revision 36385)
@@ -4,7 +4,10 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
 
 import javax.swing.JComboBox;
@@ -30,4 +33,6 @@
 
     private static final long serialVersionUID = 1L;
+
+    private static final String CADASTREWMS_CODE_DEPARTEMENT = "cadastrewms.codeDepartement";
 
     // CHECKSTYLE.OFF: LineLength
@@ -72,13 +77,10 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        WMSLayer wmsLayer = addNewLayer(new ArrayList<WMSLayer>());
+        WMSLayer wmsLayer = addNewLayer(new ArrayList<>());
         if (wmsLayer != null)
             DownloadWMSVectorImage.download(wmsLayer);
     }
 
-    public WMSLayer addNewLayer(ArrayList<WMSLayer> existingLayers) {
-        String location = "";
-        String codeDepartement = "";
-        String codeCommune = "";
+    public WMSLayer addNewLayer(List<WMSLayer> existingLayers) {
         JLabel labelSectionNewLocation = new JLabel(tr("Add a new municipality layer"));
         JPanel p = new JPanel(new GridBagLayout());
@@ -93,7 +95,7 @@
         }
         inputDepartement.setToolTipText(tr("<html>Departement number (optional)</html>"));
-        if (!Config.getPref().get("cadastrewms.codeDepartement").equals("")) {
+        if (!"".equals(Config.getPref().get(CADASTREWMS_CODE_DEPARTEMENT))) {
             for (int i = 0; i < departements.length; i += 2) {
-                if (departements[i].equals(Config.getPref().get("cadastrewms.codeDepartement")))
+                if (departements[i].equals(Config.getPref().get(CADASTREWMS_CODE_DEPARTEMENT)))
                     inputDepartement.setSelectedIndex(i/2);
             }
@@ -101,7 +103,7 @@
         p.add(labelSectionNewLocation, GBC.eol());
         p.add(labelLocation, GBC.std().insets(10, 0, 0, 0));
-        p.add(inputTown, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
+        p.add(inputTown, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
         p.add(labelDepartement, GBC.std().insets(10, 0, 0, 0));
-        p.add(inputDepartement, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
+        p.add(inputDepartement, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
         JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null) {
             private static final long serialVersionUID = 1L;
@@ -117,11 +119,17 @@
             return null;
 
+        return getWmsLayer(inputTown, inputDepartement, existingLayers);
+    }
+
+    private static WMSLayer getWmsLayer(JTextField inputTown, JComboBox<String> inputDepartement,
+                                        List<WMSLayer> existingLayers) {
         WMSLayer wmsLayer = null;
-        if (!inputTown.getText().equals("")) {
-            location = inputTown.getText().toUpperCase();
-            codeDepartement = departements[inputDepartement.getSelectedIndex()*2];
+        if (!"".equals(inputTown.getText())) {
+            String codeCommune = "";
+            String location = inputTown.getText().toUpperCase(Locale.getDefault());
+            String codeDepartement = departements[inputDepartement.getSelectedIndex()*2];
             Config.getPref().put("cadastrewms.location", location);
             Config.getPref().put("cadastrewms.codeCommune", codeCommune);
-            Config.getPref().put("cadastrewms.codeDepartement", codeDepartement);
+            Config.getPref().put(CADASTREWMS_CODE_DEPARTEMENT, codeDepartement);
             if (MainApplication.getMap() != null) {
                 for (Layer l : MainApplication.getLayerManager().getLayers()) {
@@ -137,5 +145,5 @@
             CadastrePlugin.addWMSLayer(wmsLayer);
             Logging.info("Add new layer with Location:" + inputTown.getText());
-        } else if (existingLayers != null && existingLayers.size() > 0
+        } else if (existingLayers != null && !existingLayers.isEmpty()
                 && MainApplication.getLayerManager().getActiveLayer() instanceof WMSLayer) {
             wmsLayer = (WMSLayer) MainApplication.getLayerManager().getActiveLayer();
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionRefineGeoRef.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionRefineGeoRef.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionRefineGeoRef.java	(revision 36385)
@@ -20,6 +20,6 @@
     private static final String NAME = marktr("Refine georeferencing");
 
-    private WMSLayer wmsLayer;
-    private RasterImageGeoreferencer rasterImageGeoreferencer;
+    private final transient WMSLayer wmsLayer;
+    private final transient RasterImageGeoreferencer rasterImageGeoreferencer;
 
     /**
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/MenuActionSaveRasterAs.java	(revision 36385)
@@ -9,10 +9,13 @@
 import java.io.File;
 import java.io.IOException;
+import java.io.Serializable;
 import java.util.Locale;
 
 import javax.imageio.ImageIO;
+import javax.imageio.ImageWriteParam;
 import javax.swing.JFileChooser;
 import javax.swing.filechooser.FileFilter;
 
+import org.geotools.api.referencing.FactoryException;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;
@@ -37,7 +40,7 @@
     private static final String NAME = marktr("Save image as...");
 
-    private final WMSLayer wmsLayer;
+    private final transient WMSLayer wmsLayer;
 
-    static class FiltrePng extends FileFilter {
+    static class FiltrePng extends FileFilter implements Serializable {
         @Override
         public boolean accept(File file) {
@@ -54,5 +57,5 @@
     }
 
-    static class FiltreTiff extends FileFilter {
+    static class FiltreTiff extends FileFilter implements Serializable {
         @Override
         public boolean accept(File file) {
@@ -114,5 +117,5 @@
                     GeoTiffWriter gtwriter = new GeoTiffWriter(output);
                     GeoTiffWriteParams wp = new GeoTiffWriteParams();
-                    wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
+                    wp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
                     wp.setCompressionType("LZW");
                     wp.setCompressionQuality(0.75F);
@@ -126,5 +129,5 @@
                     gtwriter.dispose();
                     coverage.dispose(true);
-                } catch (Exception e) {
+                } catch (IOException | FactoryException e) {
                     Logging.error(e);
                 }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/WMSDownloadAction.java	(revision 36385)
@@ -25,24 +25,28 @@
         ArrayList<WMSLayer> existingWMSlayers = new ArrayList<>();
         if (MainApplication.getMap() != null) {
-            Layer activeLayer = MainApplication.getLayerManager().getActiveLayer();
-            if (activeLayer instanceof WMSLayer)
-                return (WMSLayer) activeLayer;
-            for (Layer l : MainApplication.getLayerManager().getLayers()) {
-                if (l instanceof WMSLayer) {
-                    existingWMSlayers.add((WMSLayer) l);
-                }
-            }
-            if (existingWMSlayers.size() == 1)
-                return existingWMSlayers.get(0);
-            if (existingWMSlayers.size() == 0)
-                return new MenuActionNewLocation().addNewLayer(existingWMSlayers);
-            if (Config.getPref().getBoolean("cadastrewms.autoFirstLayer", false)) {
-                return existingWMSlayers.get(0);
-            } else {
-                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
-                        tr("More than one WMS layer present\nSelect one of them first, then retry"));
-            }
+            return getMapLayer(existingWMSlayers);
         } else {
             return new MenuActionNewLocation().addNewLayer(existingWMSlayers);
+        }
+    }
+
+    private static WMSLayer getMapLayer(ArrayList<WMSLayer> existingWMSlayers) {
+        Layer activeLayer = MainApplication.getLayerManager().getActiveLayer();
+        if (activeLayer instanceof WMSLayer)
+            return (WMSLayer) activeLayer;
+        for (Layer l : MainApplication.getLayerManager().getLayers()) {
+            if (l instanceof WMSLayer) {
+                existingWMSlayers.add((WMSLayer) l);
+            }
+        }
+        if (existingWMSlayers.size() == 1)
+            return existingWMSlayers.get(0);
+        if (existingWMSlayers.isEmpty())
+            return new MenuActionNewLocation().addNewLayer(existingWMSlayers);
+        if (Config.getPref().getBoolean("cadastrewms.autoFirstLayer", false)) {
+            return existingWMSlayers.get(0);
+        } else {
+            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
+                    tr("More than one WMS layer present\nSelect one of them first, then retry"));
         }
         return null;
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/Address.java	(revision 36385)
@@ -5,10 +5,9 @@
 
 import java.awt.Cursor;
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
@@ -39,6 +38,4 @@
 import javax.swing.JRadioButton;
 import javax.swing.JTextField;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
 
 import org.openstreetmap.josm.actions.mapmode.MapMode;
@@ -70,14 +67,16 @@
 public class Address extends MapMode {
 
+    private static final String MESSAGE_UNABLE_TO_PARSE_HOUSE_NUMBER = "Unable to parse house number \"{0}\"";
+
     // perhaps make all these tags configurable in the future
-    private String tagHighway = "highway";
-    private String tagHighwayName = "name";
-    private String tagHouseNumber = "addr:housenumber";
-    private String tagHouseStreet = "addr:street";
-    private String tagBuilding = "building";
-    private String relationAddrType = "associatedStreet";
-    private String relationAddrName = "name";
-    private String relationAddrStreetRole = "street";
-    private String relationMemberHouse = "house";
+    private static final String TAG_HIGHWAY = "highway";
+    private static final String TAG_HIGHWAY_NAME = "name";
+    private static final String TAG_HOUSE_NUMBER = "addr:housenumber";
+    private static final String TAG_HOUSE_STREET = "addr:street";
+    private static final String TAG_BUILDING = "building";
+    private static final String RELATION_ADDR_TYPE = "associatedStreet";
+    private static final String RELATION_ADDR_NAME = "name";
+    private static final String RELATION_ADDR_STREET_ROLE = "street";
+    private static final String RELATION_MEMBER_HOUSE = "house";
 
     private JRadioButton plusOne = new JRadioButton("+1", false);
@@ -134,105 +133,129 @@
         MapView mv = MainApplication.getMap().mapView;
         Point mousePos = e.getPoint();
+        Node currentMouseNode = mv.getNearestNode(mousePos, OsmPrimitive::isSelectable);
+        if (currentMouseNode != null) {
+            mousePressedExistingNode(currentMouseNode);
+        } else {
+            mousePressedNoExistingNode(e, mousePos, mv);
+        }
+    }
+
+    private void mousePressedExistingNode(Node currentMouseNode) {
+        // click on existing node
+        setNewSelection(currentMouseNode);
+        String num = currentMouseNode.get(TAG_HOUSE_NUMBER);
+        if (num != null
+                && currentMouseNode.get(TAG_HOUSE_STREET) == null
+                && findWayInRelationAddr(currentMouseNode) == null
+                && !inputStreet.getText().isEmpty()) {
+            // house number already present but not linked to a street
+            Collection<Command> cmds = new LinkedList<>();
+            addStreetNameOrRelation(currentMouseNode, cmds);
+            Command c = new SequenceCommand("Add node address", cmds);
+            UndoRedoHandler.getInstance().add(c);
+            setNewSelection(currentMouseNode);
+        } else {
+            if (num != null) {
+                try {
+                    // add new address
+                    Integer.parseInt(num);
+                    inputNumber.setText(num);
+                    applyInputNumberChange();
+                } catch (NumberFormatException ex) {
+                    Logging.warn(MESSAGE_UNABLE_TO_PARSE_HOUSE_NUMBER, num);
+                }
+            }
+            mousePressedExistingNode(currentMouseNode, num);
+        }
+    }
+
+    private void mousePressedExistingNode(Node currentMouseNode, String num) {
+        final boolean dontUseRelation = Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false);
+        final String houseStreet = currentMouseNode.get(TAG_HOUSE_STREET);
+        if (houseStreet != null && dontUseRelation) {
+            inputStreet.setText(currentMouseNode.get(TAG_HOUSE_STREET));
+            if (ctrl) {
+                Collection<Command> cmds = new LinkedList<>();
+                addAddrToPrimitive(currentMouseNode, cmds);
+                if (num == null)
+                    applyInputNumberChange();
+            }
+            setSelectedWay(null);
+        } else if (houseStreet == null){
+            // check if the node belongs to an associatedStreet relation
+            Way wayInRelationAddr = findWayInRelationAddr(currentMouseNode);
+            if (wayInRelationAddr == null) {
+                // node exists but doesn't carry address information : add tags like a new node
+                if (ctrl) {
+                    applyInputNumberChange();
+                }
+                Collection<Command> cmds = new LinkedList<>();
+                addAddrToPrimitive(currentMouseNode, cmds);
+            } else {
+                inputStreet.setText(wayInRelationAddr.get(TAG_HIGHWAY_NAME));
+                setSelectedWay(wayInRelationAddr);
+            }
+        }
+    }
+
+    private void mousePressedNoExistingNode(MouseEvent e, Point mousePos, MapView mv) {
         List<Way> mouseOnExistingWays = new ArrayList<>();
         List<Way> mouseOnExistingBuildingWays = new ArrayList<>();
-        Node currentMouseNode = mv.getNearestNode(mousePos, OsmPrimitive::isSelectable);
-        if (currentMouseNode != null) {
-            // click on existing node
-            setNewSelection(currentMouseNode);
-            String num = currentMouseNode.get(tagHouseNumber);
-            if (num != null
-                    && currentMouseNode.get(tagHouseStreet) == null
-                    && findWayInRelationAddr(currentMouseNode) == null
-                    && !inputStreet.getText().isEmpty()) {
-                // house number already present but not linked to a street
-                Collection<Command> cmds = new LinkedList<>();
-                addStreetNameOrRelation(currentMouseNode, cmds);
-                Command c = new SequenceCommand("Add node address", cmds);
-                UndoRedoHandler.getInstance().add(c);
-                setNewSelection(currentMouseNode);
+        List<WaySegment> wss = mv.getNearestWaySegments(mousePos, OsmPrimitive::isSelectable);
+        for (IWaySegment<Node, Way> ws : wss) {
+            if (ws.getWay().get(TAG_HIGHWAY) != null && ws.getWay().get(TAG_HIGHWAY_NAME) != null)
+                mouseOnExistingWays.add(ws.getWay());
+            else if (ws.getWay().get(TAG_BUILDING) != null && ws.getWay().get(TAG_HOUSE_NUMBER) == null)
+                mouseOnExistingBuildingWays.add(ws.getWay());
+        }
+        if (mouseOnExistingWays.size() == 1) {
+            // clicked on existing highway => set new street name
+            inputStreet.setText(mouseOnExistingWays.get(0).get(TAG_HIGHWAY_NAME));
+            setSelectedWay(mouseOnExistingWays.get(0));
+            inputNumber.setText("");
+            setNewSelection(mouseOnExistingWays.get(0));
+        } else if (mouseOnExistingWays.isEmpty()) {
+            mousePressedNoExistingNodeNoWays(e, mouseOnExistingBuildingWays);
+        }
+    }
+
+    private void mousePressedNoExistingNodeNoWays(MouseEvent e, List<Way> mouseOnExistingBuildingWays) {
+        // clicked a non highway and not a node => add the new address
+        if (inputStreet.getText().isEmpty() || inputNumber.getText().isEmpty()) {
+            Toolkit.getDefaultToolkit().beep();
+        } else {
+            Collection<Command> cmds = new LinkedList<>();
+            if (ctrl) {
+                applyInputNumberChange();
+            }
+            if (tagPolygon.isSelected()) {
+                addAddrToPolygon(mouseOnExistingBuildingWays, cmds);
             } else {
-                if (num != null) {
-                    try {
-                        // add new address
-                        Integer.parseInt(num);
-                        inputNumber.setText(num);
-                        applyInputNumberChange();
-                    } catch (NumberFormatException ex) {
-                        Logging.warn("Unable to parse house number \"" + num + "\"");
+                Node n = createNewNode(e, cmds);
+                addAddrToPrimitive(n, cmds);
+            }
+        }
+    }
+
+    private static Way findWayInRelationAddr(Node n) {
+        List<OsmPrimitive> l = n.getReferrers();
+        for (OsmPrimitive osm : l) {
+            if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(RELATION_ADDR_TYPE)) {
+                for (RelationMember rm : ((Relation) osm).getMembers()) {
+                    Way w = usableRelationRole(rm);
+                    if (w != null) {
+                        return w;
                     }
                 }
-                if (currentMouseNode.get(tagHouseStreet) != null) {
-                    if (Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false)) {
-                        inputStreet.setText(currentMouseNode.get(tagHouseStreet));
-                        if (ctrl) {
-                            Collection<Command> cmds = new LinkedList<>();
-                            addAddrToPrimitive(currentMouseNode, cmds);
-                            if (num == null)
-                                applyInputNumberChange();
-                        }
-                        setSelectedWay((Way) null);
-                    }
-                } else {
-                    // check if the node belongs to an associatedStreet relation
-                    Way wayInRelationAddr = findWayInRelationAddr(currentMouseNode);
-                    if (wayInRelationAddr == null) {
-                        // node exists but doesn't carry address information : add tags like a new node
-                        if (ctrl) {
-                            applyInputNumberChange();
-                        }
-                        Collection<Command> cmds = new LinkedList<>();
-                        addAddrToPrimitive(currentMouseNode, cmds);
-                    } else {
-                        inputStreet.setText(wayInRelationAddr.get(tagHighwayName));
-                        setSelectedWay(wayInRelationAddr);
-                    }
-                }
-            }
-        } else {
-            List<WaySegment> wss = mv.getNearestWaySegments(mousePos, OsmPrimitive::isSelectable);
-            for (IWaySegment<Node, Way> ws : wss) {
-                if (ws.getWay().get(tagHighway) != null && ws.getWay().get(tagHighwayName) != null)
-                    mouseOnExistingWays.add(ws.getWay());
-                else if (ws.getWay().get(tagBuilding) != null && ws.getWay().get(tagHouseNumber) == null)
-                    mouseOnExistingBuildingWays.add(ws.getWay());
-            }
-            if (mouseOnExistingWays.size() == 1) {
-                // clicked on existing highway => set new street name
-                inputStreet.setText(mouseOnExistingWays.get(0).get(tagHighwayName));
-                setSelectedWay(mouseOnExistingWays.get(0));
-                inputNumber.setText("");
-                setNewSelection(mouseOnExistingWays.get(0));
-            } else if (mouseOnExistingWays.isEmpty()) {
-                // clicked a non highway and not a node => add the new address
-                if (inputStreet.getText().isEmpty() || inputNumber.getText().isEmpty()) {
-                    Toolkit.getDefaultToolkit().beep();
-                } else {
-                    Collection<Command> cmds = new LinkedList<>();
-                    if (ctrl) {
-                        applyInputNumberChange();
-                    }
-                    if (tagPolygon.isSelected()) {
-                        addAddrToPolygon(mouseOnExistingBuildingWays, cmds);
-                    } else {
-                        Node n = createNewNode(e, cmds);
-                        addAddrToPrimitive(n, cmds);
-                    }
-                }
-            }
-        }
-    }
-
-    private Way findWayInRelationAddr(Node n) {
-        List<OsmPrimitive> l = n.getReferrers();
-        for (OsmPrimitive osm : l) {
-            if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) {
-                for (RelationMember rm : ((Relation) osm).getMembers()) {
-                    if (rm.getRole().equals(relationAddrStreetRole)) {
-                        OsmPrimitive osp = rm.getMember();
-                        if (osp instanceof Way && osp.hasKey(tagHighwayName)) {
-                            return (Way) osp;
-                        }
-                    }
-                }
+            }
+        }
+        return null;
+    }
+
+    private static Way usableRelationRole(RelationMember rm) {
+        if (rm.getRole().equals(RELATION_ADDR_STREET_ROLE)) {
+            OsmPrimitive osp = rm.getMember();
+            if (osp instanceof Way && osp.hasKey(TAG_HIGHWAY_NAME)) {
+                return (Way) osp;
             }
         }
@@ -252,9 +275,9 @@
                 revertInputNumberChange();
             } catch (NumberFormatException ex) {
-                Logging.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
+                Logging.warn(MESSAGE_UNABLE_TO_PARSE_HOUSE_NUMBER, inputNumber.getText());
             }
         }
         Map<String, String> tags = new HashMap<>();
-        tags.put(tagHouseNumber, inputNumber.getText());
+        tags.put(TAG_HOUSE_NUMBER, inputNumber.getText());
         cmds.add(new ChangePropertyCommand(OsmDataManager.getInstance().getEditDataSet(), Collections.singleton(osm), tags));
         addStreetNameOrRelation(osm, cmds);
@@ -265,12 +288,12 @@
             setNewSelection(osm);
         } catch (NumberFormatException ex) {
-            Logging.warn("Unable to parse house number \"" + inputNumber.getText() + "\"");
-        }
-    }
-
-    private Relation findRelationAddr(Way w) {
+            Logging.warn(MESSAGE_UNABLE_TO_PARSE_HOUSE_NUMBER, inputNumber.getText());
+        }
+    }
+
+    private static Relation findRelationAddr(Way w) {
         List<OsmPrimitive> l = w.getReferrers();
         for (OsmPrimitive osm : l) {
-            if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) {
+            if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(RELATION_ADDR_TYPE)) {
                 return (Relation) osm;
             }
@@ -283,5 +306,5 @@
         if (Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false)) {
             Map<String, String> tags = new HashMap<>();
-            tags.put(tagHouseStreet, inputStreet.getText());
+            tags.put(TAG_HOUSE_STREET, inputStreet.getText());
             cmds.add(new ChangePropertyCommand(ds, Arrays.asList(osm), tags));
         } else if (selectedWay != null) {
@@ -289,5 +312,5 @@
             // add the node to its relation
             if (selectedRelation != null) {
-                RelationMember rm = new RelationMember(relationMemberHouse, osm);
+                RelationMember rm = new RelationMember(RELATION_MEMBER_HOUSE, osm);
                 Relation newRel = new Relation(selectedRelation);
                 newRel.addMember(rm);
@@ -296,8 +319,8 @@
                 // create new relation
                 Relation newRel = new Relation();
-                newRel.put("type", relationAddrType);
-                newRel.put(relationAddrName, selectedWay.get(tagHighwayName));
-                newRel.addMember(new RelationMember(relationAddrStreetRole, selectedWay));
-                newRel.addMember(new RelationMember(relationMemberHouse, osm));
+                newRel.put("type", RELATION_ADDR_TYPE);
+                newRel.put(RELATION_ADDR_NAME, selectedWay.get(TAG_HIGHWAY_NAME));
+                newRel.addMember(new RelationMember(RELATION_ADDR_STREET_ROLE, selectedWay));
+                newRel.addMember(new RelationMember(RELATION_MEMBER_HOUSE, osm));
                 cmds.add(new AddCommand(ds, newRel));
             }
@@ -355,11 +378,11 @@
             Iterator<Pair<Node, Node>> i = segs.iterator();
             Pair<Node, Node> seg = i.next();
-            EastNorth A = seg.a.getEastNorth();
-            EastNorth B = seg.b.getEastNorth();
+            EastNorth enA = seg.a.getEastNorth();
+            EastNorth enB = seg.b.getEastNorth();
             seg = i.next();
-            EastNorth C = seg.a.getEastNorth();
-            EastNorth D = seg.b.getEastNorth();
-
-            double u = det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north());
+            EastNorth enC = seg.a.getEastNorth();
+            EastNorth enD = seg.b.getEastNorth();
+
+            double u = det(enB.east() - enA.east(), enB.north() - enA.north(), enC.east() - enD.east(), enC.north() - enD.north());
 
             // Check for parallel segments and do nothing if they are
@@ -372,8 +395,8 @@
             // if the segment is scaled to lenght 1
 
-            double q = det(B.north() - C.north(), B.east() - C.east(), D.north() - C.north(), D.east() - C.east()) / u;
+            double q = det(enB.north() - enC.north(), enB.east() - enC.east(), enD.north() - enC.north(), enD.east() - enC.east()) / u;
             EastNorth intersection = new EastNorth(
-                    B.east() + q * (A.east() - B.east()),
-                    B.north() + q * (A.north() - B.north()));
+                    enB.east() + q * (enA.east() - enB.east()),
+                    enB.north() + q * (enA.north() - enB.north()));
 
             int snapToIntersectionThreshold
@@ -390,13 +413,13 @@
             // fall through
         default:
-            EastNorth P = n.getEastNorth();
+            EastNorth enP = n.getEastNorth();
             seg = segs.iterator().next();
-            A = seg.a.getEastNorth();
-            B = seg.b.getEastNorth();
-            double a = P.distanceSq(B);
-            double b = P.distanceSq(A);
-            double c = A.distanceSq(B);
+            enA = seg.a.getEastNorth();
+            enB = seg.b.getEastNorth();
+            double a = enP.distanceSq(enB);
+            double b = enP.distanceSq(enA);
+            double c = enA.distanceSq(enB);
             q = (a - b + c) / (2*c);
-            n.setEastNorth(new EastNorth(B.east() + q * (A.east() - B.east()), B.north() + q * (A.north() - B.north())));
+            n.setEastNorth(new EastNorth(enB.east() + q * (enA.east() - enB.east()), enB.north() + q * (enA.north() - enB.north())));
         }
     }
@@ -462,19 +485,16 @@
         JLabel street = new JLabel(tr("Street"));
         p.add(number, GBC.std().insets(0, 0, 0, 0));
-        p.add(inputNumber, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
+        p.add(inputNumber, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5));
         p.add(street, GBC.std().insets(0, 0, 0, 0));
         JPanel p2 = new JPanel(new GridBagLayout());
         inputStreet.setEditable(false);
-        p2.add(inputStreet, GBC.std().fill(GBC.HORIZONTAL).insets(5, 0, 0, 0));
+        p2.add(inputStreet, GBC.std().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 0));
         p2.add(link, GBC.eol().insets(10, 0, 0, 0));
-        p.add(p2, GBC.eol().fill(GBC.HORIZONTAL));
+        p.add(p2, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
         clearButton = new JButton("Clear");
-        clearButton.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                inputNumber.setText("");
-                inputStreet.setText("");
-                setSelectedWay((Way) null);
-            }
+        clearButton.addActionListener(e -> {
+            inputNumber.setText("");
+            inputStreet.setText("");
+            setSelectedWay(null);
         });
         ButtonGroup bgIncremental = new ButtonGroup();
@@ -486,14 +506,9 @@
         p.add(plusOne, GBC.std().insets(0, 0, 10, 0));
         tagPolygon.setSelected(Config.getPref().getBoolean("cadastrewms.addr.onBuilding", false));
-        tagPolygon.addChangeListener(new ChangeListener() {
-            @Override
-            public void stateChanged(ChangeEvent arg0) {
-                Config.getPref().putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected());
-            }
-        });
-        p.add(tagPolygon, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 0));
+        tagPolygon.addChangeListener(ignored -> Config.getPref().putBoolean("cadastrewms.addr.onBuilding", tagPolygon.isSelected()));
+        p.add(tagPolygon, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(0, 0, 0, 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));
+        p.add(clearButton, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(0, 0, 0, 0));
 
         final Object[] options = {};
@@ -533,8 +548,5 @@
     private void setSelectedWay(Way w) {
         this.selectedWay = w;
-        if (w == null) {
-            link.setEnabled(false);
-        } else
-            link.setEnabled(true);
+        link.setEnabled(w != null);
         link.repaint();
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/WMSAdjustAction.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/WMSAdjustAction.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/mapmode/WMSAdjustAction.java	(revision 36385)
@@ -7,9 +7,5 @@
 import java.awt.Cursor;
 import java.awt.Graphics2D;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
 
 import javax.swing.JOptionPane;
@@ -24,15 +20,14 @@
 import org.openstreetmap.josm.tools.Logging;
 
-public class WMSAdjustAction extends MapMode implements
-        MouseListener, MouseMotionListener {
+public class WMSAdjustAction extends MapMode {
 
     private static final long serialVersionUID = 1L;
-    private WMSLayer modifiedLayer = null;
+    private transient WMSLayer modifiedLayer;
     private boolean rasterMoved;
     private EastNorth prevEastNorth;
-    enum Mode { moveXY, moveZ, rotate }
+    enum Mode {MOVE_XY, MOVE_Z, ROTATE}
 
-    private static Mode mode = null;
-    private static EastNorth[] croppedRaster = new EastNorth[5];;
+    private static Mode mode;
+    private static final EastNorth[] croppedRaster = new EastNorth[5];
 
     /**
@@ -95,13 +90,12 @@
             return;
         requestFocusInMapView();
-        boolean ctrl = (e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
-        // boolean alt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0;
-        boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
-        if (shift && !ctrl && modifiedLayer.isRaster())
-            mode = Mode.moveZ;
-        else if (shift && ctrl && modifiedLayer.isRaster())
-            mode = Mode.rotate;
-        else
-            mode = Mode.moveXY;
+        updateKeyModifiers(e);
+        if (shift && !ctrl && modifiedLayer.isRaster()) {
+            setMode(Mode.MOVE_Z);
+        } else if (shift && ctrl && modifiedLayer.isRaster()) {
+            setMode(Mode.ROTATE);
+        } else {
+            setMode(Mode.MOVE_XY);
+        }
         rasterMoved = true;
         prevEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
@@ -111,10 +105,10 @@
     @Override public void mouseDragged(MouseEvent e) {
         EastNorth newEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
-        if (mode == Mode.rotate) {
-            rotateFrameOnly(prevEastNorth, newEastNorth);
+        if (mode == Mode.ROTATE) {
+            rotateFrameOnly(modifiedLayer, prevEastNorth, newEastNorth);
         } else {
-            if (mode == Mode.moveXY) {
+            if (mode == Mode.MOVE_XY) {
                 displace(prevEastNorth, newEastNorth);
-            } else if (mode == Mode.moveZ) {
+            } else if (mode == Mode.MOVE_Z) {
                 resize(newEastNorth);
             }
@@ -127,5 +121,5 @@
 
     public static void paintAdjustFrames(Graphics2D g, final MapView mv) {
-        if (mode == Mode.rotate && croppedRaster != null) {
+        if (mode == Mode.ROTATE) {
             g.setColor(Color.red);
             for (int i = 0; i < 4; i++) {
@@ -157,5 +151,5 @@
     }
 
-    private void rotateFrameOnly(EastNorth start, EastNorth end) {
+    private static void rotateFrameOnly(WMSLayer modifiedLayer, EastNorth start, EastNorth end) {
         if (start != null && end != null) {
             EastNorth pivot = modifiedLayer.getRasterCenter();
@@ -174,5 +168,5 @@
     @Override
     public void mouseReleased(MouseEvent e) {
-        if (mode == Mode.rotate) {
+        if (mode == Mode.ROTATE) {
             EastNorth newEastNorth = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY());
             rotate(prevEastNorth, newEastNorth);
@@ -183,20 +177,9 @@
         MainApplication.getMap().mapView.setCursor(Cursor.getDefaultCursor());
         prevEastNorth = null;
-        mode = null;
+        setMode(null);
     }
 
-    @Override
-    public void mouseEntered(MouseEvent e) {
-    }
-
-    @Override
-    public void mouseExited(MouseEvent e) {
-    }
-
-    @Override
-    public void mouseMoved(MouseEvent e) {
-    }
-
-    @Override public void mouseClicked(MouseEvent e) {
+    private static void setMode(Mode mode) {
+        WMSAdjustAction.mode = mode;
     }
 
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/upload/CheckSourceUploadHook.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/upload/CheckSourceUploadHook.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/actions/upload/CheckSourceUploadHook.java	(revision 36385)
@@ -59,5 +59,5 @@
      * @return true if one of keys is "source"
      */
-    private boolean tagSourceExist(OsmPrimitive osm) {
+    private static boolean tagSourceExist(OsmPrimitive osm) {
         return osm.hasKey("source");
     }
@@ -68,5 +68,5 @@
      * @param sel the list of elements added without a key "source"
      */
-    private void displaySource(Collection<OsmPrimitive> sel) {
+    private static void displaySource(Collection<OsmPrimitive> sel) {
         if (!sel.isEmpty()) {
             JPanel p = new JPanel(new GridBagLayout());
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadSourcePanel.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadSourcePanel.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadSourcePanel.java	(revision 36385)
@@ -8,4 +8,5 @@
 import java.awt.Dimension;
 import java.awt.Font;
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.util.Arrays;
@@ -83,5 +84,5 @@
 
         // adding the download tasks
-        add(new JLabel(tr("Objects:")), GBC.std().insets(5, 5, 1, 5).anchor(GBC.CENTER));
+        add(new JLabel(tr("Objects:")), GBC.std().insets(5, 5, 1, 5).anchor(GridBagConstraints.CENTER));
         cbDownloadBuilding = createCheckBox(tr("building"), DOWNLOAD_BUILDING,
                 tr("Select to download buildings in the selected download area."));
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadTask.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadTask.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreDownloadTask.java	(revision 36385)
@@ -63,5 +63,6 @@
         try {
             for (String id : CadastreAPI.getSheets(downloadArea)) {
-                String url = String.join("/", CADASTRE_URL, id.substring(0, id.startsWith("97") ? 3 : 2), id.substring(0, 5), "edigeo-"+id+".tar.bz2");
+                String url = String.join("/", CADASTRE_URL, id.substring(0, id.startsWith("97") ? 3 : 2),
+                        id.substring(0, 5), "edigeo-"+id+".tar.bz2");
                 tasks.add(MainApplication.worker.submit(new InternalDownloadTask(settings, url, progressMonitor, zoomAfterDownload)));
             }
@@ -75,6 +76,9 @@
                 try {
                     f.get();
-                } catch (InterruptedException | ExecutionException e) {
+                } catch (ExecutionException e) {
                     Logging.error(e);
+                } catch (InterruptedException e) {
+                    Logging.error(e);
+                    Thread.currentThread().interrupt();
                 }
             }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreServerReader.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreServerReader.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/download/CadastreServerReader.java	(revision 36385)
@@ -4,8 +4,10 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.io.IOException;
 import java.util.Objects;
 
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.io.IllegalDataException;
 import org.openstreetmap.josm.io.OsmServerReader;
 import org.openstreetmap.josm.io.OsmTransferException;
@@ -35,5 +37,5 @@
             progressMonitor.beginTask(tr("Contacting Server..."), 10);
             return new EdigeoPciImporter().parseDataSet(url, data);
-        } catch (Exception e) {
+        } catch (IOException | IllegalDataException e) {
             throw new OsmTransferException(e);
         } finally {
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java	(revision 36385)
@@ -354,7 +354,7 @@
         @Override
         void processRecord(EdigeoRecord r) {
-            switch (r.name) {
-            case "REF": refPoint = safeGetEastNorth(r); break;
-            default:
+            if ("REF".equals(r.name)) {
+                refPoint = safeGetEastNorth(r);
+            } else {
                 super.processRecord(r);
             }
@@ -558,10 +558,10 @@
         List<OsmPrimitive> toPurge = new ArrayList<>();
         for (ObjectBlock obj : getObjects()) {
-            if (!ignoredObjects.stream().anyMatch(p -> p.test(obj))) {
+            if (ignoredObjects.stream().noneMatch(p -> p.test(obj))) {
                 OsmPrimitive p;
                 switch (obj.scdRef.kind) {
-                    case POINT: p = fillPoint(ds, proj, obj, obj.getConstructionRelations(), obj.getSemanticRelations()); break;
-                    case LINE: p = fillLine(ds, proj, obj, obj.getConstructionRelations(), obj.getSemanticRelations()); break;
-                    case AREA: p = fillArea(ds, proj, obj, obj.getConstructionRelations(), obj.getSemanticRelations()); break;
+                    case POINT: p = fillPoint(ds, proj, obj, obj.getConstructionRelations()); break;
+                    case LINE: p = fillLine(ds, proj, obj, obj.getConstructionRelations()); break;
+                    case AREA: p = fillArea(ds, proj, obj, obj.getConstructionRelations()); break;
                     case COMPLEX: // TODO (not used in PCI)
                     default: throw new IllegalArgumentException(obj.toString());
@@ -574,5 +574,5 @@
                                 purged = toPurge.add(p);
                                 if (p instanceof Relation) {
-									toPurge.addAll(((Relation) p).getMemberPrimitivesList());
+                                    toPurge.addAll(((Relation) p).getMemberPrimitivesList());
                                 }
                             } else {
@@ -630,5 +630,5 @@
 
     private static Node fillPoint(DataSet ds, Projection proj, ObjectBlock obj,
-            List<RelationBlock> constructionRelations, List<RelationBlock> semanticRelations) {
+            List<RelationBlock> constructionRelations) {
         assert constructionRelations.size() == 1 : constructionRelations;
         List<NodeBlock> blocks = extract(NodeBlock.class, constructionRelations, RelationKind.IS_MADE_OF);
@@ -644,10 +644,10 @@
 
     private static Way fillLine(DataSet ds, Projection proj, ObjectBlock obj,
-            List<RelationBlock> constructionRelations, List<RelationBlock> semanticRelations) {
-        assert constructionRelations.size() >= 1 : constructionRelations;
+            List<RelationBlock> constructionRelations) {
+        assert !constructionRelations.isEmpty() : constructionRelations;
         // Retrieve all arcs for the linear object
         final List<ArcBlock> arcs = extract(ArcBlock.class, constructionRelations, RelationKind.IS_MADE_OF_ARC);
         final double EPSILON = 1e-2;
-        assert arcs.size() >= 1;
+        assert !arcs.isEmpty();
         // Some lines are made of several arcs, but they need to be sorted
         if (arcs.size() > 1) {
@@ -693,8 +693,8 @@
 
     private static OsmPrimitive fillArea(DataSet ds, Projection proj, ObjectBlock obj,
-            List<RelationBlock> constructionRelations, List<RelationBlock> semanticRelations) {
-        assert constructionRelations.size() >= 1 : constructionRelations;
+            List<RelationBlock> constructionRelations) {
+        assert !constructionRelations.isEmpty() : constructionRelations;
         List<FaceBlock> faces = extract(FaceBlock.class, constructionRelations, RelationKind.IS_MADE_OF);
-        assert faces.size() >= 1;
+        assert !faces.isEmpty();
         if (faces.size() == 1) {
             return addPrimitiveAndTags(ds, obj, faceToOsmPrimitive(ds, proj, faces.get(0)));
@@ -713,5 +713,5 @@
         allArcs.addAll(extract(ArcBlock.class, face.getConstructionRelations(), RelationKind.HAS_FOR_LEFT_FACE));
         allArcs.addAll(extract(ArcBlock.class, face.getConstructionRelations(), RelationKind.HAS_FOR_RIGHT_FACE));
-        assert allArcs.size() >= 1;
+        assert !allArcs.isEmpty();
         if (allArcs.size() == 1) {
             ArcBlock ab = allArcs.get(0);
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoLotFile.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoLotFile.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoLotFile.java	(revision 36385)
@@ -27,5 +27,5 @@
     protected final ClassToInstancesMap<B> blocks = new MutableClassToInstancesMap<>();
 
-    EdigeoLotFile(Lot lot, String subsetId, Path path) throws IOException {
+    EdigeoLotFile(Lot lot, String subsetId, Path path) {
         super(path);
         this.lot = Objects.requireNonNull(lot, "lot");
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java	(revision 36385)
@@ -20,5 +20,5 @@
 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
-import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.text.WordUtils;
@@ -40,4 +40,9 @@
  */
 public class EdigeoPciReader extends AbstractReader {
+    private static final String SYM_ID = "SYM_id";
+    private static final String HIGHWAY = "highway";
+    private static final String TEX_ID = "TEX_id";
+    private static final String TEX2_ID = "TEX2_id";
+    private static final String IDU_ID = "IDU_id";
 
     private static final BiPredicate<CadastreDownloadData, OsmPrimitive> water = (x, p) -> !x.isDownloadWater();
@@ -65,5 +70,5 @@
                 "CROIX_id",    // Property boundary marker for Alsace and Moselle
                 "SYMBLIM_id"); // Common wall symbol
-        EdigeoFileVEC.addIgnoredObject("SYM_id",
+        EdigeoFileVEC.addIgnoredObject(SYM_ID,
                 "30", // Water stream arrow
                 "31", // Connecting arrows between parcelles and numbers
@@ -94,7 +99,7 @@
                 }
             }
-            p.put("highway", highwayValue);
-            p.remove("SYM_id");
-        }, symbo, "SYM_id", "23"); // Path / Footway
+            p.put(HIGHWAY, highwayValue);
+            p.remove(SYM_ID);
+        }, symbo, SYM_ID, "23"); // Path / Footway
         EdigeoFileVEC.addObjectPostProcessor("24", symbo, "man_made=pipeline"); // Pipeline
         EdigeoFileVEC.addObjectPostProcessor("25", symbo, "man_made=pipeline"); // Aqueduct
@@ -117,7 +122,7 @@
         // Mapping TEX*_id => name (first step)
         EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
-            StringBuffer sb = new StringBuffer(p.get("TEX_id").trim());
-            p.remove("TEX_id");
-            for (String t : Arrays.asList("TEX2_id", "TEX3_id", "TEX4_id", "TEX5_id", "TEX6_id", "TEX7_id", "TEX8_id", "TEX9_id")) {
+            StringBuilder sb = new StringBuilder(p.get(TEX_ID).trim());
+            p.remove(TEX_ID);
+            for (String t : Arrays.asList(TEX2_ID, "TEX3_id", "TEX4_id", "TEX5_id", "TEX6_id", "TEX7_id", "TEX8_id", "TEX9_id")) {
                 String v = p.get(t);
                 if (v == null) {
@@ -128,20 +133,19 @@
             }
             setName(p, sb.toString());
-        }, (x, p) -> false, "TEX_id");
+        }, (x, p) -> false, TEX_ID);
 
         // Objects mapping
         EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
-            p.put("highway", "road");
+            p.put(HIGHWAY, "road");
             String name = p.get("name");
             if (name != null && name.contains(" ")) {
                 String[] words = name.split(" ");
-                if (!setCorrectHighway(p, words)) {
-                    if (highways.values().stream().anyMatch(l -> l.contains(words[words.length - 1]))) {
-                        String[] newWords = new String[words.length];
-                        newWords[0] = words[words.length - 1];
-                        System.arraycopy(words, 0, newWords, 1, words.length - 1);
-                        p.put("name", String.join(" ", newWords));
-                        setCorrectHighway(p, newWords);
-                    }
+                if (!setCorrectHighway(p, words)
+                && highways.values().stream().anyMatch(l -> l.contains(words[words.length - 1]))) {
+                    String[] newWords = new String[words.length];
+                    newWords[0] = words[words.length - 1];
+                    System.arraycopy(words, 0, newWords, 1, words.length - 1);
+                    p.put("name", String.join(" ", newWords));
+                    setCorrectHighway(p, newWords);
                 }
             }
@@ -151,14 +155,14 @@
             p.put("boundary", "administrative");
             p.put("admin_level", "8");
-            p.put("ref:INSEE", "XX"+p.get("IDU_id")); // TODO: find department number
-            p.put("name", WordUtils.capitalizeFully(p.get("TEX2_id")));
-            p.remove("IDU_id");
-            p.remove("TEX2_id");
+            p.put("ref:INSEE", "XX"+p.get(IDU_ID)); // TODO: find department number
+            p.put("name", WordUtils.capitalizeFully(p.get(TEX2_ID)));
+            p.remove(IDU_ID);
+            p.remove(TEX2_ID);
         }, o -> o.hasScdIdentifier("COMMUNE_id"), commu);
 
         EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
             p.put("boundary", "cadastral");
-            p.put("ref", p.get("IDU_id"));
-            p.remove("IDU_id");
+            p.put("ref", p.get(IDU_ID));
+            p.remove(IDU_ID);
             p.remove("ICL_id");
             p.remove("COAR_id");
@@ -191,19 +195,15 @@
         }, o -> o.hasScdIdentifier("LIEUDIT_id"), local);
 
-        EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
-            p.remove("ORI_id");
-        }, o -> o.hasScdIdentifier("TPOINT_id"), (x, p) -> false);
-
-        EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
-            p.put("highway", "road");
+        EdigeoFileVEC.addObjectPostProcessor((o, p) -> p.remove("ORI_id"), o -> o.hasScdIdentifier("TPOINT_id"), (x, p) -> false);
+
+        EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
+            p.put(HIGHWAY, "road");
             p.put("area", "yes");
         }, o -> o.hasScdIdentifier("TRONROUTE_id"), symbo);
 
-        EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
-            p.put("waterway", "riverbank");
-        }, o -> o.hasScdIdentifier("TRONFLUV_id"), water);
+        EdigeoFileVEC.addObjectPostProcessor((o, p) -> p.put("waterway", "riverbank"), o -> o.hasScdIdentifier("TRONFLUV_id"), water);
 
         // Mapping TEX*_id => name (last step)
-        for (String t : Arrays.asList("TEX2_id", "TEX3_id", "TEX4_id", "TEX5_id", "TEX6_id", "TEX7_id", "TEX8_id", "TEX9_id")) {
+        for (String t : Arrays.asList(TEX2_ID, "TEX3_id", "TEX4_id", "TEX5_id", "TEX6_id", "TEX7_id", "TEX8_id", "TEX9_id")) {
             EdigeoFileVEC.addObjectPostProcessor((o, p) -> {
                 setName(p, p.get(t));
@@ -239,9 +239,9 @@
     private static void setName(OsmPrimitive p, String input) {
         if (input != null) {
-            String name = input.replaceAll("    ", " ").replaceAll("   ", " ").replaceAll("  ", " ");
+            String name = input.replaceAll(" {4}", " ").replaceAll(" {3}", " ").replaceAll(" {2}", " ");
             if (name.matches("([A-Za-z] )+[A-Za-z]")) {
-                name = name.replaceAll(" ", "");
-            }
-            if (name.length() > 2 && StringUtils.isAllUpperCase(name.replaceAll(" ", "").replaceAll("'", "").replaceAll("-", ""))) {
+                name = name.replace(" ", "");
+            }
+            if (name.length() > 2 && StringUtils.isAllUpperCase(name.replace(" ", "").replace("'", "").replace("-", ""))) {
                 name = WordUtils.capitalizeFully(name);
             }
@@ -256,5 +256,5 @@
         for (Entry<String, List<String>> e : highways.entrySet()) {
             if (e.getValue().contains(type)) {
-                p.put("highway", e.getKey());
+                p.put(HIGHWAY, e.getKey());
                 return true;
             }
@@ -275,7 +275,5 @@
         try {
             return new EdigeoPciReader().parse(file.toPath(), data, instance);
-        } catch (IOException e) {
-            throw e;
-        } catch (Exception | AssertionError e) {
+        } catch (ReflectiveOperationException | AssertionError e) {
             Logging.error(e);
             throw new IOException(e);
@@ -295,5 +293,5 @@
                     TarArchiveEntry entry;
                     tmpDir = Files.createTempDirectory(Utils.getJosmTempDir().toPath(), "cadastre");
-                    while ((entry = tar.getNextTarEntry()) != null) {
+                    while ((entry = tar.getNextEntry()) != null) {
                         File file = tmpDir.resolve(entry.getName()).toFile();
                         try (FileOutputStream out = new FileOutputStream(file)) {
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/utils/MutableClassToInstancesMap.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/utils/MutableClassToInstancesMap.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/utils/MutableClassToInstancesMap.java	(revision 36385)
@@ -11,4 +11,5 @@
  */
 public class MutableClassToInstancesMap<B> extends HashMap<Class<? extends B>, List<B>> implements ClassToInstancesMap<B> {
+    private static final long serialVersionUID = 1L;
 
     @Override
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/preferences/CadastrePreferenceSetting.java	(revision 36385)
@@ -2,8 +2,9 @@
 package org.openstreetmap.josm.plugins.fr.cadastre.preferences;
 
+import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
@@ -39,74 +40,81 @@
  */
 public class CadastrePreferenceSetting extends DefaultTabPreferenceSetting {
-
-    static final int TRANS_MIN = 1;
-    static final int TRANS_MAX = 10;
-    private JSlider sliderTrans = new JSlider(JSlider.HORIZONTAL, TRANS_MIN, TRANS_MAX, TRANS_MAX);
-
-    private JTextField sourcing = new JTextField(20);
-
-    private JCheckBox alterColors = new JCheckBox(tr("Replace original background by JOSM background color."));
-
-    private JCheckBox reversGrey = new JCheckBox(tr("Reverse grey colors (for black backgrounds)."));
-
-    private JCheckBox transparency = new JCheckBox(tr("Set background transparent."));
-
-    private JCheckBox drawBoundaries = new JCheckBox(tr("Draw boundaries of downloaded data"));
-
-    private JComboBox<String> imageInterpolationMethod = new JComboBox<>();
-
-    private JCheckBox disableImageCropping = new JCheckBox(tr("Disable image cropping during georeferencing."));
-
-    private JCheckBox enableTableauAssemblage = new JCheckBox(tr("Use \"Tableau d''assemblage\""));
-
-    private JCheckBox simplify2BitsColors = new JCheckBox(tr("Replace grey shades by white color only"));
-
-    private JCheckBox autoFirstLayer = new JCheckBox(tr("Select first WMS layer in list."));
-
-    private JCheckBox dontUseRelation = new JCheckBox(tr("Don''t use relation for addresses (but \"addr:street\" on elements)."));
-
-    private JCheckBox mergeDataLayers = new JCheckBox(tr("Merge downloaded cadastre data layers together."));
-
-    private JRadioButton grabMultiplier1 = new JRadioButton("", true);
-
-    private JRadioButton grabMultiplier2 = new JRadioButton("", true);
-
-    private JRadioButton grabMultiplier3 = new JRadioButton("", true);
-
-    private JRadioButton grabMultiplier4 = new JRadioButton("", true);
-
-    private JRadioButton crosspiece1 = new JRadioButton(tr("off"));
-
-    private JRadioButton crosspiece2 = new JRadioButton(tr("25 m"));
-
-    private JRadioButton crosspiece3 = new JRadioButton(tr("50 m"));
-
-    private JRadioButton crosspiece4 = new JRadioButton(tr("100 m"));
-
-    private JRadioButton grabRes1 = new JRadioButton(tr("high"));
-    private JRadioButton grabRes2 = new JRadioButton(tr("medium"));
-    private JRadioButton grabRes3 = new JRadioButton(tr("low"));
-
-    private JCheckBox layerLS3 = new JCheckBox(tr("water"));
-    private JCheckBox layerLS2 = new JCheckBox(tr("building"));
-    private JCheckBox layerLS1 = new JCheckBox(tr("symbol"));
-    private JCheckBox layerParcel = new JCheckBox(tr("parcel"));
-    private JCheckBox layerLabel = new JCheckBox(tr("parcel number"));
-    private JCheckBox layerNumero = new JCheckBox(tr("address"));
-    private JCheckBox layerLieudit = new JCheckBox(tr("locality"));
-    private JCheckBox layerSection = new JCheckBox(tr("section"));
-    private JCheckBox layerCommune = new JCheckBox(tr("commune"));
+    private static final int TRANS_MIN = 1;
+    private static final int TRANS_MAX = 10;
+    private static final String HIGH = marktr("high");
+    private static final String MEDIUM = marktr("medium");
+    private static final String LOW = marktr("low");
+    private static final String CADASTREWMS_RESOLUTION = "cadastrewms.resolution";
+    private static final String CADASTREWMS_IMAGE_INTERPOLATION = "cadastrewms.imageInterpolation";
+    private static final String CADASTREWMS_SCALE = "cadastrewms.scale";
+    private static final String CADASTREWMS_CROSSPIECES = "cadastrewms.crosspieces";
+    private static final String PREFERENCES = "preferences";
+    private final JSlider sliderTrans = new JSlider(SwingConstants.HORIZONTAL, TRANS_MIN, TRANS_MAX, TRANS_MAX);
+
+    private final JTextField sourcing = new JTextField(20);
+
+    private final JCheckBox alterColors = new JCheckBox(tr("Replace original background by JOSM background color."));
+
+    private final JCheckBox reversGrey = new JCheckBox(tr("Reverse grey colors (for black backgrounds)."));
+
+    private final JCheckBox transparency = new JCheckBox(tr("Set background transparent."));
+
+    private final JCheckBox drawBoundaries = new JCheckBox(tr("Draw boundaries of downloaded data"));
+
+    private final JComboBox<String> imageInterpolationMethod = new JComboBox<>();
+
+    private final JCheckBox disableImageCropping = new JCheckBox(tr("Disable image cropping during georeferencing."));
+
+    private final JCheckBox enableTableauAssemblage = new JCheckBox(tr("Use \"Tableau d''assemblage\""));
+
+    private final JCheckBox simplify2BitsColors = new JCheckBox(tr("Replace grey shades by white color only"));
+
+    private final JCheckBox autoFirstLayer = new JCheckBox(tr("Select first WMS layer in list."));
+
+    private final JCheckBox dontUseRelation = new JCheckBox(tr("Don''t use relation for addresses (but \"addr:street\" on elements)."));
+
+    private final JCheckBox mergeDataLayers = new JCheckBox(tr("Merge downloaded cadastre data layers together."));
+
+    private final JRadioButton grabMultiplier1 = new JRadioButton("", true);
+
+    private final JRadioButton grabMultiplier2 = new JRadioButton("", true);
+
+    private final JRadioButton grabMultiplier3 = new JRadioButton("", true);
+
+    private final JRadioButton grabMultiplier4 = new JRadioButton("", true);
+
+    private final JRadioButton crosspiece1 = new JRadioButton(tr("off"));
+
+    private final JRadioButton crosspiece2 = new JRadioButton(tr("25 m"));
+
+    private final JRadioButton crosspiece3 = new JRadioButton(tr("50 m"));
+
+    private final JRadioButton crosspiece4 = new JRadioButton(tr("100 m"));
+
+    private final JRadioButton grabRes1 = new JRadioButton(tr(HIGH));
+    private final JRadioButton grabRes2 = new JRadioButton(tr(MEDIUM));
+    private final JRadioButton grabRes3 = new JRadioButton(tr(LOW));
+
+    private final JCheckBox layerLS3 = new JCheckBox(tr("water"));
+    private final JCheckBox layerLS2 = new JCheckBox(tr("building"));
+    private final JCheckBox layerLS1 = new JCheckBox(tr("symbol"));
+    private final JCheckBox layerParcel = new JCheckBox(tr("parcel"));
+    private final JCheckBox layerLabel = new JCheckBox(tr("parcel number"));
+    private final JCheckBox layerNumero = new JCheckBox(tr("address"));
+    private final JCheckBox layerLieudit = new JCheckBox(tr("locality"));
+    private final JCheckBox layerSection = new JCheckBox(tr("section"));
+    private final JCheckBox layerCommune = new JCheckBox(tr("commune"));
 
     public static final int DEFAULT_SQUARE_SIZE = 100;
-    private JTextField grabMultiplier4Size = new JTextField(5);
-
-    private JCheckBox enableCache = new JCheckBox(tr("Enable automatic caching."));
+    private final JTextField grabMultiplier4Size = new JTextField(5);
+
+    private final JCheckBox enableCache = new JCheckBox(tr("Enable automatic caching."));
 
     public static final int DEFAULT_CACHE_SIZE = 0; // disabled by default
     JLabel jLabelCacheSize = new JLabel(tr("Max. cache size (in MB)"));
-    private JTextField cacheSize = new JTextField(20);
+    private final JTextField cacheSize = new JTextField(20);
 
     public static final String DEFAULT_RASTER_DIVIDER = "7";
-    private JTextField rasterDivider = new JTextField(10);
+    private final JTextField rasterDivider = new JTextField(10);
 
     static final int DEFAULT_CROSSPIECES = 0;
@@ -134,4 +142,34 @@
         cadastrewms.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
 
+        addGuiGenericOptions(cadastrewms);
+        // separator
+        addGuiSeparator(cadastrewms);
+        addGuiVectorImages(cadastrewms);
+        // separator
+        addGuiSeparator(cadastrewms);
+        addGuiRasterImages(cadastrewms);
+        // separator
+        addGuiSeparator(cadastrewms);
+        addGuiAutoCache(cadastrewms);
+        // option to fix the cache size(in MB)
+        addGuiCacheSize(cadastrewms);
+        // separator
+        addGuiSeparator(cadastrewms);
+        // option to select the first WMS layer
+        addGuiFirstWMSLayer(cadastrewms);
+        // separator
+        addGuiSeparator(cadastrewms);
+        addGuiUseRelationsInAddresses(cadastrewms);
+        // separator
+        addGuiSeparator(cadastrewms);
+        addGuiMergeDownloadedDataLayers(cadastrewms);
+        addGuiEndOfDialogScrollBar(cadastrewms, cadastrewmsMast);
+    }
+
+    private static void addGuiSeparator(JPanel cadastrewms) {
+        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GridBagConstraints.HORIZONTAL));
+    }
+
+    private void addGuiGenericOptions(JPanel cadastrewms) {
         // option to automatically set the source tag when uploading
         sourcing.setText(CadastrePlugin.source);
@@ -139,5 +177,5 @@
         JLabel jLabelSource = new JLabel(tr("Source"));
         cadastrewms.add(jLabelSource, GBC.eop().insets(0, 0, 0, 0));
-        cadastrewms.add(sourcing, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
+        cadastrewms.add(sourcing, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 0, 0, 5));
 
         // option to alter the original colors of the wms images
@@ -153,10 +191,5 @@
 
         // option to enable transparency
-        transparency.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                sliderTrans.setEnabled(transparency.isSelected());
-            }
-        });
+        transparency.addActionListener(e -> sliderTrans.setEnabled(transparency.isSelected()));
         transparency.setSelected(Config.getPref().getBoolean("cadastrewms.backgroundTransparent", false));
         transparency.setToolTipText(tr("Allows multiple layers stacking"));
@@ -172,5 +205,5 @@
         sliderTrans.setPaintLabels(false);
         sliderTrans.setEnabled(transparency.isSelected());
-        cadastrewms.add(sliderTrans, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 250, 0));
+        cadastrewms.add(sliderTrans, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(20, 0, 250, 0));
 
         // option to draw boundaries of downloaded data
@@ -189,14 +222,14 @@
         bgResolution.add(grabRes2);
         bgResolution.add(grabRes3);
-        String currentResolution = Config.getPref().get("cadastrewms.resolution", "high");
-        if (currentResolution.equals("high"))
-            grabRes1.setSelected(true);
-        if (currentResolution.equals("medium"))
-            grabRes2.setSelected(true);
-        if (currentResolution.equals("low"))
-            grabRes3.setSelected(true);
+        String currentResolution = Config.getPref().get(CADASTREWMS_RESOLUTION, HIGH);
+        switch (currentResolution) {
+            case "high" -> grabRes1.setSelected(true);
+            case "medium" -> grabRes2.setSelected(true);
+            case "low" -> grabRes3.setSelected(true);
+            default -> { /* Do nothing */ }
+        }
         cadastrewms.add(grabRes1, GBC.std().insets(5, 0, 5, 0));
         cadastrewms.add(grabRes2, GBC.std().insets(5, 0, 5, 0));
-        cadastrewms.add(grabRes3, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
+        cadastrewms.add(grabRes3, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5));
 
         // option to select image zooming interpolation method
@@ -206,41 +239,37 @@
         imageInterpolationMethod.addItem(tr("Bilinear (fast)"));
         imageInterpolationMethod.addItem(tr("Bicubic (slow)"));
-        String savedImageInterpolationMethod = Config.getPref().get("cadastrewms.imageInterpolation", "standard");
-        if (savedImageInterpolationMethod.equals("bilinear"))
+        String savedImageInterpolationMethod = Config.getPref().get(CADASTREWMS_IMAGE_INTERPOLATION, "standard");
+        if ("bilinear".equals(savedImageInterpolationMethod)) {
             imageInterpolationMethod.setSelectedIndex(1);
-        else if (savedImageInterpolationMethod.equals("bicubic"))
+        } else if ("bicubic".equals(savedImageInterpolationMethod)) {
             imageInterpolationMethod.setSelectedIndex(2);
-        else
+        } else
             imageInterpolationMethod.setSelectedIndex(0);
-        cadastrewms.add(imageInterpolationMethod, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
-
-        // separator
-        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
-
+        cadastrewms.add(imageInterpolationMethod, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 200, 5));
+    }
+
+    private void addGuiVectorImages(JPanel cadastrewms) {
         // the vectorized images multiplier
         JLabel jLabelScale = new JLabel(tr("Vector images grab multiplier:"));
         cadastrewms.add(jLabelScale, GBC.std().insets(0, 5, 10, 0));
         ButtonGroup bgGrabMultiplier = new ButtonGroup();
-        ActionListener multiplierActionListener = new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent actionEvent) {
-              AbstractButton button = (AbstractButton) actionEvent.getSource();
-              grabMultiplier4Size.setEnabled(button == grabMultiplier4);
-            }
-          };
-        grabMultiplier1.setIcon(ImageProvider.get("preferences", "unsel_box_1"));
-        grabMultiplier1.setSelectedIcon(ImageProvider.get("preferences", "sel_box_1"));
+        ActionListener multiplierActionListener = actionEvent -> {
+            AbstractButton button = (AbstractButton) actionEvent.getSource();
+            grabMultiplier4Size.setEnabled(button == grabMultiplier4);
+        };
+        grabMultiplier1.setIcon(ImageProvider.get(PREFERENCES, "unsel_box_1"));
+        grabMultiplier1.setSelectedIcon(ImageProvider.get(PREFERENCES, "sel_box_1"));
         grabMultiplier1.addActionListener(multiplierActionListener);
         grabMultiplier1.setToolTipText(tr("Grab one image full screen"));
-        grabMultiplier2.setIcon(ImageProvider.get("preferences", "unsel_box_2"));
-        grabMultiplier2.setSelectedIcon(ImageProvider.get("preferences", "sel_box_2"));
+        grabMultiplier2.setIcon(ImageProvider.get(PREFERENCES, "unsel_box_2"));
+        grabMultiplier2.setSelectedIcon(ImageProvider.get(PREFERENCES, "sel_box_2"));
         grabMultiplier2.addActionListener(multiplierActionListener);
         grabMultiplier2.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
-        grabMultiplier3.setIcon(ImageProvider.get("preferences", "unsel_box_3"));
-        grabMultiplier3.setSelectedIcon(ImageProvider.get("preferences", "sel_box_3"));
+        grabMultiplier3.setIcon(ImageProvider.get(PREFERENCES, "unsel_box_3"));
+        grabMultiplier3.setSelectedIcon(ImageProvider.get(PREFERENCES, "sel_box_3"));
         grabMultiplier3.addActionListener(multiplierActionListener);
         grabMultiplier3.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
-        grabMultiplier4.setIcon(ImageProvider.get("preferences", "unsel_box_4"));
-        grabMultiplier4.setSelectedIcon(ImageProvider.get("preferences", "sel_box_4"));
+        grabMultiplier4.setIcon(ImageProvider.get(PREFERENCES, "unsel_box_4"));
+        grabMultiplier4.setSelectedIcon(ImageProvider.get(PREFERENCES, "sel_box_4"));
         grabMultiplier4.addActionListener(multiplierActionListener);
         grabMultiplier4.setToolTipText(tr("Fixed size square (default is 100m)"));
@@ -249,5 +278,5 @@
         bgGrabMultiplier.add(grabMultiplier3);
         bgGrabMultiplier.add(grabMultiplier4);
-        String currentScale = Config.getPref().get("cadastrewms.scale", DEFAULT_GRAB_MULTIPLIER);
+        String currentScale = Config.getPref().get(CADASTREWMS_SCALE, DEFAULT_GRAB_MULTIPLIER);
         if (currentScale.equals(Scale.X1.value))
             grabMultiplier1.setSelected(true);
@@ -266,5 +295,5 @@
         grabMultiplier4Size.setToolTipText(tr("Fixed size (from 25 to 1000 meters)"));
         grabMultiplier4Size.setEnabled(currentScale.equals(Scale.SQUARE_100M.value));
-        cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
+        cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5));
 
         // WMS layers selection
@@ -298,8 +327,7 @@
         layerCommune.setToolTipText(tr("Municipality administrative borders."));
         cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0));
-
-        // separator
-        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
-
+    }
+
+    private void addGuiRasterImages(JPanel cadastrewms) {
         // for raster images (not vectorized), image grab divider (from 1 to 12)
         String savedRasterDivider = Config.getPref().get("cadastrewms.rasterDivider", DEFAULT_RASTER_DIVIDER);
@@ -308,5 +336,5 @@
         rasterDivider.setToolTipText("Raster image grab division, from 1 to 12; 12 is very high definition");
         cadastrewms.add(jLabelRasterDivider, GBC.std().insets(0, 5, 10, 0));
-        cadastrewms.add(rasterDivider, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
+        cadastrewms.add(rasterDivider, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 200, 5));
         // option to disable image cropping during raster image georeferencing
         disableImageCropping.setSelected(Config.getPref().getBoolean("cadastrewms.noImageCropping", false));
@@ -325,5 +353,5 @@
         cadastrewms.add(jLabelCrosspieces, GBC.std().insets(0, 0, 10, 0));
         ButtonGroup bgCrosspieces = new ButtonGroup();
-        int crosspieces = getNumber("cadastrewms.crosspieces", DEFAULT_CROSSPIECES);
+        int crosspieces = getNumber(CADASTREWMS_CROSSPIECES, DEFAULT_CROSSPIECES);
         if (crosspieces == 0) crosspiece1.setSelected(true);
         if (crosspieces == 1) crosspiece2.setSelected(true);
@@ -337,57 +365,52 @@
         cadastrewms.add(crosspiece2, GBC.std().insets(5, 0, 5, 0));
         cadastrewms.add(crosspiece3, GBC.std().insets(5, 0, 5, 0));
-        cadastrewms.add(crosspiece4, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
-
-        // separator
-        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
-
+        cadastrewms.add(crosspiece4, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5));
+    }
+
+    private void addGuiAutoCache(JPanel cadastrewms) {
         // option to enable automatic caching
-        enableCache.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                jLabelCacheSize.setEnabled(enableCache.isSelected());
-                cacheSize.setEnabled(enableCache.isSelected());
-            }
+        enableCache.addActionListener(e -> {
+            jLabelCacheSize.setEnabled(enableCache.isSelected());
+            cacheSize.setEnabled(enableCache.isSelected());
         });
         enableCache.setSelected(Config.getPref().getBoolean("cadastrewms.enableCaching", true));
         enableCache.setToolTipText(tr("Allows an automatic caching"));
         cadastrewms.add(enableCache, GBC.eop().insets(0, 0, 0, 0));
-
-        // option to fix the cache size(in MB)
+    }
+
+    private void addGuiCacheSize(JPanel cadastrewms) {
         int size = getNumber("cadastrewms.cacheSize", DEFAULT_CACHE_SIZE);
         cacheSize.setText(String.valueOf(size));
         cacheSize.setToolTipText(tr("Oldest files are automatically deleted when this size is exceeded"));
         cadastrewms.add(jLabelCacheSize, GBC.std().insets(20, 0, 0, 0));
-        cadastrewms.add(cacheSize, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
-
-        // separator
-        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
-
-        // option to select the first WMS layer
+        cadastrewms.add(cacheSize, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 200, 5));
+    }
+
+    private void addGuiFirstWMSLayer(JPanel cadastrewms) {
         autoFirstLayer.setSelected(Config.getPref().getBoolean("cadastrewms.autoFirstLayer", false));
         autoFirstLayer.setToolTipText(tr("Automatically selects the first WMS layer if multiple layers exist when grabbing."));
         cadastrewms.add(autoFirstLayer, GBC.eop().insets(0, 0, 0, 0));
-
-        // separator
-        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
-
+    }
+
+    private void addGuiUseRelationsInAddresses(JPanel cadastrewms) {
         // option to use or not relations in addresses
         dontUseRelation.setSelected(Config.getPref().getBoolean("cadastrewms.addr.dontUseRelation", false));
         dontUseRelation.setToolTipText(tr("Enable this to use the tag \"add:street\" on nodes."));
         cadastrewms.add(dontUseRelation, GBC.eop().insets(0, 0, 0, 0));
-
-        // separator
-        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
-
+    }
+
+    private void addGuiMergeDownloadedDataLayers(JPanel cadastrewms) {
         // option to merge downloaded data layers
         mergeDataLayers.setSelected(Config.getPref().getBoolean("cadastrewms.merge.data.layers", false));
         mergeDataLayers.setToolTipText(tr("Merge automatically all cadastre data layers in a single final layer."));
         cadastrewms.add(mergeDataLayers, GBC.eop().insets(0, 0, 0, 0));
-
+    }
+
+    private static void addGuiEndOfDialogScrollBar(JPanel cadastrewms, JPanel cadastrewmsMast) {
         // end of dialog, scroll bar
-        cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
+        cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.VERTICAL));
         JScrollPane scrollpane = new JScrollPane(cadastrewms);
         scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
-        cadastrewmsMast.add(scrollpane, GBC.eol().fill(GBC.BOTH));
+        cadastrewmsMast.add(scrollpane, GBC.eol().fill(GridBagConstraints.BOTH));
     }
 
@@ -402,23 +425,23 @@
         Config.getPref().putBoolean("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
         if (grabRes1.isSelected())
-            Config.getPref().put("cadastrewms.resolution", "high");
+            Config.getPref().put(CADASTREWMS_RESOLUTION, HIGH);
         else if (grabRes2.isSelected())
-            Config.getPref().put("cadastrewms.resolution", "medium");
+            Config.getPref().put(CADASTREWMS_RESOLUTION, MEDIUM);
         else if (grabRes3.isSelected())
-            Config.getPref().put("cadastrewms.resolution", "low");
+            Config.getPref().put(CADASTREWMS_RESOLUTION, LOW);
         if (imageInterpolationMethod.getSelectedIndex() == 2)
-            Config.getPref().put("cadastrewms.imageInterpolation", "bicubic");
+            Config.getPref().put(CADASTREWMS_IMAGE_INTERPOLATION, "bicubic");
         else if (imageInterpolationMethod.getSelectedIndex() == 1)
-            Config.getPref().put("cadastrewms.imageInterpolation", "bilinear");
+            Config.getPref().put(CADASTREWMS_IMAGE_INTERPOLATION, "bilinear");
         else
-            Config.getPref().put("cadastrewms.imageInterpolation", "standard");
+            Config.getPref().put(CADASTREWMS_IMAGE_INTERPOLATION, "standard");
         if (grabMultiplier1.isSelected())
-            Config.getPref().put("cadastrewms.scale", Scale.X1.toString());
+            Config.getPref().put(CADASTREWMS_SCALE, Scale.X1.toString());
         else if (grabMultiplier2.isSelected())
-            Config.getPref().put("cadastrewms.scale", Scale.X2.toString());
+            Config.getPref().put(CADASTREWMS_SCALE, Scale.X2.toString());
         else if (grabMultiplier3.isSelected())
-            Config.getPref().put("cadastrewms.scale", Scale.X3.toString());
+            Config.getPref().put(CADASTREWMS_SCALE, Scale.X3.toString());
         else {
-            Config.getPref().put("cadastrewms.scale", Scale.SQUARE_100M.toString());
+            Config.getPref().put(CADASTREWMS_SCALE, Scale.SQUARE_100M.toString());
             try {
                 int squareSize = Integer.parseInt(grabMultiplier4Size.getText());
@@ -448,8 +471,8 @@
         Config.getPref().putBoolean("cadastrewms.useTA", enableTableauAssemblage.isSelected());
         Config.getPref().putBoolean("cadastrewms.raster2bitsColors", simplify2BitsColors.isSelected());
-        if (crosspiece1.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "0");
-        else if (crosspiece2.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "1");
-        else if (crosspiece3.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "2");
-        else if (crosspiece4.isSelected()) Config.getPref().put("cadastrewms.crosspieces", "3");
+        if (crosspiece1.isSelected()) Config.getPref().put(CADASTREWMS_CROSSPIECES, "0");
+        else if (crosspiece2.isSelected()) Config.getPref().put(CADASTREWMS_CROSSPIECES, "1");
+        else if (crosspiece3.isSelected()) Config.getPref().put(CADASTREWMS_CROSSPIECES, "2");
+        else if (crosspiece4.isSelected()) Config.getPref().put(CADASTREWMS_CROSSPIECES, "3");
         Config.getPref().putBoolean("cadastrewms.enableCaching", enableCache.isSelected());
 
@@ -471,9 +494,9 @@
     }
 
-    private int getNumber(String pref_parameter, int def_value) {
+    private static int getNumber(String prefParameter, int defValue) {
         try {
-            return Integer.parseInt(Config.getPref().get(pref_parameter, String.valueOf(def_value)));
+            return Integer.parseInt(Config.getPref().get(prefParameter, String.valueOf(defValue)));
         } catch (NumberFormatException e) {
-            return def_value;
+            return defValue;
         }
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/session/CadastreSessionExporter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/session/CadastreSessionExporter.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/session/CadastreSessionExporter.java	(revision 36385)
@@ -3,4 +3,5 @@
 
 import java.awt.Component;
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.io.IOException;
@@ -46,5 +47,5 @@
         p.add(export, GBC.std());
         p.add(lbl, GBC.std());
-        p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
+        p.add(GBC.glue(1, 0), GBC.std().fill(GridBagConstraints.HORIZONTAL));
         return p;
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/session/CadastreSessionImporter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/session/CadastreSessionImporter.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/session/CadastreSessionImporter.java	(revision 36385)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.plugins.fr.cadastre.wms.CacheControl;
 import org.openstreetmap.josm.plugins.fr.cadastre.wms.WMSLayer;
+import org.openstreetmap.josm.tools.JosmRuntimeException;
 import org.w3c.dom.Element;
 
@@ -61,5 +62,5 @@
 
         } catch (XPathExpressionException e) {
-            throw new RuntimeException(e);
+            throw new JosmRuntimeException(e);
         }
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheControl.java	(revision 36385)
@@ -13,5 +13,4 @@
 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;
@@ -116,19 +115,16 @@
         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(MainApplication.getMainFrame(), tr("Select Feuille"));
-                    CadastrePlugin.prepareDialog(dialog);
-                    dialog.setVisible(true);
-                    return (Integer) pane.getValue();
-                    // till here
-                }
+            int reply = GuiHelper.runInEDTAndWaitAndReturn(() -> {
+                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(MainApplication.getMainFrame(), tr("Select Feuille"));
+                CadastrePlugin.prepareDialog(dialog);
+                dialog.setVisible(true);
+                return (Integer) pane.getValue();
+                // till here
             });
 
@@ -159,5 +155,5 @@
         try (
             FileInputStream fis = new FileInputStream(file);
-            ObjectInputStream ois = new ObjectInputStream(fis);
+            ObjectInputStream ois = new ObjectInputStream(fis)
         ) {
             wmsLayer.setAssociatedFile(file);
@@ -232,4 +228,5 @@
             } catch (InterruptedException e) {
                 Logging.error(e);
+                Thread.currentThread().interrupt();
             }
         }
Index: /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheFileLambert4ZoneFilter.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheFileLambert4ZoneFilter.java	(revision 36384)
+++ /applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/wms/CacheFileLambert4ZoneFilter.java	(revision 36385)
@@ -2,4 +2,5 @@
 package org.openstreetmap.josm.plugins.fr.cadastre.wms;
 
+import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
 
@@ -10,4 +11,5 @@
 
 public final class CacheFileLambert4ZoneFilter extends FileFilter {
+    private static final String LAMBERT_ZONE_MESSAGE = marktr("Lambert Zone {0} cache file (.{0})");
 
     /**
@@ -21,8 +23,8 @@
      */
     public 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)),
-        new CacheFileLambert4ZoneFilter("3", tr("Lambert Zone {0} cache file (.{0})", 3)),
-        new CacheFileLambert4ZoneFilter("4", tr("Lambert Zone {0} cache file (.{0})", 4))
+        new CacheFileLambert4ZoneFilter("1", tr(LAMBERT_ZONE_MESSAGE, 1)),
+        new CacheFileLambert4ZoneFilter("2", tr(LAMBERT_ZONE_MESSAGE, 2)),
+        new CacheFileLambert4ZoneFilter("3", tr(LAMBERT_ZONE_MESSAGE, 3)),
+        new CacheFileLambert4ZoneFilter("4", tr(LAMBERT_ZONE_MESSAGE, 4))
         };
 
