Index: src/wmsplugin/WMSLayer.java
===================================================================
--- src/wmsplugin/WMSLayer.java	(revision 15029)
+++ src/wmsplugin/WMSLayer.java	(working copy)
@@ -83,6 +83,7 @@
         executor = Executors.newFixedThreadPool(3);
     }
     
+    @Override
     public void destroy() {
         try { 
             executor.shutdown();  
@@ -175,6 +176,7 @@
         for(int x = bminx; x<bmaxx; ++x)
             for(int y = bminy; y<bmaxy; ++y){
                 GeorefImage img = images[modulo(x,dax)][modulo(y,day)];
+                g.drawRect(x, y, dax, bminy);
                 if(!img.paint(g, mv, dx, dy) && !img.downloadingStarted){
                     img.downloadingStarted = true;
                     img.image = null;
Index: src/wmsplugin/Grabber.java
===================================================================
--- src/wmsplugin/Grabber.java	(revision 15029)
+++ src/wmsplugin/Grabber.java	(working copy)
@@ -11,6 +11,7 @@
 import java.awt.Color;
 import java.awt.Font;
 import javax.swing.JOptionPane;
+import org.openstreetmap.josm.data.coor.LatLon;
 
 abstract public class Grabber implements Runnable {
     protected Bounds b;
@@ -22,7 +23,25 @@
 
     Grabber(Bounds b, Projection proj,
             double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) {
-        this.b = b;
+
+
+        if (b.min != null && b.max != null && WMSPlugin.doOverlap) {
+            double latCent = (b.min.lat() + b.max.lat()) / 2;
+            double lonCent = (b.min.lon() + b.max.lon()) / 2;
+            
+            double latSize =  b.max.lat() - b.min.lat();
+            double lonSize =  b.max.lon() - b.min.lon();
+
+            double latCoef = (100.0 + WMSPlugin.overlapLat) / 100.0 / 2.0;
+            double lonCoef = (100.0 + WMSPlugin.overlapLon) / 100.0 / 2.0;
+            
+            this.b = new Bounds( new LatLon(latCent - latCoef * latSize,
+                                            lonCent - lonCoef * lonSize),
+                                 new LatLon(latCent + latCoef * latSize,
+                                            lonCent + lonCoef * lonSize));            
+        } else
+            this.b = b;
+            
         this.proj = proj;
         this.pixelPerDegree = pixelPerDegree;
         this.image = image;
Index: src/wmsplugin/WMSPlugin.java
===================================================================
--- src/wmsplugin/WMSPlugin.java	(revision 15029)
+++ src/wmsplugin/WMSPlugin.java	(working copy)
@@ -37,6 +37,10 @@
     static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
     static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>();
 
+    static boolean doOverlap = false;
+    static int overlapLat = 4;
+    static int overlapLon = 14;
+    
     // remember state of menu item to restore on changed preferences
     static private boolean menuEnabled = false;
 
@@ -76,6 +80,22 @@
         Map<String,String> prefs = Main.pref.getAllPrefix("wmsplugin.url.");
 
         TreeSet<String> keys = new TreeSet<String>(prefs.keySet());
+       
+        // Here we load the settings for "overlap" checkbox and spinboxes.
+        
+        try {
+            doOverlap = Boolean.valueOf(prefs.get("wmsplugin.url.overlap"));            
+        } catch (Exception e) {} // If sth fails, we drop to default settings.
+
+        try {
+            overlapLat = Integer.valueOf(prefs.get("wmsplugin.url.overlapLat"));            
+        } catch (Exception e) {} // If sth fails, we drop to default settings.
+
+        try {
+            overlapLon = Integer.valueOf(prefs.get("wmsplugin.url.overlapLon"));            
+        } catch (Exception e) {} // If sth fails, we drop to default settings.
+        
+        // And then the names+urls of WMS servers        
         int prefid = 0;
         String name = null;
         String url = null;
Index: src/wmsplugin/GeorefImage.java
===================================================================
--- src/wmsplugin/GeorefImage.java	(revision 15029)
+++ src/wmsplugin/GeorefImage.java	(working copy)
@@ -1,5 +1,6 @@
 package wmsplugin;
 
+import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Image;
@@ -79,6 +80,8 @@
         // but the performance improvements when moving are huge
         // Zooming is still slow because the images need to be resized
         if(diffx >= 0 && diffx <= 2 && diffy >= 0 && diffy <= 2 && reImg != null) {
+            /*g.setColor(Color.RED);
+              g.drawRect(minPt.x, minPt.y-height, width, height);*/
             g.drawImage(reImg, minPt.x, maxPt.y, null);
             return true;
         }
@@ -119,6 +122,8 @@
                 reImg.getGraphics().dispose();
 
                 reImgHash.setSize(width, height);
+                /*g.setColor(Color.RED);
+                  g.drawRect(minPt.x, minPt.y-height, width, height);*/
                 g.drawImage(reImg, minPt.x, maxPt.y, null);
             }
         } catch(Exception e) {
Index: src/wmsplugin/WMSPreferenceEditor.java
===================================================================
--- src/wmsplugin/WMSPreferenceEditor.java	(revision 15029)
+++ src/wmsplugin/WMSPreferenceEditor.java	(working copy)
@@ -1,5 +1,11 @@
 package wmsplugin;
 
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import javax.swing.JCheckBox;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
+import org.openstreetmap.josm.Main;
 import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.Dimension;
@@ -31,9 +37,13 @@
     private DefaultTableModel model;
     private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
 
+    JCheckBox overlapCheckBox;
+    JSpinner spinLat;
+    JSpinner spinLon;
+    
     public void addGui(final PreferenceDialog gui) {
         JPanel p = gui.createPreferenceTab("wms", tr("WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS plugin menu"));
-
+        
         model = new DefaultTableModel(new String[]{tr("Menu Name"), tr("WMS URL")}, 0);
         final JTable list = new JTable(model);
         JScrollPane scroll = new JScrollPane(list);
@@ -58,9 +68,10 @@
             modeldef.addRow(new String[]{i.getKey(), i.getValue()});
         }
 
+        JPanel buttonPanel = new JPanel(new FlowLayout());
+        
         JButton add = new JButton(tr("Add"));
-        p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
-        p.add(add, GBC.std().insets(0,5,0,0));
+        buttonPanel.add(add, GBC.std().insets(0,5,0,0));
         add.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e) {
                 JPanel p = new JPanel(new GridBagLayout());
@@ -78,7 +89,7 @@
         });
 
         JButton delete = new JButton(tr("Delete"));
-        p.add(delete, GBC.std().insets(0,5,0,0));
+        buttonPanel.add(delete, GBC.std().insets(0,5,0,0));
         delete.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e) {
                 if (list.getSelectedRow() == -1)
@@ -93,7 +104,7 @@
         });
 
         JButton copy = new JButton(tr("Copy Default"));
-        p.add(copy, GBC.std().insets(0,5,0,0));
+        buttonPanel.add(copy, GBC.std().insets(0,5,0,0));
         copy.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e) {
                 Integer line = listdef.getSelectedRow();
@@ -106,6 +117,24 @@
                 }
             }
         });
+
+        p.add(buttonPanel);        
+        p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
+        
+        overlapCheckBox = new JCheckBox(tr("Overlap tiles"), WMSPlugin.doOverlap );
+        JLabel labelLat = new JLabel(tr("% of lat:"));
+        JLabel labelLon = new JLabel(tr("% of lon:"));
+        spinLat = new JSpinner(new SpinnerNumberModel(WMSPlugin.overlapLat, 1, 50, 1));
+        spinLon = new JSpinner(new SpinnerNumberModel(WMSPlugin.overlapLon, 1, 50, 1));
+        
+        JPanel overlapPanel = new JPanel(new FlowLayout());
+        overlapPanel.add(overlapCheckBox);
+        overlapPanel.add(labelLat);
+        overlapPanel.add(spinLat);
+        overlapPanel.add(labelLon);
+        overlapPanel.add(spinLon);
+        
+        p.add(overlapPanel);
     }
 
     public boolean ok() {
@@ -144,6 +173,15 @@
         }
 
         if (change) WMSPlugin.refreshMenu();
+        
+        WMSPlugin.doOverlap = overlapCheckBox.getModel().isSelected();
+        WMSPlugin.overlapLat = (Integer) spinLat.getModel().getValue();
+        WMSPlugin.overlapLon = (Integer) spinLon.getModel().getValue();
+        
+        Main.pref.put("wmsplugin.url.overlap",    String.valueOf(WMSPlugin.doOverlap));
+        Main.pref.put("wmsplugin.url.overlapLat", String.valueOf(WMSPlugin.overlapLat));
+        Main.pref.put("wmsplugin.url.overlapLon", String.valueOf(WMSPlugin.overlapLon));
+        
         return false;
     }
 
