Index: trunk/MagicSoft/Mars/mbase/MClone.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 2206)
@@ -112,5 +112,5 @@
 //  the name of it was given in the constructor.
 //
-Bool_t MClone::PreProcess(MParList *pList)
+Int_t MClone::PreProcess(MParList *pList)
 {
     //
@@ -158,5 +158,5 @@
 //  again.
 //
-Bool_t MClone::Process()
+Int_t MClone::Process()
 {
     //
Index: trunk/MagicSoft/Mars/mbase/MClone.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MClone.h	(revision 2206)
@@ -27,6 +27,6 @@
     ~MClone();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     TObject *GetClone() const  { return fClone; }
Index: trunk/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 2206)
@@ -112,5 +112,5 @@
 //  before this instance to the tasklist and preprocesses the filter.
 //
-Bool_t MContinue::PreProcess(MParList *list)
+Int_t MContinue::PreProcess(MParList *list)
 {
     if (!GetFilter())
@@ -147,4 +147,20 @@
 }
 
+void MContinue::SetDisplay(MStatusDisplay *d)
+{
+    if (GetFilter())
+        GetFilter()->SetDisplay(d);
+
+    MTask::SetDisplay(d);
+}
+
+void MContinue::SetLogStream(MLog *lg)
+{
+    if (GetFilter())
+        GetFilter()->SetLogStream(lg);
+
+    MTask::SetLogStream(lg);
+}
+
 // --------------------------------------------------------------------------
 //
@@ -152,5 +168,5 @@
 // from the tasklist.
 //
-Bool_t MContinue::PostProcess()
+Int_t MContinue::PostProcess()
 {
     if (!TestBit(kFilterIsPrivate))
Index: trunk/MagicSoft/Mars/mbase/MContinue.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 2206)
@@ -15,6 +15,8 @@
 #endif
 
+class MLog;
 class MFilter;
 class MTaskList;
+class MStatusDisplay;
 
 class MContinue : public MTask
@@ -23,7 +25,7 @@
     MTaskList *fTaskList;  //! pointer to the present tasklist
 
-    Bool_t PreProcess(MParList *list);
-    Bool_t Process() { return kCONTINUE; }
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *list);
+    Int_t Process() { return kCONTINUE; }
+    Int_t PostProcess();
 
     enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15) };
@@ -37,4 +39,7 @@
     Bool_t IsInverted() const;
 
+    void SetDisplay(MStatusDisplay *d);
+    void SetLogStream(MLog *lg);
+
     ClassDef(MContinue, 1) //Task returning kCONTINUE
 };
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 2206)
@@ -109,4 +109,6 @@
     fName = name;
 
+    gROOT->GetListOfCleanups()->Add(this); // To remove fDisplay
+
     *fLog << inf << underline << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl;
 }
@@ -122,4 +124,13 @@
 }
 
+void MEvtLoop::SetParList(MParList *p)
+{
+    if (!p)
+        return;
+
+    p->SetBit(kMustCleanup);
+    fParList = p;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -152,4 +163,10 @@
 }
 
+void MEvtLoop::SetProgressBar(TGProgressBar *bar)
+{
+    fProgress = bar;
+    fProgress->SetBit(kMustCleanup);
+}
+
 #ifdef __MARS__
 // --------------------------------------------------------------------------
@@ -160,5 +177,5 @@
 void MEvtLoop::SetProgressBar(MProgressBar *bar)
 {
-    fProgress = bar->GetBar();
+    SetProgressBar(bar->GetBar());
 }
 #endif
@@ -200,6 +217,4 @@
     // Check whether display is still existing
     //
-    if (fDisplay && !gROOT->GetListOfSpecials()->FindObject(fDisplay))
-        fDisplay = NULL;
     if (fDisplay)
     {
@@ -238,5 +253,5 @@
 Bool_t MEvtLoop::ProcessGuiEvents(Int_t num)
 {
-    if (!fProgress)
+    if (!fProgress || gROOT->IsBatch())
         return kTRUE;
 
@@ -255,11 +270,4 @@
             fDisplay->ClearStatus();
             break;
-        case MStatusDisplay::kFileExit:
-            fParList->SetDisplay(NULL);
-            delete fDisplay;
-            SetDisplay(NULL);
-            fProgress = NULL;
-            gSystem->ProcessEvents();
-            return kTRUE;
         default:
             *fLog << warn << "MEvtloop: fDisplay->ChecStatus() has returned unknown status #" << fDisplay->CheckStatus() << "... cleared." << endl;
@@ -348,5 +356,5 @@
     Int_t entries = INT_MAX;
 
-    if (fProgress)
+    if (fProgress && !gROOT->IsBatch())
     {
         fProgress->Reset();
@@ -409,5 +417,5 @@
     clock.Stop();
 
-    if (fProgress)
+    if (fProgress && !gROOT->IsBatch())
     {
         fProgress->SetPosition(maxcnt>0 ? TMath::Min(maxcnt, entries) : entries);
@@ -912,2 +920,29 @@
     return kTRUE;
 }
+
+void MEvtLoop::RecursiveRemove(TObject *obj)
+{
+    if (obj==fParList)
+    {
+        fParList=NULL;
+        fTaskList=NULL;
+    }
+
+    if (obj==fProgress)
+        fProgress = NULL;
+
+    if (obj==fDisplay)
+    {
+        if (fParList)
+            fParList->SetDisplay(NULL);
+        SetDisplay(NULL);
+        fProgress = NULL;
+    }
+
+    if (obj==fLog)
+    {
+        if (fParList)
+            fParList->SetLogStream(NULL);
+        SetLogStream(NULL);
+    }
+}
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 2206)
@@ -28,5 +28,5 @@
     MTaskList *fTaskList;      //!
 
-    TGProgressBar   *fProgress;  //!
+    TGProgressBar *fProgress;  //!
 
     enum { kIsOwner = BIT(14) };
@@ -43,7 +43,7 @@
     virtual ~MEvtLoop();
 
-    void       SetParList(MParList *p)  { fParList = p; }
-    MParList  *GetParList() const       { return fParList; }
-    MTaskList *GetTaskList() const      { return fTaskList; }
+    void       SetParList(MParList *p);
+    MParList  *GetParList() const  { return fParList; }
+    MTaskList *GetTaskList() const { return fTaskList; }
 
     MTask *FindTask(const char *name) const;
@@ -54,5 +54,5 @@
     void SetOwner(Bool_t enable=kTRUE);
 
-    void SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
+    void SetProgressBar(TGProgressBar *bar);
 #ifdef __MARS__
     void SetProgressBar(MProgressBar *bar);
@@ -77,7 +77,10 @@
     Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
 
+    void RecursiveRemove(TObject *obj);
+
     ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
 };
 
+// FIXME: Move as (persistent) static data member to MParContainer
 R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop
 
Index: trunk/MagicSoft/Mars/mbase/MGTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGTask.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MGTask.cc	(revision 2206)
@@ -70,5 +70,5 @@
 //  MTask::CallPreProcess
 //
-Bool_t MGTask::CallPreProcess(MParList *plist)
+Int_t MGTask::CallPreProcess(MParList *plist)
 {
     HideGui();
@@ -82,5 +82,5 @@
 //  MTask::CallPostProcess
 //
-Bool_t MGTask::CallPostProcess()
+Int_t MGTask::CallPostProcess()
 {
     ShowGui();
Index: trunk/MagicSoft/Mars/mbase/MGTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGTask.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MGTask.h	(revision 2206)
@@ -38,6 +38,6 @@
     virtual ~MGTask();
 
-    Bool_t CallPreProcess(MParList *plist);
-    Bool_t CallPostProcess();
+    Int_t CallPreProcess(MParList *plist);
+    Int_t CallPostProcess();
 
     virtual Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
Index: trunk/MagicSoft/Mars/mbase/MPrint.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 2206)
@@ -107,5 +107,5 @@
 //  the name of it was given in the constructor.
 //
-Bool_t MPrint::PreProcess(MParList *pList)
+Int_t MPrint::PreProcess(MParList *pList)
 {
     //
@@ -142,5 +142,5 @@
 //  Calls overloaded TObject::Print
 //
-Bool_t MPrint::Process()
+Int_t MPrint::Process()
 {
     fObject->Print(fOption);
Index: trunk/MagicSoft/Mars/mbase/MPrint.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MPrint.h	(revision 2206)
@@ -26,6 +26,6 @@
     void EnableSkip(Bool_t skip=kTRUE) { skip ? SetBit(kSkip) : ResetBit(kSkip); }
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     ClassDef(MPrint, 0) // Task to call Print() function
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 2206)
@@ -165,5 +165,5 @@
 // Sets the preprocessed flag dependend on the return value of PreProcess.
 //
-Bool_t MTask::CallPreProcess(MParList *plist)
+Int_t MTask::CallPreProcess(MParList *plist)
 {
     fNumExecutions = 0;
@@ -199,5 +199,5 @@
 // If Process is executed, the execution counter is increased.
 //
-Bool_t MTask::CallProcess()
+Int_t MTask::CallProcess()
 {
     //
@@ -221,5 +221,5 @@
 // resets this flag.
 //
-Bool_t MTask::CallPostProcess()
+Int_t MTask::CallPostProcess()
 {
     if (!fIsPreprocessed)
@@ -261,5 +261,5 @@
 // the virtual implementation returns kTRUE
 //
-Bool_t MTask::PreProcess(MParList *pList)
+Int_t MTask::PreProcess(MParList *pList)
 {
     return kTRUE;
@@ -272,5 +272,5 @@
 // the virtual implementation returns kTRUE
 //
-Bool_t MTask::Process()
+Int_t MTask::Process()
 {
     return kTRUE;
@@ -283,5 +283,5 @@
 // the virtual implementation returns kTRUE
 //
-Bool_t MTask::PostProcess()
+Int_t MTask::PostProcess()
 {
     return kTRUE;
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 2206)
@@ -29,7 +29,7 @@
     UInt_t fNumExecutions;  //! Number of Excutions
 
-    virtual Bool_t PreProcess(MParList *pList);
-    virtual Bool_t Process();
-    virtual Bool_t PostProcess();
+    virtual Int_t PreProcess(MParList *pList);
+    virtual Int_t Process();
+    virtual Int_t PostProcess();
 
 protected:
@@ -75,7 +75,7 @@
     virtual Bool_t ReInit(MParList *pList);
 
-    virtual Bool_t CallPreProcess(MParList *plist);
-    virtual Bool_t CallProcess();
-    virtual Bool_t CallPostProcess();
+    virtual Int_t CallPreProcess(MParList *plist);
+    virtual Int_t CallProcess();
+    virtual Int_t CallPostProcess();
 
     const TList *GetListOfBranches() const { return fListOfBranches; }
Index: trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc	(revision 2206)
@@ -75,5 +75,5 @@
 }
 
-inline Bool_t MTaskInteractive::Return(Int_t no, void *params)
+inline Int_t MTaskInteractive::Return(Int_t no, void *params)
 {
     // Static function called when SetFCN is called in interactive mode
Index: trunk/MagicSoft/Mars/mbase/MTaskInteractive.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskInteractive.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MTaskInteractive.h	(revision 2206)
@@ -23,13 +23,13 @@
     TMethodCall *fCall[3];
 
-    Bool_t (*fPreProcess)(MParList *list);
-    Bool_t (*fProcess)();
-    Bool_t (*fPostProcess)();
+    Int_t (*fPreProcess)(MParList *list);
+    Int_t (*fProcess)();
+    Int_t (*fPostProcess)();
 
-    Bool_t PreProcess(MParList *list) { if (fCall[0]) return Return(0, &list); return fPreProcess  ? (*fPreProcess)(list) : kTRUE; }
-    Bool_t Process()                  { if (fCall[1]) return Return(1);        return fProcess     ? (*fProcess)()        : kTRUE; }
-    Bool_t PostProcess()              { if (fCall[2]) return Return(2);        return fPostProcess ? (*fPostProcess)()    : kTRUE; }
+    Int_t PreProcess(MParList *list) { if (fCall[0]) return Return(0, &list); return fPreProcess  ? (*fPreProcess)(list) : kTRUE; }
+    Int_t Process()                  { if (fCall[1]) return Return(1);        return fProcess     ? (*fProcess)()        : kTRUE; }
+    Int_t PostProcess()              { if (fCall[2]) return Return(2);        return fPostProcess ? (*fPostProcess)()    : kTRUE; }
 
-    Bool_t Return(Int_t no, void *param=NULL);
+    Int_t Return(Int_t no, void *param=NULL);
     Bool_t Set(void *fcn, Int_t no, const char *params);
     void   Free(Int_t no);
@@ -40,7 +40,7 @@
 
     // This is to be used in compiled code
-    void SetPreProcess(Bool_t (*func)(MParList *list)) { fPreProcess = func;  Free(0); }
-    void SetProcess(Bool_t (*func)())                  { fProcess = func;     Free(1);  }
-    void SetPostProcess(Bool_t (*func)())              { fPostProcess = func; Free(2);  }
+    void SetPreProcess(Int_t (*func)(MParList *list)) { fPreProcess = func;  Free(0); }
+    void SetProcess(Int_t (*func)())                  { fProcess = func;     Free(1);  }
+    void SetPostProcess(Int_t (*func)())              { fPostProcess = func; Free(2);  }
 
     // This is for usage in CINT
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2206)
@@ -92,4 +92,9 @@
 
     fTasks = new TList;
+
+    gROOT->GetListOfCleanups()->Add(fTasks);
+    gROOT->GetListOfCleanups()->Add(&fTasksProcess);
+    fTasks->SetBit(kMustCleanup);
+    fTasksProcess.SetBit(kMustCleanup);
 }
 
@@ -212,4 +217,5 @@
     *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
     fTasks->AddBefore((TObject*)where, task);
     *fLog << "Done." << endl;
@@ -232,4 +238,5 @@
     *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
     fTasks->AddAfter((TObject*)where, task);
     *fLog << "Done." << endl;
@@ -252,4 +259,5 @@
     *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
     fTasks->Add(task);
     *fLog << "Done." << endl;
@@ -331,5 +339,5 @@
 //  doing no Processing are not Processed.
 //
-Bool_t MTaskList::PreProcess(MParList *pList)
+Int_t MTaskList::PreProcess(MParList *pList)
 {
     *fLog << all << "Preprocessing... " << flush;
@@ -399,5 +407,5 @@
 // do the event execution of all tasks in the task-list
 //
-Bool_t MTaskList::Process()
+Int_t MTaskList::Process()
 {
     //
@@ -501,5 +509,5 @@
 //  only tasks which have successfully been preprocessed are postprocessed.
 //
-Bool_t MTaskList::PostProcess()
+Int_t MTaskList::PostProcess()
 {
     *fLog << all << "Postprocessing... " << flush;
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 2196)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 2206)
@@ -63,7 +63,7 @@
     Bool_t ReInit(MParList *pList=NULL);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     void Print(Option_t *opt = "") const;
