Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Buildings.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Buildings.java	(revision 20658)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Buildings.java	(revision 20659)
@@ -269,10 +269,10 @@
                 test_x = x + this.dirsX[new_dir];
                 test_y = y + this.dirsY[new_dir];
-                if(test_x < 0 || test_x >= selectedImage.image.getWidth() ||
+                if (test_x < 0 || test_x >= selectedImage.image.getWidth() ||
                         test_y < 0 || test_y >= selectedImage.image.getHeight()){
                     System.out.println("Outside image");
                     return false;
                 }
-                if(bim.isBuildingOrRoofColor(selectedImage.image, test_x, test_y, buildingColors, ignoreParcels)){
+                if (bim.isBuildingOrRoofColor(selectedImage.image, test_x, test_y, buildingColors, ignoreParcels)){
                     System.out.println("building color at "+test_x+","+test_y+" new_dir="+new_dir);
                     break;
@@ -304,7 +304,12 @@
             y = test_y;
             // Break the loop if we managed to get back to our starting point
-            if (listPixels.contains(new Pixel(x, y, 0))){
+            if (x == startX && y == startY) {
                 System.out.println("loop closed at "+x+","+y+", exit");
                 break;
+            } else if (listPixels.contains(new Pixel(x, y, 0))){
+                int j = listPixels.indexOf(new Pixel(x, y, 0));
+                int l = listPixels.size();
+                for (int k = j; k < l; k++)
+                    listPixels.remove(j);
             }
             addPixeltoList(x, y, new_dir);
@@ -544,9 +549,9 @@
                         n0.getCoor().getX(), n0.getCoor().getY(),
                         n2.getCoor().getX(), n2.getCoor().getY());
-                System.out.println("angle n0,n1,n2="+(angle1*180/Math.PI));
+//                System.out.println("angle n0,n1,n2="+(angle1*180/Math.PI));
                 double angle2 = AngleOfView(n2.getCoor().getX(), n2.getCoor().getY(),
                         n1.getCoor().getX(), n1.getCoor().getY(),
                         n3.getCoor().getX(), n3.getCoor().getY());
-                System.out.println("angle n1,n2,n3="+(angle2*180/Math.PI));
+//                System.out.println("angle n1,n2,n3="+(angle2*180/Math.PI));
                 if (angle1 > Math.PI*0.9 && angle1 < Math.PI*1.1) {
                     way.removeNode(n1);
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 20658)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 20659)
@@ -109,4 +109,5 @@
  *                 -     non-modal JDialog in MenuActionGrabPlanImage
  *                 -     new options in the image filter (bilinear, bicubic)
+ * 1.9 xx-xxx-xxxx - added a scroll bar in preferences
  */
 public class CadastrePlugin extends Plugin {
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java	(revision 20658)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java	(revision 20659)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -95,5 +96,8 @@
                 + "http://www.cadastre.gouv.fr/scpc/html/CU_01_ConditionsGenerales_fr.html</a> <BR>"
                 + "before any upload of data created by this plugin.");
-        JPanel cadastrewms = gui.createPreferenceTab("cadastrewms.gif", I18n.tr("French cadastre WMS"), description);
+        JPanel cadastrewmsMast = gui.createPreferenceTab("cadastrewms.gif", I18n.tr("French cadastre WMS"), description);
+        
+        JPanel cadastrewms = new JPanel(new GridBagLayout());
+        cadastrewms.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
 
         // option to automatically set the source tag when uploading
@@ -326,4 +330,9 @@
         cadastrewms.add(autoFirstLayer, GBC.eop().insets(0, 0, 0, 0));
         cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
+//        JTabbedPane cadastrecontent = new JTabbedPane();
+//        cadastrecontent.add(cadastrewms);
+        JScrollPane scrollpane = new JScrollPane(cadastrewms);
+        scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
+        cadastrewmsMast.add(scrollpane, GBC.eol().fill(GBC.BOTH));
 
     }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 20658)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 20659)
@@ -61,4 +61,6 @@
     
     public static int currentFormat;
+    
+    private static final int cBBoxForBuildings = 50; // hard coded size of grabbed boxes for building layers
 
     private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>();
@@ -141,5 +143,5 @@
                         CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)), 0);
             } else if (buildingsOnly)
-                divideBbox(b, 5, 80); // hard coded size of 80 meters per box
+                divideBbox(b, 5, cBBoxForBuildings);
             else
                 divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.scale", Scale.X1.toString())), 0);
