Index: trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 3153)
+++ trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java	(revision 3154)
@@ -11,4 +11,9 @@
 import org.openstreetmap.josm.data.coor.QuadTiling;
 
+/**
+ * Note: bbox of primitives added to QuadBuckets has to stay the same. In case of coordinate change, primitive must
+ * be removed and readded.
+ *
+ */
 public class QuadBuckets<T extends OsmPrimitive> implements Collection<T>
 {
@@ -127,4 +132,6 @@
                 // changes made by threads will show up in children array too late, leading to QBLevel with all children
                 // set to null
+                if (content == null)
+                    return false;
                 boolean ret = this.content.remove(o);
                 if (this.content.size() == 0) {
@@ -194,5 +201,5 @@
             }
             if (!hasChildren()) {
-                // All items stay at this level (get_index == 1). Create at least first child to keep the contract
+                // All items stay at this level (get_index == -1). Create at least first child to keep the contract
                 // that at least one child always exists
                 children[0] = new QBLevel(this, 0);
@@ -378,33 +385,4 @@
             return ret;
         }
-        boolean contains(T n)
-        {
-            QBLevel res = find_exact(n);
-            if (res == null)
-                return false;
-            return true;
-        }
-        QBLevel find_exact(T n)
-        {
-            if (content != null && content.contains(n))
-                return this;
-            return find_exact_child(n);
-        }
-        private QBLevel find_exact_child(T n)
-        {
-            QBLevel ret = null;
-            if (children == null)
-                return ret;
-            for (QBLevel l : children) {
-                if (l == null) {
-                    continue;
-                }
-                ret = l.find_exact(n);
-                if (ret != null) {
-                    break;
-                }
-            }
-            return ret;
-        }
 
         void doAdd(T o) {
@@ -615,6 +593,6 @@
     {
         boolean changed = false;
-        for (Object o : objects) {
-            changed = changed | this.add(convert(o));
+        for (T o : objects) {
+            changed = changed | this.add(o);
         }
         return changed;
@@ -639,49 +617,14 @@
         return this.remove(convert(o));
     }
-    private boolean remove_slow(T removeme)
-    {
-        boolean ret = false;
-        Iterator<T> i = this.iterator();
-        while (i.hasNext()) {
-            T o = i.next();
-            if (o != removeme) {
-                continue;
-            }
-            i.remove();
-            ret = true;
-            break;
-        }
-        if (debug) {
-            out("qb slow remove result: " + ret);
-        }
-        return ret;
-    }
-    public boolean remove(T o)
-    {
-        /*
-         * We first try a locational search
-         */
-        QBLevel bucket = root.find_exact(o);
-        /*
-         * That may fail because the object was
-         * moved or changed in some way, so we
-         * resort to an iterative search:
-         */
-        if (bucket == null)
-            return remove_slow(o);
-        boolean ret = bucket.remove_content(o);
-        if (debug) {
-            out("qb remove result: " + ret);
-        }
+    public boolean remove(T o) {
         search_cache = null; // Search cache might point to one of removed buckets
-        return ret;
-    }
-    public boolean contains(Object o)
-    {
-        QBLevel bucket = root.find_exact(convert(o));
-        if (bucket == null)
-            return false;
-        return true;
-    }
+        QBLevel bucket = root.findBucket(o.getBBox());
+        return bucket.remove_content(o);
+    }
+    public boolean contains(Object o) {
+        QBLevel bucket = root.findBucket(convert(o).getBBox());
+        return bucket != null && bucket.content != null && bucket.content.contains(o);
+    }
+
     public ArrayList<T> toArrayList()
     {
