Index: /trunk/Mars/mdata/MDataPhrase.cc
===================================================================
--- /trunk/Mars/mdata/MDataPhrase.cc	(revision 19333)
+++ /trunk/Mars/mdata/MDataPhrase.cc	(revision 19334)
@@ -425,4 +425,11 @@
 }
 
+void MDataPhrase::RecursiveRemove(TObject *obj)
+{
+    if (fFormula==obj)
+        fFormula = NULL;
+}
+
+
 // --------------------------------------------------------------------------
 //
@@ -441,4 +448,5 @@
 
     fFormula = new TFormula;
+    fFormula->SetBit(kMustCleanup);
 
     // Must have a name otherwise all axis labels disappear like a miracle
@@ -517,4 +525,9 @@
     if (rule)
         SetRule(rule);
+
+    // Make sure that all object deleted are also deleted from this list
+    gROOT->GetListOfCleanups()->Add(this);
+    // Make sure that this doesn't remain in ListOfCleanups after deletion
+    SetBit(kMustCleanup);
 }
 
@@ -541,4 +554,5 @@
 
     fFormula = f ? (TFormula*)f->Clone() : 0;
+    fFormula->SetBit(kMustCleanup);
     gROOT->GetListOfFunctions()->Remove(fFormula);
 
@@ -549,4 +563,9 @@
     while ((o=Next()))
         fMembers.AddLast(o->Clone());
+
+    // Make sure that all object deleted are also deleted from this list
+    gROOT->GetListOfCleanups()->Add(this);
+    // Make sure that this doesn't remain in ListOfCleanups after deletion
+    SetBit(kMustCleanup);
 }
 
Index: /trunk/Mars/mdata/MDataPhrase.h
===================================================================
--- /trunk/Mars/mdata/MDataPhrase.h	(revision 19333)
+++ /trunk/Mars/mdata/MDataPhrase.h	(revision 19334)
@@ -36,4 +36,5 @@
     // TObject
     void     Clear(Option_t *o="");
+    void     RecursiveRemove(TObject *obj);
 
     // MParContainer
