Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9302)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9315)
@@ -291,4 +291,5 @@
         // Delete the file. This'll also close the file (if open)
         //
+        *fLog << inf3 << "Closing file " << fOut->GetName() << "." << endl;
         delete fOut;
 
@@ -299,5 +300,4 @@
         // - Branches are automatically deleted by the tree destructor
         //
-        *fLog << inf << "Output File closed and object deleted." << endl;
     }
 
@@ -325,9 +325,5 @@
     *fLog << all << underline << "File: " << GetFileName() << dec << endl;
 
-    if (fTrees.GetEntries()==0)
-    {
-        *fLog << "  No contents." << endl;
-        return;
-    }
+    Bool_t cont = kFALSE;
 
     TObject *obj;
@@ -347,4 +343,5 @@
 
         *fLog << " + " << name.Strip(TString::kTrailing, '.') << ": \t" << (ULong_t)branch->GetEntries() << " entries." << endl;
+        cont = kTRUE;
     }
 
@@ -353,7 +350,11 @@
     while ((t=(TTree*)NextTree()))
         if (t->TestBit(kIsNewTree))
+        {
             *fLog << " + " << t->GetName() << ": \t" << (ULong_t)t->GetEntries() << " entries." << endl;
+            cont = kTRUE;
+        }
 
     TIter NextKey(fOut->GetList());
+    
     while ((obj=NextKey()))
     {
@@ -365,5 +366,10 @@
 
         *fLog << " - " << obj->GetName() << ": \t" << (ULong_t)((TTree*)obj)->GetEntries() << " entries." << endl;
-    }
+        cont = kTRUE;
+    }
+
+    if (!cont)
+        *fLog << "  No contents." << endl;
+
     *fLog << endl;
 }
@@ -822,6 +828,7 @@
 
     // Close/delete the old file (keys already written above)
+    *fLog << inf3 << "Closing file " << fOut->GetName() << "." << endl;
     delete fOut;
-
+ 
     // Replace current with new file
     fOut = newfile;
@@ -912,7 +919,18 @@
     *fLog << inf << out << flush;
 
-    TTree *clone=t.CloneTree();
-    clone->Write();
-    delete clone;
+    // When a new file has been opened the old clone (if existing) has
+    // been moved to the new file. We could now use CopyTree but then
+    // we would have to unpack all data and repack it. Instead
+    // we delete the moved old tree.
+    //  FIXME: In priciple we could delete a "wrong" tree with the same name.
+    //         Should we flag the clones and delete them in ChangeFile?
+    TObject *old = fOut->GetList()->Remove(fOut->GetList()->FindObject(t.GetName()));
+    delete old;
+
+    // Now we clone the tree without unpacking and repacking.
+    // When it has not been moved it will be deleted in the TFile destructor
+    /*TTree *clone =*/ t.CloneTree(-1, "fast");
+    //clone->Write();
+    //delete clone;
 
     *fLog << "done." << endl;
