diff --git a/ext/fox16_c/include/FXRbTreeList.h b/ext/fox16_c/include/FXRbTreeList.h
index 9d12e1ab12c671ab3230415b28e0828f9bd972d5..608ebcc18f9de2036912c3d73af02544fcb96b18 100644
--- a/ext/fox16_c/include/FXRbTreeList.h
+++ b/ext/fox16_c/include/FXRbTreeList.h
@@ -129,11 +129,11 @@ protected:
 #include "FXRbObjectVirtuals.h"
 #include "FXRbTreeItemVirtuals.h"
 public:
-  // Pointer to this tree item's owner (if any)
-  FXWindow *owner;
+  // Is this tree item owned by an FXTreeList yet?
+  FXbool owned;
 public:
   // Constructor
-  FXRbTreeItem(const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL) : FXTreeItem(text,oi,ci,ptr),owner(0){}
+  FXRbTreeItem(const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL) : FXTreeItem(text,oi,ci,ptr),owned(FALSE){}
 
   // Mark dependencies for the GC
   static void markfunc(FXTreeItem* self);
diff --git a/ext/fox16_c/markfuncs.cpp b/ext/fox16_c/markfuncs.cpp
index 040ea3b81263b492537b11a38350b127332b20c2..e001bbb3da2c5df972a1a0dccc2069e1ecd43ef6 100644
--- a/ext/fox16_c/markfuncs.cpp
+++ b/ext/fox16_c/markfuncs.cpp
@@ -18,7 +18,7 @@ static void delete_if_not_owned(BASECLASS* self,SUBCLASS*){
         if(!dynamic_cast<SUBCLASS*>(self)->owned){
           delete self; // also unregisters it
           }
-	}
+        }
       }
     FXRbUnregisterRubyObj(self);
     }
@@ -33,7 +33,7 @@ static void delete_if_not_owned_by_app(BASECLASS* self,SUBCLASS*){
         if(!dynamic_cast<SUBCLASS*>(self)->ownedByApp){
           delete self; // also unregisters it
           }
-	}
+        }
       }
     FXRbUnregisterRubyObj(self);
     }
@@ -419,26 +419,7 @@ void FXRbTreeItem::markfunc(FXTreeItem* self){
 
 
 void FXRbTreeItem::freefunc(FXTreeItem* self){
-  if(self!=0){
-    if(!FXRbIsBorrowed(self)){
-      if(self->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        FXRbTreeItem* treeItem=dynamic_cast<FXRbTreeItem*>(self);
-        FXASSERT(treeItem);
-        FXTreeList* treeList=dynamic_cast<FXTreeList*>(treeItem->owner);
-        if(treeList){
-          FXRbUnregisterRubyObj(self); // MAYBE
-          treeList->removeItem(self,TRUE);
-          }
-        else{
-          FXTreeListBox* treeListBox=dynamic_cast<FXTreeListBox*>(treeItem->owner);
-          if(treeListBox){
-            treeListBox->removeItem(self);
-            }
-          }
-        }
-      }
-    FXRbUnregisterRubyObj(self);
-    }
+  delete_if_not_owned(self,reinterpret_cast<FXRbTreeItem*>(0));
   }
 
 
diff --git a/ext/fox16_c/unregisterOwnedObjects.cpp b/ext/fox16_c/unregisterOwnedObjects.cpp
index 5cad30f7cd8211b555c703666d085c9dcd95bfeb..157025d45093fb2ed6421117164fe5611abc7f49 100644
--- a/ext/fox16_c/unregisterOwnedObjects.cpp
+++ b/ext/fox16_c/unregisterOwnedObjects.cpp
@@ -96,7 +96,7 @@ void FXRbTable::unregisterOwnedObjects(FXTable *self)
     FXRbUnregisterRubyObj(self->getColumnHeader());
     for(r=0; r<self->getNumRows(); r++){
       for(c=0; c<self->getNumColumns(); c++){
-	FXRbUnregisterRubyObj(self->getItem(r,c));
+        FXRbUnregisterRubyObj(self->getItem(r,c));
         }
       }
 }
@@ -117,4 +117,3 @@ void FXRbTreeList::unregisterOwnedObjects(FXTreeList *self)
     // Now zero-out pointers held by still-alive Ruby objects
     for (FXint i = 0; i < items.no(); i++) FXRbUnregisterRubyObj(items[i]);
 }
-
diff --git a/swig-interfaces/FXFoldingList.i b/swig-interfaces/FXFoldingList.i
index 22892f859f5772910c93114f412ec2db2b12e323..cbefbd491df3b47f7bb282fac9fef8031668a645 100644
--- a/swig-interfaces/FXFoldingList.i
+++ b/swig-interfaces/FXFoldingList.i
@@ -233,11 +233,11 @@ public:
       if(FXMALLOC(&strings,FXchar*,len+1)){
         for(long i=0;i<len;i++){
           VALUE s=rb_ary_entry(stringArray,i);
-	  strings[i]=StringValuePtr(s);
+          strings[i]=StringValuePtr(s);
           }
-	strings[len]=0;
+        strings[len]=0;
         self->setHeaders(strings,size);
-	FXFREE(&strings);
+        FXFREE(&strings);
         }
       }
   }
@@ -296,7 +296,7 @@ public:
     FXFoldingItem* insertItem(FXFoldingItem* other,FXFoldingItem* father,FXFoldingItem* item,FXbool notify=FALSE){
       if(item->isMemberOf(FXMETACLASS(FXRbFoldingItem))){
         dynamic_cast<FXRbFoldingItem*>(item)->owned=TRUE;
-	}
+        }
       return self->insertItem(other,father,item,notify);
       }
   }
@@ -309,7 +309,7 @@ public:
     FXFoldingItem* appendItem(FXFoldingItem* father,FXFoldingItem* item,FXbool notify=FALSE){
       if(item->isMemberOf(FXMETACLASS(FXRbFoldingItem))){
         dynamic_cast<FXRbFoldingItem*>(item)->owned=TRUE;
-	}
+        }
       return self->appendItem(father,item,notify);
       }
   }
@@ -322,7 +322,7 @@ public:
     FXFoldingItem* prependItem(FXFoldingItem* father,FXFoldingItem* item,FXbool notify=FALSE){
       if(item->isMemberOf(FXMETACLASS(FXRbFoldingItem))){
         dynamic_cast<FXRbFoldingItem*>(item)->owned=TRUE;
-	}
+        }
       return self->prependItem(father,item,notify);
       }
   }
diff --git a/swig-interfaces/FXTreeList.i b/swig-interfaces/FXTreeList.i
index b11e2dcf35456c5dd458dfd4c2b8d75a25c7c052..43bc2dcc9e7559b1328afed44316adf995d83602 100644
--- a/swig-interfaces/FXTreeList.i
+++ b/swig-interfaces/FXTreeList.i
@@ -260,55 +260,41 @@ public:
     /// Insert [possibly subclassed] item under father before other item
     FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item,FXbool notify=FALSE){
       if(item->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        dynamic_cast<FXRbTreeItem*>(item)->owner=self;
-	}
+        dynamic_cast<FXRbTreeItem*>(item)->owned=TRUE;
+        }
       return self->insertItem(other,father,item,notify);
       }
+  }
 
-    /// Insert item with given text and optional icons, and user-data pointer under father before other item
-    FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ITEMDATA=NULL,FXbool notify=FALSE){
-      FXTreeItem* item=self->insertItem(other,father,text,oi,ci,ITEMDATA,notify);
-      if(item->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        dynamic_cast<FXRbTreeItem*>(item)->owner=self;
-	}
-      return item;
-      }
+  /// Insert item with given text and optional icons, and user-data pointer under father before other item
+  FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ITEMDATA=NULL,FXbool notify=FALSE);
 
+  %extend {
     /// Append [possibly subclassed] item as last child of father
     FXTreeItem* appendItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=FALSE){
       if(item->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        dynamic_cast<FXRbTreeItem*>(item)->owner=self;
-	}
+        dynamic_cast<FXRbTreeItem*>(item)->owned=TRUE;
+        }
       return self->appendItem(father,item,notify);
       }
+  }
 
-    /// Append item with given text and optional icons, and user-data pointer as last child of father
-    FXTreeItem* appendItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ITEMDATA=NULL,FXbool notify=FALSE){
-      FXTreeItem* item=self->appendItem(father,text,oi,ci,ITEMDATA,notify);
-      if(item->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        dynamic_cast<FXRbTreeItem*>(item)->owner=self;
-	}
-      return item;
-      }
+  /// Append item with given text and optional icons, and user-data pointer as last child of father
+  FXTreeItem* appendItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ITEMDATA=NULL,FXbool notify=FALSE);
 
+  %extend {
     /// Prepend [possibly subclassed] item as first child of father
     FXTreeItem* prependItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=FALSE){
       if(item->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        dynamic_cast<FXRbTreeItem*>(item)->owner=self;
-	}
+        dynamic_cast<FXRbTreeItem*>(item)->owned=TRUE;
+        }
       return self->prependItem(father,item,notify);
       }
-
-    /// Prepend item with given text and optional icons, and user-data pointer as first child of father
-    FXTreeItem* prependItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ITEMDATA=NULL,FXbool notify=FALSE){
-      FXTreeItem* item=self->prependItem(father,text,oi,ci,ITEMDATA,notify);
-      if(item->isMemberOf(FXMETACLASS(FXRbTreeItem))){
-        dynamic_cast<FXRbTreeItem*>(item)->owner=self;
-	}
-      return item;
-      }
   }
 
+  /// Prepend item with given text and optional icons, and user-data pointer as first child of father
+  FXTreeItem* prependItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ITEMDATA=NULL,FXbool notify=FALSE);
+
   /// Move item under father before other item
   FXTreeItem *moveItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item);
 
@@ -360,7 +346,7 @@ public:
         FXRbUnregisterRubyObj(items[i]);
         }
       }
-  }
+    }
 
   /// Return item width
   FXint getItemWidth(const FXTreeItem* item) const;