Index: /applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java
===================================================================
--- /applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java	(revision 21805)
+++ /applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java	(revision 21806)
@@ -73,5 +73,5 @@
 	private void updMetrics() {
 		meter = 2 * Math.PI / (Math.cos(Math.toRadians(eastNorth2latlon(en[0]).lat())) * eqlen);
-		reset();
+		len = 0;
 	}
 
@@ -128,5 +128,5 @@
 	public void setPlace(EastNorth p2, double width, double lenstep, boolean ignoreConstraints) {
 		if (en[0] == null)
-			en[0] = p2;
+			throw new IllegalStateException("setPlace() called without the base point");
 		this.heading = en[0].heading(p2);
 		double hdang = 0;
@@ -153,4 +153,6 @@
 
 	public void setPlaceRect(EastNorth p2) {
+		if (en[0] == null)
+			throw new IllegalStateException("SetPlaceRect() called without the base point");
 		if (!isRectDrawing())
 			throw new IllegalStateException("Invalid drawing mode");
@@ -187,11 +189,16 @@
 		DataSet ds = Main.main.getCurrentDataSet();
 		LatLon l = eastNorth2latlon(en);
-		List<Node> nodes = ds.searchNodes(new BBox(l.lon() - 0.00001, l.lat() - 0.00001,
-				l.lon() + 0.00001, l.lat() + 0.00001));
+		List<Node> nodes = ds.searchNodes(new BBox(l.lon() - 0.0000001, l.lat() - 0.0000001,
+				l.lon() + 0.0000001, l.lat() + 0.0000001));
+		Node bestnode = null;
+		double mindist = 0.0003;
 		for (Node n : nodes) {
-			if (OsmPrimitive.isUsablePredicate.evaluate(n))
-				return n;
-		}
-		return null;
+			double dist = n.getCoor().distanceSq(l);
+			if (dist < mindist && OsmPrimitive.isUsablePredicate.evaluate(n)) {
+				bestnode = n;
+				mindist = dist;
+			}
+		}
+		return bestnode;
 	}
 
@@ -202,4 +209,5 @@
 		final Node[] nodes = new Node[4];
 		for (int i = 0; i < 4; i++) {
+
 			Node n = findNode(en[i]);
 			if (n == null) {
@@ -218,5 +226,5 @@
 		Way w = new Way();
 		w.addNode(nodes[0]);
-		if (projection1(latlon2eastNorth(nodes[2].getCoor())) > 0) {
+		if (projection1(en[2]) > 0) {
 			w.addNode(nodes[1]);
 			w.addNode(nodes[2]);
