Index: trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 2120)
+++ trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 2123)
@@ -142,7 +142,6 @@
     }
 
-    *fLog << inf << "MReadMarsFile: Switching to #" << GetFileIndex();
-    *fLog << " '" << GetFileName() << "' (before event #";
-    *fLog << GetNumEntry()-1 << ")" << endl;
+    if (!MReadTree::Notify())
+        return kFALSE;
 
     if (fDisplay)
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2120)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2123)
@@ -138,5 +138,6 @@
     TChainElement *element = NULL;
     while ((element=(TChainElement*)Next()))
-        delete (MParContainer**)element->GetBaddress();
+        if (element->GetBaddress())
+            delete (MParContainer**)element->GetBaddress();
 
     //
@@ -155,4 +156,51 @@
 // --------------------------------------------------------------------------
 //
+// This check whether all branches in the tree have the same size. If
+// this is not the case the events in the different branches cannot
+// be ordered correctly.
+//
+Bool_t MReadTree::CheckBranchSize()
+{
+    TArrayI entries(fChain->GetStatus()->GetSize());
+    Int_t num=0;
+
+    // Loop over all branches which have a corresponding container
+    TIter Next(fChain->GetStatus());
+
+    TChainElement *element = NULL;
+    while ((element=(TChainElement*)Next()))
+    {
+        // Get branch name and find pointer to corresponding branch
+        const TString name = element->GetName();
+        const TBranch *b = fChain->FindBranch(name);
+
+        // Skip element without corresponding branches (like "*")
+        if (!b)
+            continue;
+
+        entries[num++] = (Int_t)b->GetEntries();
+    }
+
+    // Check the number of entries of the branches pair-wise
+    for (int i=0; i<num; i++)
+        for (int j=i; j<num; j++)
+        {
+            if (entries[i]==entries[j])
+                continue;
+
+            *fLog << err << "ERROR - File corrupttion detected:" << endl;
+            *fLog << "  Due to several circumstances (such at a bug in MReadTree or wrong" << endl;
+            *fLog << "  usage of the file UPDATE mode) you may have produced a file in which" << endl;
+            *fLog << "  at least two branches in the same tree (" << fChain->GetName() << ") have different" << endl;
+            *fLog << "  number of entries. Sorry, but this file (" << GetFileName() << ")" << endl;
+            *fLog << "  is unusable." << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
 //  If the owner flag is set all TObjects which are scheduled via
 //  AddNotify are deleted by the destructor of MReadTree
@@ -171,6 +219,13 @@
 Bool_t MReadTree::Notify()
 {
-    *fLog << inf << GetDescriptor() << ": Notify '" << fChain->GetName();
-    *fLog << "' (before processing event #" << GetNumEntry()-1 << ")" << endl;
+    //
+    // Do a consistency check for all branches
+    //
+    if (!CheckBranchSize())
+        return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Switching to #" << GetFileIndex();
+    *fLog << " '" << GetFileName() << "' (before event #";
+    *fLog << GetNumEntry()-1 << ")" << endl;
 
     //fNotify->Notify();
@@ -542,4 +597,5 @@
 
     Int_t num=0;
+
     //
     // loop over all tasks for processing
@@ -622,4 +678,10 @@
 
     //
+    // Do a consistency check for all branches
+    //
+//    if (!CheckBranchSize())
+//        return kFALSE;
+
+    //
     // If auto enabling scheme isn't disabled, do auto enabling
     //
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2120)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2123)
@@ -33,4 +33,6 @@
     void EnableBranches(MParList *plist);
     void EnableBranchChoosing();
+
+    Bool_t CheckBranchSize();
 
     virtual void SetReadyToSave(Bool_t flag=kTRUE);
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2120)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 2123)
@@ -140,10 +140,16 @@
 void MWriteRootFile::Print(Option_t *) const
 {
-    *fLog << all << underline << "File: " << GetFileName() << ":" << endl;
+    *fLog << all << underline << "File: " << GetFileName() << endl;
+
+    if (fTrees.GetEntries()==0)
+    {
+        *fLog << " No contents." << endl;
+        return;
+    }
 
     TTree *t = NULL;
     TIter Next(&fTrees);
     while ((t=(TTree*)Next()))
-        *fLog << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
+        *fLog << " " << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
     *fLog << endl;
 }
