Index: applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersAddLayerAction.java
===================================================================
--- applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersAddLayerAction.java	(revision 16522)
+++ applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersAddLayerAction.java	(revision 16549)
@@ -2,12 +2,8 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
 import java.awt.event.ActionEvent;
 import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
 import java.net.URL;
 import java.util.regex.Matcher;
@@ -19,7 +15,7 @@
 import org.openstreetmap.josm.actions.JosmAction;
 import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
-import org.openstreetmap.josm.tools.OsmUrlToBounds;
+import org.openstreetmap.josm.data.coor.LatLon;
 
+@SuppressWarnings("serial")
 public class WalkingPapersAddLayerAction extends JosmAction {
 
@@ -31,6 +27,6 @@
     public void actionPerformed(ActionEvent e) {
         String wpid = JOptionPane.showInputDialog(Main.parent, 
-        	tr("Image id from walking-papers.org"),
-        	Main.pref.get("walkingpapers.last-used-id"));
+        	tr("Image id from walking-papers.org (the bit after the ?id= in the URL)"),
+        		Main.pref.get("walkingpapers.last-used-id"));
 
         if (wpid == null || wpid.equals("")) return;
@@ -39,47 +35,41 @@
         String wpUrl = "http://walking-papers.org/scan.php?id=" + wpid;
 
-        Pattern locationPattern = 
-        	Pattern.compile("<a id=\"print-location\" href=\"(http://www.openstreetmap.org/[^\"]+)\"");
-        Pattern hiddenFieldPattern = 
-        	Pattern.compile("<input name=\"(\\S+)\" type=\"hidden\" value=\"(.*)\" />");
+        Pattern spanPattern = Pattern.compile("<span class=\"(\\S+)\">(\\S+)</span>");
         Matcher m;
         
-        Bounds b = null;
-        int minx = -1;
-        int maxx = -1;
-        int miny = -1;
-        int maxy = -1;
+        double north = 0;
+        double south = 0;
+        double east = 0;
+        double west = 0;
         int minz = -1;
         int maxz = -1;
+        String tile = null;
 
         try {
         	BufferedReader r = new BufferedReader(new InputStreamReader(new URL(wpUrl).openStream(), "utf-8"));
         	for (String line = r.readLine(); line != null; line = r.readLine()) {
-        		m = locationPattern.matcher(line);
+        		m = spanPattern.matcher(line);
         		if (m.find()) {
-        			String escapedUrl = m.group(1);
-        			b = OsmUrlToBounds.parse(escapedUrl.replace("&amp;","&"));
-        		} else {
-        			m = hiddenFieldPattern.matcher(line);
-        			if (m.find()) {
-        				if ("maxrow".equals(m.group(1))) maxy = (int) Double.parseDouble(m.group(2));
-        				else if ("maxcolumn".equals(m.group(1))) maxx = (int) Double.parseDouble(m.group(2));
-        				else if ("minrow".equals(m.group(1))) miny = (int) Double.parseDouble(m.group(2));
-        				else if ("mincolumn".equals(m.group(1))) minx = (int) Double.parseDouble(m.group(2));
-        				else if ("minzoom".equals(m.group(1))) minz = Integer.parseInt(m.group(2));
-        				else if ("maxzoom".equals(m.group(1))) maxz = Integer.parseInt(m.group(2));
-        			}
+        			if ("tile".equals(m.group(1))) tile = m.group(2);
+        			else if ("north".equals(m.group(1))) north = Double.parseDouble(m.group(2));
+        			else if ("south".equals(m.group(1))) south = Double.parseDouble(m.group(2));
+        			else if ("east".equals(m.group(1))) east = Double.parseDouble(m.group(2));
+        			else if ("west".equals(m.group(1))) west = Double.parseDouble(m.group(2));
+        			else if ("minzoom".equals(m.group(1))) minz = Integer.parseInt(m.group(2));
+        			else if ("maxzoom".equals(m.group(1))) maxz = Integer.parseInt(m.group(2));
         		}
         	}
         	r.close();
-        	if ((b == null) || (minx < 0)) throw new Exception();
+        	if ((tile == null) || (north == 0 && south == 0) || (east == 0 && west == 0)) throw new Exception();
         } catch (Exception ex) {
-            JOptionPane.showMessageDialog(Main.parent,tr("Could not read information from walking-papers.org for this id."));
-            return;
+        	JOptionPane.showMessageDialog(Main.parent,tr("Could not read information from walking-papers.org for this id."));
+        	return;
         }
+
+        Main.pref.put("walkingpapers.last-used-id", wpid);
+
+        Bounds b = new Bounds(new LatLon(south, west), new LatLon(north, east));
         
-        // FIXME min/max values are not any good, they just indicate the centre tile x/y for the 
-        // minimum and the maximum zoom lvl but not how many tiles there are...
-        WalkingPapersLayer wpl = new WalkingPapersLayer(wpid, b, /* minx, maxx, miny, maxy, */ minz, maxz);
+        WalkingPapersLayer wpl = new WalkingPapersLayer(wpid, tile, b, minz, maxz);
         Main.main.addLayer(wpl);
 
Index: applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersLayer.java
===================================================================
--- applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersLayer.java	(revision 16522)
+++ applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersLayer.java	(revision 16549)
@@ -9,4 +9,5 @@
 import java.awt.Point;
 import java.awt.image.ImageObserver;
+import java.net.URL;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -49,39 +50,37 @@
 	private Image bufferImage;
 	private boolean needRedraw;
-	// FIXME need to find out bounds of Walking Papers scan: private int minx, maxx, miny, maxy, 
+
 	private int minzoom, maxzoom;
+	private Bounds printBounds;
+	private String tileUrlTemplate;
 	private String walkingPapersId;
 	
 	@SuppressWarnings("serial")
-	public WalkingPapersLayer(String id, Bounds b, /*int minx, int maxx, int miny, int maxy,*/ int minz, int maxz) {
+	public WalkingPapersLayer(String id, String tile, Bounds b, int minz, int maxz) {
 		super(tr("Walking Papers: " +id));
 		background = true;
 		walkingPapersId = id;
 
-		/*
-		this.minx = minx; this.maxx = maxx;
-		this.miny = miny; this.maxy = maxy;
-		*/
+		tileUrlTemplate = tile;
+		this.printBounds = b;
 		this.minzoom = minz; this.maxzoom = maxz;
 		currentZoomLevel = minz;
 		
 		clearTileStorage();
-		final Bounds copyOfB = b;
 		
 	    Layer.listeners.add(new LayerChangeListener() {
 	        public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+	        	// if user changes to a walking papers layer, zoom there just as if
+	        	// it was newly added
 	        	layerAdded(newLayer);
 	        }
 
 	        public void layerAdded(Layer newLayer) {
-	            /*Main.worker.execute(new Runnable() {
-	                public void run() {
-	                	*/
-	                    BoundingXYVisitor bbox = new BoundingXYVisitor();
-	                    bbox.visit(copyOfB);
-	                    Main.map.mapView.recalculateCenterScale(bbox);
-	             /*   }
-	            });*/
-	        	
+	        	// only do something if we are affected
+	        	if (newLayer != WalkingPapersLayer.this) return;
+	        	BoundingXYVisitor bbox = new BoundingXYVisitor();
+	        	bbox.visit(printBounds);
+	        	Main.map.mapView.recalculateCenterScale(bbox);
+	        	needRedraw = true;
 	        }
 
@@ -224,12 +223,6 @@
 		}
 		
-		boolean protectServerFromOverload = false;
-		if ((viewportMaxX-viewportMinX) * (viewportMaxY-viewportMinY) > 100) {
-			System.out.println("more than 100 visible tiles - will not download new ones");
-			protectServerFromOverload = true;
-		}
 		if (viewportMaxX-viewportMinX > 18) return;
 		if (viewportMaxY-viewportMinY > 18) return;
-		
 
 		for (int x = viewportMinX - 1; x <= viewportMaxX + 1; x++) {
@@ -255,5 +248,8 @@
 				if (!key.valid) continue;
 				if (tile == null) {
-					if (protectServerFromOverload) continue;
+					// check if tile is in range
+					Bounds tileBounds = new Bounds(new LatLon(tileYToLat(y+1), tileXToLon(x)), 
+						new LatLon(tileYToLat(y), tileXToLon(x+1)));
+					if (!tileBounds.asRect().intersects(printBounds.asRect())) continue;
 					tile = new WalkingPapersTile(x, y, currentZoomLevel, this);
 					tileStorage.put(key, tile);
@@ -272,4 +268,10 @@
 				}
 			}
+		}
+		
+		if (count == 0)
+		{
+			//System.out.println("no images on " + walkingPapersId + ", return");
+			return;
 		}
 
@@ -406,5 +408,15 @@
 	}
 	
-
+	public URL formatImageUrl(int x, int y, int z) {
+		String urlstr = tileUrlTemplate.
+			replace("{x}", String.valueOf(x)).
+			replace("{y}", String.valueOf(y)).
+			replace("{z}", String.valueOf(z));
+		try {
+			return new URL(urlstr);
+		} catch (Exception ex) {
+			return null;
+		}
+	}
 	
 }
Index: applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersPlugin.java
===================================================================
--- applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersPlugin.java	(revision 16522)
+++ applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersPlugin.java	(revision 16549)
@@ -11,5 +11,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.MainMenu;
-import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
 import org.openstreetmap.josm.plugins.Plugin;
 
@@ -33,5 +32,5 @@
         walkingPapersMenu.add(new JMenuItem(new WalkingPapersAddLayerAction()));
         
-        JOptionPane.showMessageDialog(Main.parent,tr("You are running the highly experimental Walking Papers plugin. Please report all problems."));
+        JOptionPane.showMessageDialog(Main.parent,tr("You are running the highly experimental Walking Papers plugin. Expect a rougher than usual ride..."));
     }
 
Index: applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersTile.java
===================================================================
--- applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersTile.java	(revision 16522)
+++ applications/editors/josm/plugins/walkingpapers/src/org/openstreetmap/josm/plugins/walkingpapers/WalkingPapersTile.java	(revision 16549)
@@ -1,13 +1,7 @@
 package org.openstreetmap.josm.plugins.walkingpapers;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.Image;
 import java.awt.Toolkit;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.URLConnection;
 
 /**
@@ -39,10 +33,5 @@
 
     public URL getImageUrl() {
-        try {
-            return new URL("http://paperwalking-uploads.s3.amazonaws.com/scans/" + parentLayer.getWalkingPapersId() + "/" + z + "/" + x + "/" + y + ".jpg");
-        } catch (MalformedURLException mfu) {
-        	mfu.printStackTrace();
-        }
-        return null;
+    	return parentLayer.formatImageUrl(x, y, z);
     }
 
