Index: /trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java	(revision 3144)
+++ /trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java	(revision 3145)
@@ -7,7 +7,5 @@
     public static double WORLD_PARTS = (1 << NR_LEVELS);
 
-    public static int MAX_OBJECTS_PER_LEVEL = 16;
-    // has to be a power of 2
-    public static int TILES_PER_LEVEL_SHIFT = 2;
+    public static int TILES_PER_LEVEL_SHIFT = 2; // Has to be 2. Other parts of QuadBuckets code rely on it
     public static int TILES_PER_LEVEL = 1<<TILES_PER_LEVEL_SHIFT;
     static public int X_PARTS = 360;
@@ -97,6 +95,5 @@
         return (int)(mask & (quad >> total_shift));
     }
-    static public int index(LatLon coor, int level)
-    {
+    static public int index(LatLon coor, int level) {
         // The nodes that don't return coordinates will all get
         // stuck in a single tile.  Hopefully there are not too
@@ -104,6 +101,9 @@
         if (coor == null)
             return 0;
-        long quad = coorToTile(coor);
-        return index(level, quad);
+
+        long x = lon2x(coor.lon());
+        long y = lat2y(coor.lat());
+        int shift = NR_LEVELS-level-1;
+        return (int)((x >> shift & 1) * 2 + (y >> shift & 1));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 3144)
+++ /trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 3145)
@@ -60,7 +60,8 @@
     class QBLevel
     {
-        int level;
-        long quad;
-        QBLevel parent;
+        final int level;
+        private final BBox bbox;
+        final long quad;
+        final QBLevel parent;
 
         public List<T> content;
@@ -71,8 +72,44 @@
             return super.toString()+ "["+level+"]: " + bbox();
         }
-        public QBLevel(QBLevel parent)
-        {
-            init(parent);
-        }
+        /**
+         * Constructor for root node
+         */
+        public QBLevel() {
+            level = 0;
+            quad = 0;
+            parent = null;
+            bbox = new BBox(-180, 90, 180, -90);
+        }
+
+        public QBLevel(QBLevel parent, int parent_index) {
+            this.parent = parent;
+            this.level = parent.level + 1;
+            int shift = (QuadBuckets.NR_LEVELS - level) * 2;
+            long mult = 1;
+            // Java blows the big one.  It seems to wrap when
+            // you shift by > 31
+            if (shift >= 30) {
+                shift -= 30;
+                mult = 1<<30;
+            }
+            long this_quadpart = mult * (parent_index << shift);
+            this.quad = parent.quad | this_quadpart;
+            this.bbox = calculateBBox(); // calculateBBox reference quad
+            if (debug) {
+                out("new level["+this.level+"] bbox["+parent_index+"]: " + this.bbox()
+                        + " coor: " + this.coor()
+                        + " quadpart: " + Long.toHexString(this_quadpart)
+                        + " quad: " + Long.toHexString(this.quad));
+            }
+        }
+
+        private BBox calculateBBox() {
+            LatLon bottom_left = this.coor();
+            double lat = bottom_left.lat() + parent.height() / 2;
+            double lon = bottom_left.lon() + parent.width() / 2;
+            LatLon top_right = new LatLon(lat, lon);
+            return new BBox(bottom_left, top_right);
+        }
+
         boolean remove_content(T o)
         {
@@ -535,14 +572,4 @@
             return Long.toHexString(quad);
         }
-        public void init(QBLevel parent)
-        {
-            this.parent = parent;
-            if (parent == null) {
-                this.level = 0;
-            } else {
-                this.level = parent.level + 1;
-            }
-            this.quad = 0;
-        }
         int index_of(QBLevel find_this)
         {
@@ -556,57 +583,13 @@
             return -1;
         }
-        public QBLevel(QBLevel parent, int parent_index)
-        {
-            this.init(parent);
-            int shift = (QuadBuckets.NR_LEVELS - level) * 2;
-            long mult = 1;
-            // Java blows the big one.  It seems to wrap when
-            // you shift by > 31
-            if (shift >= 30) {
-                shift -= 30;
-                mult = 1<<30;
-            }
-            long this_quadpart = mult * (parent_index << shift);
-            this.quad = parent.quad | this_quadpart;
-            if (debug) {
-                out("new level["+this.level+"] bbox["+parent_index+"]: " + this.bbox()
-                        + " coor: " + this.coor()
-                        + " quadpart: " + Long.toHexString(this_quadpart)
-                        + " quad: " + Long.toHexString(this.quad));
-            }
-        }
-        /*
-         * Surely we can calculate these efficiently instead of storing
-         */
-        double width = Double.NEGATIVE_INFINITY;
-        double width()
-        {
-            if (width != Double.NEGATIVE_INFINITY)
-                return this.width;
-            if (level == 0) {
-                width = this.bbox().width();
-            } else {
-                width = parent.width()/2;
-            }
-            return width;
-        }
-        double height()
-        {
-            return width()/2;
-        }
-        private BBox bbox = null;
-        public BBox bbox()
-        {
-            if (bbox != null)
-                return bbox;
-            if (level == 0) {
-                bbox = new BBox(-180, 90, 180, -90);
-            } else {
-                LatLon bottom_left = this.coor();
-                double lat = bottom_left.lat() + this.height();
-                double lon = bottom_left.lon() + this.width();
-                LatLon top_right = new LatLon(lat, lon);
-                bbox = new BBox(bottom_left, top_right);
-            }
+        double width() {
+            return bbox.width();
+        }
+
+        double height() {
+            return bbox.height();
+        }
+
+        public BBox bbox() {
             return bbox;
         }
@@ -675,5 +658,5 @@
     public void clear()
     {
-        root = new QBLevel(null);
+        root = new QBLevel();
         search_cache = null;
         if (debug) {
@@ -717,5 +700,5 @@
     public void reindex()
     {
-        QBLevel newroot = new QBLevel(null);
+        QBLevel newroot = new QBLevel();
         Iterator<T> i = this.iterator();
         while (i.hasNext()) {
