diff --git a/CEP/BB/BBSControl/include/BBSControl/BBSStep.h b/CEP/BB/BBSControl/include/BBSControl/BBSStep.h
index 62cf62e3c3a702ce0004384470216e9aa5561be4..b112a367470175c7b3d5bc1dcaada0d5acd0758d 100644
--- a/CEP/BB/BBSControl/include/BBSControl/BBSStep.h
+++ b/CEP/BB/BBSControl/include/BBSControl/BBSStep.h
@@ -93,6 +93,12 @@ namespace LOFAR
 	      const ACC::APS::ParameterSet& parSet,
 	      const BBSStep* parent);
 
+      // Check to see if there's an infinite recursion present in the
+      // definition of a BBSStep. This can happen when one of the steps
+      // (identified by the argument \a name) defining a BBSMultiStep refers
+      // directly or indirectly to that same BBSMultiStep. 
+      void infiniteRecursionCheck(const string& name) const;
+
     private:
       // Override the default values, "inherited" from the parent step object,
       // for those members that are specified in \a parSet.
diff --git a/CEP/BB/BBSControl/include/BBSControl/BlackBoardDemo.h b/CEP/BB/BBSControl/include/BBSControl/BlackBoardDemo.h
index 74dbae093626f93165a8a741e7a5949e046ad5d3..f57b9f058f202c805f5fecd076ad622307e28a80 100644
--- a/CEP/BB/BBSControl/include/BBSControl/BlackBoardDemo.h
+++ b/CEP/BB/BBSControl/include/BBSControl/BlackBoardDemo.h
@@ -1,68 +1,70 @@
-//  BlackBoardDemo.h: An empty simulator  
-//
-//  Copyright (C) 2000, 2002
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////
+//#  BlackBoardDemo.h: An empty simulator  
+//#
+//#  Copyright (C) 2000, 2002
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #ifndef LOFAR_BBSCONTROL_BLACKBOARDDEMO_H
 #define LOFAR_BBSCONTROL_BLACKBOARDDEMO_H
 
 // \file
-// This is an ApplicationHolder class which demonstrates the use of a blackboard control
-// architecture in combination with calibration software.
+// This is an ApplicationHolder class which demonstrates the use of a
+// blackboard control architecture in combination with calibration software.
 
 #include <CEPFrame/ApplicationHolder.h>
 #include <Blob/KeyValueMap.h>
 
 namespace LOFAR
 {
+  //# Forward declarations
+  class Step;
 
-// \addtogroup BBS
-// @{
+  namespace BBS
+  {
 
-class Step;
+    // \addtogroup BBS
+    // @{
 
-class BlackBoardDemo: public LOFAR::ApplicationHolder
-{
-public:
-  BlackBoardDemo();
-  virtual ~BlackBoardDemo();
+    class BlackBoardDemo: public LOFAR::ApplicationHolder
+    {
+    public:
+      BlackBoardDemo();
+      virtual ~BlackBoardDemo();
+
+      // overloaded methods from the Simulator base class
+      virtual void define(const LOFAR::KeyValueMap& params = 
+			  LOFAR::KeyValueMap());
+      virtual void run(int);
+      virtual void dump() const;
+      virtual void quit();
 
-  // overloaded methods from the Simulator base class
-  virtual void define(const LOFAR::KeyValueMap& params = LOFAR::KeyValueMap());
-  virtual void run(int);
-  virtual void dump() const;
-  virtual void quit();
+      void undefine();
 
-  void undefine();
+    private:
+      Step** itsPDSteps;  // Pointer to array of Prediffer steps
+      int itsNumberPD;    // Total number of Prediffers
+    };
 
-private:
-  LOFAR::Step** itsPDSteps;  // Pointer to array of Prediffer steps
-  int itsNumberPD;           // Total number of Prediffers
-};
+    // @}
 
-// @}
+  } // namespace BBS
 
-} // end namespace LOFAR
+} // namespace LOFAR
 
 #endif
diff --git a/CEP/BB/BBSControl/include/BBSControl/DH_Prediff.h b/CEP/BB/BBSControl/include/BBSControl/DH_Prediff.h
index 3667cbda7a9d2406d9290c3f7dd0ddbbd532de86..3128377c70f5524026355944455de60d6bf6ded8 100644
--- a/CEP/BB/BBSControl/include/BBSControl/DH_Prediff.h
+++ b/CEP/BB/BBSControl/include/BBSControl/DH_Prediff.h
@@ -1,27 +1,24 @@
-//  DH_Prediff.h:  DataHolder for 'prediffed' data
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  DH_Prediff.h:  DataHolder for 'prediffed' data
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #ifndef LOFAR_BBSCONTROL_DH_PREDIFF_H
 #define LOFAR_BBSCONTROL_DH_PREDIFF_H
@@ -33,106 +30,101 @@
 #include <Common/lofar_vector.h>
 
 //# Forward Declarations.
-namespace casa {
-  class LSQFit;
-}
+namespace casa { class LSQFit; }
 
-namespace LOFAR {
+namespace LOFAR
+{
+  //# Forward Declarations.
   class ParmDataInfo;
-}
 
+  namespace BBS
+  {
+    // \addtogroup BBS
+    // @{
 
-namespace LOFAR
-{
-// \addtogroup BBS
-// @{
-
-/**
-   This class is a DataHolder which contains the difference between measured
-   and predicted data and derivatives for each solvable parm (spid) for a
-   certain domain [baseline, time, frequency, polarization].
-*/
-class DH_Prediff: public DataHolder
-{
-public:
+    // This class is a DataHolder which contains the difference between
+    // measured and predicted data and derivatives for each solvable parm
+    // (spid) for a certain domain [baseline, time, frequency, polarization].
+    class DH_Prediff: public DataHolder
+    {
+    public:
 
-  enum woStatus{New,Assigned,Executed};
+      enum woStatus{New,Assigned,Executed};
 
-  explicit DH_Prediff (const string& name = "dh_prediff");
+      explicit DH_Prediff (const string& name = "DH_Prediff");
 
-  DH_Prediff(const DH_Prediff&);
+      DH_Prediff(const DH_Prediff&);
 
-  virtual ~DH_Prediff();
+      virtual ~DH_Prediff();
 
-  DataHolder* clone() const;
+      DataHolder* clone() const;
 
-/*   // Create a TPO object and set the table name in it. */
-/*   virtual void initPO (const string& tableName); */
+      // Allocate the buffers.
+      virtual void init();
 
-  /// Allocate the buffers.
-  virtual void init();
+      void setBufferSize(int size);
+      int getBufferSize();
 
-  void setBufferSize(int size);
-  int getBufferSize();
+      void setDataSize(unsigned int size);
+      unsigned int getDataSize() const;
 
-  void setDataSize(unsigned int size);
-  unsigned int getDataSize() const;
+      double* getDataBuffer();
 
-  double* getDataBuffer();
+      void setParmData (const ParmDataInfo& pdata);
+      bool getParmData (ParmDataInfo& pdata); 
 
-  void setParmData (const ParmDataInfo& pdata);
-  bool getParmData (ParmDataInfo& pdata); 
+      void setFitters (const vector<casa::LSQFit>& fitters);
+      bool getFitters (vector<casa::LSQFit>& fitters);
 
-  void setFitters (const vector<casa::LSQFit>& fitters);
-  bool getFitters (vector<casa::LSQFit>& fitters);
+      double getStartFreq() const;
+      double getEndFreq() const;
+      double getStartTime() const;
+      double getEndTime() const;
+      void setDomain(double fStart, double fEnd, double tStart, double tEnd);
 
-  double getStartFreq() const;
-  double getEndFreq() const;
-  double getStartTime() const;
-  double getEndTime() const;
-  void setDomain(double fStart, double fEnd, double tStart, double tEnd);
+      virtual void dump() const;
 
-  virtual void dump() const;
+      void clearData();
 
-  void clearData();
+    private:
+      /// Forbid assignment.
+      DH_Prediff& operator= (const DH_Prediff&);
 
-private:
-  /// Forbid assignment.
-  DH_Prediff& operator= (const DH_Prediff&);
+      // Fill the pointers to the data in the blob.
+      virtual void fillDataPointers();
 
-  // Fill the pointers to the data in the blob.
-  virtual void fillDataPointers();
+      unsigned int* itsDataSize;    // Number of equations in data buffer
+      double* itsDataBuffer;
+      double* itsStartFreq;        // Start frequency of the domain
+      double* itsEndFreq;          // End frequency of the domain
+      double* itsStartTime;        // Start time of the domain
+      double* itsEndTime;          // End time of the domain
+    };
 
-  unsigned int* itsDataSize;    // Number of equations in data buffer
-  double* itsDataBuffer;
-  double* itsStartFreq;        // Start frequency of the domain
-  double* itsEndFreq;          // End frequency of the domain
-  double* itsStartTime;        // Start time of the domain
-  double* itsEndTime;          // End time of the domain
-};
+    inline void DH_Prediff::setDataSize(unsigned int size)
+    { *itsDataSize = size; }
 
-inline void DH_Prediff::setDataSize(unsigned int size)
-{ *itsDataSize = size; }
+    inline unsigned int DH_Prediff::getDataSize() const
+    { return *itsDataSize; }
 
-inline unsigned int DH_Prediff::getDataSize() const
-{ return *itsDataSize; }
+    inline double* DH_Prediff::getDataBuffer()
+    { return itsDataBuffer; }
 
-inline double* DH_Prediff::getDataBuffer()
-{ return itsDataBuffer; }
+    inline double DH_Prediff::getStartFreq() const
+    { return *itsStartFreq; }
 
-inline double DH_Prediff::getStartFreq() const
-{ return *itsStartFreq; }
+    inline double DH_Prediff::getEndFreq() const
+    { return *itsEndFreq; }
 
-inline double DH_Prediff::getEndFreq() const
-{ return *itsEndFreq; }
+    inline double DH_Prediff::getStartTime() const
+    { return *itsStartTime; }
 
-inline double DH_Prediff::getStartTime() const
-{ return *itsStartTime; }
+    inline double DH_Prediff::getEndTime() const
+    { return *itsEndTime; }
 
-inline double DH_Prediff::getEndTime() const
-{ return *itsEndTime; }
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/DH_Solution.h b/CEP/BB/BBSControl/include/BBSControl/DH_Solution.h
index e07bfc60c417841d879e5775e23fb020113642f6..a6a14dd75920ec12a148f576e7c59ed27cf3d43e 100644
--- a/CEP/BB/BBSControl/include/BBSControl/DH_Solution.h
+++ b/CEP/BB/BBSControl/include/BBSControl/DH_Solution.h
@@ -33,119 +33,130 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-// \addtogroup BBS
-// @{
+    // \addtogroup BBS
+    // @{
 
-/**
-   This class is a DataHolder which holds the parameters solved by
-   a BBS Solver knowledge source.
-*/
+    // This class is a DataHolder which holds the parameters solved by a BBS
+    // Solver knowledge source.
 
-class DH_Solution: public LOFAR::DH_DB
-{
-public:
-  explicit DH_Solution (const string& name="dh_solution", bool writeIndivParms=false,
-			const string& parmTableName="bbs3parmsolutions");
+    class DH_Solution: public LOFAR::DH_DB
+    {
+    public:
+      explicit DH_Solution (const string& name = "dh_solution", 
+			    bool writeIndivParms = false,
+			    const string& parmTableName = "bbs3parmsolutions");
 
-  virtual ~DH_Solution();
+      virtual ~DH_Solution();
 
-  DataHolder* clone() const;
+      DataHolder* clone() const;
 
-  /// Allocate the buffers.
-  virtual void init();
+      /// Allocate the buffers.
+      virtual void init();
 
-  // Data access methods
-  int getWorkOrderID() const;
-  void setWorkOrderID(const int id);
+      // Data access methods
+      int getWorkOrderID() const;
+      void setWorkOrderID(const int id);
 
-  int getIteration() const;
-  void setIteration(int iter);
+      int getIteration() const;
+      void setIteration(int iter);
 
-  void setSolutionID(const int id);  // Set id of solution to retrieve from database
-  int getSolutionID() const;
+      // Set id of solution to retrieve from database
+      void setSolutionID(const int id);
+      int getSolutionID() const;
 
-  Quality getQuality() const;
-  void setQuality(const Quality& quality);
+      Quality getQuality() const;
+      void setQuality(const Quality& quality);
 
-  bool getSolution(ParmDataInfo& pData);
-  void setSolution(const ParmDataInfo& pData);
+      bool getSolution(ParmDataInfo& pData);
+      void setSolution(const ParmDataInfo& pData);
 
-  double getStartFreq() const;
-  double getEndFreq() const;
-  double getStartTime() const;
-  double getEndTime() const;
-  void setDomain(double fStart, double fEnd, double tStart, double tEnd);
+      double getStartFreq() const;
+      double getEndFreq() const;
+      double getStartTime() const;
+      double getEndTime() const;
+      void setDomain(double fStart, double fEnd, double tStart, double tEnd);
 
-  bool hasConverged() const;
-  void setConverged(bool converged);
+      bool hasConverged() const;
+      void setConverged(bool converged);
   
-  // Resets (clears) the contents of its DataPacket 
-  void clearData();
+      // Resets (clears) the contents of its DataPacket 
+      void clearData();
   
-  virtual void dump() const;
-
- protected:
-  virtual string createInsertStatement(TH_DB* th);
-
-private:
-  /// Forbid assignment.
-  DH_Solution& operator= (const DH_Solution&);
-  DH_Solution(const DH_Solution&);
-
-  // Fill the pointers (itsCounter and itsBuffer) to the data in the blob.
-  virtual void fillDataPointers();
-
-  int*          itsWOID;
-  int*          itsIteration;
-  double*       itsFit;
-  //  int*          itsRank;
-  double*       itsMu;
-  double*       itsStdDev;
-  double*       itsChi;
+      virtual void dump() const;
+
+    protected:
+      virtual string createInsertStatement(TH_DB* th);
+
+    private:
+      /// Forbid assignment.
+      DH_Solution& operator= (const DH_Solution&);
+      DH_Solution(const DH_Solution&);
+
+      // Fill the pointers (itsCounter and itsBuffer) to the data in the blob.
+      virtual void fillDataPointers();
+
+      int*          itsWOID;
+      int*          itsIteration;
+      double*       itsFit;
+      //  int*          itsRank;
+      double*       itsMu;
+      double*       itsStdDev;
+      double*       itsChi;
   
-  double*       itsStartFreq;        // Start frequency of the domain
-  double*       itsEndFreq;          // End frequency of the domain
-  double*       itsStartTime;        // Start time of the domain
-  double*       itsEndTime;          // End time of the domain
-
-  unsigned int* itsHasConverged;     // Does the solution comply with the convergence criterion?
+      // Start frequency of the domain
+      double*       itsStartFreq;
+      // End frequency of the domain
+      double*       itsEndFreq;
+      // Start time of the domain
+      double*       itsStartTime;
+      // End time of the domain
+      double*       itsEndTime;
+
+     // Does the solution comply with the convergence criterion?
+      unsigned int* itsHasConverged;
   
-  bool          itsWriteIndivParms;  // Write parameters individually in a subtable? 
-  string        itsParmTableName;    // Table name of individual parameter storage
-};
+      // Write parameters individually in a subtable? 
+      bool          itsWriteIndivParms;
+      // Table name of individual parameter storage
+      string        itsParmTableName;
+    };
+
+    inline int DH_Solution::getWorkOrderID() const
+    { return *itsWOID; }
 
-inline int DH_Solution::getWorkOrderID() const
-{ return *itsWOID; }
+    inline void DH_Solution::setWorkOrderID(const int id)
+    { *itsWOID = id; }
 
-inline void DH_Solution::setWorkOrderID(const int id)
-{ *itsWOID = id; }
+    inline int DH_Solution::getIteration() const
+    { return *itsIteration; }
 
-inline int DH_Solution::getIteration() const
-{ return *itsIteration; }
+    inline void DH_Solution::setIteration(int iter)
+    { *itsIteration = iter; }
 
-inline void DH_Solution::setIteration(int iter)
-{ *itsIteration = iter; }
+    inline double DH_Solution::getStartFreq() const
+    { return *itsStartFreq; }
 
-inline double DH_Solution::getStartFreq() const
-{ return *itsStartFreq; }
+    inline double DH_Solution::getEndFreq() const
+    { return *itsEndFreq; }
 
-inline double DH_Solution::getEndFreq() const
-{ return *itsEndFreq; }
+    inline double DH_Solution::getStartTime() const
+    { return *itsStartTime; }
 
-inline double DH_Solution::getStartTime() const
-{ return *itsStartTime; }
+    inline double DH_Solution::getEndTime() const
+    { return *itsEndTime; }
 
-inline double DH_Solution::getEndTime() const
-{ return *itsEndTime; }
+    inline bool DH_Solution::hasConverged() const
+    { return ((*itsHasConverged==0)?(false):(true)); }
 
-inline bool DH_Solution::hasConverged() const
-{ return ((*itsHasConverged==0)?(false):(true)); }
+    inline void DH_Solution::setConverged(bool converged)
+    { *itsHasConverged = converged; }
 
-inline void DH_Solution::setConverged(bool converged)
-{ *itsHasConverged = converged; }
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/DH_WOPrediff.h b/CEP/BB/BBSControl/include/BBSControl/DH_WOPrediff.h
index a22edac8b07f2e1db8a01b44afba4cb5457e1d50..7d3a363ceaebbf33bafbd4f2b10ae01633c344b4 100644
--- a/CEP/BB/BBSControl/include/BBSControl/DH_WOPrediff.h
+++ b/CEP/BB/BBSControl/include/BBSControl/DH_WOPrediff.h
@@ -33,283 +33,331 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-using ACC::APS::ParameterSet;
+    using ACC::APS::ParameterSet;
 
-// \addtogroup BBS
-// @{
+    // \addtogroup BBS
+    // @{
 
-/**
-   This class is a DataHolder which contains the work orders.
-*/
+    /**
+       This class is a DataHolder which contains the work orders.
+    */
 
-class DH_WOPrediff: public DH_DB
-{
-public:
+    class DH_WOPrediff: public DH_DB
+    {
+    public:
+
+      enum woStatus{New,Assigned,Executed};
+
+      explicit DH_WOPrediff (const string& name = "dh_woprediff");
+
+      DH_WOPrediff(const DH_WOPrediff&);
+
+      virtual ~DH_WOPrediff();
+
+      DataHolder* clone() const;
+
+      /// Allocate the buffers.
+      virtual void init();
+
+      /// Data access methods.
+      int getWorkOrderID() const;
+      void setWorkOrderID(int id);
+
+      int getStrategyControllerID() const;
+      void setStrategyControllerID(int id);
+
+      unsigned int getStatus() const ;
+      void setStatus(unsigned int status);
+
+      string getKSType() const;
+      void setKSType(const string& ksType);
+
+      bool getDoNothing() const;
+      void setDoNothing(bool doNothing);
+
+      bool getNewBaselines() const;
+      void setNewBaselines(bool newBaselines);
 
-  enum woStatus{New,Assigned,Executed};
+      bool getNewDomain() const;
+      void setNewDomain(bool newDomain);
 
-  explicit DH_WOPrediff (const string& name = "dh_woprediff");
+      bool getNewPeelSources() const;
+      void setNewPeelSources(bool newSources);
 
-  DH_WOPrediff(const DH_WOPrediff&);
+      bool getSubtractSources() const;
+      void setSubtractSources(bool subtract);
 
-  virtual ~DH_WOPrediff();
+      bool getWritePredData() const;
+      void setWritePredData(bool write);
 
-  DataHolder* clone() const;
+      bool getWriteInDataCol() const;
+      void setWriteInDataCol(bool write);
 
-  /// Allocate the buffers.
-  virtual void init();
+      int getMaxIterations() const;
+      void setMaxIterations(int nr);
 
-  /// Data access methods.
-  int getWorkOrderID() const;
-  void setWorkOrderID(int id);
+      int getStartChannel() const;
+      void setStartChannel(int chan);
 
-  int getStrategyControllerID() const;
-  void setStrategyControllerID(int id);
+      int getEndChannel() const;
+      void setEndChannel(int chan);
 
-  unsigned int getStatus() const ;
-  void setStatus(unsigned int status);
+      double getStartTime() const;
+      void setStartTime(double time);
 
-  string getKSType() const;
-  void setKSType(const string& ksType);
+      double getTimeLength() const;
+      void setTimeLength(double time);
 
-  bool getDoNothing() const;
-  void setDoNothing(bool doNothing);
+      string getModelType() const;
+      void setModelType(const string& type);
 
-  bool getNewBaselines() const;
-  void setNewBaselines(bool newBaselines);
+      bool getCalcUVW() const;
+      void setCalcUVW(bool calc);
 
-  bool getNewDomain() const;
-  void setNewDomain(bool newDomain);
+      bool getUseAutoCorrelations() const;
+      void setUseAutoCorrelations(bool use);
 
-  bool getNewPeelSources() const;
-  void setNewPeelSources(bool newSources);
+      bool getCleanUp() const;
+      void setCleanUp(bool clean);
 
-  bool getSubtractSources() const;
-  void setSubtractSources(bool subtract);
+      bool getUpdateParms() const;
+      void setUpdateParms(bool update);
 
-  bool getWritePredData() const;
-  void setWritePredData(bool write);
+      int getSolutionID() const;
+      void setSolutionID(int id);
 
-  bool getWriteInDataCol() const;
-  void setWriteInDataCol(bool write);
+      void setVarData(const ParameterSet& predArgs,
+		      vector<int>& antNrs,
+		      vector<string>& pNames,
+		      vector<string>& exPNames,
+		      vector<int>& peelSrcs,
+		      vector<int>& corrs);
+      bool getVarData(ParameterSet& predArgs,
+		      vector<int>& antNrs,
+		      vector<string>& pNames,
+		      vector<string>& exPNames,
+		      vector<int>& peelSrcs,
+		      vector<int>& corrs);
 
-  int getMaxIterations() const;
-  void setMaxIterations(int nr);
+      virtual void dump() const;
 
-  int getStartChannel() const;
-  void setStartChannel(int chan);
+      void clearData();
 
-  int getEndChannel() const;
-  void setEndChannel(int chan);
+      // Get maximum scid present in prediffer workorder table. Returns 0 if
+      // empty.
+      int getMaxSCID(TH_DB* th);
+      // Get maximum woid present in prediffer workorder table. Returns 0 if
+      // empty.
+      int getMaxWOID(TH_DB* th);
 
-  double getStartTime() const;
-  void setStartTime(double time);
+    protected:
+      // Methods to obtain the specific queries to insert/update this
+      // DataHolder
+      string createInsertStatement(TH_DB* th);
 
-  double getTimeLength() const;
-  void setTimeLength(double time);
+      // \note This implementation assumes only the
+      // status has changed and needs to be updated
+      string createUpdateStatement(TH_DB* th);
+    private:
+      /// Forbid assignment.
+      DH_WOPrediff& operator= (const DH_WOPrediff&);
 
-  string getModelType() const;
-  void setModelType(const string& type);
+      // Fill the pointers (itsCounter and itsBuffer) to the data in the blob.
+      virtual void fillDataPointers();
 
-  bool getCalcUVW() const;
-  void setCalcUVW(bool calc);
+      // Unique workorder id
+      int*          itsWOID;
 
-  bool getUseAutoCorrelations() const;
-  void setUseAutoCorrelations(bool use);
+      // ID of the sending StrategyController (SC)
+      int*          itsSCID;
 
-  bool getCleanUp() const;
-  void setCleanUp(bool clean);
+      // Workorder status
+      unsigned int* itsStatus;
 
-  bool getUpdateParms() const;
-  void setUpdateParms(bool update);
+      // Knowledge Source type
+      char*         itsKSType;
 
-  int getSolutionID() const;
-  void setSolutionID(int id);
+      // Do nothing?
+      unsigned int* itsDoNothing;
 
-  void setVarData(const ParameterSet& predArgs,
-		  vector<int>& antNrs,
-		  vector<string>& pNames,
-		  vector<string>& exPNames,
-		  vector<int>& peelSrcs,
-		  vector<int>& corrs);
-  bool getVarData(ParameterSet& predArgs,
-		  vector<int>& antNrs,
-		  vector<string>& pNames,
-		  vector<string>& exPNames,
-		  vector<int>& peelSrcs,
-		  vector<int>& corrs);
+      // New baseline selection?
+      unsigned int* itsNewBaselines;
 
-  virtual void dump() const;
+      // New domain selection?
+      unsigned int* itsNewDomain;
 
-  void clearData();
+      // New peel sources selection?
+      unsigned int* itsNewPeelSources;
 
-  // Get maximum scid present in prediffer workorder table. Returns 0 if empty.
-  int getMaxSCID(TH_DB* th);
-  // Get maximum woid present in prediffer workorder table. Returns 0 if empty. 
-  int getMaxWOID(TH_DB* th);
+      // Subtract peel sources?
+      unsigned int* itsSubtractSources;
 
-protected:
-  // Methods to obtain the specific queries to insert/update this DataHolder
-  string createInsertStatement(TH_DB* th);
-  string createUpdateStatement(TH_DB* th); // NB.This implementation assumes only the
-                                           // status has changed and needs to be updated
-private:
-  /// Forbid assignment.
-  DH_WOPrediff& operator= (const DH_WOPrediff&);
-
-  // Fill the pointers (itsCounter and itsBuffer) to the data in the blob.
-  virtual void fillDataPointers();
-
-  int*          itsWOID;                    // Unique workorder id
-  int*          itsSCID;                    // ID of the sending StrategyController (SC)
-  unsigned int* itsStatus;                  // Workorder status
-  char*         itsKSType;                  // Knowledge Source type
-  unsigned int* itsDoNothing;               // Do nothing?
-  unsigned int* itsNewBaselines;            // New baseline selection?
-  unsigned int* itsNewDomain;               // New domain selection?
-  unsigned int* itsNewPeelSources;          // New peel sources selection?
-  unsigned int* itsSubtractSources;         // Subtract peel sources?
-  unsigned int* itsWritePredData;           // Write predicted data?
-  unsigned int* itsWriteInDataCol;          // Write predicted data in DATA column?
-  int*          itsMaxIterations;           // Maximum number of iterations to do
-  int*          itsStartChan;               // Start channel
-  int*          itsEndChan;                 // End channel
-  double*       itsStartTime;               // Start time of time interval
-  double*       itsTimeLength;              // Time interval size (s)
-  char*         itsModelType;
-  unsigned int* itsCalcUVW;
-  unsigned int* itsUseAutoCorr;
-  unsigned int* itsCleanUp;                 // Clean up Prediffer object when finished?
-  unsigned int* itsUpdateParms;             // Update solvable parameters?
-  int*          itsSolutionID;              // (wo)ID of solution in solution table
+      // Write predicted data?
+      unsigned int* itsWritePredData;
+
+      // Write predicted data in DATA column?
+      unsigned int* itsWriteInDataCol;
+
+      // Maximum number of iterations to do
+      int*          itsMaxIterations;
+
+      // Start channel
+      int*          itsStartChan;
+
+      // End channel
+      int*          itsEndChan;
+
+      // Start time of time interval
+      double*       itsStartTime;
+
+      // Time interval size (s)
+      double*       itsTimeLength;
+
+      char*         itsModelType;
+      unsigned int* itsCalcUVW;
+      unsigned int* itsUseAutoCorr;
+
+      // Clean up Prediffer object when finished?
+      unsigned int* itsCleanUp;
+
+      // Update solvable parameters?
+      unsigned int* itsUpdateParms;
+
+      // (wo)ID of solution in solution table
+      int*          itsSolutionID; 
   
-};
+    };
 
-inline int DH_WOPrediff::getWorkOrderID() const
-{ return *itsWOID; }
+    inline int DH_WOPrediff::getWorkOrderID() const
+    { return *itsWOID; }
 
-inline void DH_WOPrediff::setWorkOrderID(int id)
-{ *itsWOID = id; }
+    inline void DH_WOPrediff::setWorkOrderID(int id)
+    { *itsWOID = id; }
 
-inline int DH_WOPrediff::getStrategyControllerID() const
-{ return *itsSCID; }
+    inline int DH_WOPrediff::getStrategyControllerID() const
+    { return *itsSCID; }
 
-inline void DH_WOPrediff::setStrategyControllerID(int id)
-{ *itsSCID = id; }
+    inline void DH_WOPrediff::setStrategyControllerID(int id)
+    { *itsSCID = id; }
 
-inline unsigned int DH_WOPrediff::getStatus() const
-{ return *itsStatus; }
+    inline unsigned int DH_WOPrediff::getStatus() const
+    { return *itsStatus; }
 
-inline void DH_WOPrediff::setStatus(unsigned int status)
-{ *itsStatus = status; }
+    inline void DH_WOPrediff::setStatus(unsigned int status)
+    { *itsStatus = status; }
 
-inline string DH_WOPrediff::getKSType() const
-{ return string(itsKSType); }
+    inline string DH_WOPrediff::getKSType() const
+    { return string(itsKSType); }
 
-inline bool DH_WOPrediff::getDoNothing() const
-{ return ((*itsDoNothing==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getDoNothing() const
+    { return ((*itsDoNothing==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setDoNothing(bool doNothing)
-{ *itsDoNothing = doNothing; }
+    inline void DH_WOPrediff::setDoNothing(bool doNothing)
+    { *itsDoNothing = doNothing; }
 
-inline bool DH_WOPrediff::getNewBaselines() const
-{ return ((*itsNewBaselines==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getNewBaselines() const
+    { return ((*itsNewBaselines==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setNewBaselines(bool newBaselines)
-{ *itsNewBaselines = newBaselines; }
+    inline void DH_WOPrediff::setNewBaselines(bool newBaselines)
+    { *itsNewBaselines = newBaselines; }
 
-inline bool DH_WOPrediff::getNewDomain() const
-{ return ((*itsNewDomain==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getNewDomain() const
+    { return ((*itsNewDomain==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setNewDomain(bool newDomain)
-{ *itsNewDomain = newDomain; }
+    inline void DH_WOPrediff::setNewDomain(bool newDomain)
+    { *itsNewDomain = newDomain; }
 
-inline bool DH_WOPrediff::getNewPeelSources() const
-{ return ((*itsNewPeelSources==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getNewPeelSources() const
+    { return ((*itsNewPeelSources==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setNewPeelSources(bool newSources)
-{ *itsNewPeelSources = newSources; }
+    inline void DH_WOPrediff::setNewPeelSources(bool newSources)
+    { *itsNewPeelSources = newSources; }
 
-inline bool DH_WOPrediff::getSubtractSources() const
-{ return ((*itsSubtractSources==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getSubtractSources() const
+    { return ((*itsSubtractSources==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setSubtractSources(bool subtract)
-{ *itsSubtractSources = subtract; }
+    inline void DH_WOPrediff::setSubtractSources(bool subtract)
+    { *itsSubtractSources = subtract; }
 
-inline bool DH_WOPrediff::getWritePredData() const
-{ return ((*itsWritePredData==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getWritePredData() const
+    { return ((*itsWritePredData==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setWritePredData(bool write)
-{ *itsWritePredData = write; }
+    inline void DH_WOPrediff::setWritePredData(bool write)
+    { *itsWritePredData = write; }
 
-inline bool DH_WOPrediff::getWriteInDataCol() const
-{ return ((*itsWriteInDataCol==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getWriteInDataCol() const
+    { return ((*itsWriteInDataCol==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setWriteInDataCol(bool write)
-{ *itsWriteInDataCol = write; }
+    inline void DH_WOPrediff::setWriteInDataCol(bool write)
+    { *itsWriteInDataCol = write; }
 
-inline int DH_WOPrediff::getMaxIterations() const
-{ return *itsMaxIterations; }
+    inline int DH_WOPrediff::getMaxIterations() const
+    { return *itsMaxIterations; }
 
-inline void DH_WOPrediff::setMaxIterations(int nr)
-{ *itsMaxIterations = nr; }
+    inline void DH_WOPrediff::setMaxIterations(int nr)
+    { *itsMaxIterations = nr; }
 
-inline int DH_WOPrediff::getStartChannel() const
-{ return *itsStartChan; }
+    inline int DH_WOPrediff::getStartChannel() const
+    { return *itsStartChan; }
 
-inline void DH_WOPrediff::setStartChannel(int chan)
-{ *itsStartChan = chan; }
+    inline void DH_WOPrediff::setStartChannel(int chan)
+    { *itsStartChan = chan; }
 
-inline int DH_WOPrediff::getEndChannel() const
-{ return *itsEndChan; }
+    inline int DH_WOPrediff::getEndChannel() const
+    { return *itsEndChan; }
 
-inline void DH_WOPrediff::setEndChannel(int chan)
-{ *itsEndChan = chan; }
+    inline void DH_WOPrediff::setEndChannel(int chan)
+    { *itsEndChan = chan; }
 
-inline double DH_WOPrediff::getStartTime() const
-{ return *itsStartTime; }
+    inline double DH_WOPrediff::getStartTime() const
+    { return *itsStartTime; }
 
-inline void DH_WOPrediff::setStartTime(double time)
-{ *itsStartTime = time; }
+    inline void DH_WOPrediff::setStartTime(double time)
+    { *itsStartTime = time; }
 
-inline double DH_WOPrediff::getTimeLength() const
-{ return *itsTimeLength; }
+    inline double DH_WOPrediff::getTimeLength() const
+    { return *itsTimeLength; }
 
-inline void DH_WOPrediff::setTimeLength(double time)
-{ *itsTimeLength = time; }
+    inline void DH_WOPrediff::setTimeLength(double time)
+    { *itsTimeLength = time; }
 
-inline bool DH_WOPrediff::getCalcUVW() const
-{ return ((*itsCalcUVW==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getCalcUVW() const
+    { return ((*itsCalcUVW==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setCalcUVW(bool calc)
-{ *itsCalcUVW = calc; }
+    inline void DH_WOPrediff::setCalcUVW(bool calc)
+    { *itsCalcUVW = calc; }
 
-inline bool DH_WOPrediff::getUseAutoCorrelations() const
-{ return ((*itsUseAutoCorr==0)?(false):(true)); }
+    inline bool DH_WOPrediff::getUseAutoCorrelations() const
+    { return ((*itsUseAutoCorr==0)?(false):(true)); }
 
-inline void DH_WOPrediff::setUseAutoCorrelations(bool use)
-{ *itsUseAutoCorr = use; }
+    inline void DH_WOPrediff::setUseAutoCorrelations(bool use)
+    { *itsUseAutoCorr = use; }
 
-inline bool DH_WOPrediff::getCleanUp() const
-{ return *itsCleanUp; }
+    inline bool DH_WOPrediff::getCleanUp() const
+    { return *itsCleanUp; }
 
-inline void DH_WOPrediff::setCleanUp(bool clean)
-{ *itsCleanUp = clean; }
+    inline void DH_WOPrediff::setCleanUp(bool clean)
+    { *itsCleanUp = clean; }
 
-inline bool DH_WOPrediff::getUpdateParms() const
-{ return *itsUpdateParms; }
+    inline bool DH_WOPrediff::getUpdateParms() const
+    { return *itsUpdateParms; }
 
-inline void DH_WOPrediff::setUpdateParms(bool update)
-{ *itsUpdateParms = update; }
+    inline void DH_WOPrediff::setUpdateParms(bool update)
+    { *itsUpdateParms = update; }
 
-inline int DH_WOPrediff::getSolutionID() const
-{ return *itsSolutionID; }
+    inline int DH_WOPrediff::getSolutionID() const
+    { return *itsSolutionID; }
  
-inline void DH_WOPrediff::setSolutionID(int id)
-{ *itsSolutionID = id; }
+    inline void DH_WOPrediff::setSolutionID(int id)
+    { *itsSolutionID = id; }
+
+    // @}
+
+  } // namespace BBS
 
-// @}
 } // namespace LOFAR
 
 #endif 
diff --git a/CEP/BB/BBSControl/include/BBSControl/DH_WOSolve.h b/CEP/BB/BBSControl/include/BBSControl/DH_WOSolve.h
index 66b46cef559d3378541c82109e32db74d64314fd..baf85dd825395d27117888a5a82aa60714eb7980 100644
--- a/CEP/BB/BBSControl/include/BBSControl/DH_WOSolve.h
+++ b/CEP/BB/BBSControl/include/BBSControl/DH_WOSolve.h
@@ -33,160 +33,185 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
+    // \addtogroup BBS
+    // @{
 
-// \addtogroup BBS
-// @{
+    // This class is a DataHolder which contains the work orders for the
+    // Solver.
+    class DH_WOSolve: public DH_DB
+    {
+    public:
 
-/**
-   This class is a DataHolder which contains the work orders for the Solver.
-*/
+      enum woStatus{New,Assigned,Executed};
 
-class DH_WOSolve: public DH_DB
-{
-public:
+      explicit DH_WOSolve (const string& name = "dh_wosolve");
+
+      DH_WOSolve(const DH_WOSolve&);
+
+      virtual ~DH_WOSolve();
+
+      DataHolder* clone() const;
+
+      /// Allocate the buffers.
+      virtual void init();
+
+      /// Data access methods.
+      int getWorkOrderID() const;
+      void setWorkOrderID(int id);
 
-  enum woStatus{New,Assigned,Executed};
+      int getStrategyControllerID() const;
+      void setStrategyControllerID(int id);
 
-  explicit DH_WOSolve (const string& name = "dh_wosolve");
+      unsigned int getStatus() const ;
+      void setStatus(unsigned int status);
 
-  DH_WOSolve(const DH_WOSolve&);
+      string getKSType() const;
+      void setKSType(const string& ksType);
 
-  virtual ~DH_WOSolve();
+      int getIteration() const;
+      void setIteration(int iter);
 
-  DataHolder* clone() const;
+      bool getDoNothing() const;
+      void setDoNothing(bool doNothing);
 
-  /// Allocate the buffers.
-  virtual void init();
+      bool getNewDomain() const;
+      void setNewDomain(bool newDomain);
 
-  /// Data access methods.
-  int getWorkOrderID() const;
-  void setWorkOrderID(int id);
+      int getMaxIterations() const;
+      void setMaxIterations(int nr);
 
-  int getStrategyControllerID() const;
-  void setStrategyControllerID(int id);
+      double getFitCriterion() const;
+      void setFitCriterion(double val);
 
-  unsigned int getStatus() const ;
-  void setStatus(unsigned int status);
+      bool getUseSVD() const;
+      void setUseSVD(bool useSVD);
 
-  string getKSType() const;
-  void setKSType(const string& ksType);
+      bool getCleanUp() const;
+      void setCleanUp(bool clean);
 
-  int getIteration() const;
-  void setIteration(int iter);
+      virtual void dump() const;
 
-  bool getDoNothing() const;
-  void setDoNothing(bool doNothing);
+      void clearData();
 
-  bool getNewDomain() const;
-  void setNewDomain(bool newDomain);
+    protected:
+      // Methods to obtain the specific queries to insert/update this
+      // DataHolder
+      string createInsertStatement(TH_DB* th);
 
-  int getMaxIterations() const;
-  void setMaxIterations(int nr);
+      // \note This implementation assumes only the status has changed and
+      // needs to be updated
+      string createUpdateStatement(TH_DB* th);
 
-  double getFitCriterion() const;
-  void setFitCriterion(double val);
+    private:
+      /// Forbid assignment.
+      DH_WOSolve& operator= (const DH_WOSolve&);
 
-  bool getUseSVD() const;
-  void setUseSVD(bool useSVD);
+      // Fill the pointers (itsCounter and itsBuffer) to the data in the blob.
+      virtual void fillDataPointers();
 
-  bool getCleanUp() const;
-  void setCleanUp(bool clean);
+      // Unique workorder id
+      int*          itsWOID;
 
-  virtual void dump() const;
+      // ID of sending StrategyController (SC)
+      int*          itsSCID;
 
-  void clearData();
+      // Workorder status
+      unsigned int* itsStatus;
 
-protected:
-  // Methods to obtain the specific queries to insert/update this DataHolder
-  string createInsertStatement(TH_DB* th);
-  string createUpdateStatement(TH_DB* th); // NB.This implementation assumes only the
-                                           // status has changed and needs to be updated
+      // Knowledge Source type
+      char*         itsKSType;
 
-private:
-  /// Forbid assignment.
-  DH_WOSolve& operator= (const DH_WOSolve&);
+      // Iteration number
+      int*          itsIteration;
 
-  // Fill the pointers (itsCounter and itsBuffer) to the data in the blob.
-  virtual void fillDataPointers();
+      // Do nothing?
+      unsigned int* itsDoNothing;
 
-  int*        itsWOID;                    // Unique workorder id
-  int*          itsSCID;                    // ID of sending StrategyController (SC)
-  unsigned int* itsStatus;                  // Workorder status
-  char*         itsKSType;                  // Knowledge Source type
-  int*          itsIteration;               // Iteration number
-  unsigned int* itsDoNothing;               // Do nothing?
-  unsigned int* itsNewDomain;               // Solve on a new domain?
-  int*          itsMaxIterations;           // Maximum number of iterations to do
-  double*       itsFitCriterion;            // Iterate until this value is obtained for the fit
-  unsigned int* itsUseSVD;                  // UseSVD in solver?
-  unsigned int* itsCleanUp;                 // Clean up Solver when finished?
+      // Solve on a new domain?
+      unsigned int* itsNewDomain;
+
+      // Maximum number of iterations to do
+      int*          itsMaxIterations;
+
+      // Iterate until this value is obtained for the fit
+      double*       itsFitCriterion;
+
+      // UseSVD in solver?
+      unsigned int* itsUseSVD;
+
+      // Clean up Solver when finished?
+      unsigned int* itsCleanUp;
  
-};
+    };
+
+    inline int DH_WOSolve::getWorkOrderID() const
+    { return *itsWOID; }
 
-inline int DH_WOSolve::getWorkOrderID() const
-{ return *itsWOID; }
+    inline void DH_WOSolve::setWorkOrderID(int id)
+    { *itsWOID = id; }
 
-inline void DH_WOSolve::setWorkOrderID(int id)
-{ *itsWOID = id; }
+    inline int DH_WOSolve::getStrategyControllerID() const
+    { return *itsSCID; }
 
-inline int DH_WOSolve::getStrategyControllerID() const
-{ return *itsSCID; }
+    inline void DH_WOSolve::setStrategyControllerID(int id)
+    { *itsSCID = id; }
 
-inline void DH_WOSolve::setStrategyControllerID(int id)
-{ *itsSCID = id; }
+    inline unsigned int DH_WOSolve::getStatus() const
+    { return *itsStatus; }
 
-inline unsigned int DH_WOSolve::getStatus() const
-{ return *itsStatus; }
+    inline void DH_WOSolve::setStatus(unsigned int status)
+    { *itsStatus = status; }
 
-inline void DH_WOSolve::setStatus(unsigned int status)
-{ *itsStatus = status; }
+    inline string DH_WOSolve::getKSType() const
+    {  return string(itsKSType); }
 
-inline string DH_WOSolve::getKSType() const
-{  return string(itsKSType); }
+    inline int DH_WOSolve::getIteration() const
+    { return *itsIteration; }
 
-inline int DH_WOSolve::getIteration() const
-{ return *itsIteration; }
+    inline void DH_WOSolve::setIteration(int iter)
+    { *itsIteration = iter; }
 
-inline void DH_WOSolve::setIteration(int iter)
-{ *itsIteration = iter; }
+    inline bool DH_WOSolve::getDoNothing() const
+    { return ((*itsDoNothing==0)?(false):(true)); }
 
-inline bool DH_WOSolve::getDoNothing() const
-{ return ((*itsDoNothing==0)?(false):(true)); }
+    inline void DH_WOSolve::setDoNothing(bool doNothing)
+    { *itsDoNothing = doNothing; }
 
-inline void DH_WOSolve::setDoNothing(bool doNothing)
-{ *itsDoNothing = doNothing; }
+    inline bool DH_WOSolve::getNewDomain() const
+    { return ((*itsNewDomain==0)?(false):(true)); }
 
-inline bool DH_WOSolve::getNewDomain() const
-{ return ((*itsNewDomain==0)?(false):(true)); }
+    inline void DH_WOSolve::setNewDomain(bool doNewDomain)
+    { *itsNewDomain = doNewDomain; }
 
-inline void DH_WOSolve::setNewDomain(bool doNewDomain)
-{ *itsNewDomain = doNewDomain; }
+    inline int DH_WOSolve::getMaxIterations() const
+    { return *itsMaxIterations; }
 
-inline int DH_WOSolve::getMaxIterations() const
-{ return *itsMaxIterations; }
+    inline void DH_WOSolve::setMaxIterations(int nr)
+    { *itsMaxIterations = nr; }
 
-inline void DH_WOSolve::setMaxIterations(int nr)
-{ *itsMaxIterations = nr; }
+    inline double DH_WOSolve::getFitCriterion() const
+    { return *itsFitCriterion; }
 
-inline double DH_WOSolve::getFitCriterion() const
-{ return *itsFitCriterion; }
+    inline void DH_WOSolve::setFitCriterion(double val)
+    { *itsFitCriterion = val; }
 
-inline void DH_WOSolve::setFitCriterion(double val)
-{ *itsFitCriterion = val; }
+    inline bool DH_WOSolve::getUseSVD() const
+    { return ((*itsUseSVD==0)?(false):(true)); }
 
-inline bool DH_WOSolve::getUseSVD() const
-{ return ((*itsUseSVD==0)?(false):(true)); }
+    inline void DH_WOSolve::setUseSVD(bool useSVD)
+    { *itsUseSVD = useSVD; }
 
-inline void DH_WOSolve::setUseSVD(bool useSVD)
-{ *itsUseSVD = useSVD; }
+    inline bool DH_WOSolve::getCleanUp() const
+    { return *itsCleanUp; }
 
-inline bool DH_WOSolve::getCleanUp() const
-{ return *itsCleanUp; }
+    inline void DH_WOSolve::setCleanUp(bool clean)
+    { *itsCleanUp = clean; }
 
-inline void DH_WOSolve::setCleanUp(bool clean)
-{ *itsCleanUp = clean; }
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/ParmWriter.h b/CEP/BB/BBSControl/include/BBSControl/ParmWriter.h
index 2668da293b89ce97a4fdc1a2abb4e98989b7b4c2..174747688b25ac4ea70978b68d6d277cbd08443b 100644
--- a/CEP/BB/BBSControl/include/BBSControl/ParmWriter.h
+++ b/CEP/BB/BBSControl/include/BBSControl/ParmWriter.h
@@ -29,39 +29,41 @@
 // Writes/updates parameters in ParmTables.
 
 //# Includes
-#include <Common/lofar_map.h>
 
 namespace LOFAR
 {
-  // \addtogroup BBS
-  // @{
   //# Forward Declarations
   class ParmDataInfo;
   class MeqMatrix;
-  namespace ParmDB {
-    class ParmValueRep;
-  }
+  namespace ParmDB { class ParmValueRep; }
 
-
-  // Description of class.
-  class ParmWriter
+  namespace BBS
   {
-  public:
-    // Constructor
-    ParmWriter();
+    // \addtogroup BBS
+    // @{
+
+    // Description of class.
+    class ParmWriter
+    {
+    public:
+      // Constructor
+      ParmWriter();
+
+      // Destructor
+      ~ParmWriter();
+
+      void write (const ParmDataInfo& pData,
+		  double fStart, double fEnd, 
+		  double tStart, double tEnd);
 
-    // Destructor
-    ~ParmWriter();
+    private:
+      void setCoeff (ParmDB::ParmValueRep& pval, const MeqMatrix& coeff);
+    };
 
-    void write (const ParmDataInfo& pData,
-		double fStart, double fEnd, 
-		double tStart, double tEnd);
+    // @}
 
-  private:
-    void setCoeff (ParmDB::ParmValueRep& pval, const MeqMatrix& coeff);
-  };
+  } // namespace BBS
 
-  // @}
 } // namespace LOFAR
 
 #endif
diff --git a/CEP/BB/BBSControl/include/BBSControl/SC_CompoundIter.h b/CEP/BB/BBSControl/include/BBSControl/SC_CompoundIter.h
index 25fd8e5a24094842b32e6d36392f6a89d6fa42c8..40375b98817dc00c5632e811310fda6895e00878 100644
--- a/CEP/BB/BBSControl/include/BBSControl/SC_CompoundIter.h
+++ b/CEP/BB/BBSControl/include/BBSControl/SC_CompoundIter.h
@@ -24,7 +24,10 @@
 #define LOFAR_BBSCONTROL_SC_COMPOUNDITER_H
 
 // \file SC_CompoundIter
-// A calibration strategy which sends compound workorders (multiple iterations).// NB. This strategy only works correctly when Prediffer and Solver run in 
+
+// A calibration strategy which sends compound workorders (multiple
+// iterations).
+// \note This strategy only works correctly when Prediffer and Solver run in
 // separate processes.
 
 //# Includes
@@ -34,59 +37,70 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-// \addtogroup BBS
-// @{
+    // \addtogroup BBS
+    // @{
 
-//# Forward Declarations
+    //# Forward Declarations
 
-using ACC::APS::ParameterSet;
+    using ACC::APS::ParameterSet;
 
-class SC_CompoundIter : public StrategyController
-{
-public:
-  SC_CompoundIter(Connection* inSolConn, Connection* outWOPDConn, 
-	    Connection* outWOSolveConn, int nrPrediffers,
-	    const ParameterSet& args);
+    class SC_CompoundIter : public StrategyController
+    {
+    public:
+      SC_CompoundIter(Connection* inSolConn, Connection* outWOPDConn, 
+		      Connection* outWOSolveConn, int nrPrediffers,
+		      const ParameterSet& args);
 
-  virtual ~SC_CompoundIter();
+      virtual ~SC_CompoundIter();
 
-  /// Execute the strategy
-  virtual bool execute();
+      /// Execute the strategy
+      virtual bool execute();
 
-  /// Postprocess
-  virtual void postprocess();
+      /// Postprocess
+      virtual void postprocess();
     
-  /// Get strategy type
-  virtual string getType() const;
-
- private:
-  SC_CompoundIter(const SC_CompoundIter&);
-  SC_CompoundIter& operator=(const SC_CompoundIter&);
-
-  void readFinalSolution();
-
-  bool         itsFirstCall;
-  int          itsPrevWOID;
-  ParameterSet itsArgs;
-  int          itsMaxIterations;
-  double       itsFitCriterion;
-  int          itsCurIter;
-  double       itsCurStartTime;
-  bool         itsControlParmUpd;    // Does this Controller update the parameters?
-  bool         itsWriteParms;        // Write the parameters in the parmtable at the end of each interval?
-  double       itsStartTime;
-  double       itsEndTime;
-  double       itsTimeLength;
-  int          itsStartChannel;
-  int          itsEndChannel;
-  bool         itsSendDoNothingWO;  // Flag to indicate whether the previous sent workorder was a "do nothing"
-};
-
-inline string SC_CompoundIter::getType() const
-{ return "CompoundIter"; }
-
-// @}
+      /// Get strategy type
+      virtual string getType() const;
+
+    private:
+      SC_CompoundIter(const SC_CompoundIter&);
+      SC_CompoundIter& operator=(const SC_CompoundIter&);
+
+      void readFinalSolution();
+
+      bool         itsFirstCall;
+      int          itsPrevWOID;
+      ParameterSet itsArgs;
+      int          itsMaxIterations;
+      double       itsFitCriterion;
+      int          itsCurIter;
+      double       itsCurStartTime;
+
+      // Does this Controller update the parameters?
+      bool         itsControlParmUpd;
+
+      // Write the parameters in the parmtable at the end of each interval?
+      bool         itsWriteParms;
+      double       itsStartTime;
+      double       itsEndTime;
+      double       itsTimeLength;
+      int          itsStartChannel;
+      int          itsEndChannel;
+
+      // Flag to indicate whether the previous sent workorder was a "do
+      // nothing"
+      bool         itsSendDoNothingWO;
+    };
+
+    inline string SC_CompoundIter::getType() const
+    { return "CompoundIter"; }
+
+    // @}
+
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/SC_Simple.h b/CEP/BB/BBSControl/include/BBSControl/SC_Simple.h
index 097f8e0a13d7849e705d595d7e4bd824dd67bc8a..74b7a547a83442e22b6e745409336bc58913511e 100644
--- a/CEP/BB/BBSControl/include/BBSControl/SC_Simple.h
+++ b/CEP/BB/BBSControl/include/BBSControl/SC_Simple.h
@@ -33,59 +33,67 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-// \addtogroup BBS
-// @{
+    // \addtogroup BBS
+    // @{
 
-//# Forward Declarations
+    //# Forward Declarations
 
-using ACC::APS::ParameterSet;
+    class SC_Simple : public StrategyController
+    {
+    public:
+      SC_Simple(Connection* inSolConn, Connection* outWOPDConn, 
+		Connection* outWOSolveConn, int nrPrediffers,
+		const ACC::APS::ParameterSet& args);
 
-class SC_Simple : public StrategyController
-{
-public:
-  SC_Simple(Connection* inSolConn, Connection* outWOPDConn, 
-	    Connection* outWOSolveConn, int nrPrediffers,
-	    const ParameterSet& args);
+      virtual ~SC_Simple();
 
-  virtual ~SC_Simple();
+      // Execute the strategy
+      virtual bool execute();
 
-  /// Execute the strategy
-  virtual bool execute();
+      // Preprocess
+      virtual void preprocess();
 
-  /// Postprocess
-  virtual void postprocess();
+      // Postprocess
+      virtual void postprocess();
     
-  /// Get strategy type
-  virtual string getType() const;
-
- private:
-  SC_Simple(const SC_Simple&);
-  SC_Simple& operator=(const SC_Simple&);
-
-  void readSolution();
-
-  bool         itsFirstCall;
-  int          itsPrevWOID;
-  ParameterSet itsArgs;
-  int          itsNrIterations;
-  double       itsFitCriterion;
-  int          itsCurIter;
-  double       itsCurStartTime;
-  bool         itsControlParmUpd;    // Does this Controller update the parameters?
-  bool         itsWriteParms;        // Write the parameters in the parmtable at the end of each interval?
-  double       itsStartTime;
-  double       itsEndTime;
-  double       itsTimeLength;
-  int          itsStartChannel;
-  int          itsEndChannel;
-  bool         itsSendDoNothingWO;  // Flag to indicate whether the previous sent workorder was a "do nothing"
-};
-
-inline string SC_Simple::getType() const
-{ return "Simple"; }
-
-// @}
+      // Get strategy type
+      virtual string getType() const;
+
+    private:
+      SC_Simple(const SC_Simple&);
+      SC_Simple& operator=(const SC_Simple&);
+
+      void readSolution();
+
+      int          itsPrevWOID;
+      ACC::APS::ParameterSet itsArgs;
+      int          itsNrIterations;
+      double       itsFitCriterion;
+      int          itsCurIter;
+      double       itsCurStartTime;
+      // Does this Controller update the parameters?
+      bool         itsControlParmUpd;
+      // Write the parameters in the parmtable at the end of each interval?
+      bool         itsWriteParms;
+      double       itsStartTime;
+      double       itsEndTime;
+      double       itsTimeLength;
+      int          itsStartChannel;
+      int          itsEndChannel;
+      // Flag indicating whether the previous sent workorder was a "do
+      // nothing"
+      bool         itsSendDoNothingWO;
+    };
+
+    inline string SC_Simple::getType() const
+    { return "Simple"; }
+
+    // @}
+
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/SC_WritePredData.h b/CEP/BB/BBSControl/include/BBSControl/SC_WritePredData.h
index d23109fca42c27bc96c74426706f5a071b7f955a..7e40f94555de11441a5cb09767063fc374e31889 100644
--- a/CEP/BB/BBSControl/include/BBSControl/SC_WritePredData.h
+++ b/CEP/BB/BBSControl/include/BBSControl/SC_WritePredData.h
@@ -33,51 +33,51 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-// \addtogroup BBS
-// @{
+    // \addtogroup BBS
+    // @{
 
-//# Forward Declarations
+    class SC_WritePredData : public StrategyController
+    {
+    public:
+      SC_WritePredData(Connection* inSolConn, Connection* outWOPDConn, 
+		       Connection* outWOSolveConn, int nrPrediffers,
+		       const ACC::APS::ParameterSet& args);
 
-using ACC::APS::ParameterSet;
+      virtual ~SC_WritePredData();
 
-class SC_WritePredData : public StrategyController
-{
-public:
-  SC_WritePredData(Connection* inSolConn, Connection* outWOPDConn, 
-	    Connection* outWOSolveConn, int nrPrediffers,
-	    const ParameterSet& args);
-
-  virtual ~SC_WritePredData();
-
-  /// Execute the strategy
-  virtual bool execute();
+      /// Execute the strategy
+      virtual bool execute();
 
-  /// Postprocess
-  virtual void postprocess();
+      /// Postprocess
+      virtual void postprocess();
     
-  /// Get strategy type
-  virtual string getType() const;
-
- private:
-  SC_WritePredData(const SC_WritePredData&);
-  SC_WritePredData& operator=(const SC_WritePredData&);
-
-  bool         itsFirstCall;
-  ParameterSet itsArgs;
-  double       itsCurStartTime;
-  bool         itsWriteInDataCol;
-  double       itsStartTime;
-  double       itsEndTime;
-  double       itsTimeLength;
-  int          itsStartChannel;
-  int          itsEndChannel;
-};
-
-inline string SC_WritePredData::getType() const
-{ return "WritePredData"; }
-
-// @}
+      /// Get strategy type
+      virtual string getType() const;
+
+    private:
+      SC_WritePredData(const SC_WritePredData&);
+      SC_WritePredData& operator=(const SC_WritePredData&);
+
+      bool         itsFirstCall;
+      ACC::APS::ParameterSet itsArgs;
+      double       itsCurStartTime;
+      bool         itsWriteInDataCol;
+      double       itsStartTime;
+      double       itsEndTime;
+      double       itsTimeLength;
+      int          itsStartChannel;
+      int          itsEndChannel;
+    };
+
+    inline string SC_WritePredData::getType() const
+    { return "WritePredData"; }
+
+    // @}
+
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/StrategyController.h b/CEP/BB/BBSControl/include/BBSControl/StrategyController.h
index bef1413bd1c738c42f66a5cb8f9e5e30d4729024..ebe5957b9300bc9b6062578f71d59bf538b63180 100644
--- a/CEP/BB/BBSControl/include/BBSControl/StrategyController.h
+++ b/CEP/BB/BBSControl/include/BBSControl/StrategyController.h
@@ -35,90 +35,98 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
+    // \addtogroup BBS
+    // @{
+
+    //# Forward Declarations
+    class DH_Solution;
+    class DH_WOPrediff;
+    class DH_WOSolve;
+
+    // This is an abstract base class for all calibration strategy controllers
+    class StrategyController
+    {
+    public:
+      // Creation of a StrategyController with its DataHolders to read and
+      // write.
+      StrategyController(Connection* inSolConn, 
+			 Connection* outWOPDConn, 
+			 Connection* outWOSolveConn,
+			 int nrPrediffers);
+
+      // Destructor
+      virtual ~StrategyController();
+
+      // Execute the strategy
+      virtual bool execute() = 0;
+   
+      // Preprocessing, can be used to initialize and/or load data, etc.
+      virtual void preprocess();
 
-// \addtogroup BBS
-// @{
-
-//# Forward Declarations
-class DH_Solution;
-class DH_WOPrediff;
-class DH_WOSolve;
+      // Postprocessing, can be used to do some clean-up, saving etc.
+      virtual void postprocess();
 
-/* This is an abstract base class for all calibration strategy controllers
-*/
+      // Get strategy implementation type
+      virtual string getType() const = 0;
 
-class StrategyController
-{
-public:
-  // Creation of a StrategyController with its DataHolders to read and write.
-  StrategyController(Connection* inSolConn, 
-		     Connection* outWOPDConn, 
-		     Connection* outWOSolveConn,
-		     int nrPrediffers);
-
-  // Destructor
-  virtual ~StrategyController();
-
-  /// Execute the strategy
-  virtual bool execute() = 0;
-   
-  /// Postprocessing, can be used to do some clean-up, saving etc.
-  virtual void postprocess() = 0;
+      // Get and set in/output dataholders
+      DH_Solution* getSolution() const;
 
-  /// Get strategy implementation type
-  virtual string getType() const = 0;
+      DH_WOPrediff* getPrediffWorkOrder() const;
 
-  /// Get and set in/output dataholders
-  DH_Solution* getSolution() const;
+      DH_WOSolve* getSolveWorkOrder() const;
 
-  DH_WOPrediff* getPrediffWorkOrder() const;
+      int getID() const;
 
-  DH_WOSolve* getSolveWorkOrder() const;
+      int getNewWorkOrderID();
 
-  int getID() const;
+      int getNumberOfPrediffers() const;
 
-  int getNewWorkOrderID();
+      ParmWriter& getParmWriter();
 
-  int getNumberOfPrediffers() const;
+    protected:
+      Connection*   itsInSolConn;
+      Connection*   itsOutWOPDConn;
+      Connection*   itsOutWOSolveConn;
+      int           itsNrPrediffers;
+ 
+    private:
+      int           itsID;
+      ParmWriter    itsParmWriter;
 
-  ParmWriter& getParmWriter();
+      // Unique ID for next Strategy Controller instance
+      static int    theirNextSCID;
 
-protected:
-  Connection*   itsInSolConn;
-  Connection*   itsOutWOPDConn;
-  Connection*   itsOutWOSolveConn;
-  int           itsNrPrediffers;
- 
-private:
-  int           itsID;
-  ParmWriter    itsParmWriter;
+      // Unique ID for next workorder
+      static int  theirNextWOID;
+    };
 
-  static int    theirNextSCID;   // Unique ID for next Strategy Controller instance
-  static int  theirNextWOID;     // Unique ID for next workorder
-};
+    inline DH_Solution* StrategyController::getSolution() const
+    { return (DH_Solution*)itsInSolConn->getDataHolder(true); }
 
-inline DH_Solution* StrategyController::getSolution() const
-{ return (DH_Solution*)itsInSolConn->getDataHolder(true); }
+    inline DH_WOPrediff* StrategyController::getPrediffWorkOrder() const
+    { return (DH_WOPrediff*)itsOutWOPDConn->getDataHolder(); }
 
-inline DH_WOPrediff* StrategyController::getPrediffWorkOrder() const
-{ return (DH_WOPrediff*)itsOutWOPDConn->getDataHolder(); }
+    inline DH_WOSolve* StrategyController::getSolveWorkOrder() const
+    { return (DH_WOSolve*)itsOutWOSolveConn->getDataHolder(); }
 
-inline DH_WOSolve* StrategyController::getSolveWorkOrder() const
-{ return (DH_WOSolve*)itsOutWOSolveConn->getDataHolder(); }
+    inline int StrategyController::getID() const
+    { return itsID; }
 
-inline int StrategyController::getID() const
-{ return itsID; }
+    inline int StrategyController::getNewWorkOrderID()
+    { return theirNextWOID++; }
 
-inline int StrategyController::getNewWorkOrderID()
-{ return theirNextWOID++; }
+    inline ParmWriter& StrategyController::getParmWriter()
+    { return itsParmWriter; }
 
-inline ParmWriter& StrategyController::getParmWriter()
-{ return itsParmWriter; }
+    inline int StrategyController::getNumberOfPrediffers() const
+    { return itsNrPrediffers; }
 
-inline int StrategyController::getNumberOfPrediffers() const
-{ return itsNrPrediffers; }
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/WH_Control.h b/CEP/BB/BBSControl/include/BBSControl/WH_Control.h
index 885dea969555589b8fe4fb8776920bc3921fe14d..9d511f7d4c3f19bd828977b94b248f09cb196cea 100644
--- a/CEP/BB/BBSControl/include/BBSControl/WH_Control.h
+++ b/CEP/BB/BBSControl/include/BBSControl/WH_Control.h
@@ -1,27 +1,24 @@
-//  WH_Control.h: This class implements the controller of the blackboard.
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  WH_Control.h: This class implements the controller of the blackboard.
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #ifndef LOFAR_BBSCONTROL_WH_CONTROL_H
 #define LOFAR_BBSCONTROL_WH_CONTROL_H
@@ -36,71 +33,77 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-// \addtogroup BBS
-// @{
+    // \addtogroup BBS
+    // @{
 
-class StrategyController;
-using ACC::APS::ParameterSet; 
+    //# Forward declarations.
+    class StrategyController;
 
-/**
- This class implements the controller of the blackboard
-*/
-class WH_Control: public LOFAR::WorkHolder
-{
+    // This class implements the controller of the blackboard
+    class WH_Control: public LOFAR::WorkHolder
+    {
+
+    public:
+      /// Construct the work holder and give it a name.
+      /// It is possible to specify how many input and output data holders
+      /// are created and how many elements there are in the buffer.
+      /// The first WorkHolder should have nin=0.
+      explicit WH_Control (const string& name, int nrPrediffers,
+			   const ACC::APS::ParameterSet& args);
+
+      virtual ~WH_Control();
+
+      /// Make a fresh copy of the WH object.
+      virtual WH_Control* make (const string& name);
+
+      /// Static function to create an object.
+      static WorkHolder* construct (const string& name, int nrPrediffers,
+				    const ACC::APS::ParameterSet& args);
 
-public:
-  /// Construct the work holder and give it a name.
-  /// It is possible to specify how many input and output data holders
-  /// are created and how many elements there are in the buffer.
-  /// The first WorkHolder should have nin=0.
-  explicit WH_Control (const string& name, int nrPrediffers,
-		       const ParameterSet& args);
+      /// Preprocess
+      virtual void preprocess();
 
-  virtual ~WH_Control();
+      /// Do a process step.
+      virtual void process();
 
-  /// Make a fresh copy of the WH object.
-  virtual WH_Control* make (const string& name);
+      /// Postprocess
+      virtual void postprocess();
 
-  /// Static function to create an object.
-  static WorkHolder* construct (const string& name, int nrPrediffers,
-				const ParameterSet& args);
+      /// Show the work holder on stdout.
+      virtual void dump() const;
 
-  /// Preprocess
-  virtual void preprocess();
+    private:
+      typedef list<StrategyController*> ControllerList;
 
-  /// Do a process step.
-  virtual void process();
+      /// Forbid copy constructor.
+      WH_Control (const WH_Control&);
 
-  /// Postprocess
-  virtual void postprocess();
+      /// Forbid assignment.
+      WH_Control& operator= (const WH_Control&);
 
-  /// Show the work holder on stdout.
-  virtual void dump() const;
+      // Private help functions to create strategy controller(s)
+      void createStrategyControllers();
 
-private:
-  typedef list<StrategyController*> ControllerList;
+      // Number of available prediffers
+      int                      itsNrPrediffers;
 
-  /// Forbid copy constructor.
-  WH_Control (const WH_Control&);
+      // Input parameters
+      ACC::APS::ParameterSet   itsArgs;
 
-  /// Forbid assignment.
-  WH_Control& operator= (const WH_Control&);
+      // All StrategyControllers   
+      ControllerList           itsControllers;
 
-  // Private help functions to create strategy controller(s)
-  void createStrategyControllers();
+      // Iterator indicating the currently active strategy controller. At the
+      // moment each process() call executes one StrategyController
+      ControllerList::iterator itsCtrlIter;
+    };
 
-  int                      itsNrPrediffers;  // Number of available prediffers
-  ParameterSet             itsArgs;          // Input parameters
-  ControllerList           itsControllers;   // All StrategyControllers   
-  ControllerList::iterator itsCtrlIter;      // Iterator indicating the currently
-                                             // active strategy controller.
-                                             // At the moment each process() call 
-                                             // executes one StrategyController
-  bool                     itsFirstCall;
-};
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/WH_Prediff.h b/CEP/BB/BBSControl/include/BBSControl/WH_Prediff.h
index 4e5f8143d1c474f5aadf745d5851c2ed06f5b6bb..5bbbc1a2b221a577036e36efb2949a196f3eefcc 100644
--- a/CEP/BB/BBSControl/include/BBSControl/WH_Prediff.h
+++ b/CEP/BB/BBSControl/include/BBSControl/WH_Prediff.h
@@ -34,82 +34,94 @@
 
 namespace LOFAR
 {
-
-using ACC::APS::ParameterSet;
-// \addtogroup BBS
-// @{
-
-//# Forward Declarations
-class Prediffer;
-class ParmDataInfo;
-
-  // This workholder class predicts (calculates) visibilities based on current values
-  // of the parameters and determines the difference to the measured data for a 
-  // certain domain.
-class WH_Prediff : public LOFAR::WorkHolder
-{
- public:
-  // Construct the workholder and give it a name
-  explicit WH_Prediff(const string& name, const string& id, const ParameterSet& pset);
+  //# Forward Declarations
+  class Prediffer;
+  class ParmDataInfo;
+
+  namespace BBS
+  {
+
+    // \addtogroup BBS
+    // @{
+
+    // This workholder class predicts (calculates) visibilities based on
+    // current values of the parameters and determines the difference to the
+    // measured data for a certain domain.
+    class WH_Prediff : public LOFAR::WorkHolder
+    {
+    public:
+      // Construct the workholder and give it a name
+      explicit WH_Prediff(const string& name, const string& id, 
+			  const ACC::APS::ParameterSet& pset);
   
-  // Destructor
-  virtual ~WH_Prediff();
+      // Destructor
+      virtual ~WH_Prediff();
   
-  // Make a fresh copy of the WH object.
-  virtual WH_Prediff* make (const string& name);
+      // Make a fresh copy of the WH object.
+      virtual WH_Prediff* make (const string& name);
 
-  // Preprocess
-  virtual void preprocess();
+      // Preprocess
+      virtual void preprocess();
 
-  // Do a process step.
-  virtual void process();
+      // Do a process step.
+      virtual void process();
   
-  // Show the workholder on stdout.
-  virtual void dump() const;
+      // Show the workholder on stdout.
+      virtual void dump() const;
+
+    private:
+      typedef map<int, Prediffer*> PrediffMap;
+
+      // Forbid copy constructor
+      WH_Prediff(const WH_Prediff&);
 
- private:
-  typedef map<int, Prediffer*> PrediffMap;
+      // Forbid assignment
+      WH_Prediff& operator= (const WH_Prediff&);
 
-  // Forbid copy constructor
-  WH_Prediff(const WH_Prediff&);
+      // Create a Prediffer object or get it from the Map
+      Prediffer* getPrediffer(int id, 
+			      const ACC::APS::ParameterSet& args, 
+			      const vector<int>& antNrs,
+			      bool& isNew);
 
-  // Forbid assignment
-  WH_Prediff& operator= (const WH_Prediff&);
+      // Delete the Prediffer object with specified ID
+      void deletePrediffer (int id);
 
-  // Create a Prediffer object or get it from the Map
-  Prediffer* getPrediffer(int id, 
-			  const ParameterSet& args, 
-			  const vector<int>& antNrs,
-			  bool& isNew);
+      // Read the next workorder
+      void readWorkOrder();
 
-  // Delete the Prediffer object with specified ID
-  void deletePrediffer (int id);
+      // Get the sourceGroups specification.
+      void getSrcGrp (const ACC::APS::ParameterSet& args, 
+		      vector<vector<int> >& srcgrp) const;
 
-  // Read the next workorder
-  void readWorkOrder();
+      // Read a parameter solution with specified workorder id
+      void readSolution(int woid, ParmDataInfo& solVec);
 
-  // Get the sourceGroups specification.
-  void getSrcGrp (const ParameterSet& args, vector<vector<int> >& srcgrp) const;
+      // Read a parameter solution with specified workorder id and iteration
+      // and return a boolean indicating if this solution has converged.
+      bool readSolution(int woid, int iteration, ParmDataInfo& solVec);
 
-  // Read a parameter solution with specified workorder id
-  void readSolution(int woid, ParmDataInfo& solVec);
+      static ParmDB::ParmDBMeta makePDM (const string& nameKey,
+					 const ACC::APS::ParameterSet& ps);
 
-  // Read a parameter solution with specified workorder id and iteration
-  // and return a boolean indicating if this solution has converged.
-  bool readSolution(int woid, int iteration, ParmDataInfo& solVec);
 
-  static ParmDB::ParmDBMeta makePDM (const string& nameKey,
-				     const ParameterSet& ps);
+      // Identification number
+      string       itsID;
+      
+       // Arguments
+      ACC::APS::ParameterSet itsArgs;
+      
+      // Map of Prediffer objects, each associated with a strategy
+      // (controller)
+      PrediffMap   itsPrediffs;
 
-  string       itsID;         // Identification number
-  ParameterSet itsArgs;       // Arguments
-  PrediffMap   itsPrediffs;   // Map of Prediffer objects, each associated
-  // with a strategy (controller)
+      // \attention Needs to be done correctly for multiple strategies!!
+      bool        itsFirstCall;
+    };
 
-  bool        itsFirstCall;  // Temporary!!! Needs to be done correctly for multiple strategies
-};
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/include/BBSControl/WH_Solve.h b/CEP/BB/BBSControl/include/BBSControl/WH_Solve.h
index a28b1c4439d5c5d32395c09cb07e02d1cc3a13cf..d0073e581799a0167915dd1f4df788a6cb44b339 100644
--- a/CEP/BB/BBSControl/include/BBSControl/WH_Solve.h
+++ b/CEP/BB/BBSControl/include/BBSControl/WH_Solve.h
@@ -31,67 +31,75 @@
 
 namespace LOFAR
 {
-
-// \addtogroup BBS
-// @{
-
-//# Forward Declarations
-class Solver;
-
-// This workholder class solves for a certain domain
-
-class WH_Solve : public LOFAR::WorkHolder
-{
- public:
-  // Construct the workholder and give it a name
-  explicit WH_Solve(const string& name, int nPrediffInputs, 
-		    bool writeIndivParms, 
-		    const string& parmTableName="bbs3parmsolutions");
+  //# Forward Declarations
+  class Solver;
+
+  namespace BBS
+  {
+    // \addtogroup BBS
+    // @{
+
+    // This workholder class solves for a certain domain
+    class WH_Solve : public LOFAR::WorkHolder
+    {
+    public:
+      // Construct the workholder and give it a name
+      explicit WH_Solve(const string& name, int nPrediffInputs, 
+			bool writeIndivParms, 
+			const string& parmTableName="bbs3parmsolutions");
   
-  // Destructor
-  virtual ~WH_Solve();
+      // Destructor
+      virtual ~WH_Solve();
   
-  // Make a fresh copy of the WH object.
-  virtual WH_Solve* make (const string& name);
+      // Make a fresh copy of the WH object.
+      virtual WH_Solve* make (const string& name);
 
-  // Preprocess
-  virtual void preprocess();
+      // Preprocess
+      virtual void preprocess();
 
-  // Do a process step.
-  virtual void process();
+      // Do a process step.
+      virtual void process();
   
-  // Show the workholder on stdout.
-  virtual void dump() const;
+      // Show the workholder on stdout.
+      virtual void dump() const;
 
- private:
-  typedef map<int, Solver*> SolverMap;
+    private:
+      typedef map<int, Solver*> SolverMap;
 
-  // Forbid copy constructor
-  WH_Solve(const WH_Solve&);
+      // Forbid copy constructor
+      WH_Solve(const WH_Solve&);
 
-  // Forbid assignment
-  WH_Solve& operator= (const WH_Solve&);
+      // Forbid assignment
+      WH_Solve& operator= (const WH_Solve&);
 
-  // Create a Solver object
-  Solver* getSolver(int id);
+      // Create a Solver object
+      Solver* getSolver(int id);
 
-  // Delete a Solver object
-  void deleteSolver(int id);
+      // Delete a Solver object
+      void deleteSolver(int id);
 
-  // Read all Prediffer inputs
-  void readInputs(Solver* solver, bool firstRead);
+      // Read all Prediffer inputs
+      void readInputs(Solver* solver, bool firstRead);
   
-  // Read all Prediffer inputs and set solvable parameter data.
-  void setParmData(Solver* solver);
+      // Read all Prediffer inputs and set solvable parameter data.
+      void setParmData(Solver* solver);
+
+      // Number of Prediffer inputs
+      int         itsNPrediffers;
+
+      // Write individual parameter solutions in a separate table?
+      bool        itsWriteIndivParms;
+
+      // Map of Solver objects, each associated with a strategy (controller).
+      SolverMap   itsSolvers;
+
+      // Individual parameters table name
+      string      itsParmTableName;
+    };
 
-  int         itsNPrediffers;     // Number of Prediffer inputs
-  bool        itsWriteIndivParms; // Write individual parameter solutions in a separate table?
-  SolverMap   itsSolvers;         // Map of Solver objects, each associated
-                                  // with a strategy (controller).
-  string      itsParmTableName;   // Individual parameters table name
-};
+    // @}
 
-// @}
+  } // namespace BBS
 
 } // namespace LOFAR
 
diff --git a/CEP/BB/BBSControl/src/BBS.cc b/CEP/BB/BBSControl/src/BBS.cc
index 55f3bd2375c612bad1cea0d83e8dfb06bed62914..0ba23f3ea11cced48189e53cebc72bc160d3ad18 100644
--- a/CEP/BB/BBSControl/src/BBS.cc
+++ b/CEP/BB/BBSControl/src/BBS.cc
@@ -1,24 +1,24 @@
-//  BBS.cc:
-//
-//  Copyright (C) 2004
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
+//#  BBS.cc:
+//#
+//#  Copyright (C) 2004
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
@@ -46,6 +46,7 @@
 #include <casa/Quanta/MVTime.h>
 
 using namespace LOFAR;
+using namespace LOFAR::BBS;
 using namespace casa;
 
 // This program should be called with input file name(1) and user name(2) as
diff --git a/CEP/BB/BBSControl/src/BBSMultiStep.cc b/CEP/BB/BBSControl/src/BBSMultiStep.cc
index db448e75315d89622849e2f56dbe00866f5ee723..0384b6a5553cbdbdd07683ca096753723cd80bc1 100644
--- a/CEP/BB/BBSControl/src/BBSMultiStep.cc
+++ b/CEP/BB/BBSControl/src/BBSMultiStep.cc
@@ -46,6 +46,13 @@ namespace LOFAR
 
       // Create a new step for each name in \a steps.
       for (uint i = 0; i < steps.size(); ++i) {
+	// Should add something like BBSStep::infiniteRecursionCheck(name),
+	// which checks, RECURSIVELY, if steps[i] may be used for the step to
+	// be created.
+// 	ASSERTSTR(name != steps[i], 
+// 		  "Infinite recursion detected in BBSStep definition! "
+// 		  "Please check your ParameterSet file");
+	infiniteRecursionCheck(steps[i]);
 	itsSteps.push_back(BBSStep::create(steps[i], parset, this));
       }
     }
diff --git a/CEP/BB/BBSControl/src/BBSStep.cc b/CEP/BB/BBSControl/src/BBSStep.cc
index d63f66b3a860b8e931aac190f2bd8915e2e39b51..bb619de08d4ec110faabb817e6844f1055617031 100644
--- a/CEP/BB/BBSControl/src/BBSStep.cc
+++ b/CEP/BB/BBSControl/src/BBSStep.cc
@@ -130,6 +130,17 @@ namespace LOFAR
     }
 
 
+    void BBSStep::infiniteRecursionCheck(const string& name) const
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+      if (name == itsName) 
+	THROW (BBSControlException, 
+	       "Infinite recursion detected in defintion of BBSStep \""
+	       << name << "\". Please check your ParameterSet file.");
+      if (itsParent) itsParent->infiniteRecursionCheck(name);
+    }
+
+
     //##--------   P r i v a t e   m e t h o d s   --------##//
 
     void BBSStep::setParms(const ParameterSet& ps)
diff --git a/CEP/BB/BBSControl/src/BlackBoardDemo.cc b/CEP/BB/BBSControl/src/BlackBoardDemo.cc
index 4c83fcde371d3855592295689db11d9f0f3368e0..1e15006a98dd5f12d00d2b6874b11388a90d30ad 100644
--- a/CEP/BB/BBSControl/src/BlackBoardDemo.cc
+++ b/CEP/BB/BBSControl/src/BlackBoardDemo.cc
@@ -1,33 +1,30 @@
-//  BlackBoardDemo.cc: A blackboard simulator class
-//
-//  Copyright (C) 2000, 2002
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////////
+//#  BlackBoardDemo.cc: A blackboard simulator class
+//#
+//#  Copyright (C) 2000, 2002
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
-#include <stdio.h>
+#include <cstdio>
+#include <cstdlib>
 #include <Common/lofar_iostream.h>
-#include <stdlib.h>
 #include <Common/lofar_string.h>
 
 #include <APS/ParameterSet.h>
@@ -40,167 +37,168 @@
 #include <BBSControl/WH_Control.h>
 #include <BBSControl/WH_Prediff.h>
 #include <BBSControl/WH_Solve.h>
+#include <Common/lofar_sstream.h>
 
 #ifdef HAVE_MPI
-#include <Transport/TH_MPI.h>
+# include <Transport/TH_MPI.h>
 #endif
 
 namespace LOFAR
 {
-
-string i2string(int i) {
-  char str[32];
-  sprintf(str, "%i", i);
-  return string(str);
-}
-
-BlackBoardDemo::BlackBoardDemo()
-  : itsPDSteps(0),
-    itsNumberPD(0)
-{
-  LOG_TRACE_FLOW(">>>>>>>> BlackBoardDemo constructor <<<<<<<<<<");
-}
-
-BlackBoardDemo::~BlackBoardDemo()
-{
-  LOG_TRACE_FLOW(">>>>>>>> BlackBoardDemo destructor <<<<<<<<<<");
-  undefine();
-}
-
-/**
-   Define function for the BlackBoardDemo simulation. It defines the steps that 
-   process part of the data.
- */
-void BlackBoardDemo::define(const KeyValueMap&)
-{
-  // Free any memory previously allocated
-  undefine();
-
-  // Create the top-level Composite
-  Composite topComposite(0, 0,"BlackBoardDemo");
-  setComposite(topComposite);
-
-  // Set node and application number of Simul
-  topComposite.runOnNode(0,0);
-  topComposite.setCurAppl(0);
-
-  // Get control properties
-  ACC::APS::ParameterSet ctrlParams = itsParamSet.makeSubset("CTRLparams.");
-
-  int itsNumberPD = itsParamSet.getInt32("nrPrediffers");
-  string bbDBName = itsParamSet.getString("BBDBname");
-  bool writeIndivParms = false;
-  if (itsParamSet.isDefined("writeIndividualParms"))
-  {
-    writeIndivParms = itsParamSet.getBool("writeIndividualParms");
-  }
-
-  TH_Postgresql::useDatabase("dop50.astron.nl", bbDBName, "postgres");
-
-  // Create the controller WorkHolder and Step
-  WH_Control controlWH("control", itsNumberPD, ctrlParams);
-  Step controlStep(controlWH, "controlStep");
-  controlStep.runOnNode(0,0);
-  topComposite.addBlock(controlStep);
-
-  // Create the Prediffers
-  itsPDSteps = new Step*[itsNumberPD];
-  string pdID;
-  for (int pdNo=1; pdNo<=itsNumberPD; pdNo++)
-  { 
-    // Create the Workholders and Steps
-    pdID = i2string(pdNo);
-
-    WH_Prediff predWH("Prediff"+pdID, pdID, ctrlParams);
-
-    int index = pdNo - 1;
-    itsPDSteps[index] = new Step(predWH, "prediffer"+pdID);
-    itsPDSteps[index]->runOnNode(pdNo,0);
-    topComposite.addBlock(itsPDSteps[index]);
-  }
-
-  string parmTableName("bbs3ParmSolutions");
-  if (itsParamSet.isDefined("parmSolutionTable"))
+  namespace BBS
   {
-    parmTableName = itsParamSet.getString("parmSolutionTable");
-  }
+
+    using ACC::APS::ParameterSet;
+
+    BlackBoardDemo::BlackBoardDemo()
+      : itsPDSteps(0),
+	itsNumberPD(0)
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+    }
+
+    BlackBoardDemo::~BlackBoardDemo()
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+      undefine();
+    }
+
+    // Define function for the BlackBoardDemo simulation. It defines the steps
+    // that process part of the data.
+    void BlackBoardDemo::define(const KeyValueMap&)
+    {
+      // Free any memory previously allocated
+      undefine();
+
+      // Create the top-level Composite
+      Composite topComposite(0, 0,"BlackBoardDemo");
+      setComposite(topComposite);
+
+      // Set node and application number of Simul
+      topComposite.runOnNode(0,0);
+      topComposite.setCurAppl(0);
+
+      // Get control properties
+      ParameterSet ctrlParams = itsParamSet.makeSubset("CTRLparams.");
+
+      int itsNumberPD = itsParamSet.getInt32("nrPrediffers");
+      string bbDBName = itsParamSet.getString("BBDBname");
+      bool writeIndivParms = false;
+      if (itsParamSet.isDefined("writeIndividualParms"))
+      {
+	writeIndivParms = itsParamSet.getBool("writeIndividualParms");
+      }
+
+      TH_Postgresql::useDatabase("dop50.astron.nl", bbDBName, "postgres");
+
+      // Create the controller WorkHolder and Step
+      WH_Control controlWH("control", itsNumberPD, ctrlParams);
+      Step controlStep(controlWH, "controlStep");
+      controlStep.runOnNode(0,0);
+      topComposite.addBlock(controlStep);
+
+      // Create the Prediffers
+      itsPDSteps = new Step*[itsNumberPD];
+      string pdID;
+      for (int pdNo=1; pdNo<=itsNumberPD; pdNo++)
+      { 
+	// Create the Workholders and Steps
+	ostringstream oss;
+	oss << pdNo;
+	pdID = oss.str();
+
+	WH_Prediff predWH("Prediff"+pdID, pdID, ctrlParams);
+
+	int index = pdNo - 1;
+	itsPDSteps[index] = new Step(predWH, "prediffer"+pdID);
+	itsPDSteps[index]->runOnNode(pdNo,0);
+	topComposite.addBlock(itsPDSteps[index]);
+      }
+
+      string parmTableName("bbs3ParmSolutions");
+      if (itsParamSet.isDefined("parmSolutionTable"))
+      {
+	parmTableName = itsParamSet.getString("parmSolutionTable");
+      }
   
-  // Create the Solver
-  WH_Solve solveWH("Solver", itsNumberPD, writeIndivParms, parmTableName);
-  Step solverStep(solveWH, "solverStep");
-  solverStep.runOnNode(itsNumberPD+1,0);
-  topComposite.addBlock(solverStep);
-
-  // All DataHolders connected to a database table are connected to their 
-  // dummy equivalent in the same WorkHolder. In this way the number of 
-  // writing DataHolders remains independent of the number of reading 
-  // DataHolders also connected to the same table. (However, this introduces
-  // some overhead in the preprocess phase)
-
-  // Create the connections to the database (themselves).
-  controlStep.connect(0, &controlStep, 0, 1, new TH_Postgresql());
-  controlStep.connect(1, &controlStep, 1, 1, new TH_Postgresql());
-  controlStep.connect(2, &controlStep, 2, 1, new TH_Postgresql());
-
-  // Same for Solver
-  solverStep.connect(0, &solverStep, 0, 1, new TH_Postgresql());
-  solverStep.connect(1, &solverStep, 1, 1, new TH_Postgresql());
-
-  for (int index = 0; index < itsNumberPD; index++)
-  {
-    // Create the connection to the database.
-    itsPDSteps[index]->connect(0, itsPDSteps[index], 0, 1, new TH_Postgresql());
-    itsPDSteps[index]->connect(1, itsPDSteps[index], 1, 1, new TH_Postgresql());
-    // Create the connection to the Solver
+      // Create the Solver
+      WH_Solve solveWH("Solver", itsNumberPD, writeIndivParms, parmTableName);
+      Step solverStep(solveWH, "solverStep");
+      solverStep.runOnNode(itsNumberPD+1,0);
+      topComposite.addBlock(solverStep);
+
+      // All DataHolders connected to a database table are connected to their 
+      // dummy equivalent in the same WorkHolder. In this way the number of 
+      // writing DataHolders remains independent of the number of reading 
+      // DataHolders also connected to the same table. (However, this introduces
+      // some overhead in the preprocess phase)
+
+      // Create the connections to the database (themselves).
+      controlStep.connect(0, &controlStep, 0, 1, new TH_Postgresql());
+      controlStep.connect(1, &controlStep, 1, 1, new TH_Postgresql());
+      controlStep.connect(2, &controlStep, 2, 1, new TH_Postgresql());
+
+      // Same for Solver
+      solverStep.connect(0, &solverStep, 0, 1, new TH_Postgresql());
+      solverStep.connect(1, &solverStep, 1, 1, new TH_Postgresql());
+
+      for (int index = 0; index < itsNumberPD; index++)
+      {
+	// Create the connection to the database.
+	itsPDSteps[index]->connect(0, itsPDSteps[index], 0, 1, new TH_Postgresql());
+	itsPDSteps[index]->connect(1, itsPDSteps[index], 1, 1, new TH_Postgresql());
+	// Create the connection to the Solver
 #ifdef HAVE_MPI
-    solverStep.connect(index+2, itsPDSteps[index], 2, 1, new TH_MPI(index+1,itsNumberPD+1)); 
+	solverStep.connect(index+2, itsPDSteps[index], 2, 1, new TH_MPI(index+1,itsNumberPD+1)); 
 #else
-    solverStep.connect(index+2, itsPDSteps[index], 2, 1, new TH_Mem(), false);   
+	solverStep.connect(index+2, itsPDSteps[index], 2, 1, new TH_Mem(), false);   
 #endif
-  }
-
-}  
-
-void BlackBoardDemo::run(int nSteps) {
-  LOG_TRACE_FLOW("Call run()");
-  Profiler::init();
-  Step::clearEventCount();
-
-  LOG_TRACE_RTTI("Start Processing simul");    
-  for (int i=0; i<nSteps; i++) {
-    if (i==2) Profiler::activate();
-    LOG_TRACE_RTTI("Call simul.process() ");
-    cout << "Run " << i << "/" << nSteps << endl;
-    getComposite().process();
-    if (i==5) Profiler::deActivate();
-  }
-
-  LOG_TRACE_RTTI_STR("END OF BLACKBOARDDEMO on node " 
-		     << TRANSPORTER::getCurrentRank () );
+      }
+
+    }  
+
+    void BlackBoardDemo::run(int nSteps) {
+      LOG_TRACE_FLOW("Call run()");
+      Profiler::init();
+      Step::clearEventCount();
+
+      LOG_TRACE_RTTI("Start Processing simul");    
+      for (int i=0; i<nSteps; i++) {
+	if (i==2) Profiler::activate();
+	LOG_TRACE_RTTI("Call simul.process() ");
+	cout << "Run " << i << "/" << nSteps << endl;
+	getComposite().process();
+	if (i==5) Profiler::deActivate();
+      }
+
+      LOG_TRACE_RTTI_STR("END OF BLACKBOARDDEMO on node " 
+			 << TRANSPORTER::getCurrentRank () );
  
 #if 0
-  //     close environment
-  TRANSPORTER::finalize();
+      //     close environment
+      TRANSPORTER::finalize();
 #endif
 
-}
+    }
+
+    void BlackBoardDemo::dump() const {
+      getComposite().dump();
+    }
 
-void BlackBoardDemo::dump() const {
-  getComposite().dump();
-}
+    void BlackBoardDemo::quit() {  
+    }
 
-void BlackBoardDemo::quit() {  
-}
+    void BlackBoardDemo::undefine() {
+      LOG_TRACE_FLOW("Enter BlackBoardDemo::undefine");
+      if (itsPDSteps) 
+	for (int iStep = 0; iStep < itsNumberPD; iStep++) 
+	  delete itsPDSteps[iStep];
+      delete [] itsPDSteps;
 
-void BlackBoardDemo::undefine() {
-  LOG_TRACE_FLOW("Enter BlackBoardDemo::undefine");
-  if (itsPDSteps) 
-    for (int iStep = 0; iStep < itsNumberPD; iStep++) 
-      delete itsPDSteps[iStep];
-  delete [] itsPDSteps;
+      LOG_TRACE_FLOW("Leaving BlackBoardDemo::undefine");
+    }
 
-  LOG_TRACE_FLOW("Leaving BlackBoardDemo::undefine");
-}
 
+  } // namespace BBS
 
-} // end namespace LOFAR
+} // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/DH_Prediff.cc b/CEP/BB/BBSControl/src/DH_Prediff.cc
index 8bc7c061629d55699699c5b984da5bf8f3118212..f47cd9d3491a079dd97d1b12a433c04d2fd5ebea 100644
--- a/CEP/BB/BBSControl/src/DH_Prediff.cc
+++ b/CEP/BB/BBSControl/src/DH_Prediff.cc
@@ -1,27 +1,24 @@
-//  DH_Prediff.cc:
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  DH_Prediff.cc:
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
@@ -41,165 +38,170 @@ using namespace casa;
 
 namespace LOFAR
 {
+  namespace BBS
+  {
+
+    DH_Prediff::DH_Prediff (const string& name)
+      : DataHolder    (name, "DH_Prediff", 1),
+	itsDataSize   (0),
+	itsDataBuffer (0),
+	itsStartFreq  (0),
+	itsEndFreq    (0),
+	itsStartTime  (0),
+	itsEndTime    (0)
+    {
+      LOG_TRACE_FLOW("DH_Prediff constructor");
+      setExtraBlob("Extra", 1);
+    }
 
-DH_Prediff::DH_Prediff (const string& name)
-  : DataHolder    (name, "DH_Prediff", 1),
-    itsDataSize   (0),
-    itsDataBuffer (0),
-    itsStartFreq  (0),
-    itsEndFreq    (0),
-    itsStartTime  (0),
-    itsEndTime    (0)
-{
-  LOG_TRACE_FLOW("DH_Prediff constructor");
-  setExtraBlob("Extra", 1);
-}
-
-DH_Prediff::DH_Prediff(const DH_Prediff& that)
-  : DataHolder    (that),
-    itsDataSize   (0),
-    itsDataBuffer (0),
-    itsStartFreq  (0),
-    itsEndFreq    (0),
-    itsStartTime  (0),
-    itsEndTime    (0)
-{
-  LOG_TRACE_FLOW("DH_Prediff copy constructor");
-  setExtraBlob("Extra", 1);
-}
+    DH_Prediff::DH_Prediff(const DH_Prediff& that)
+      : DataHolder    (that),
+	itsDataSize   (0),
+	itsDataBuffer (0),
+	itsStartFreq  (0),
+	itsEndFreq    (0),
+	itsStartTime  (0),
+	itsEndTime    (0)
+    {
+      LOG_TRACE_FLOW("DH_Prediff copy constructor");
+      setExtraBlob("Extra", 1);
+    }
 
-DH_Prediff::~DH_Prediff()
-{
-  LOG_TRACE_FLOW("DH_Prediff destructor");
-}
+    DH_Prediff::~DH_Prediff()
+    {
+      LOG_TRACE_FLOW("DH_Prediff destructor");
+    }
 
-DataHolder* DH_Prediff::clone() const
-{
-  return new DH_Prediff(*this);
-}
+    DataHolder* DH_Prediff::clone() const
+    {
+      return new DH_Prediff(*this);
+    }
 
-void DH_Prediff::init()
-{
-  LOG_TRACE_FLOW("DH_Prediff preprocess");
-  // Add the fields to the data definition.
-  addField ("DataSize", BlobField<unsigned int>(1));
-  addField ("StartFreq", BlobField<double>(1));
-  addField ("EndFreq", BlobField<double>(1));
-  addField ("StartTime", BlobField<double>(1));
-  addField ("EndTime", BlobField<double>(1));
-  addField ("DataBuf", BlobField<double>(1, 0u));
-
-  // Create the data blob (which calls fillPointers).
-  createDataBlock();
-
-  *itsDataSize = 0;
-  *itsStartFreq = 0;
-  *itsEndFreq = 0;
-  *itsStartTime = 0;
-  *itsEndTime = 0;
-}
-
-void DH_Prediff::fillDataPointers()
-{
-  // Fill in the pointers.
-  itsDataSize = getData<unsigned int> ("DataSize");
-  itsDataBuffer = getData<double> ("DataBuf");
-  itsStartFreq = getData<double> ("StartFreq");
-  itsEndFreq = getData<double> ("EndFreq");
-  itsStartTime = getData<double> ("StartTime");
-  itsEndTime = getData<double> ("EndTime");
-}
-
-bool DH_Prediff::getParmData (ParmDataInfo& pdata)
-{ 
-  bool found;
-  int version;
-  BlobIStream& bis = getExtraBlob (found, version);
-  if (found) {
-    bis >> pdata;
-  }
-  return found;
-}
-
-void DH_Prediff::setParmData (const ParmDataInfo& pdata)
-{
-  BlobOStream& bos = createExtraBlob();
-  bos << pdata;
-}
+    void DH_Prediff::init()
+    {
+      LOG_TRACE_FLOW("DH_Prediff preprocess");
+      // Add the fields to the data definition.
+      addField ("DataSize", BlobField<unsigned int>(1));
+      addField ("StartFreq", BlobField<double>(1));
+      addField ("EndFreq", BlobField<double>(1));
+      addField ("StartTime", BlobField<double>(1));
+      addField ("EndTime", BlobField<double>(1));
+      addField ("DataBuf", BlobField<double>(1, 0u));
+
+      // Create the data blob (which calls fillPointers).
+      createDataBlock();
+
+      *itsDataSize = 0;
+      *itsStartFreq = 0;
+      *itsEndFreq = 0;
+      *itsStartTime = 0;
+      *itsEndTime = 0;
+    }
 
-void DH_Prediff::setFitters (const vector<LSQFit>& fitters)
-{
-  BlobOStream& bos = createExtraBlob();
-  BlobAipsIO bio(bos);
-  casa::AipsIO aio(&bio);
-  aio.putstart ("fitters", 1);
-  aio << static_cast<uInt>(fitters.size());
-  for (uint i=0; i<fitters.size(); ++i) {
-    fitters[i].toAipsIO (aio);
-  }
-  aio.putend();
-}
-
-bool DH_Prediff::getFitters (vector<LSQFit>& fitters)
-{
-  bool found;
-  int version;
-  BlobIStream& bis = getExtraBlob (found, version);
-  if (found) {
-    BlobAipsIO bio(bis);
-    casa::AipsIO aio(&bio);
-    aio.getstart ("fitters");
-    uInt sz;
-    aio >> sz;
-    fitters.resize (sz);
-    for (uint i=0; i<sz; ++i) {
-      fitters[i].fromAipsIO (aio);
+    void DH_Prediff::fillDataPointers()
+    {
+      // Fill in the pointers.
+      itsDataSize = getData<unsigned int> ("DataSize");
+      itsDataBuffer = getData<double> ("DataBuf");
+      itsStartFreq = getData<double> ("StartFreq");
+      itsEndFreq = getData<double> ("EndFreq");
+      itsStartTime = getData<double> ("StartTime");
+      itsEndTime = getData<double> ("EndTime");
     }
-    aio.getend();
-  }
-  return found;
-}
 
-void DH_Prediff::setBufferSize (int size)
-{
-  vector<uint32> shp(1);
-  shp[0] = size;
-  getDataField("DataBuf").setShape(shp);
-  createDataBlock();
-}
+    bool DH_Prediff::getParmData (ParmDataInfo& pdata)
+    { 
+      bool found;
+      int version;
+      BlobIStream& bis = getExtraBlob (found, version);
+      if (found) {
+	bis >> pdata;
+      }
+      return found;
+    }
 
-int DH_Prediff::getBufferSize()
-{
-  return getDataField("DataBuf").getShape()[0];
-}
+    void DH_Prediff::setParmData (const ParmDataInfo& pdata)
+    {
+      BlobOStream& bos = createExtraBlob();
+      bos << pdata;
+    }
 
-void DH_Prediff::setDomain(double fStart, double fEnd, double tStart, double tEnd)
-{
-  *itsStartFreq = fStart;
-  *itsEndFreq = fEnd;
-  *itsStartTime = tStart;
-  *itsEndTime = tEnd;
-}
+    void DH_Prediff::setFitters (const vector<LSQFit>& fitters)
+    {
+      BlobOStream& bos = createExtraBlob();
+      BlobAipsIO bio(bos);
+      casa::AipsIO aio(&bio);
+      aio.putstart ("fitters", 1);
+      aio << static_cast<uInt>(fitters.size());
+      for (uint i=0; i<fitters.size(); ++i) {
+	fitters[i].toAipsIO (aio);
+      }
+      aio.putend();
+    }
 
-void DH_Prediff::dump() const
-{
-  cout << "DH_Prediff: " << endl;
-  cout << "Parm data : " << endl;
-  cout << "Start frequency = " << getStartFreq() << endl;
-  cout << "End frequency = " << getEndFreq() << endl;
-  cout << "Start time = " << getStartTime() << endl;
-  cout << "End time = " << getEndTime() << endl;
-  ParmDataInfo pData;
-  if (const_cast<DH_Prediff*>(this)->getParmData(pData)) {
-    cout << pData << endl;
-  }
-}
-
-void DH_Prediff::clearData()
-{
-  // Kludge to get around fact that temporaries must be copy constructable
-  ParmDataInfo dummy;
-  setParmData (dummy);
-}
+    bool DH_Prediff::getFitters (vector<LSQFit>& fitters)
+    {
+      bool found;
+      int version;
+      BlobIStream& bis = getExtraBlob (found, version);
+      if (found) {
+	BlobAipsIO bio(bis);
+	casa::AipsIO aio(&bio);
+	aio.getstart ("fitters");
+	uInt sz;
+	aio >> sz;
+	fitters.resize (sz);
+	for (uint i=0; i<sz; ++i) {
+	  fitters[i].fromAipsIO (aio);
+	}
+	aio.getend();
+      }
+      return found;
+    }
+
+    void DH_Prediff::setBufferSize (int size)
+    {
+      vector<uint32> shp(1);
+      shp[0] = size;
+      getDataField("DataBuf").setShape(shp);
+      createDataBlock();
+    }
+
+    int DH_Prediff::getBufferSize()
+    {
+      return getDataField("DataBuf").getShape()[0];
+    }
+
+    void DH_Prediff::setDomain(double fStart, double fEnd, 
+			       double tStart, double tEnd)
+    {
+      *itsStartFreq = fStart;
+      *itsEndFreq = fEnd;
+      *itsStartTime = tStart;
+      *itsEndTime = tEnd;
+    }
+
+    void DH_Prediff::dump() const
+    {
+      cout << "DH_Prediff: " << endl;
+      cout << "Parm data : " << endl;
+      cout << "Start frequency = " << getStartFreq() << endl;
+      cout << "End frequency = " << getEndFreq() << endl;
+      cout << "Start time = " << getStartTime() << endl;
+      cout << "End time = " << getEndTime() << endl;
+      ParmDataInfo pData;
+      if (const_cast<DH_Prediff*>(this)->getParmData(pData)) {
+	cout << pData << endl;
+      }
+    }
+
+    void DH_Prediff::clearData()
+    {
+      // Kludge to get around fact that temporaries must be copy constructable
+      ParmDataInfo dummy;
+      setParmData (dummy);
+    }
+
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/DH_Solution.cc b/CEP/BB/BBSControl/src/DH_Solution.cc
index d048b5fa6b716872bc62f6a3e03b92e20f7863a9..3880c0f3c7406e347e38b3d2ec0dd6c831a0805e 100644
--- a/CEP/BB/BBSControl/src/DH_Solution.cc
+++ b/CEP/BB/BBSControl/src/DH_Solution.cc
@@ -1,27 +1,24 @@
-//  DH_Solution.cc:
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  DH_Solution.cc:
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
@@ -34,260 +31,268 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
+    // Number of digits to be used when printing floating point numbers.
+    const uint precision = 20;
 
-#define PRECISION 20
-
-const unsigned int MaxNumberOfParam = 32;  // These need NOT be the same as in DH_WorkOrder
-const unsigned int MaxParamNameLength = 16;
+    // These need NOT be the same as in DH_WorkOrder
+    const uint MaxNumberOfParam = 32;
+    const uint MaxParamNameLength = 16;
 
-DH_Solution::DH_Solution (const string& name, bool writeIndivParms,
-			  const string& parmTableName)
-  : DH_DB             (name, "DH_Solution", 1),
-    itsWOID           (0),
-    itsIteration      (0),
-    itsFit            (0),
-    //    itsRank         (0),
-    itsMu             (0),
-    itsStdDev         (0),
-    itsChi            (0),
-    itsStartFreq      (0),
-    itsEndFreq        (0),
-    itsStartTime      (0),
-    itsEndTime        (0),
-    itsHasConverged   (0),
-    itsWriteIndivParms(writeIndivParms),
-    itsParmTableName  (parmTableName)
-{
-  setExtraBlob("Extra", 1);
-}
+    DH_Solution::DH_Solution (const string& name, bool writeIndivParms,
+			      const string& parmTableName)
+      : DH_DB             (name, "DH_Solution", 1),
+	itsWOID           (0),
+	itsIteration      (0),
+	itsFit            (0),
+	//    itsRank         (0),
+	itsMu             (0),
+	itsStdDev         (0),
+	itsChi            (0),
+	itsStartFreq      (0),
+	itsEndFreq        (0),
+	itsStartTime      (0),
+	itsEndTime        (0),
+	itsHasConverged   (0),
+	itsWriteIndivParms(writeIndivParms),
+	itsParmTableName  (parmTableName)
+    {
+      setExtraBlob("Extra", 1);
+    }
 
-DH_Solution::DH_Solution(const DH_Solution& that)
-  : DH_DB             (that),
-    itsWOID           (0),
-    itsIteration      (0),
-    itsFit            (0),
-    //    itsRank         (0),
-    itsMu             (0),
-    itsStdDev         (0),
-    itsChi            (0),
-    itsStartFreq      (0),
-    itsEndFreq        (0),
-    itsStartTime      (0),
-    itsEndTime        (0),
-    itsHasConverged   (0),
-    itsWriteIndivParms(that.itsWriteIndivParms),
-    itsParmTableName  (that.itsParmTableName)
-{
-  setExtraBlob("Extra", 1);
-}
+    DH_Solution::DH_Solution(const DH_Solution& that)
+      : DH_DB             (that),
+	itsWOID           (0),
+	itsIteration      (0),
+	itsFit            (0),
+	//    itsRank         (0),
+	itsMu             (0),
+	itsStdDev         (0),
+	itsChi            (0),
+	itsStartFreq      (0),
+	itsEndFreq        (0),
+	itsStartTime      (0),
+	itsEndTime        (0),
+	itsHasConverged   (0),
+	itsWriteIndivParms(that.itsWriteIndivParms),
+	itsParmTableName  (that.itsParmTableName)
+    {
+      setExtraBlob("Extra", 1);
+    }
 
-DH_Solution::~DH_Solution()
-{
-}
+    DH_Solution::~DH_Solution()
+    {
+    }
 
-DataHolder* DH_Solution::clone() const
-{
-  return new DH_Solution(*this);
-}
+    DataHolder* DH_Solution::clone() const
+    {
+      return new DH_Solution(*this);
+    }
 
-void DH_Solution::init()
-{
-  // Add the fields to the data definition.
-  addField ("WOID", BlobField<int>(1));
-  addField ("Iteration", BlobField<int>(1));
-  addField ("Fit", BlobField<double>(1));
-  //  addField ("Rank", BlobField<int>(1));
-  addField ("Mu", BlobField<double>(1));
-  addField ("StdDev", BlobField<double>(1));
-  addField ("Chi", BlobField<double>(1));
-  addField ("StartFreq", BlobField<double>(1));
-  addField ("EndFreq", BlobField<double>(1));
-  addField ("StartTime", BlobField<double>(1));
-  addField ("EndTime", BlobField<double>(1));
-  addField ("HasConverged", BlobField<unsigned int>(1));
+    void DH_Solution::init()
+    {
+      // Add the fields to the data definition.
+      addField ("WOID", BlobField<int>(1));
+      addField ("Iteration", BlobField<int>(1));
+      addField ("Fit", BlobField<double>(1));
+      //  addField ("Rank", BlobField<int>(1));
+      addField ("Mu", BlobField<double>(1));
+      addField ("StdDev", BlobField<double>(1));
+      addField ("Chi", BlobField<double>(1));
+      addField ("StartFreq", BlobField<double>(1));
+      addField ("EndFreq", BlobField<double>(1));
+      addField ("StartTime", BlobField<double>(1));
+      addField ("EndTime", BlobField<double>(1));
+      addField ("HasConverged", BlobField<unsigned int>(1));
 
-  // Create the data blob (which calls fillPointers).
-  createDataBlock();
+      // Create the data blob (which calls fillPointers).
+      createDataBlock();
 
-  *itsWOID = -1;
-  *itsIteration = -1;
-  *itsFit = 0;
-  //  *itsRank = 0;
-  *itsMu = 0;
-  *itsStdDev =0;
-  *itsChi = 0;
-  *itsStartFreq = 0;
-  *itsEndFreq = 0;
-  *itsStartTime = 0;
-  *itsEndTime = 0;
-  *itsHasConverged = 0;
-}
+      *itsWOID = -1;
+      *itsIteration = -1;
+      *itsFit = 0;
+      //  *itsRank = 0;
+      *itsMu = 0;
+      *itsStdDev =0;
+      *itsChi = 0;
+      *itsStartFreq = 0;
+      *itsEndFreq = 0;
+      *itsStartTime = 0;
+      *itsEndTime = 0;
+      *itsHasConverged = 0;
+    }
 
-void DH_Solution::fillDataPointers()
-{
- // Fill in the pointers.
-  itsWOID = getData<int> ("WOID");
-  itsIteration = getData<int> ("Iteration");
-  itsFit = getData<double> ("Fit");
-  //  itsRank = getData<int> ("Rank");
-  itsMu = getData<double> ("Mu");
-  itsStdDev = getData<double> ("StdDev");
-  itsChi = getData<double> ("Chi");
-  itsStartFreq = getData<double> ("StartFreq");
-  itsEndFreq = getData<double> ("EndFreq");
-  itsStartTime = getData<double> ("StartTime");
-  itsEndTime = getData<double> ("EndTime");
-  itsHasConverged = getData<unsigned int> ("HasConverged");
-}
+    void DH_Solution::fillDataPointers()
+    {
+      // Fill in the pointers.
+      itsWOID = getData<int> ("WOID");
+      itsIteration = getData<int> ("Iteration");
+      itsFit = getData<double> ("Fit");
+      //  itsRank = getData<int> ("Rank");
+      itsMu = getData<double> ("Mu");
+      itsStdDev = getData<double> ("StdDev");
+      itsChi = getData<double> ("Chi");
+      itsStartFreq = getData<double> ("StartFreq");
+      itsEndFreq = getData<double> ("EndFreq");
+      itsStartTime = getData<double> ("StartTime");
+      itsEndTime = getData<double> ("EndTime");
+      itsHasConverged = getData<unsigned int> ("HasConverged");
+    }
 
-Quality DH_Solution::getQuality() const
-{
-  Quality qual;
-  qual.itsFit = *itsFit;
-  //  qual.itsRank = *itsRank;
-  qual.itsMu = *itsMu;
-  qual.itsStddev = *itsStdDev;
-  qual.itsChi = *itsChi;
-  return qual;
-}
+    Quality DH_Solution::getQuality() const
+    {
+      Quality qual;
+      qual.itsFit = *itsFit;
+      //  qual.itsRank = *itsRank;
+      qual.itsMu = *itsMu;
+      qual.itsStddev = *itsStdDev;
+      qual.itsChi = *itsChi;
+      return qual;
+    }
 
-void DH_Solution::setQuality(const Quality& quality)
-{
-  *itsFit = quality.itsFit;
-  //  *itsRank = quality.itsRank;
-  *itsMu = quality.itsMu;
-  *itsStdDev = quality.itsStddev;
-  *itsChi = quality.itsChi;
-}
+    void DH_Solution::setQuality(const Quality& quality)
+    {
+      *itsFit = quality.itsFit;
+      //  *itsRank = quality.itsRank;
+      *itsMu = quality.itsMu;
+      *itsStdDev = quality.itsStddev;
+      *itsChi = quality.itsChi;
+    }
 
-bool DH_Solution::getSolution(ParmDataInfo& pData)
-{
-  bool found;
-  int version;
-  BlobIStream& bis = getExtraBlob(found, version);
-  if (found) {
-    bis >> pData;
-  }
-  return found;
-}
+    bool DH_Solution::getSolution(ParmDataInfo& pData)
+    {
+      bool found;
+      int version;
+      BlobIStream& bis = getExtraBlob(found, version);
+      if (found) {
+	bis >> pData;
+      }
+      return found;
+    }
 
-void DH_Solution::setSolution(const ParmDataInfo& pData)
-{
-  BlobOStream& bos = createExtraBlob();
-  bos << pData;
-}
+    void DH_Solution::setSolution(const ParmDataInfo& pData)
+    {
+      BlobOStream& bos = createExtraBlob();
+      bos << pData;
+    }
 
-void DH_Solution::setDomain(double fStart, double fEnd, double tStart, double tEnd)
-{
-  *itsStartFreq = fStart;
-  *itsEndFreq = fEnd;
-  *itsStartTime = tStart;
-  *itsEndTime = tEnd;
-}
+    void DH_Solution::setDomain(double fStart, double fEnd, 
+				double tStart, double tEnd)
+    {
+      *itsStartFreq = fStart;
+      *itsEndFreq = fEnd;
+      *itsStartTime = tStart;
+      *itsEndTime = tEnd;
+    }
 
 
-void DH_Solution::clearData()
-{
-  setWorkOrderID(-1);
-  setIteration(-1);
-  Quality q;
-  setQuality(q);
-  clearExtraBlob();
-  setDomain(0, 0, 0, 0);
-}
+    void DH_Solution::clearData()
+    {
+      setWorkOrderID(-1);
+      setIteration(-1);
+      Quality q;
+      setQuality(q);
+      clearExtraBlob();
+      setDomain(0, 0, 0, 0);
+    }
 
-void DH_Solution::dump() const
-{
-  ParmDataInfo pData;
-  const_cast<DH_Solution*>(this)->getSolution(pData);
+    void DH_Solution::dump() const
+    {
+      ParmDataInfo pData;
+      const_cast<DH_Solution*>(this)->getSolution(pData);
   
-  cout << "Workorder id = " << getWorkOrderID() << endl;
-  cout << "Iteration = " << getIteration() << endl;
-  cout << "Parm data : " << endl;
-  cout << pData << endl;
+      cout << "Workorder id = " << getWorkOrderID() << endl;
+      cout << "Iteration = " << getIteration() << endl;
+      cout << "Parm data : " << endl;
+      cout << pData << endl;
 
-  cout << "Quality = " << getQuality() << endl;
+      cout << "Quality = " << getQuality() << endl;
 
-  cout << "Start frequency = " << getStartFreq() << endl;
-  cout << "End frequency = " << getEndFreq() << endl;
-  cout << "Start time = " << getStartTime() << endl;
-  cout << "End time = " << getEndTime() << endl;
+      cout << "Start frequency = " << getStartFreq() << endl;
+      cout << "End frequency = " << getEndFreq() << endl;
+      cout << "Start time = " << getStartTime() << endl;
+      cout << "End time = " << getEndTime() << endl;
 
-}
+    }
 
-string DH_Solution::createInsertStatement(TH_DB* th)
-{
-  ostringstream q;
-  q.precision(PRECISION);
-  if (itsWriteIndivParms) // Store parameters individually in a subtable
-  {
-    q << "INSERT INTO bbs3solutions (data, woid, iteration, fit, mu, stddev, chi, "
-      << "startfreq, endfreq, starttime, endtime, hasconverged) VALUES ('";
-    th->addDBBlob(this, q);
-    q << "', "
-      << getWorkOrderID() << ", "
-      << getIteration() << ", "
-      << getQuality().itsFit << ", "
-      << getQuality().itsMu << ", "
-      << getQuality().itsStddev << ", "
-      << getQuality().itsChi << ", "
-      << getStartFreq() << ", "
-      << getEndFreq() << ", "
-      << getStartTime() << ", "
-      << getEndTime() << ", "
-      << hasConverged() << ");";
-    // store all parameters
-    ParmDataInfo pSolsInfo;
-    getSolution(pSolsInfo);
-    const vector<ParmData>& pSols = pSolsInfo.parms();
-    for (uint i=0; i<pSols.size(); i++)
+    string DH_Solution::createInsertStatement(TH_DB* th)
     {
-      int nrval = pSols[i].size();
-      for (int j=0; j<nrval; j++)
+      ostringstream q;
+      q.precision(precision);
+      if (itsWriteIndivParms) // Store parameters individually in a subtable
       {
-	const MeqMatrix& coeffMat = pSols[i].getCoeff(j);
-	q << "INSERT INTO "
-	  << itsParmTableName 
-	  << " (woid, iteration, domainnr, parmname, nx, ny, coeff) VALUES ( "
-	  << getWorkOrderID() << ", " 
+	q << "INSERT INTO bbs3solutions (data, woid, iteration, fit, mu, "
+	  << "stddev, chi, startfreq, endfreq, starttime, endtime, "
+	  << "hasconverged) VALUES ('";
+	th->addDBBlob(this, q);
+	q << "', "
+	  << getWorkOrderID() << ", "
 	  << getIteration() << ", "
-	  << j << ", '"
-	  << pSols[i].getName() << "', "
-	  << coeffMat.nx() << ", "
-	  << coeffMat.ny() << ", '{";
-	int nrCoeffs = coeffMat.nelements();
-	const double* coeffs = coeffMat.doubleStorage();
-	for (int coeff=0; coeff<nrCoeffs; coeff++)
+	  << getQuality().itsFit << ", "
+	  << getQuality().itsMu << ", "
+	  << getQuality().itsStddev << ", "
+	  << getQuality().itsChi << ", "
+	  << getStartFreq() << ", "
+	  << getEndFreq() << ", "
+	  << getStartTime() << ", "
+	  << getEndTime() << ", "
+	  << hasConverged() << ");";
+	// store all parameters
+	ParmDataInfo pSolsInfo;
+	getSolution(pSolsInfo);
+	const vector<ParmData>& pSols = pSolsInfo.parms();
+	for (uint i=0; i<pSols.size(); i++)
 	{
-	  q << coeffs[coeff];
-	  if (coeff < nrCoeffs-1)
+	  int nrval = pSols[i].size();
+	  for (int j=0; j<nrval; j++)
 	  {
-	    q << ", ";
+	    const MeqMatrix& coeffMat = pSols[i].getCoeff(j);
+	    q << "INSERT INTO "
+	      << itsParmTableName 
+	      << " (woid, iteration, domainnr, parmname, nx, ny, coeff) VALUES ( "
+	      << getWorkOrderID() << ", " 
+	      << getIteration() << ", "
+	      << j << ", '"
+	      << pSols[i].getName() << "', "
+	      << coeffMat.nx() << ", "
+	      << coeffMat.ny() << ", '{";
+	    int nrCoeffs = coeffMat.nelements();
+	    const double* coeffs = coeffMat.doubleStorage();
+	    for (int coeff=0; coeff<nrCoeffs; coeff++)
+	    {
+	      q << coeffs[coeff];
+	      if (coeff < nrCoeffs-1)
+	      {
+		q << ", ";
+	      }
+	    }
+	    q << "}' ); ";
 	  }
 	}
-	q << "}' ); ";
       }
+      else
+      {
+	q << "INSERT INTO bbs3solutions (data, woid, iteration, fit, mu, "
+	  << "stddev, chi, startfreq, endfreq, starttime, endtime, "
+	  << "hasconverged) VALUES ('";
+	th->addDBBlob(this, q);
+	q << "', "
+	  << getWorkOrderID() << ", "
+	  << getIteration() << ", "
+	  << getQuality().itsFit << ", "
+	  << getQuality().itsMu << ", "
+	  << getQuality().itsStddev << ", "
+	  << getQuality().itsChi << ", "
+	  << getStartFreq() << ", "
+	  << getEndFreq() << ", "
+	  << getStartTime() << ", "
+	  << getEndTime() << ", "
+	  << hasConverged() <<");";
+      }
+      return q.str();
     }
-  }
-  else
-  {
-    q << "INSERT INTO bbs3solutions (data, woid, iteration, fit, mu, stddev, chi, "
-      << "startfreq, endfreq, starttime, endtime, hasconverged) VALUES ('";
-    th->addDBBlob(this, q);
-    q << "', "
-      << getWorkOrderID() << ", "
-      << getIteration() << ", "
-      << getQuality().itsFit << ", "
-      << getQuality().itsMu << ", "
-      << getQuality().itsStddev << ", "
-      << getQuality().itsChi << ", "
-      << getStartFreq() << ", "
-      << getEndFreq() << ", "
-      << getStartTime() << ", "
-      << getEndTime() << ", "
-      << hasConverged() <<");";
-  }
-  return q.str();
-}
+
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/DH_WOPrediff.cc b/CEP/BB/BBSControl/src/DH_WOPrediff.cc
index e61179094809c7362a62748d91259198480c498c..de99f370ca90ee948f9432236eaecbf2f5fb779c 100644
--- a/CEP/BB/BBSControl/src/DH_WOPrediff.cc
+++ b/CEP/BB/BBSControl/src/DH_WOPrediff.cc
@@ -1,27 +1,24 @@
-//  DH_WOPrediff.cc:
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  DH_WOPrediff.cc:
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
@@ -35,524 +32,531 @@
 
 namespace LOFAR
 {
-
-const unsigned int MaxKSTypeLength = 16;
-const unsigned int MaxModelTypeLength = 50;
-
-DH_WOPrediff::DH_WOPrediff (const string& name)
-  : DH_DB(name, "DH_WOPrediff", 1),
-    itsWOID            (0),
-    itsSCID            (0),
-    itsStatus          (0),
-    itsKSType          (0),
-    itsDoNothing       (0),
-    itsNewBaselines    (0),
-    itsNewDomain       (0),
-    itsNewPeelSources  (0),
-    itsSubtractSources (0),
-    itsWritePredData   (0),
-    itsWriteInDataCol  (0),
-    itsMaxIterations   (0),
-    itsStartChan       (0),
-    itsEndChan         (0),
-    itsStartTime       (0),
-    itsTimeLength      (0),
-    itsModelType       (0),
-    itsCalcUVW         (0),
-    itsUseAutoCorr     (0),
-    itsCleanUp         (0),
-    itsUpdateParms     (0),
-    itsSolutionID      (0)
-{
-  LOG_TRACE_FLOW("DH_WOPrediff constructor");
-  setExtraBlob("Extra", 1);
-}
-
-DH_WOPrediff::DH_WOPrediff(const DH_WOPrediff& that)
-  : DH_DB(that),
-    itsWOID            (0),
-    itsSCID            (0),
-    itsStatus          (0),
-    itsKSType          (0),
-    itsDoNothing       (0),
-    itsNewBaselines    (0),
-    itsNewDomain       (0),
-    itsNewPeelSources  (0),
-    itsSubtractSources (0),
-    itsWritePredData   (0),
-    itsWriteInDataCol  (0),
-    itsMaxIterations   (0),
-    itsStartChan       (0),
-    itsEndChan         (0),
-    itsStartTime       (0),
-    itsTimeLength      (0),
-    itsModelType       (0),
-    itsCalcUVW         (0),
-    itsUseAutoCorr     (0),
-    itsCleanUp         (0),
-    itsUpdateParms     (0),
-    itsSolutionID      (0)
-{
-  LOG_TRACE_FLOW("DH_WOPrediff copy constructor");
-  setExtraBlob("Extra", 1);
-}
-
-DH_WOPrediff::~DH_WOPrediff()
-{
-  LOG_TRACE_FLOW("DH_WOPrediff destructor");
-}
-
-DataHolder* DH_WOPrediff::clone() const
-{
-  return new DH_WOPrediff(*this);
-}
-
-void DH_WOPrediff::init()
-{
-  // Add the fields to the data definition.
-  addField ("WOID", BlobField<int>(1));
-  addField ("SCID", BlobField<int>(1));
-  addField ("Status", BlobField<unsigned int>(1));
-  addField ("KSType", BlobField<char>(1, MaxKSTypeLength));
-  addField ("DoNothing", BlobField<unsigned int>(1));
-  addField ("NewBaselines", BlobField<unsigned int>(1));
-  addField ("NewDomain", BlobField<unsigned int>(1));
-  addField ("NewPeelSources", BlobField<unsigned int>(1));
-  addField ("SubtractSources", BlobField<unsigned int>(1));
-  addField ("WritePredData", BlobField<unsigned int>(1));
-  addField ("WriteInDataCol", BlobField<unsigned int>(1));
-  addField ("MaxIterations", BlobField<int>(1));
-  addField ("StartChan", BlobField<int>(1));
-  addField ("EndChan", BlobField<int>(1));
-  addField ("StartTime", BlobField<double>(1));
-  addField ("TimeLength", BlobField<double>(1));
-  addField ("ModelType", BlobField<char>(1, MaxModelTypeLength));
-  addField ("CalcUVW", BlobField<unsigned int>(1));
-  addField ("UseAutoCorr", BlobField<unsigned int>(1));
-  addField ("CleanUp", BlobField<unsigned int>(1));
-  addField ("UpdateParms", BlobField<unsigned int>(1));
-  addField ("SolutionID", BlobField<int>(1));
-
-  // Create the data blob (which calls fillPointers).
-  createDataBlock();
-  // Initialize the buffers.
-  for (unsigned int k=0; k<MaxKSTypeLength; k++)
+  namespace BBS
   {
-    itsKSType[k] = 0;
-  }
 
-  for (unsigned int m=0; m<MaxModelTypeLength; m++)
-  {
-    itsModelType[m] = 0;
-  }
-
-  *itsWOID = 0;
-  *itsSCID = -1;
-  *itsStatus = DH_WOPrediff::New;
-  *itsDoNothing = 0;
-  *itsNewBaselines = 0;
-  *itsNewDomain = 0;
-  *itsNewPeelSources = 0;
-  *itsSubtractSources = 0;
-  *itsWritePredData = 0;
-  *itsWriteInDataCol = 0;
-  *itsMaxIterations = 1;
-  *itsStartChan = 0;
-  *itsEndChan = 0;
-  *itsStartTime = 0;
-  *itsTimeLength = 0;
-  *itsCalcUVW = 0;
-  *itsUseAutoCorr = 0;
-  *itsCleanUp = 0;
-  *itsUpdateParms = 0;
-  *itsSolutionID = -1;
-}
-
-void DH_WOPrediff::fillDataPointers()
-{
-  // Fill in the pointers.
-  itsWOID = getData<int> ("WOID");
-  itsSCID = getData<int> ("SCID");
-  itsStatus = getData<unsigned int> ("Status");
-  itsKSType = getData<char> ("KSType");
-  itsDoNothing = getData<unsigned int> ("DoNothing");
-  itsNewBaselines = getData<unsigned int> ("NewBaselines");
-  itsNewDomain = getData<unsigned int> ("NewDomain");
-  itsNewPeelSources = getData<unsigned int> ("NewPeelSources");
-  itsSubtractSources = getData<unsigned int> ("SubtractSources");
-  itsWritePredData = getData<unsigned int> ("WritePredData");
-  itsWriteInDataCol = getData<unsigned int> ("WriteInDataCol");
-  itsMaxIterations = getData<int> ("MaxIterations");
-  itsStartChan = getData<int> ("StartChan");
-  itsEndChan = getData<int> ("EndChan");
-  itsStartTime = getData<double> ("StartTime");
-  itsTimeLength = getData<double> ("TimeLength");
-  itsModelType = getData<char> ("ModelType");
-  itsCalcUVW = getData<unsigned int> ("CalcUVW");
-  itsUseAutoCorr = getData<unsigned int> ("UseAutoCorr");
-  itsCleanUp = getData<unsigned int> ("CleanUp");
-  itsUpdateParms = getData<unsigned int> ("UpdateParms");
-  itsSolutionID = getData<int> ("SolutionID");
-}
-
-void DH_WOPrediff::setKSType(const string& ksType)
-{
-  ASSERTSTR(ksType.size() < MaxKSTypeLength, "KS type name is too long");
-  char* ptr;
-  ptr = itsKSType;
-  strcpy(ptr, ksType.c_str());
-}
-
-string DH_WOPrediff::getModelType() const
-{
-  return itsModelType;
-}
+    const unsigned int MaxKSTypeLength = 16;
+    const unsigned int MaxModelTypeLength = 50;
+
+    DH_WOPrediff::DH_WOPrediff (const string& name)
+      : DH_DB(name, "DH_WOPrediff", 1),
+	itsWOID            (0),
+	itsSCID            (0),
+	itsStatus          (0),
+	itsKSType          (0),
+	itsDoNothing       (0),
+	itsNewBaselines    (0),
+	itsNewDomain       (0),
+	itsNewPeelSources  (0),
+	itsSubtractSources (0),
+	itsWritePredData   (0),
+	itsWriteInDataCol  (0),
+	itsMaxIterations   (0),
+	itsStartChan       (0),
+	itsEndChan         (0),
+	itsStartTime       (0),
+	itsTimeLength      (0),
+	itsModelType       (0),
+	itsCalcUVW         (0),
+	itsUseAutoCorr     (0),
+	itsCleanUp         (0),
+	itsUpdateParms     (0),
+	itsSolutionID      (0)
+    {
+      LOG_TRACE_FLOW("DH_WOPrediff constructor");
+      setExtraBlob("Extra", 1);
+    }
 
-void DH_WOPrediff::setModelType(const string& type)
-{
-  ASSERTSTR(type.size() < MaxModelTypeLength, "Model type name is too long");
-  char* ptr;
-  ptr = itsModelType;
-  strcpy(ptr, type.c_str());
-}
-
-void DH_WOPrediff::setVarData(const ParameterSet& predArgs,
-			      vector<int>& antNrs,
-			      vector<string>& pNames,
-			      vector<string>& exPNames,
-			      vector<int>& peelSrcs,
-			      vector<int>& corrs)
-{
-  BlobOStream& bos = createExtraBlob();
-  // Put prediffer arguments into extra blob
-  string buffer;
-  predArgs.writeBuffer(buffer);
-  bos << buffer;
-
-  // Put parameter names into extra blob
-  bos.putStart("antNrs", 1);
-  vector<int>::const_iterator iter;
-  int nAnt = antNrs.size();
-  bos << nAnt;
-  for (iter = antNrs.begin(); iter != antNrs.end(); iter++)
-  {
-    bos << *iter;
-  }
-  bos.putEnd();
-
-  // Put parameter names into extra blob
-  bos.putStart("names", 1);
-  vector<string>::const_iterator sIter;
-  int nParam = pNames.size();
-  bos << nParam;
-  for (sIter = pNames.begin(); sIter != pNames.end(); sIter++)
-  {
-    bos << *sIter;
-  }
-  bos.putEnd();
-
-  // Put exclude paramater names into extra blob
-  bos.putStart("exNames", 1);
-  vector<string>::const_iterator xIter;
-  int nExParam = exPNames.size();
-  bos << nExParam;
-  for (xIter = exPNames.begin(); xIter != exPNames.end(); xIter++)
-  {
-    bos << *xIter;
-  }
-  bos.putEnd();
-
-  // Put start solutions into extra blob
-  bos.putStart("peelSrcs", 1);
-  unsigned int nPeelSrcs = peelSrcs.size();
-  bos << nPeelSrcs;
-  for (iter = peelSrcs.begin(); iter != peelSrcs.end(); iter++)
-  {
-    bos << *iter;
-  }
-  bos.putEnd();
-
-  // Put correlations into extra blob
-  bos.putStart("correlations", 1);
-  unsigned int nCorrs = corrs.size();
-  bos << nCorrs;
-  for (iter = corrs.begin(); iter != corrs.end(); iter++)
-  {
-    bos << *iter;
-  }
-  bos.putEnd();
-}
-
-bool DH_WOPrediff::getVarData(ParameterSet& predArgs,
-			      vector<int>& antNrs,
-			      vector<string>& pNames,
-			      vector<string>& exPNames,
-			      vector<int>& peelSrcs,
-			      vector<int>& corrs)
-{
-  bool found;
-  int version;
-  BlobIStream& bis = getExtraBlob(found, version);
-  if (!found) {
-    return false;
-  }
-  else
-  {
-    // Get prediffer arguments
-    string buffer;
-    bis >> buffer;
-    predArgs.clear();
-    predArgs.adoptBuffer(buffer);
-
-    // Get antenna numbers.
-    bis.getStart("antNrs");
-    antNrs.clear();
-    int nr;
-    bis >> nr;
-    antNrs.resize(nr);
-    for (int i=0; i < nr; i++)
+    DH_WOPrediff::DH_WOPrediff(const DH_WOPrediff& that)
+      : DH_DB(that),
+	itsWOID            (0),
+	itsSCID            (0),
+	itsStatus          (0),
+	itsKSType          (0),
+	itsDoNothing       (0),
+	itsNewBaselines    (0),
+	itsNewDomain       (0),
+	itsNewPeelSources  (0),
+	itsSubtractSources (0),
+	itsWritePredData   (0),
+	itsWriteInDataCol  (0),
+	itsMaxIterations   (0),
+	itsStartChan       (0),
+	itsEndChan         (0),
+	itsStartTime       (0),
+	itsTimeLength      (0),
+	itsModelType       (0),
+	itsCalcUVW         (0),
+	itsUseAutoCorr     (0),
+	itsCleanUp         (0),
+	itsUpdateParms     (0),
+	itsSolutionID      (0)
     {
-      bis >> antNrs[i];
+      LOG_TRACE_FLOW("DH_WOPrediff copy constructor");
+      setExtraBlob("Extra", 1);
     }
-    bis.getEnd();
-    
-    // Get parameter names.
-    bis.getStart("names");
-    pNames.clear();
-    int nmbr;
-    bis >> nmbr;
-    pNames.resize(nmbr);
-    for (int i=0; i < nmbr; i++)
+
+    DH_WOPrediff::~DH_WOPrediff()
     {
-      bis >> pNames[i];
+      LOG_TRACE_FLOW("DH_WOPrediff destructor");
     }
-    bis.getEnd();
-
-    // Get exclude parameter names.
-    bis.getStart("exNames");
-    exPNames.clear();
-    int nrExP;
-    bis >> nrExP;
-    exPNames.resize(nrExP);
-    for (int k=0; k < nrExP; k++)
+
+    DataHolder* DH_WOPrediff::clone() const
     {
-      bis >> exPNames[k];
+      return new DH_WOPrediff(*this);
     }
-    bis.getEnd();
-
-    // Get source numbers
-    bis.getStart("peelSrcs");
-    peelSrcs.clear();
-    int number;
-    bis >> number;
-    peelSrcs.resize(number);
-    for (int j=0; j < number; j++)
+
+    void DH_WOPrediff::init()
     {
-      bis >> peelSrcs[j];
+      // Add the fields to the data definition.
+      addField ("WOID", BlobField<int>(1));
+      addField ("SCID", BlobField<int>(1));
+      addField ("Status", BlobField<unsigned int>(1));
+      addField ("KSType", BlobField<char>(1, MaxKSTypeLength));
+      addField ("DoNothing", BlobField<unsigned int>(1));
+      addField ("NewBaselines", BlobField<unsigned int>(1));
+      addField ("NewDomain", BlobField<unsigned int>(1));
+      addField ("NewPeelSources", BlobField<unsigned int>(1));
+      addField ("SubtractSources", BlobField<unsigned int>(1));
+      addField ("WritePredData", BlobField<unsigned int>(1));
+      addField ("WriteInDataCol", BlobField<unsigned int>(1));
+      addField ("MaxIterations", BlobField<int>(1));
+      addField ("StartChan", BlobField<int>(1));
+      addField ("EndChan", BlobField<int>(1));
+      addField ("StartTime", BlobField<double>(1));
+      addField ("TimeLength", BlobField<double>(1));
+      addField ("ModelType", BlobField<char>(1, MaxModelTypeLength));
+      addField ("CalcUVW", BlobField<unsigned int>(1));
+      addField ("UseAutoCorr", BlobField<unsigned int>(1));
+      addField ("CleanUp", BlobField<unsigned int>(1));
+      addField ("UpdateParms", BlobField<unsigned int>(1));
+      addField ("SolutionID", BlobField<int>(1));
+
+      // Create the data blob (which calls fillPointers).
+      createDataBlock();
+      // Initialize the buffers.
+      for (unsigned int k=0; k<MaxKSTypeLength; k++)
+      {
+	itsKSType[k] = 0;
+      }
+
+      for (unsigned int m=0; m<MaxModelTypeLength; m++)
+      {
+	itsModelType[m] = 0;
+      }
+
+      *itsWOID = 0;
+      *itsSCID = -1;
+      *itsStatus = DH_WOPrediff::New;
+      *itsDoNothing = 0;
+      *itsNewBaselines = 0;
+      *itsNewDomain = 0;
+      *itsNewPeelSources = 0;
+      *itsSubtractSources = 0;
+      *itsWritePredData = 0;
+      *itsWriteInDataCol = 0;
+      *itsMaxIterations = 1;
+      *itsStartChan = 0;
+      *itsEndChan = 0;
+      *itsStartTime = 0;
+      *itsTimeLength = 0;
+      *itsCalcUVW = 0;
+      *itsUseAutoCorr = 0;
+      *itsCleanUp = 0;
+      *itsUpdateParms = 0;
+      *itsSolutionID = -1;
     }
-    bis.getEnd();
-
-    bis.getStart("correlations");
-    corrs.clear();
-    int nrCorr;
-    bis >> nrCorr;
-    corrs.resize(nrCorr);
-    for (int l=0; l < nrCorr; l++)
+
+    void DH_WOPrediff::fillDataPointers()
     {
-      bis >> corrs[l];
+      // Fill in the pointers.
+      itsWOID = getData<int> ("WOID");
+      itsSCID = getData<int> ("SCID");
+      itsStatus = getData<unsigned int> ("Status");
+      itsKSType = getData<char> ("KSType");
+      itsDoNothing = getData<unsigned int> ("DoNothing");
+      itsNewBaselines = getData<unsigned int> ("NewBaselines");
+      itsNewDomain = getData<unsigned int> ("NewDomain");
+      itsNewPeelSources = getData<unsigned int> ("NewPeelSources");
+      itsSubtractSources = getData<unsigned int> ("SubtractSources");
+      itsWritePredData = getData<unsigned int> ("WritePredData");
+      itsWriteInDataCol = getData<unsigned int> ("WriteInDataCol");
+      itsMaxIterations = getData<int> ("MaxIterations");
+      itsStartChan = getData<int> ("StartChan");
+      itsEndChan = getData<int> ("EndChan");
+      itsStartTime = getData<double> ("StartTime");
+      itsTimeLength = getData<double> ("TimeLength");
+      itsModelType = getData<char> ("ModelType");
+      itsCalcUVW = getData<unsigned int> ("CalcUVW");
+      itsUseAutoCorr = getData<unsigned int> ("UseAutoCorr");
+      itsCleanUp = getData<unsigned int> ("CleanUp");
+      itsUpdateParms = getData<unsigned int> ("UpdateParms");
+      itsSolutionID = getData<int> ("SolutionID");
     }
-    bis.getEnd();
 
-    return true;
-  }  
+    void DH_WOPrediff::setKSType(const string& ksType)
+    {
+      ASSERTSTR(ksType.size() < MaxKSTypeLength, "KS type name is too long");
+      char* ptr;
+      ptr = itsKSType;
+      strcpy(ptr, ksType.c_str());
+    }
 
-}
+    string DH_WOPrediff::getModelType() const
+    {
+      return itsModelType;
+    }
 
-void DH_WOPrediff::dump() const
-{
-  cout << "DH_WOPrediff: " << endl;
-  cout << "ID = " << getWorkOrderID() << endl;
-  cout << "Controller ID = " << getStrategyControllerID() << endl;
-  cout << "Status = " << getStatus() << endl;
-  cout << "KS Type = " << getKSType() << endl;
-  cout << "Do nothing? = " << getDoNothing() << endl;
-  cout << "New baselines? = " << getNewBaselines() << endl;
-  cout << "New domain? = " << getNewDomain() << endl;
-  cout << "New peel sources? = " << getNewPeelSources() << endl;
-  cout << "Subtract peel sources? = " << getSubtractSources() << endl;
-  cout << "Write predicted data? = " << getWritePredData() << endl;
-  cout << "Write in DATA column? = " << getWriteInDataCol() << endl;
-  cout << "Number of iterations = " << getMaxIterations() << endl;
-  cout << "Start channel = " << getStartChannel() << endl;
-  cout << "End channel = " << getEndChannel() << endl;
-  cout << "Start time = " << getStartTime() << endl;
-  cout << "Time length = " << getTimeLength() << endl;
-  cout << "Model type = " << getModelType() << endl;
-  cout << "Calc UVW = " << getCalcUVW() << endl;
-  cout << "Use auto correlations = " << getUseAutoCorrelations() << endl;
-  cout << "Clean up = " << getCleanUp() << endl;
-  cout << "Update parameters = " << getUpdateParms() << endl;
-  cout << "Solution id = " << getSolutionID() << endl;
-
-  ParameterSet sArguments;
-  vector<int> antNrs;
-  vector<string> pNames;
-  vector<string> exPNames;
-  vector<int> srcs;
-  vector<int> corrs;
-  if (const_cast<DH_WOPrediff*>(this)->getVarData(sArguments, antNrs,
-						  pNames, exPNames,
-						  srcs, corrs))
-  { 
-    cout << "MS name = " << sArguments.getString ("MSName")
-	 << endl;
-    cout << "General MS path = " << sArguments.getString ("generalMSPath")
-	 << endl;
-    cout << "Subset MS path = " << sArguments.getString ("subsetMSPath")
-	 << endl;
-    cout << "Database host = " << sArguments.getString ("DBHost")
-	 << endl;
-    cout << "Database type = " << sArguments.getString ("DBType")
-	 << endl;
-    cout << "Database name = " << sArguments.getString ("DBName")
-	 << endl;
-    cout << "Database password = " << sArguments.getString ("DBPwd")
-	 << endl;
-    cout << "Meq table name = " << sArguments.getString ("meqTableName")
-	 << endl;
-    cout << "Sky table name = " << sArguments.getString ("skyTableName")
-	 << endl;
-    cout << "Antenna numbers : [ " ;
-    for (unsigned int i = 0; i < antNrs.size(); i++)
+    void DH_WOPrediff::setModelType(const string& type)
     {
-      cout << antNrs[i] << ", ";
+      ASSERTSTR(type.size() < MaxModelTypeLength, "Model type name is too long");
+      char* ptr;
+      ptr = itsModelType;
+      strcpy(ptr, type.c_str());
     }
-    cout << " ]" << endl;
-    cout << "Number of parameters = "  << pNames.size() << endl;
-    
-    cout << "Parameter names : " << endl;
-    for (unsigned int i = 0; i < pNames.size(); i++)
+
+    void DH_WOPrediff::setVarData(const ParameterSet& predArgs,
+				  vector<int>& antNrs,
+				  vector<string>& pNames,
+				  vector<string>& exPNames,
+				  vector<int>& peelSrcs,
+				  vector<int>& corrs)
     {
-      cout << pNames[i] << endl ;
+      BlobOStream& bos = createExtraBlob();
+      // Put prediffer arguments into extra blob
+      string buffer;
+      predArgs.writeBuffer(buffer);
+      bos << buffer;
+
+      // Put parameter names into extra blob
+      bos.putStart("antNrs", 1);
+      vector<int>::const_iterator iter;
+      int nAnt = antNrs.size();
+      bos << nAnt;
+      for (iter = antNrs.begin(); iter != antNrs.end(); iter++)
+      {
+	bos << *iter;
+      }
+      bos.putEnd();
+
+      // Put parameter names into extra blob
+      bos.putStart("names", 1);
+      vector<string>::const_iterator sIter;
+      int nParam = pNames.size();
+      bos << nParam;
+      for (sIter = pNames.begin(); sIter != pNames.end(); sIter++)
+      {
+	bos << *sIter;
+      }
+      bos.putEnd();
+
+      // Put exclude paramater names into extra blob
+      bos.putStart("exNames", 1);
+      vector<string>::const_iterator xIter;
+      int nExParam = exPNames.size();
+      bos << nExParam;
+      for (xIter = exPNames.begin(); xIter != exPNames.end(); xIter++)
+      {
+	bos << *xIter;
+      }
+      bos.putEnd();
+
+      // Put start solutions into extra blob
+      bos.putStart("peelSrcs", 1);
+      unsigned int nPeelSrcs = peelSrcs.size();
+      bos << nPeelSrcs;
+      for (iter = peelSrcs.begin(); iter != peelSrcs.end(); iter++)
+      {
+	bos << *iter;
+      }
+      bos.putEnd();
+
+      // Put correlations into extra blob
+      bos.putStart("correlations", 1);
+      unsigned int nCorrs = corrs.size();
+      bos << nCorrs;
+      for (iter = corrs.begin(); iter != corrs.end(); iter++)
+      {
+	bos << *iter;
+      }
+      bos.putEnd();
     }
 
-    cout << "Number of exclude parameters = "  << exPNames.size() << endl;
+    bool DH_WOPrediff::getVarData(ParameterSet& predArgs,
+				  vector<int>& antNrs,
+				  vector<string>& pNames,
+				  vector<string>& exPNames,
+				  vector<int>& peelSrcs,
+				  vector<int>& corrs)
+    {
+      bool found;
+      int version;
+      BlobIStream& bis = getExtraBlob(found, version);
+      if (!found) {
+	return false;
+      }
+      else
+      {
+	// Get prediffer arguments
+	string buffer;
+	bis >> buffer;
+	predArgs.clear();
+	predArgs.adoptBuffer(buffer);
+
+	// Get antenna numbers.
+	bis.getStart("antNrs");
+	antNrs.clear();
+	int nr;
+	bis >> nr;
+	antNrs.resize(nr);
+	for (int i=0; i < nr; i++)
+	{
+	  bis >> antNrs[i];
+	}
+	bis.getEnd();
     
-    cout << "Exclude parameter names : " << endl;
-    for (unsigned int i = 0; i < exPNames.size(); i++)
+	// Get parameter names.
+	bis.getStart("names");
+	pNames.clear();
+	int nmbr;
+	bis >> nmbr;
+	pNames.resize(nmbr);
+	for (int i=0; i < nmbr; i++)
+	{
+	  bis >> pNames[i];
+	}
+	bis.getEnd();
+
+	// Get exclude parameter names.
+	bis.getStart("exNames");
+	exPNames.clear();
+	int nrExP;
+	bis >> nrExP;
+	exPNames.resize(nrExP);
+	for (int k=0; k < nrExP; k++)
+	{
+	  bis >> exPNames[k];
+	}
+	bis.getEnd();
+
+	// Get source numbers
+	bis.getStart("peelSrcs");
+	peelSrcs.clear();
+	int number;
+	bis >> number;
+	peelSrcs.resize(number);
+	for (int j=0; j < number; j++)
+	{
+	  bis >> peelSrcs[j];
+	}
+	bis.getEnd();
+
+	bis.getStart("correlations");
+	corrs.clear();
+	int nrCorr;
+	bis >> nrCorr;
+	corrs.resize(nrCorr);
+	for (int l=0; l < nrCorr; l++)
+	{
+	  bis >> corrs[l];
+	}
+	bis.getEnd();
+
+	return true;
+      }  
+
+    }
+
+    void DH_WOPrediff::dump() const
     {
-      cout << exPNames[i] << endl ;
+      cout << "DH_WOPrediff: " << endl;
+      cout << "ID = " << getWorkOrderID() << endl;
+      cout << "Controller ID = " << getStrategyControllerID() << endl;
+      cout << "Status = " << getStatus() << endl;
+      cout << "KS Type = " << getKSType() << endl;
+      cout << "Do nothing? = " << getDoNothing() << endl;
+      cout << "New baselines? = " << getNewBaselines() << endl;
+      cout << "New domain? = " << getNewDomain() << endl;
+      cout << "New peel sources? = " << getNewPeelSources() << endl;
+      cout << "Subtract peel sources? = " << getSubtractSources() << endl;
+      cout << "Write predicted data? = " << getWritePredData() << endl;
+      cout << "Write in DATA column? = " << getWriteInDataCol() << endl;
+      cout << "Number of iterations = " << getMaxIterations() << endl;
+      cout << "Start channel = " << getStartChannel() << endl;
+      cout << "End channel = " << getEndChannel() << endl;
+      cout << "Start time = " << getStartTime() << endl;
+      cout << "Time length = " << getTimeLength() << endl;
+      cout << "Model type = " << getModelType() << endl;
+      cout << "Calc UVW = " << getCalcUVW() << endl;
+      cout << "Use auto correlations = " << getUseAutoCorrelations() << endl;
+      cout << "Clean up = " << getCleanUp() << endl;
+      cout << "Update parameters = " << getUpdateParms() << endl;
+      cout << "Solution id = " << getSolutionID() << endl;
+
+      ParameterSet sArguments;
+      vector<int> antNrs;
+      vector<string> pNames;
+      vector<string> exPNames;
+      vector<int> srcs;
+      vector<int> corrs;
+      if (const_cast<DH_WOPrediff*>(this)->getVarData(sArguments, antNrs,
+						      pNames, exPNames,
+						      srcs, corrs))
+      { 
+	cout << "MS name = " << sArguments.getString ("MSName")
+	     << endl;
+	cout << "General MS path = " << sArguments.getString ("generalMSPath")
+	     << endl;
+	cout << "Subset MS path = " << sArguments.getString ("subsetMSPath")
+	     << endl;
+	cout << "Database host = " << sArguments.getString ("DBHost")
+	     << endl;
+	cout << "Database type = " << sArguments.getString ("DBType")
+	     << endl;
+	cout << "Database name = " << sArguments.getString ("DBName")
+	     << endl;
+	cout << "Database password = " << sArguments.getString ("DBPwd")
+	     << endl;
+	cout << "Meq table name = " << sArguments.getString ("meqTableName")
+	     << endl;
+	cout << "Sky table name = " << sArguments.getString ("skyTableName")
+	     << endl;
+	cout << "Antenna numbers : [ " ;
+	for (unsigned int i = 0; i < antNrs.size(); i++)
+	{
+	  cout << antNrs[i] << ", ";
+	}
+	cout << " ]" << endl;
+	cout << "Number of parameters = "  << pNames.size() << endl;
+    
+	cout << "Parameter names : " << endl;
+	for (unsigned int i = 0; i < pNames.size(); i++)
+	{
+	  cout << pNames[i] << endl ;
+	}
+
+	cout << "Number of exclude parameters = "  << exPNames.size() << endl;
+    
+	cout << "Exclude parameter names : " << endl;
+	for (unsigned int i = 0; i < exPNames.size(); i++)
+	{
+	  cout << exPNames[i] << endl ;
+	}
+
+	cout << "Source numbers : " << endl;
+	for (unsigned int i = 0; i < srcs.size(); i++)
+	{
+	  cout << srcs[i] << endl ;
+	}
+
+	cout << "Correlations : " << endl;
+	for (unsigned int i = 0; i < corrs.size(); i++)
+	{
+	  cout << corrs[i] << endl ;
+	}
+
+      }
+
     }
 
-    cout << "Source numbers : " << endl;
-    for (unsigned int i = 0; i < srcs.size(); i++)
+    void DH_WOPrediff::clearData()
     {
-      cout << srcs[i] << endl ;
+      clearExtraBlob();
+      setWorkOrderID(-1);
+      setStrategyControllerID(-1);
+      setStatus(DH_WOPrediff::New);
+      setKSType("");
+      setDoNothing(false);
+      setNewBaselines(true);
+      setNewDomain(true);
+      setNewPeelSources(true);
+      setSubtractSources(false);
+      setWritePredData(false);
+      setWriteInDataCol(false);
+      setMaxIterations(1);
+      setStartChannel(0);
+      setEndChannel(0);
+      setStartTime(0);
+      setTimeLength(0);
+      setModelType("");
+      setCalcUVW(false);
+      setUseAutoCorrelations(true);
+      setCleanUp(false);
+      setUpdateParms(false);
+      setSolutionID(0);
     }
 
-    cout << "Correlations : " << endl;
-    for (unsigned int i = 0; i < corrs.size(); i++)
+    string DH_WOPrediff::createInsertStatement(TH_DB* th)
     {
-      cout << corrs[i] << endl ;
+      ostringstream q;
+      q << "INSERT INTO bbs3woprediffer (data, woid, scid, status, kstype, "
+	<< "donothing, newbaselines, newdomain, newsources, subtractsources, "
+	<< "writepreddata, writeindatacol, maxiterations, startchan, endchan, "
+	<< "starttime, timelength, cleanup, updateparms, solutionid) VALUES ('";
+      th->addDBBlob(this, q);
+      q << "', "
+	<< getWorkOrderID() << ", "
+	<< getStrategyControllerID() << ", "
+	<< getStatus() << ", '"
+	<< getKSType() << "', "
+	<< getDoNothing() << ", "
+	<< getNewBaselines() << ", "
+	<< getNewDomain() << ", "
+	<< getNewPeelSources() << ", "
+	<< getSubtractSources() << ", "
+	<< getWritePredData() << ", "
+	<< getWriteInDataCol() << ", "
+	<< getMaxIterations() << ", "
+	<< getStartChannel() << ", "
+	<< getEndChannel() << ", "
+	<< getStartTime() << ", "
+	<< getTimeLength() << ", "
+	<< getCleanUp() << ", "
+	<< getUpdateParms() << ", "
+	<< getSolutionID() << ");";
+      return q.str();
     }
 
-  }
+    string DH_WOPrediff::createUpdateStatement(TH_DB* th)
+    {
+      // This implementation assumes only the status has changed. So only the
+      // blob and the status field are updated!
+      ostringstream q;
+      q << "UPDATE bbs3woprediffer SET data='";
+      th->addDBBlob(this, q);
+      q << "', status=" << getStatus() 
+	<<" WHERE woid=" << getWorkOrderID();
+      return q.str();
+    }
 
-}
+    int DH_WOPrediff::getMaxSCID(TH_DB* th)
+    {
+      string query("SELECT MAX(SCID) FROM bbs3woprediffer");
+      char res[10];
+      if (th->queryDB(query, res, 10) <= 0)
+      {
+	return 0;
+      }
+      else
+      {
+	return atoi(res);
+      }
+    }
 
-void DH_WOPrediff::clearData()
-{
-  clearExtraBlob();
-  setWorkOrderID(-1);
-  setStrategyControllerID(-1);
-  setStatus(DH_WOPrediff::New);
-  setKSType("");
-  setDoNothing(false);
-  setNewBaselines(true);
-  setNewDomain(true);
-  setNewPeelSources(true);
-  setSubtractSources(false);
-  setWritePredData(false);
-  setWriteInDataCol(false);
-  setMaxIterations(1);
-  setStartChannel(0);
-  setEndChannel(0);
-  setStartTime(0);
-  setTimeLength(0);
-  setModelType("");
-  setCalcUVW(false);
-  setUseAutoCorrelations(true);
-  setCleanUp(false);
-  setUpdateParms(false);
-  setSolutionID(0);
-}
-
-string DH_WOPrediff::createInsertStatement(TH_DB* th)
-{
-   ostringstream q;
-   q << "INSERT INTO bbs3woprediffer (data, woid, scid, status, kstype, donothing, newbaselines, newdomain, newsources, subtractsources, writepreddata, writeindatacol, maxiterations, startchan, endchan, starttime, timelength, cleanup, updateparms, solutionid) VALUES ('";
-   th->addDBBlob(this, q);
-   q << "', "
-     << getWorkOrderID() << ", "
-     << getStrategyControllerID() << ", "
-     << getStatus() << ", '"
-     << getKSType() << "', "
-     << getDoNothing() << ", "
-     << getNewBaselines() << ", "
-     << getNewDomain() << ", "
-     << getNewPeelSources() << ", "
-     << getSubtractSources() << ", "
-     << getWritePredData() << ", "
-     << getWriteInDataCol() << ", "
-     << getMaxIterations() << ", "
-     << getStartChannel() << ", "
-     << getEndChannel() << ", "
-     << getStartTime() << ", "
-     << getTimeLength() << ", "
-     << getCleanUp() << ", "
-     << getUpdateParms() << ", "
-     << getSolutionID() << ");";
-   return q.str();
-}
-
-string DH_WOPrediff::createUpdateStatement(TH_DB* th)
-{
-  // This implementation assumes only the status has changed. So only the blob and
-  // the status field are updated!
-  ostringstream q;
-  q << "UPDATE bbs3woprediffer SET data='";
-  th->addDBBlob(this, q);
-  q << "', status=" << getStatus() 
-    <<" WHERE woid=" << getWorkOrderID();
-  return q.str();
-}
-
-int DH_WOPrediff::getMaxSCID(TH_DB* th)
-{
-  string query("SELECT MAX(SCID) FROM bbs3woprediffer");
-  char res[10];
-  if (th->queryDB(query, res, 10) <= 0)
-  {
-    return 0;
-  }
-  else
-  {
-    return atoi(res);
-  }
-}
+    int DH_WOPrediff::getMaxWOID(TH_DB* th)
+    {
+      string query("SELECT MAX(WOID) FROM bbs3woprediffer");
+      char res[10];
+      if (th->queryDB(query, res, 10) <= 0)
+      {
+	return 0;
+      }
+      else
+      {
+	return atoi(res);
+      }
+    }
 
-int DH_WOPrediff::getMaxWOID(TH_DB* th)
-{
-  string query("SELECT MAX(WOID) FROM bbs3woprediffer");
-  char res[10];
-  if (th->queryDB(query, res, 10) <= 0)
-  {
-    return 0;
-  }
-  else
-  {
-    return atoi(res);
-  }
-}
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/DH_WOSolve.cc b/CEP/BB/BBSControl/src/DH_WOSolve.cc
index d5ffddea0cf8bfe60af958355de03ff45f8cd2ae..0762244171edfe4b34363b0419cca2e39650c9b0 100644
--- a/CEP/BB/BBSControl/src/DH_WOSolve.cc
+++ b/CEP/BB/BBSControl/src/DH_WOSolve.cc
@@ -1,27 +1,24 @@
-//  DH_WOSolve.cc:
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  DH_WOSolve.cc:
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
@@ -34,177 +31,182 @@
 
 namespace LOFAR
 {
-const unsigned int MaxKSTypeLength = 8;
-
-DH_WOSolve::DH_WOSolve (const string& name)
-  : DH_DB(name, "DH_WOSolve", 1),
-    itsWOID            (0),
-    itsSCID            (0),
-    itsStatus          (0),
-    itsKSType          (0),
-    itsIteration       (0),
-    itsDoNothing       (0),
-    itsNewDomain       (0),
-    itsMaxIterations   (0),
-    itsFitCriterion    (0),
-    itsUseSVD          (0),
-    itsCleanUp         (0)
-{
-  LOG_TRACE_FLOW("DH_WOSolve constructor");
-  setExtraBlob("Extra", 1);
-}
-
-DH_WOSolve::DH_WOSolve(const DH_WOSolve& that)
-  : DH_DB(that),
-    itsWOID            (0),
-    itsSCID            (0),
-    itsStatus          (0),
-    itsKSType          (0),
-    itsIteration       (0),
-    itsDoNothing       (0),
-    itsNewDomain       (0),
-    itsMaxIterations   (0),
-    itsFitCriterion    (0),
-    itsUseSVD          (0),
-    itsCleanUp         (0)
-{
-  LOG_TRACE_FLOW("DH_WOSolve copy constructor");
-  setExtraBlob("Extra", 1);
-}
-
-DH_WOSolve::~DH_WOSolve()
-{
-  LOG_TRACE_FLOW("DH_WOSolve destructor");
-}
-
-DataHolder* DH_WOSolve::clone() const
-{
-  return new DH_WOSolve(*this);
-}
-
-void DH_WOSolve::init()
-{
-  // Add the fields to the data definition.
-  addField ("WOID", BlobField<int>(1));
-  addField ("SCID", BlobField<int>(1));
-  addField ("Status", BlobField<unsigned int>(1));
-  addField ("KSType", BlobField<char>(1, MaxKSTypeLength));
-  addField ("Iteration", BlobField<int>(1));
-  addField ("DoNothing", BlobField<unsigned int>(1));
-  addField ("NewDomain", BlobField<unsigned int>(1));
-  addField ("MaxIterations", BlobField<int>(1));
-  addField ("FitCriterion", BlobField<double>(1));
-  addField ("UseSVD", BlobField<unsigned int>(1));
-  addField ("CleanUp", BlobField<unsigned int>(1));
-
-  // Create the data blob (which calls fillPointers).
-  createDataBlock();
-  // Initialize the buffers.
-  for (unsigned int k=0; k<MaxKSTypeLength; k++)
+  namespace BBS
   {
-    itsKSType[k] = 0;
-  }
-
-  *itsWOID = 0;
-  *itsSCID = -1;
-  *itsStatus = DH_WOSolve::New;
-  *itsIteration = -1;
-  *itsDoNothing = 0;
-  *itsNewDomain = 0;
-  *itsMaxIterations = 1;
-  *itsFitCriterion = -1;
-  *itsUseSVD = 0;
-  *itsCleanUp = 0;
-}
-
-void DH_WOSolve::fillDataPointers()
-{
-  // Fill in the pointers.
-  itsWOID = getData<int> ("WOID");
-  itsSCID = getData<int> ("SCID");
-  itsStatus = getData<unsigned int> ("Status");
-  itsKSType = getData<char> ("KSType");
-  itsIteration = getData<int> ("Iteration");
-  itsDoNothing = getData<unsigned int> ("DoNothing");  
-  itsNewDomain = getData<unsigned int> ("NewDomain");
-  itsMaxIterations = getData<int> ("MaxIterations");
-  itsFitCriterion = getData<double> ("FitCriterion");
-  itsUseSVD = getData<unsigned int> ("UseSVD");
-  itsCleanUp = getData<unsigned int> ("CleanUp");
-}
-
-void DH_WOSolve::setKSType(const string& ksType)
-{
-  ASSERTSTR(ksType.size() < MaxKSTypeLength, "KS type name is too long");
-  char* ptr;
-  ptr = itsKSType;
-  strcpy(ptr, ksType.c_str());
-}
-
-void DH_WOSolve::dump() const
-{
-  cout << "DH_WOSolve: " << endl;
-  cout << "ID = " << getWorkOrderID() << endl;
-  cout << "Controller ID = " << getStrategyControllerID() << endl;
-  cout << "Status = " << getStatus() << endl;
-  cout << "KS Type = " << getKSType() << endl;
-  cout << "Iteration number = " << getIteration() << endl;
-  cout << "Do nothing? = " << getDoNothing() << endl;
-  cout << "NewDomain? = " << getNewDomain() << endl;
-  cout << "Number of iterations = " << getMaxIterations() << endl;
-  cout << "Fit criterion = " << getFitCriterion() << endl;
-  cout << "UseSVD? = " << getUseSVD() << endl;
-  cout << "Clean up = " << getCleanUp() << endl;
-}
-
-void DH_WOSolve::clearData()
-{
-  clearExtraBlob();
-  setWorkOrderID(-1);
-  setStrategyControllerID(-1);
-  setStatus(DH_WOSolve::New);
-  setKSType("");
-  setIteration(-1);
-  setDoNothing(false);
-  setNewDomain(true);
-  setMaxIterations(1);
-  setFitCriterion(-1);
-  setUseSVD(false);
-  setCleanUp(false);
-}
-
-string DH_WOSolve::createInsertStatement(TH_DB* th)
-{
-   ostringstream q;
-   q << "INSERT INTO bbs3wosolver (data, woid, scid, status, kstype, iteration,"
-     << " donothing, newdomain, maxiterations, fitcriterion, usesvd, cleanup) VALUES ('";
-   th->addDBBlob(this, q);
-   q << "', "
-     << getWorkOrderID() << ", "
-     << getStrategyControllerID() << ", "
-     << getStatus() << ", '"
-     << getKSType() << "', "
-     << getIteration() << ", "
-     << getDoNothing() << ", "
-     << getNewDomain() << ", "
-     << getMaxIterations() << ", "
-     << getFitCriterion() << ", "
-     << getUseSVD() << ", "
-     << getCleanUp() << ");";
-   return q.str();
-}
-
-string DH_WOSolve::createUpdateStatement(TH_DB* th)
-{
-  // NB:This implementation assumes only the status has changed. So only the blob and
-  // the status field are updated!
-  ostringstream q;
-  q << "UPDATE bbs3wosolver SET data='";
-  th->addDBBlob(this, q);
-  q << "', status=" << getStatus()
-    <<" WHERE woid=" << getWorkOrderID();
-  return q.str();
-}
 
+    const unsigned int MaxKSTypeLength = 8;
+
+    DH_WOSolve::DH_WOSolve (const string& name)
+      : DH_DB(name, "DH_WOSolve", 1),
+	itsWOID            (0),
+	itsSCID            (0),
+	itsStatus          (0),
+	itsKSType          (0),
+	itsIteration       (0),
+	itsDoNothing       (0),
+	itsNewDomain       (0),
+	itsMaxIterations   (0),
+	itsFitCriterion    (0),
+	itsUseSVD          (0),
+	itsCleanUp         (0)
+    {
+      LOG_TRACE_FLOW("DH_WOSolve constructor");
+      setExtraBlob("Extra", 1);
+    }
+
+    DH_WOSolve::DH_WOSolve(const DH_WOSolve& that)
+      : DH_DB(that),
+	itsWOID            (0),
+	itsSCID            (0),
+	itsStatus          (0),
+	itsKSType          (0),
+	itsIteration       (0),
+	itsDoNothing       (0),
+	itsNewDomain       (0),
+	itsMaxIterations   (0),
+	itsFitCriterion    (0),
+	itsUseSVD          (0),
+	itsCleanUp         (0)
+    {
+      LOG_TRACE_FLOW("DH_WOSolve copy constructor");
+      setExtraBlob("Extra", 1);
+    }
+
+    DH_WOSolve::~DH_WOSolve()
+    {
+      LOG_TRACE_FLOW("DH_WOSolve destructor");
+    }
+
+    DataHolder* DH_WOSolve::clone() const
+    {
+      return new DH_WOSolve(*this);
+    }
+
+    void DH_WOSolve::init()
+    {
+      // Add the fields to the data definition.
+      addField ("WOID", BlobField<int>(1));
+      addField ("SCID", BlobField<int>(1));
+      addField ("Status", BlobField<unsigned int>(1));
+      addField ("KSType", BlobField<char>(1, MaxKSTypeLength));
+      addField ("Iteration", BlobField<int>(1));
+      addField ("DoNothing", BlobField<unsigned int>(1));
+      addField ("NewDomain", BlobField<unsigned int>(1));
+      addField ("MaxIterations", BlobField<int>(1));
+      addField ("FitCriterion", BlobField<double>(1));
+      addField ("UseSVD", BlobField<unsigned int>(1));
+      addField ("CleanUp", BlobField<unsigned int>(1));
+
+      // Create the data blob (which calls fillPointers).
+      createDataBlock();
+      // Initialize the buffers.
+      for (unsigned int k=0; k<MaxKSTypeLength; k++)
+      {
+	itsKSType[k] = 0;
+      }
+
+      *itsWOID = 0;
+      *itsSCID = -1;
+      *itsStatus = DH_WOSolve::New;
+      *itsIteration = -1;
+      *itsDoNothing = 0;
+      *itsNewDomain = 0;
+      *itsMaxIterations = 1;
+      *itsFitCriterion = -1;
+      *itsUseSVD = 0;
+      *itsCleanUp = 0;
+    }
+
+    void DH_WOSolve::fillDataPointers()
+    {
+      // Fill in the pointers.
+      itsWOID = getData<int> ("WOID");
+      itsSCID = getData<int> ("SCID");
+      itsStatus = getData<unsigned int> ("Status");
+      itsKSType = getData<char> ("KSType");
+      itsIteration = getData<int> ("Iteration");
+      itsDoNothing = getData<unsigned int> ("DoNothing");  
+      itsNewDomain = getData<unsigned int> ("NewDomain");
+      itsMaxIterations = getData<int> ("MaxIterations");
+      itsFitCriterion = getData<double> ("FitCriterion");
+      itsUseSVD = getData<unsigned int> ("UseSVD");
+      itsCleanUp = getData<unsigned int> ("CleanUp");
+    }
+
+    void DH_WOSolve::setKSType(const string& ksType)
+    {
+      ASSERTSTR(ksType.size() < MaxKSTypeLength, "KS type name is too long");
+      char* ptr;
+      ptr = itsKSType;
+      strcpy(ptr, ksType.c_str());
+    }
+
+    void DH_WOSolve::dump() const
+    {
+      cout << "DH_WOSolve: " << endl;
+      cout << "ID = " << getWorkOrderID() << endl;
+      cout << "Controller ID = " << getStrategyControllerID() << endl;
+      cout << "Status = " << getStatus() << endl;
+      cout << "KS Type = " << getKSType() << endl;
+      cout << "Iteration number = " << getIteration() << endl;
+      cout << "Do nothing? = " << getDoNothing() << endl;
+      cout << "NewDomain? = " << getNewDomain() << endl;
+      cout << "Number of iterations = " << getMaxIterations() << endl;
+      cout << "Fit criterion = " << getFitCriterion() << endl;
+      cout << "UseSVD? = " << getUseSVD() << endl;
+      cout << "Clean up = " << getCleanUp() << endl;
+    }
+
+    void DH_WOSolve::clearData()
+    {
+      clearExtraBlob();
+      setWorkOrderID(-1);
+      setStrategyControllerID(-1);
+      setStatus(DH_WOSolve::New);
+      setKSType("");
+      setIteration(-1);
+      setDoNothing(false);
+      setNewDomain(true);
+      setMaxIterations(1);
+      setFitCriterion(-1);
+      setUseSVD(false);
+      setCleanUp(false);
+    }
+
+    string DH_WOSolve::createInsertStatement(TH_DB* th)
+    {
+      ostringstream q;
+      q << "INSERT INTO bbs3wosolver (data, woid, scid, status, kstype, "
+	<< "iteration, donothing, newdomain, maxiterations, fitcriterion, "
+	<< "usesvd, cleanup) VALUES ('";
+      th->addDBBlob(this, q);
+      q << "', "
+	<< getWorkOrderID() << ", "
+	<< getStrategyControllerID() << ", "
+	<< getStatus() << ", '"
+	<< getKSType() << "', "
+	<< getIteration() << ", "
+	<< getDoNothing() << ", "
+	<< getNewDomain() << ", "
+	<< getMaxIterations() << ", "
+	<< getFitCriterion() << ", "
+	<< getUseSVD() << ", "
+	<< getCleanUp() << ");";
+      return q.str();
+    }
+
+    string DH_WOSolve::createUpdateStatement(TH_DB* th)
+    {
+      // NB:This implementation assumes only the status has changed. So only
+      // the blob and the status field are updated!
+      ostringstream q;
+      q << "UPDATE bbs3wosolver SET data='";
+      th->addDBBlob(this, q);
+      q << "', status=" << getStatus()
+	<<" WHERE woid=" << getWorkOrderID();
+      return q.str();
+    }
+
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/ParmWriter.cc b/CEP/BB/BBSControl/src/ParmWriter.cc
index 65bd77c2455fa9509d07cf41f8aa286ae0dd43dc..5d0f07301441f9601646bd344cfcd86033623414 100644
--- a/CEP/BB/BBSControl/src/ParmWriter.cc
+++ b/CEP/BB/BBSControl/src/ParmWriter.cc
@@ -30,89 +30,95 @@
 #include <ParmDB/ParmDB.h>
 #include <ParmDB/ParmValue.h>
 #include <Common/LofarLogger.h>
-#include <iomanip>
-
-
-using namespace std;
+#include <Common/lofar_iomanip.h>
+#include <Common/lofar_map.h>
 
 namespace LOFAR
 {
-ParmWriter::ParmWriter()
-{}
+  namespace BBS
+  {
 
-ParmWriter::~ParmWriter()
-{}
+    
+    ParmWriter::ParmWriter()
+    {}
 
-void ParmWriter::write (const ParmDataInfo& pDataInfo,
-			double fStart, double fEnd,
-			double tStart, double tEnd)
-{
-  const vector<ParmData>& pData = pDataInfo.parms();
-  ParmDB::ParmDomain pdomain(fStart, fEnd, tStart, tEnd);
-  // Store all parameters, all domains in their own ParmTable
-  // Use one ParmTable at the time to avoid reopening the same table.
-  vector<char> done(pData.size(), 0);
-  uint nrDone = 0;
-  while (nrDone < pData.size()) {
-    int lastDBnr = -1;
-    vector<string> parmNames;
-    vector<int>    parmIndex;
-    parmNames.reserve (pData.size());
-    parmIndex.reserve (pData.size());
-    for (uint i=0; i<pData.size(); ++i) {
-      if (done[i] == 0) {
-	if (lastDBnr < 0) {
-	  lastDBnr = pData[i].getParmDBSeqNr();
+    ParmWriter::~ParmWriter()
+    {}
+
+    void ParmWriter::write (const ParmDataInfo& pDataInfo,
+			    double fStart, double fEnd,
+			    double tStart, double tEnd)
+    {
+      const vector<ParmData>& pData = pDataInfo.parms();
+      ParmDB::ParmDomain pdomain(fStart, fEnd, tStart, tEnd);
+      // Store all parameters, all domains in their own ParmTable
+      // Use one ParmTable at the time to avoid reopening the same table.
+      vector<char> done(pData.size(), 0);
+      uint nrDone = 0;
+      while (nrDone < pData.size()) {
+	int lastDBnr = -1;
+	vector<string> parmNames;
+	vector<int>    parmIndex;
+	parmNames.reserve (pData.size());
+	parmIndex.reserve (pData.size());
+	for (uint i=0; i<pData.size(); ++i) {
+	  if (done[i] == 0) {
+	    if (lastDBnr < 0) {
+	      lastDBnr = pData[i].getParmDBSeqNr();
+	    }
+	    if (pData[i].getParmDBSeqNr() == lastDBnr) {
+	      LOG_TRACE_FLOW_STR("Writing parm " << pData[i].getName());
+	      parmNames.push_back (pData[i].getName());
+	      parmIndex.push_back (i);
+	      done[i] = 1;
+	      nrDone++;
+	    }
+	  }
 	}
-	if (pData[i].getParmDBSeqNr() == lastDBnr) {
-	  LOG_TRACE_FLOW_STR("Writing parm " << pData[i].getName() << endl);
-	  parmNames.push_back (pData[i].getName());
-	  parmIndex.push_back (i);
-	  done[i] = 1;
-	  nrDone++;
+	DBGASSERT (lastDBnr >= 0);
+	// Get the ParmDB object for this ParmDB index.
+	// It requires that Prediffer and Controller open the ParmDBs in
+	// the same order.
+	ParmDB::ParmDB pdb = ParmDB::ParmDB::getParmDB (lastDBnr);
+	map<string,ParmDB::ParmValueSet> vals;
+	pdb.getValues (vals, parmNames, pdomain);
+	// Add entries for parms not present in the map.
+	// They are clearly new parms.
+	// Set the value for all parms.
+	for (uint i=0; i<parmNames.size(); i++) {
+	  const ParmData& parmd = pData[parmIndex[i]];
+	  map<string,ParmDB::ParmValueSet>::iterator pos = 
+	    vals.find(parmNames[i]);
+	  if (pos == vals.end()) {
+	    ParmDB::ParmValueSet pset(parmNames[i]);
+	    ParmDB::ParmValue pval = pdb.getDefValue (parmNames[i]);
+	    for (int j=0; j<parmd.size(); ++j) {
+	      //// set correct domain
+	      setCoeff (pval.rep(), parmd.getCoeff(j));
+	      pset.getValues().push_back (pval);
+	    }
+	    vals.insert (make_pair(parmNames[i], pset));
+	  } else {
+	    ASSERT (uint(parmd.size()) == pos->second.getValues().size());
+	    for (int j=0; j<parmd.size(); ++j) {
+	      setCoeff (pos->second.getValues()[j].rep(), parmd.getCoeff(j));
+	    }
+	  }
 	}
+	pdb.putValues (vals);
       }
     }
-    DBGASSERT (lastDBnr >= 0);
-    // Get the ParmDB object for this ParmDB index.
-    // It requires that Prediffer and Controller open the ParmDBs in
-    // the same order.
-    ParmDB::ParmDB pdb = ParmDB::ParmDB::getParmDB (lastDBnr);
-    map<string,ParmDB::ParmValueSet> vals;
-    pdb.getValues (vals, parmNames, pdomain);
-    // Add entries for parms not present in the map.
-    // They are clearly new parms.
-    // Set the value for all parms.
-    for (uint i=0; i<parmNames.size(); i++) {
-      const ParmData& parmd = pData[parmIndex[i]];
-      map<string,ParmDB::ParmValueSet>::iterator pos = vals.find(parmNames[i]);
-      if (pos == vals.end()) {
-	ParmDB::ParmValueSet pset(parmNames[i]);
-	ParmDB::ParmValue pval = pdb.getDefValue (parmNames[i]);
-	for (int j=0; j<parmd.size(); ++j) {
-	  //// set correct domain
-	  setCoeff (pval.rep(), parmd.getCoeff(j));
-	  pset.getValues().push_back (pval);
-	}
-	vals.insert (make_pair(parmNames[i], pset));
-      } else {
-	ASSERT (uint(parmd.size()) == pos->second.getValues().size());
-	for (int j=0; j<parmd.size(); ++j) {
-	  setCoeff (pos->second.getValues()[j].rep(), parmd.getCoeff(j));
-	}
+
+    void ParmWriter::setCoeff (ParmDB::ParmValueRep& pval, 
+			       const MeqMatrix& coeff)
+    {
+      ASSERT (int(pval.itsCoeff.size()) == coeff.nelements());
+      const double* vals = coeff.doubleStorage();
+      for (int i=0; i<coeff.nelements(); ++i) {
+	pval.itsCoeff[i] = vals[i];
       }
     }
-    pdb.putValues (vals);
-  }
-}
 
-void ParmWriter::setCoeff (ParmDB::ParmValueRep& pval, const MeqMatrix& coeff)
-{
-  ASSERT (int(pval.itsCoeff.size()) == coeff.nelements());
-  const double* vals = coeff.doubleStorage();
-  for (int i=0; i<coeff.nelements(); ++i) {
-    pval.itsCoeff[i] = vals[i];
-  }
-}
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/SC_CompoundIter.cc b/CEP/BB/BBSControl/src/SC_CompoundIter.cc
index 859149026676738febaadb8489ab8d1370d3f987..061f43517883e68175b21b6d58e5dd5d2df90de8 100644
--- a/CEP/BB/BBSControl/src/SC_CompoundIter.cc
+++ b/CEP/BB/BBSControl/src/SC_CompoundIter.cc
@@ -31,238 +31,251 @@
 
 namespace LOFAR
 {
-
-SC_CompoundIter::SC_CompoundIter(Connection* inSolConn, Connection* outWOPDConn, 
-		     Connection* outWOSolveConn, int nrPrediffers,
-		     const ParameterSet& args)
-  : StrategyController(inSolConn, outWOPDConn, outWOSolveConn, 
-		       nrPrediffers), 
-    itsFirstCall      (true),
-    itsPrevWOID       (0),
-    itsArgs           (args),
-    itsCurIter        (0),
-    itsCurStartTime   (0),
-    itsControlParmUpd (false),
-    itsStartTime      (0),
-    itsEndTime        (0),
-    itsTimeLength     (0),
-    itsStartChannel   (0),
-    itsEndChannel     (0),
-    itsSendDoNothingWO(false)
-{
-  itsMaxIterations = itsArgs.getInt32("maxNrIterations");
-  if (itsArgs.isDefined("fitCriterion"))
+  namespace BBS
   {
-    itsFitCriterion = itsArgs.getDouble("fitCriterion");
-  }
-  else
-  {
-    itsFitCriterion = -1;
-  }
-  itsControlParmUpd = itsArgs.getBool ("controlParmUpdate");
-  itsWriteParms = itsArgs.getBool("writeParms");
-  itsStartTime = itsArgs.getDouble ("startTimeSec");
-  itsEndTime = itsArgs.getDouble ("endTimeSec");
-  itsTimeLength = itsArgs.getDouble ("timeInterval");
-  itsStartChannel = itsArgs.getInt32 ("startChan");
-  itsEndChannel = itsArgs.getInt32 ("endChan");
-}
-
-SC_CompoundIter::~SC_CompoundIter()
-{}
-
-bool SC_CompoundIter::execute()
-{
-  BBSTest::ScopedTimer si_exec("C:strategycontroller_execute");
-  BBSTest::ScopedTimer getWOTimer("C:getWorkOrders");
-  bool finished = false;  // Has this strategy completed?
-  DH_WOPrediff* WOPD = getPrediffWorkOrder();
-  DH_WOSolve* WOSolve = getSolveWorkOrder();
-  getWOTimer.end();
-
-  if (itsFirstCall)
-  {
-    BBSTest::Logger::log("Start of testrun");
-    itsFirstCall = false;
-
-    itsCurStartTime = itsArgs.getDouble ("startTimeSec");
-
-    WOPD->setNewBaselines(true);
-    WOPD->setNewPeelSources(true);
-    WOPD->setDoNothing(false);
-    WOPD->setCleanUp(false);
-    WOSolve->setDoNothing(false);
-    WOSolve->setCleanUp(false);
-  }
-  else
-  {
-    WOPD->setNewBaselines(false);
-    WOPD->setNewPeelSources(false);
-    WOPD->setCleanUp(false);            // Reset
-    WOSolve->setCleanUp(false);
-  
-    if (itsWriteParms) // If Controller writes parameters at end of interval
-    {
-      // Read final solution of previously issued workorders
-      BBSTest::ScopedTimer readSolTimer("C:read solutions");
-      readFinalSolution();
-      readSolTimer.end();
-
-      // Controller writes new parameter values directly to the tables
-      ParmDataInfo pData;
-      getSolution()->getSolution(pData);
-      double fStart = getSolution()->getStartFreq();
-      double fEnd = getSolution()->getEndFreq();
-      double tStart = getSolution()->getStartTime();
-      double tEnd = getSolution()->getEndTime();
-      BBSTest::ScopedTimer st("C:parmwriter");
-      getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
-    }
 
-    itsCurStartTime += itsTimeLength;
-
-    if (itsCurStartTime >= itsEndTime) // If all time intervals handled, send workorders to
-    {                                  // clean up.
-      itsSendDoNothingWO = true;
-      WOPD->setCleanUp(true);
-      WOSolve->setCleanUp(true);
-      finished = true;                 // This strategy has finished!
+    SC_CompoundIter::SC_CompoundIter(Connection* inSolConn, 
+				     Connection* outWOPDConn, 
+				     Connection* outWOSolveConn, 
+				     int nrPrediffers,
+				     const ParameterSet& args)
+      : StrategyController(inSolConn, outWOPDConn, outWOSolveConn, 
+			   nrPrediffers), 
+	itsFirstCall      (true),
+	itsPrevWOID       (0),
+	itsArgs           (args),
+	itsCurIter        (0),
+	itsCurStartTime   (0),
+	itsControlParmUpd (false),
+	itsStartTime      (0),
+	itsEndTime        (0),
+	itsTimeLength     (0),
+	itsStartChannel   (0),
+	itsEndChannel     (0),
+	itsSendDoNothingWO(false)
+    {
+      itsMaxIterations = itsArgs.getInt32("maxNrIterations");
+      if (itsArgs.isDefined("fitCriterion"))
+      {
+	itsFitCriterion = itsArgs.getDouble("fitCriterion");
+      }
+      else
+      {
+	itsFitCriterion = -1;
+      }
+      itsControlParmUpd = itsArgs.getBool ("controlParmUpdate");
+      itsWriteParms = itsArgs.getBool("writeParms");
+      itsStartTime = itsArgs.getDouble ("startTimeSec");
+      itsEndTime = itsArgs.getDouble ("endTimeSec");
+      itsTimeLength = itsArgs.getDouble ("timeInterval");
+      itsStartChannel = itsArgs.getInt32 ("startChan");
+      itsEndChannel = itsArgs.getInt32 ("endChan");
     }
-    BBSTest::Logger::log("NextInterval");
-  }
 
-  // Set prediffer workorder data
-  WOPD->setStatus(DH_WOPrediff::New);
-  WOPD->setKSType("Prediff1");
+    SC_CompoundIter::~SC_CompoundIter()
+    {}
 
-  // The following settings remain the same for each workorder:
-  {
-    WOPD->setUpdateParms(false);
-    WOPD->setMaxIterations(itsMaxIterations);
-    WOPD->setDoNothing(itsSendDoNothingWO);
-    WOPD->setNewDomain(true);
-    WOPD->setSubtractSources(false);
-    WOPD->setStartChannel (itsStartChannel);
-    WOPD->setEndChannel (itsEndChannel); 
-    WOPD->setTimeLength (itsTimeLength); 
-    WOPD->setModelType (itsArgs.getString ("modelType"));
-    WOPD->setUseAutoCorrelations(itsArgs.getBool ("useAutoCorr"));
-    WOPD->setCalcUVW (itsArgs.getBool ("calcUVW"));
-    ParameterSet msParams = itsArgs.makeSubset("MSDBparams.");
-    vector<int> ant = itsArgs.getInt32Vector("antennas");
-    vector<string> pNames = itsArgs.getStringVector("solvableParams");
-    vector<string> exPNames;
-    if (itsArgs.isDefined("excludeParams"))
+    bool SC_CompoundIter::execute()
     {
-      exPNames = itsArgs.getStringVector("excludeParams");
+      BBSTest::ScopedTimer si_exec("C:strategycontroller_execute");
+      BBSTest::ScopedTimer getWOTimer("C:getWorkOrders");
+      bool finished = false;  // Has this strategy completed?
+      DH_WOPrediff* WOPD = getPrediffWorkOrder();
+      DH_WOSolve* WOSolve = getSolveWorkOrder();
+      getWOTimer.end();
+
+      if (itsFirstCall)
+      {
+	BBSTest::Logger::log("Start of testrun");
+	itsFirstCall = false;
+
+	itsCurStartTime = itsArgs.getDouble ("startTimeSec");
+
+	WOPD->setNewBaselines(true);
+	WOPD->setNewPeelSources(true);
+	WOPD->setDoNothing(false);
+	WOPD->setCleanUp(false);
+	WOSolve->setDoNothing(false);
+	WOSolve->setCleanUp(false);
+      }
+      else
+      {
+	WOPD->setNewBaselines(false);
+	WOPD->setNewPeelSources(false);
+	WOPD->setCleanUp(false);            // Reset
+	WOSolve->setCleanUp(false);
+  
+	// If Controller writes parameters at end of interval
+	if (itsWriteParms)
+	{
+	  // Read final solution of previously issued workorders
+	  BBSTest::ScopedTimer readSolTimer("C:read solutions");
+	  readFinalSolution();
+	  readSolTimer.end();
+
+	  // Controller writes new parameter values directly to the tables
+	  ParmDataInfo pData;
+	  getSolution()->getSolution(pData);
+	  double fStart = getSolution()->getStartFreq();
+	  double fEnd = getSolution()->getEndFreq();
+	  double tStart = getSolution()->getStartTime();
+	  double tEnd = getSolution()->getEndTime();
+	  BBSTest::ScopedTimer st("C:parmwriter");
+	  getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+	}
+
+	itsCurStartTime += itsTimeLength;
+
+	// If all time intervals handled, send workorders to clean up.
+	if (itsCurStartTime >= itsEndTime)
+	{
+	  itsSendDoNothingWO = true;
+	  WOPD->setCleanUp(true);
+	  WOSolve->setCleanUp(true);
+	  finished = true;                 // This strategy has finished!
+	}
+	BBSTest::Logger::log("NextInterval");
+      }
+
+      // Set prediffer workorder data
+      WOPD->setStatus(DH_WOPrediff::New);
+      WOPD->setKSType("Prediff1");
+
+      // The following settings remain the same for each workorder:
+      {
+	WOPD->setUpdateParms(false);
+	WOPD->setMaxIterations(itsMaxIterations);
+	WOPD->setDoNothing(itsSendDoNothingWO);
+	WOPD->setNewDomain(true);
+	WOPD->setSubtractSources(false);
+	WOPD->setStartChannel (itsStartChannel);
+	WOPD->setEndChannel (itsEndChannel); 
+	WOPD->setTimeLength (itsTimeLength); 
+	WOPD->setModelType (itsArgs.getString ("modelType"));
+	WOPD->setUseAutoCorrelations(itsArgs.getBool ("useAutoCorr"));
+	WOPD->setCalcUVW (itsArgs.getBool ("calcUVW"));
+	ParameterSet msParams = itsArgs.makeSubset("MSDBparams.");
+	vector<int> ant = itsArgs.getInt32Vector("antennas");
+	vector<string> pNames = itsArgs.getStringVector("solvableParams");
+	vector<string> exPNames;
+	if (itsArgs.isDefined("excludeParams"))
+	{
+	  exPNames = itsArgs.getStringVector("excludeParams");
+	}
+	vector<int> srcs = itsArgs.getInt32Vector("sources");
+	vector<int> corrs;
+	if (itsArgs.isDefined("correlations"))
+	{
+	  corrs = itsArgs.getInt32Vector("correlations");
+	}
+	// the prediffer needs to know the modelType too
+	msParams.add ("modelType", itsArgs.getString("modelType"));
+	msParams.add ("calcUVW", itsArgs.getString("calcUVW"));
+	WOPD->setVarData (msParams, ant, pNames, exPNames, srcs, corrs);
+	WOPD->setStrategyControllerID(getID());
+ 
+	WOSolve->setDoNothing(itsSendDoNothingWO); 
+	WOSolve->setNewDomain(true);
+	WOSolve->setMaxIterations(itsMaxIterations);
+	WOSolve->setFitCriterion(itsFitCriterion);
+	WOSolve->setUseSVD (itsArgs.getBool ("useSVD"));
+	WOSolve->setIteration(itsCurIter);
+	WOSolve->setStrategyControllerID(getID());
+      }
+
+      WOPD->setStartTime (itsCurStartTime);
+
+      int woid = getNewWorkOrderID();
+      WOPD->setWorkOrderID(woid);
+
+      // WOID of solution (the same for each prediffer)
+      WOPD->setSolutionID(woid);
+
+      // Set solver workorder data  
+      WOSolve->setStatus(DH_WOSolve::New);
+      WOSolve->setKSType("Solver");
+      WOSolve->setWorkOrderID(woid);
+
+      // Remember the issued workorder id
+      itsPrevWOID = woid; 
+
+      // Temporarily show on cout
+      //  cout << "!!!!!!! Sent workorders: " << endl;
+      //WOPD->dump();
+      //WOSolve->dump();
+
+      //  cout << "!!!!!!! " << endl;
+
+      // Insert WorkOrders into database
+      BBSTest::ScopedTimer st("C:putWOinDB");
+      WOPD->insertDB(*itsOutWOPDConn);
+
+      // Send workorders the same workorders to other prediffers (if there are
+      // more than 1)
+      int nrPred = getNumberOfPrediffers();
+      for (int i = 2; i <= nrPred; i++)
+      {
+	WOPD->setWorkOrderID(getNewWorkOrderID());
+	char str[32];
+	sprintf(str, "%i", i);
+	WOPD->setKSType("Prediff"+string(str));
+	WOPD->insertDB(*itsOutWOPDConn);
+      }
+
+      WOSolve->insertDB(*itsOutWOSolveConn);
+
+      return (!finished);
     }
-    vector<int> srcs = itsArgs.getInt32Vector("sources");
-    vector<int> corrs;
-    if (itsArgs.isDefined("correlations"))
+
+    void SC_CompoundIter::postprocess()
     {
-      corrs = itsArgs.getInt32Vector("correlations");
+      if ((!itsSendDoNothingWO) && itsWriteParms)   // If Controller writes parameters at end of interval
+      {
+	// Read final solution of previously issued workorders
+	readFinalSolution();
+
+	// Controller writes found parameter values in the tables
+	ParmDataInfo pData;
+	getSolution()->getSolution(pData);
+	double fStart = getSolution()->getStartFreq();
+	double fEnd = getSolution()->getEndFreq();
+	double tStart = getSolution()->getStartTime();
+	double tEnd = getSolution()->getEndTime();
+	BBSTest::ScopedTimer st("C:parmwriter");
+	getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+      }
+      BBSTest::Logger::log("End of TestRun");
     }
-    // the prediffer needs to know the modelType too
-    msParams.add ("modelType", itsArgs.getString("modelType"));
-    msParams.add ("calcUVW", itsArgs.getString("calcUVW"));
-    WOPD->setVarData (msParams, ant, pNames, exPNames, srcs, corrs);
-    WOPD->setStrategyControllerID(getID());
- 
-    WOSolve->setDoNothing(itsSendDoNothingWO); 
-    WOSolve->setNewDomain(true);
-    WOSolve->setMaxIterations(itsMaxIterations);
-    WOSolve->setFitCriterion(itsFitCriterion);
-    WOSolve->setUseSVD (itsArgs.getBool ("useSVD"));
-    WOSolve->setIteration(itsCurIter);
-    WOSolve->setStrategyControllerID(getID());
-  }
-
-  WOPD->setStartTime (itsCurStartTime);
-
-  int woid = getNewWorkOrderID();
-  WOPD->setWorkOrderID(woid);
-  WOPD->setSolutionID(woid);  // WOID of solution (the same for each prediffer)
-
-  // Set solver workorder data  
-  WOSolve->setStatus(DH_WOSolve::New);
-  WOSolve->setKSType("Solver");
-  WOSolve->setWorkOrderID(woid);  
-  itsPrevWOID = woid;        // Remember the issued workorder id
-
-  // Temporarily show on cout
-  //  cout << "!!!!!!! Sent workorders: " << endl;
-  //WOPD->dump();
-  //WOSolve->dump();
-
-  //  cout << "!!!!!!! " << endl;
-
-  // Insert WorkOrders into database
-  BBSTest::ScopedTimer st("C:putWOinDB");
-  WOPD->insertDB(*itsOutWOPDConn);
-
-  // Send workorders the same workorders to other prediffers (if there are more than 1)
-  int nrPred = getNumberOfPrediffers();
-  for (int i = 2; i <= nrPred; i++)
-  {
-    WOPD->setWorkOrderID(getNewWorkOrderID());
-    char str[32];
-    sprintf(str, "%i", i);
-    WOPD->setKSType("Prediff"+string(str));
-    WOPD->insertDB(*itsOutWOPDConn);
-  }
-
-  WOSolve->insertDB(*itsOutWOSolveConn);
-
-  return (!finished);
-}
-
-void SC_CompoundIter::postprocess()
-{
-  if ((!itsSendDoNothingWO) && itsWriteParms)   // If Controller writes parameters at end of interval
-  {
-    // Read final solution of previously issued workorders
-    readFinalSolution();
-
-    // Controller writes found parameter values in the tables
-    ParmDataInfo pData;
-    getSolution()->getSolution(pData);
-    double fStart = getSolution()->getStartFreq();
-    double fEnd = getSolution()->getEndFreq();
-    double tStart = getSolution()->getStartTime();
-    double tEnd = getSolution()->getEndTime();
-    BBSTest::ScopedTimer st("C:parmwriter");
-    getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
-  }
-  BBSTest::Logger::log("End of TestRun");
-}
-
-void SC_CompoundIter::readFinalSolution()
-{
-  LOG_TRACE_FLOW("SC_CompoundIter reading solution");
-
-  DH_DB* solPtr = getSolution();
-
-  // Wait for solution
-  bool firstTime = true;
-  int id = itsPrevWOID;
-  char str[128];
-  sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i AND (HASCONVERGED=1 OR ITERATION=%i)", 
-	  id, itsMaxIterations-1);
-  string query(str);
 
-  while (solPtr->queryDB(query, *itsInSolConn) <= 0)
-  {
-    if (firstTime)
+    void SC_CompoundIter::readFinalSolution()
     {
-      cout << "No solution found by SC_CompoundIter " << getID() 
-	   << ". Waiting for solution..." << endl;
-      firstTime = false;
-    }
-  }
+      LOG_TRACE_FLOW("SC_CompoundIter reading solution");
+
+      DH_DB* solPtr = getSolution();
+
+      // Wait for solution
+      bool firstTime = true;
+      int id = itsPrevWOID;
+      char str[128];
+      sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i AND "
+	      "(HASCONVERGED=1 OR ITERATION=%i)", id, itsMaxIterations-1);
+      string query(str);
+
+      while (solPtr->queryDB(query, *itsInSolConn) <= 0)
+      {
+	if (firstTime)
+	{
+	  cout << "No solution found by SC_CompoundIter " << getID() 
+	       << ". Waiting for solution..." << endl;
+	  firstTime = false;
+	}
+      }
+
+      //getSolution()->dump();
 
-  //getSolution()->dump();
+    }
 
-}
 
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/SC_Simple.cc b/CEP/BB/BBSControl/src/SC_Simple.cc
index 5ebaccb3eaaf1962dcb059080d0cb3780def883c..837eee570a12507417f20924d17e0a38b1e07a3b 100644
--- a/CEP/BB/BBSControl/src/SC_Simple.cc
+++ b/CEP/BB/BBSControl/src/SC_Simple.cc
@@ -31,278 +31,297 @@
 
 namespace LOFAR
 {
-
-SC_Simple::SC_Simple(Connection* inSolConn, Connection* outWOPDConn, 
-		     Connection* outWOSolveConn, int nrPrediffers,
-		     const ParameterSet& args)
-  : StrategyController(inSolConn, outWOPDConn, outWOSolveConn, 
-		       nrPrediffers), 
-    itsFirstCall      (true),
-    itsPrevWOID       (0),
-    itsArgs           (args),
-    itsCurIter        (-1),
-    itsCurStartTime   (0),
-    itsControlParmUpd (false),
-    itsStartTime      (0),
-    itsTimeLength     (0),
-    itsStartChannel   (0),
-    itsEndChannel     (0),
-    itsSendDoNothingWO(false)
-{
-  itsNrIterations = itsArgs.getInt32("maxNrIterations");
-  if (itsArgs.isDefined("fitCriterion"))
+  namespace BBS
   {
-    itsFitCriterion = itsArgs.getDouble("fitCriterion");
-  }
-  else
-  {
-    itsFitCriterion = -1;
-  }
-  itsControlParmUpd = itsArgs.getBool ("controlParmUpdate");
-  itsWriteParms = itsArgs.getBool("writeParms");
-  itsStartTime = itsArgs.getDouble ("startTimeSec");
-  itsEndTime = itsArgs.getDouble ("endTimeSec");
-  itsTimeLength = itsArgs.getDouble ("timeInterval");
-  itsStartChannel = itsArgs.getInt32 ("startChan");
-  itsEndChannel = itsArgs.getInt32 ("endChan");
-}
-
-SC_Simple::~SC_Simple()
-{}
-
-bool SC_Simple::execute()
-{
-  BBSTest::ScopedTimer si_exec("C:strategycontroller_execute");
-  BBSTest::ScopedTimer getWOTimer("C:getWorkOrders");
-  bool finished = false;   // Has this strategy completed?
-  DH_WOPrediff* WOPD = getPrediffWorkOrder();
-  DH_WOSolve* WOSolve = getSolveWorkOrder();
-  getWOTimer.end();
-
-  itsCurIter++;
-  bool nextInter = false;
-  if (itsFirstCall)
-  {
-    BBSTest::Logger::log("Start of testrun");
-    itsFirstCall = false;
-    nextInter = true;
-    WOPD->setNewBaselines(true);
-    WOPD->setNewPeelSources(true);
-    WOPD->setSubtractSources(false);
-    WOPD->setUpdateParms(false);
-    WOPD->setCleanUp(false);
-    WOSolve->setNewDomain(true);
-    WOSolve->setCleanUp(false);
-    itsCurStartTime = itsArgs.getDouble ("startTimeSec");
-  }
-  else
-  {
-
-    WOPD->setNewBaselines(false);
-    WOPD->setNewPeelSources(false);
-    WOPD->setSubtractSources(false);
-    WOPD->setUpdateParms(true);
-    WOPD->setCleanUp(false);         //Reset
-    WOSolve->setNewDomain(false);
-    WOSolve->setCleanUp(false);
-
-    if (itsSendDoNothingWO==false)  /// if previous sent WorkOrder was a "do nothing", do not read solution
+    SC_Simple::SC_Simple(Connection* inSolConn, Connection* outWOPDConn, 
+			 Connection* outWOSolveConn, int nrPrediffers,
+			 const ParameterSet& args)
+      : StrategyController(inSolConn, outWOPDConn, outWOSolveConn, 
+			   nrPrediffers), 
+	itsPrevWOID       (0),
+	itsArgs           (args),
+	itsCurIter        (-1),
+	itsCurStartTime   (0),
+	itsControlParmUpd (false),
+	itsStartTime      (0),
+	itsTimeLength     (0),
+	itsStartChannel   (0),
+	itsEndChannel     (0),
+	itsSendDoNothingWO(false)
     {
-      // Read solution of previously issued workorders
-      BBSTest::ScopedTimer readSolTimer("C:read solutions");
-      readSolution();
-      readSolTimer.end();
-
-      if (itsControlParmUpd)   // If Controller handles parameter writing
+      itsNrIterations = itsArgs.getInt32("maxNrIterations");
+      if (itsArgs.isDefined("fitCriterion"))
       {
-	// Controller writes new parameter values directly to the tables
-	ParmDataInfo pData;
-	getSolution()->getSolution(pData);
-	double fStart = getSolution()->getStartFreq();
-	double fEnd = getSolution()->getEndFreq();
-	double tStart = getSolution()->getStartTime();
-	double tEnd = getSolution()->getEndTime();
-	BBSTest::ScopedTimer st("C:parmwriter");
-	getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+	itsFitCriterion = itsArgs.getDouble("fitCriterion");
       }
       else
       {
-	// Send the (reference to) parameter values to Prediffers.
-	WOPD->setSolutionID(itsPrevWOID);
+	itsFitCriterion = -1;
       }
+      itsControlParmUpd = itsArgs.getBool ("controlParmUpdate");
+      itsWriteParms = itsArgs.getBool("writeParms");
+      itsStartTime = itsArgs.getDouble ("startTimeSec");
+      itsEndTime = itsArgs.getDouble ("endTimeSec");
+      itsTimeLength = itsArgs.getDouble ("timeInterval");
+      itsStartChannel = itsArgs.getInt32 ("startChan");
+      itsEndChannel = itsArgs.getInt32 ("endChan");
     }
-     
-    // Take absolute value of fit
-    double fit = getSolution()->getQuality().itsFit;
-    if (fit<0)
+
+    SC_Simple::~SC_Simple()
+    {}
+
+    void SC_Simple::preprocess()
     {
-      fit = -fit;
+      DH_WOPrediff* WOPD = getPrediffWorkOrder();
+      DH_WOSolve* WOSolve = getSolveWorkOrder();
+      BBSTest::Logger::log("Start of testrun");
+      WOPD->setNewBaselines(true);
+      WOPD->setNewPeelSources(true);
+      WOPD->setSubtractSources(false);
+      WOPD->setUpdateParms(false);
+      WOPD->setCleanUp(false);
+      WOSolve->setNewDomain(true);
+      WOSolve->setCleanUp(false);
+      itsCurStartTime = itsArgs.getDouble ("startTimeSec");
     }
 
-    itsSendDoNothingWO = false;
-    // If max number of iterations reached, go to next interval.
-    // If solution for this interval is good enough, send "do nothing" workorders until 
-    // max number of iterations reached.
-    if (itsCurIter == itsNrIterations)
+    bool SC_Simple::execute()
     {
-      nextInter = true;
-      itsCurIter = 0;
-      WOPD->setUpdateParms(false);  // New time interval, so do not reread parameters
-      WOPD->setSolutionID(-1);  // New time interval, so do not use solution from previous interval
-      itsCurStartTime += itsArgs.getDouble ("timeInterval");
-
-      if (itsCurStartTime >= itsEndTime)  // If all time intervals handled, send workorders to
-      {                                  // clean up.
-	itsSendDoNothingWO = true;
-	WOPD->setCleanUp(true);
-	WOSolve->setCleanUp(true);
-	finished = true;               // This strategy has finished!
+      BBSTest::ScopedTimer si_exec("C:strategycontroller_execute");
+      BBSTest::ScopedTimer getWOTimer("C:getWorkOrders");
+      bool finished = false;   // Has this strategy completed?
+      DH_WOPrediff* WOPD = getPrediffWorkOrder();
+      DH_WOSolve* WOSolve = getSolveWorkOrder();
+      getWOTimer.end();
+
+      itsCurIter++;
+      bool nextInter = false;
+      {
+	
+	WOPD->setNewBaselines(false);
+	WOPD->setNewPeelSources(false);
+	WOPD->setSubtractSources(false);
+	WOPD->setUpdateParms(true);
+	WOPD->setCleanUp(false);         //Reset
+	WOSolve->setNewDomain(false);
+	WOSolve->setCleanUp(false);
+	
+	// If previous sent WorkOrder was a "do nothing", do not read solution
+	if (itsSendDoNothingWO==false)
+	{
+	  // Read solution of previously issued workorders
+	  BBSTest::ScopedTimer readSolTimer("C:read solutions");
+	  readSolution();
+	  readSolTimer.end();
+
+	  // If Controller handles parameter writing
+	  if (itsControlParmUpd)
+	  {
+	    // Controller writes new parameter values directly to the tables
+	    ParmDataInfo pData;
+	    getSolution()->getSolution(pData);
+	    double fStart = getSolution()->getStartFreq();
+	    double fEnd = getSolution()->getEndFreq();
+	    double tStart = getSolution()->getStartTime();
+	    double tEnd = getSolution()->getEndTime();
+	    BBSTest::ScopedTimer st("C:parmwriter");
+	    getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+	  }
+	  else
+	  {
+	    // Send the (reference to) parameter values to Prediffers.
+	    WOPD->setSolutionID(itsPrevWOID);
+	  }
+	}
+     
+	// Take absolute value of fit
+	double fit = getSolution()->getQuality().itsFit;
+	if (fit<0)
+	{
+	  fit = -fit;
+	}
+
+	itsSendDoNothingWO = false;
+	// If max number of iterations reached, go to next interval. If
+	// solution for this interval is good enough, send "do nothing"
+	// workorders until max number of iterations reached.
+	if (itsCurIter == itsNrIterations)
+	{
+	  nextInter = true;
+	  itsCurIter = 0;
+
+	  // New time interval, so do not reread parameters
+	  WOPD->setUpdateParms(false);
+
+	  // New time interval, so do not use solution from previous interval
+	  WOPD->setSolutionID(-1);
+
+	  itsCurStartTime += itsArgs.getDouble ("timeInterval");
+
+	  // If all time intervals handled, send workorders to clean up.
+	  if (itsCurStartTime >= itsEndTime)
+	  {
+	    itsSendDoNothingWO = true;
+	    WOPD->setCleanUp(true);
+	    WOSolve->setCleanUp(true);
+	    finished = true;               // This strategy has finished!
+	  }
+
+	  // If controller should write params at end of each interval and has
+	  // not already done so...
+	  if (itsWriteParms && (!itsControlParmUpd))
+	  {
+	    ParmDataInfo pData;
+	    getSolution()->getSolution(pData);
+	    double fStart = getSolution()->getStartFreq();
+	    double fEnd = getSolution()->getEndFreq();
+	    double tStart = getSolution()->getStartTime();
+	    double tEnd = getSolution()->getEndTime();
+	    BBSTest::ScopedTimer st("C:parmwriter");
+	    getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+	  }
+	  BBSTest::Logger::log("NextInterval");
+	}
+	else if (fit < itsFitCriterion)
+	{
+	  LOG_INFO_STR("Fit criterion met after " << itsCurIter 
+		       << " iterations");
+	  itsSendDoNothingWO = true;
+	}
       }
 
-      if (itsWriteParms && (!itsControlParmUpd))  // If controller should write params at end of
-      {                                           // each interval and has not already done so.
-	ParmDataInfo pData;
-	getSolution()->getSolution(pData);
-	double fStart = getSolution()->getStartFreq();
-	double fEnd = getSolution()->getEndFreq();
-	double tStart = getSolution()->getStartTime();
-	double tEnd = getSolution()->getEndTime();
-	BBSTest::ScopedTimer st("C:parmwriter");
-	getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+      WOPD->setDoNothing(itsSendDoNothingWO);
+      WOSolve->setDoNothing(itsSendDoNothingWO);
+      if (itsSendDoNothingWO==false)
+      {
+	// Set prediffer workorder data
+	WOPD->setStatus(DH_WOPrediff::New);
+	WOPD->setKSType("Prediff1");
+	WOPD->setStartChannel (itsStartChannel);
+	WOPD->setEndChannel (itsEndChannel);
+	WOPD->setStartTime (itsCurStartTime);
+	double timeLength = itsArgs.getDouble ("timeInterval");
+	WOPD->setTimeLength (timeLength);
+	WOPD->setModelType (itsArgs.getString ("modelType"));
+	WOPD->setUseAutoCorrelations(itsArgs.getBool ("useAutoCorr"));
+	WOPD->setCalcUVW (itsArgs.getBool ("calcUVW"));
+	ParameterSet msParams = itsArgs.makeSubset("MSDBparams.");
+	vector<int> ant = itsArgs.getInt32Vector("antennas");
+	vector<string> pNames = itsArgs.getStringVector("solvableParams");
+	vector<string> exPNames;
+	if (itsArgs.isDefined("excludeParams"))
+	{
+	  exPNames = itsArgs.getStringVector("excludeParams");
+	}
+	vector<int> srcs = itsArgs.getInt32Vector("sources");
+	vector<int> corrs;
+	if (itsArgs.isDefined("correlations"))
+	{
+	  corrs = itsArgs.getInt32Vector("correlations");
+	}
+	// the prediffer needs to know the modelType too
+	msParams.add ("modelType", itsArgs.getString("modelType"));
+	msParams.add ("calcUVW", itsArgs.getString("calcUVW"));
+	WOPD->setVarData (msParams, ant, pNames, exPNames, srcs, corrs);
       }
-      BBSTest::Logger::log("NextInterval");
-    }
-    else if (fit < itsFitCriterion)
-    {
-      LOG_INFO_STR("Fit criterion met after " << itsCurIter << " iterations");
-      itsSendDoNothingWO = true;
-    }
-  }
 
-  WOPD->setDoNothing(itsSendDoNothingWO);
-  WOSolve->setDoNothing(itsSendDoNothingWO);
-  if (itsSendDoNothingWO==false)
-  {
-    // Set prediffer workorder data
-    WOPD->setStatus(DH_WOPrediff::New);
-    WOPD->setKSType("Prediff1");
-    WOPD->setStartChannel (itsStartChannel);
-    WOPD->setEndChannel (itsEndChannel);
-    WOPD->setStartTime (itsCurStartTime);
-    double timeLength = itsArgs.getDouble ("timeInterval");
-    WOPD->setTimeLength (timeLength);
-    WOPD->setModelType (itsArgs.getString ("modelType"));
-    WOPD->setUseAutoCorrelations(itsArgs.getBool ("useAutoCorr"));
-    WOPD->setCalcUVW (itsArgs.getBool ("calcUVW"));
-    ParameterSet msParams = itsArgs.makeSubset("MSDBparams.");
-    vector<int> ant = itsArgs.getInt32Vector("antennas");
-    vector<string> pNames = itsArgs.getStringVector("solvableParams");
-    vector<string> exPNames;
-    if (itsArgs.isDefined("excludeParams"))
-    {
-      exPNames = itsArgs.getStringVector("excludeParams");
-    }
-    vector<int> srcs = itsArgs.getInt32Vector("sources");
-    vector<int> corrs;
-    if (itsArgs.isDefined("correlations"))
-    {
-      corrs = itsArgs.getInt32Vector("correlations");
-    }
-    // the prediffer needs to know the modelType too
-    msParams.add ("modelType", itsArgs.getString("modelType"));
-    msParams.add ("calcUVW", itsArgs.getString("calcUVW"));
-    WOPD->setVarData (msParams, ant, pNames, exPNames, srcs, corrs);
-  }
-
-  int woid = getNewWorkOrderID();
-  WOPD->setWorkOrderID(woid);
-  WOPD->setStrategyControllerID(getID());
-  WOPD->setNewDomain(nextInter);
-
-  // Set solver workorder data  
-  WOSolve->setStatus(DH_WOSolve::New);
-  WOSolve->setKSType("Solver");
-  WOSolve->setUseSVD (itsArgs.getBool ("useSVD"));
-  WOSolve->setIteration(itsCurIter);
-
-  WOSolve->setWorkOrderID(woid);
-  itsPrevWOID = WOSolve->getWorkOrderID();  // Remember the issued workorder id
-  WOSolve->setStrategyControllerID(getID());
-  WOSolve->setNewDomain(nextInter);
-
-  // Temporarily show on cout
-  //  cout << "!!!!!!! Sent workorders: " << endl;
-  //WOPD->dump();
-  //WOSolve->dump();
-
-  //  cout << "!!!!!!! " << endl;
-
-  // Insert WorkOrders into database
-  BBSTest::ScopedTimer st("C:putWOinDB");
-  WOPD->insertDB(*itsOutWOPDConn);
-
-  // Send workorders the same workorders to other prediffers (if there are more than 1)
-  int nrPred = getNumberOfPrediffers();
-  for (int i = 2; i <= nrPred; i++)
-  {
-    WOPD->setWorkOrderID(getNewWorkOrderID());
-    char str[32];
-    sprintf(str, "%i", i);
-    WOPD->setKSType("Prediff"+string(str));
-    WOPD->insertDB(*itsOutWOPDConn);
-  }
+      int woid = getNewWorkOrderID();
+      WOPD->setWorkOrderID(woid);
+      WOPD->setStrategyControllerID(getID());
+      WOPD->setNewDomain(nextInter);
 
-  WOSolve->insertDB(*itsOutWOSolveConn);
+      // Set solver workorder data  
+      WOSolve->setStatus(DH_WOSolve::New);
+      WOSolve->setKSType("Solver");
+      WOSolve->setUseSVD (itsArgs.getBool ("useSVD"));
+      WOSolve->setIteration(itsCurIter);
 
-  return (!finished);
-}
+      WOSolve->setWorkOrderID(woid);
 
-void SC_Simple::postprocess()
-{
-  if (itsSendDoNothingWO == false) // Only read solution if previous workorder was not a "do nothing"
-  {
-    if (itsWriteParms || itsControlParmUpd)           // write solution in parmtable
-    {
-      readSolution();
-      // Controller writes found parameter values in the tables
-      ParmDataInfo pData;
-      getSolution()->getSolution(pData);
-      double fStart = getSolution()->getStartFreq();
-      double fEnd = getSolution()->getEndFreq();
-      double tStart = getSolution()->getStartTime();
-      double tEnd = getSolution()->getEndTime();
-      BBSTest::ScopedTimer st("C:parmwriter");
-      getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
-    }
-  }
-  BBSTest::Logger::log("End of TestRun");
-}
+      // Remember the issued workorder id
+      itsPrevWOID = WOSolve->getWorkOrderID();
 
-void SC_Simple::readSolution()
-{
-  LOG_TRACE_FLOW("SC_Simple reading solution");
+      WOSolve->setStrategyControllerID(getID());
+      WOSolve->setNewDomain(nextInter);
 
-  DH_DB* solPtr = getSolution();
+      // Temporarily show on cout
+      //  cout << "!!!!!!! Sent workorders: " << endl;
+      //WOPD->dump();
+      //WOSolve->dump();
 
-  // Wait for solution
-  bool firstTime = true;
-  int id = itsPrevWOID;
-  char str[64];
-  sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i", id);
-  string query(str);
+      //  cout << "!!!!!!! " << endl;
 
-  while (solPtr->queryDB(query, *itsInSolConn) <= 0)
-  {
-    if (firstTime)
+      // Insert WorkOrders into database
+      BBSTest::ScopedTimer st("C:putWOinDB");
+      WOPD->insertDB(*itsOutWOPDConn);
+
+      // Send workorders the same workorders to other prediffers (if there are
+      // more than 1)
+      int nrPred = getNumberOfPrediffers();
+      for (int i = 2; i <= nrPred; i++)
+      {
+	WOPD->setWorkOrderID(getNewWorkOrderID());
+	char str[32];
+	sprintf(str, "%i", i);
+	WOPD->setKSType("Prediff"+string(str));
+	WOPD->insertDB(*itsOutWOPDConn);
+      }
+
+      WOSolve->insertDB(*itsOutWOSolveConn);
+
+      return (!finished);
+    }
+
+    void SC_Simple::postprocess()
     {
-      cout << "No solution found by SC_Simple " << getID() 
-	   << ". Waiting for solution..." << endl;
-      firstTime = false;
+      // Only read solution if previous workorder was not a "do nothing"
+      if (itsSendDoNothingWO == false)
+      {
+	// write solution in parmtable
+	if (itsWriteParms || itsControlParmUpd)
+	{
+	  readSolution();
+	  // Controller writes found parameter values in the tables
+	  ParmDataInfo pData;
+	  getSolution()->getSolution(pData);
+	  double fStart = getSolution()->getStartFreq();
+	  double fEnd = getSolution()->getEndFreq();
+	  double tStart = getSolution()->getStartTime();
+	  double tEnd = getSolution()->getEndTime();
+	  BBSTest::ScopedTimer st("C:parmwriter");
+	  getParmWriter().write(pData, fStart, fEnd, tStart, tEnd);
+	}
+      }
+      BBSTest::Logger::log("End of TestRun");
     }
-  }
 
-  //getSolution()->dump();
+    void SC_Simple::readSolution()
+    {
+      LOG_TRACE_FLOW("SC_Simple reading solution");
+
+      DH_DB* solPtr = getSolution();
+
+      // Wait for solution
+      bool firstTime = true;
+      int id = itsPrevWOID;
+      char str[64];
+      sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i", id);
+      string query(str);
+
+      while (solPtr->queryDB(query, *itsInSolConn) <= 0)
+      {
+	if (firstTime)
+	{
+	  cout << "No solution found by SC_Simple " << getID() 
+	       << ". Waiting for solution..." << endl;
+	  firstTime = false;
+	}
+      }
+
+      //getSolution()->dump();
+
+    }
 
-}
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/SC_WritePredData.cc b/CEP/BB/BBSControl/src/SC_WritePredData.cc
index 89cbabdeb5365be276c3ce7b5480ad74dc2c1a64..f21ae96f7a77c8eb2de2f09886e90ecca41e03e0 100644
--- a/CEP/BB/BBSControl/src/SC_WritePredData.cc
+++ b/CEP/BB/BBSControl/src/SC_WritePredData.cc
@@ -31,133 +31,140 @@
 
 namespace LOFAR
 {
-
-SC_WritePredData::SC_WritePredData(Connection* inSolConn, Connection* outWOPDConn, 
-		     Connection* outWOSolveConn, int nrPrediffers,
-		     const ParameterSet& args)
-  : StrategyController(inSolConn, outWOPDConn, outWOSolveConn, 
-		       nrPrediffers), 
-    itsFirstCall      (true),
-    itsArgs           (args),
-    itsCurStartTime   (0),
-    itsStartTime      (0),
-    itsEndTime        (0),
-    itsTimeLength     (0),
-    itsStartChannel   (0),
-    itsEndChannel     (0)
-{
-  itsWriteInDataCol = itsArgs.getBool ("writeInDataCol");
-  itsStartTime = itsArgs.getDouble ("startTimeSec");
-  itsEndTime = itsArgs.getDouble ("endTimeSec");
-  itsTimeLength = itsArgs.getDouble ("timeInterval");
-  itsStartChannel = itsArgs.getInt32 ("startChan");
-  itsEndChannel = itsArgs.getInt32 ("endChan");
-}
-
-SC_WritePredData::~SC_WritePredData()
-{}
-
-bool SC_WritePredData::execute()
-{
-  BBSTest::ScopedTimer si_exec("C:strategycontroller_execute");
-  BBSTest::ScopedTimer getWOTimer("C:getWorkOrders");
-  bool finished = false; // Has this strategy completed?
-  DH_WOPrediff* WOPD = getPrediffWorkOrder();
-  DH_WOSolve* WOSolve = getSolveWorkOrder();
-  getWOTimer.end();
-
-  WOPD->setCleanUp(false);
-  WOPD->setDoNothing(false);
-  
-  if (itsFirstCall)
+  namespace BBS
   {
-    BBSTest::Logger::log("Start of testrun");
-    itsFirstCall = false;
-    itsCurStartTime = itsStartTime;
-  }
-  else
-  {
-    itsCurStartTime += itsTimeLength;
-    BBSTest::Logger::log("NextInterval");
-    
-    if (itsCurStartTime >= itsEndTime)  // If all time intervals handled, send workorder to
-    {                                  // clean up.
-      WOPD->setDoNothing(true);
-      WOPD->setCleanUp(true);
-      finished = true;               // This strategy has finished!
+
+    SC_WritePredData::SC_WritePredData(Connection* inSolConn, 
+				       Connection* outWOPDConn, 
+				       Connection* outWOSolveConn, 
+				       int nrPrediffers,
+				       const ParameterSet& args)
+      : StrategyController(inSolConn, outWOPDConn, outWOSolveConn, 
+			   nrPrediffers), 
+	itsFirstCall      (true),
+	itsArgs           (args),
+	itsCurStartTime   (0),
+	itsStartTime      (0),
+	itsEndTime        (0),
+	itsTimeLength     (0),
+	itsStartChannel   (0),
+	itsEndChannel     (0)
+    {
+      itsWriteInDataCol = itsArgs.getBool ("writeInDataCol");
+      itsStartTime = itsArgs.getDouble ("startTimeSec");
+      itsEndTime = itsArgs.getDouble ("endTimeSec");
+      itsTimeLength = itsArgs.getDouble ("timeInterval");
+      itsStartChannel = itsArgs.getInt32 ("startChan");
+      itsEndChannel = itsArgs.getInt32 ("endChan");
     }
 
-  }
-
-  // Set prediffer workorder data
-  WOPD->setStatus(DH_WOPrediff::New);
-  WOPD->setKSType("Prediff1");
-  WOPD->setWritePredData(true);
-  WOPD->setWriteInDataCol(itsWriteInDataCol);
-  WOPD->setStartChannel (itsStartChannel);
-  WOPD->setEndChannel (itsEndChannel);
-  WOPD->setStartTime (itsCurStartTime);
-  WOPD->setTimeLength (itsTimeLength);
-  WOPD->setModelType (itsArgs.getString ("modelType"));
-  WOPD->setCalcUVW (itsArgs.getBool ("calcUVW"));
-  ParameterSet msParams = itsArgs.makeSubset("MSDBparams.");
-  vector<int> ant = itsArgs.getInt32Vector("antennas");
-
-  vector<int> srcs = itsArgs.getInt32Vector("sources");
-  vector<int> corrs;
-  if (itsArgs.isDefined("correlations"))
-  {
-    corrs = itsArgs.getInt32Vector("correlations");
-  }
-  // the prediffer needs to know the modelType too
-  msParams.add ("modelType", itsArgs.getString("modelType"));
-  msParams.add ("calcUVW", itsArgs.getString("calcUVW"));
-  vector<string> pNames;    // Empty vector
-  vector<string> exPNames;    // Empty vector
-  WOPD->setVarData (msParams, ant, pNames, exPNames, srcs, corrs);
- 
-  int woid = getNewWorkOrderID();  
-  WOPD->setWorkOrderID(woid);
-  WOPD->setStrategyControllerID(getID());
-  WOPD->setNewDomain(true);
-
-  // Set solver workorder data  
-  WOSolve->setStatus(DH_WOSolve::New);
-  WOSolve->setKSType("Solver");
-  WOSolve->setDoNothing(true);  // Solver is not used in this strategy
-  WOSolve->setWorkOrderID(woid);
-  WOSolve->setStrategyControllerID(getID());
-
-  // Temporarily show on cout
-  cout << "!!!!!!! Sent workorders: " << endl;
-  //WOPD->dump();
-  //WOSolve->dump();
-
-  cout << "!!!!!!! " << endl;
-
-  // Insert WorkOrders into database
-  BBSTest::ScopedTimer st("C:putWOinDB");
-  WOPD->insertDB(*itsOutWOPDConn);
-
-  // Send workorders the same workorders to other prediffers (if there are more than 1)
-  int nrPred = getNumberOfPrediffers();
-  for (int i = 2; i <= nrPred; i++)
-  {
-    WOPD->setWorkOrderID(getNewWorkOrderID());
-    char str[32];
-    sprintf(str, "%i", i);
-    WOPD->setKSType("Prediff"+string(str));
-    WOPD->insertDB(*itsOutWOPDConn);
-  }
+    SC_WritePredData::~SC_WritePredData()
+    {}
 
-  WOSolve->insertDB(*itsOutWOSolveConn);
+    bool SC_WritePredData::execute()
+    {
+      BBSTest::ScopedTimer si_exec("C:strategycontroller_execute");
+      BBSTest::ScopedTimer getWOTimer("C:getWorkOrders");
+      bool finished = false; // Has this strategy completed?
+      DH_WOPrediff* WOPD = getPrediffWorkOrder();
+      DH_WOSolve* WOSolve = getSolveWorkOrder();
+      getWOTimer.end();
 
-  return (!finished);
-}
+      WOPD->setCleanUp(false);
+      WOPD->setDoNothing(false);
+  
+      if (itsFirstCall)
+      {
+	BBSTest::Logger::log("Start of testrun");
+	itsFirstCall = false;
+	itsCurStartTime = itsStartTime;
+      }
+      else
+      {
+	itsCurStartTime += itsTimeLength;
+	BBSTest::Logger::log("NextInterval");
+    
+	// If all time intervals handled, send workorder to clean up.
+	if (itsCurStartTime >= itsEndTime)
+	{
+	  WOPD->setDoNothing(true);
+	  WOPD->setCleanUp(true);
+	  finished = true;               // This strategy has finished!
+	}
+
+      }
+
+      // Set prediffer workorder data
+      WOPD->setStatus(DH_WOPrediff::New);
+      WOPD->setKSType("Prediff1");
+      WOPD->setWritePredData(true);
+      WOPD->setWriteInDataCol(itsWriteInDataCol);
+      WOPD->setStartChannel (itsStartChannel);
+      WOPD->setEndChannel (itsEndChannel);
+      WOPD->setStartTime (itsCurStartTime);
+      WOPD->setTimeLength (itsTimeLength);
+      WOPD->setModelType (itsArgs.getString ("modelType"));
+      WOPD->setCalcUVW (itsArgs.getBool ("calcUVW"));
+      ParameterSet msParams = itsArgs.makeSubset("MSDBparams.");
+      vector<int> ant = itsArgs.getInt32Vector("antennas");
+
+      vector<int> srcs = itsArgs.getInt32Vector("sources");
+      vector<int> corrs;
+      if (itsArgs.isDefined("correlations"))
+      {
+	corrs = itsArgs.getInt32Vector("correlations");
+      }
+      // the prediffer needs to know the modelType too
+      msParams.add ("modelType", itsArgs.getString("modelType"));
+      msParams.add ("calcUVW", itsArgs.getString("calcUVW"));
+      vector<string> pNames;    // Empty vector
+      vector<string> exPNames;    // Empty vector
+      WOPD->setVarData (msParams, ant, pNames, exPNames, srcs, corrs);
+ 
+      int woid = getNewWorkOrderID();  
+      WOPD->setWorkOrderID(woid);
+      WOPD->setStrategyControllerID(getID());
+      WOPD->setNewDomain(true);
+
+      // Set solver workorder data  
+      WOSolve->setStatus(DH_WOSolve::New);
+      WOSolve->setKSType("Solver");
+      WOSolve->setDoNothing(true);  // Solver is not used in this strategy
+      WOSolve->setWorkOrderID(woid);
+      WOSolve->setStrategyControllerID(getID());
+
+      // Temporarily show on cout
+      cout << "!!!!!!! Sent workorders: " << endl;
+      //WOPD->dump();
+      //WOSolve->dump();
+
+      cout << "!!!!!!! " << endl;
+
+      // Insert WorkOrders into database
+      BBSTest::ScopedTimer st("C:putWOinDB");
+      WOPD->insertDB(*itsOutWOPDConn);
+
+      // Send workorders the same workorders to other prediffers (if there are
+      // more than 1)
+      int nrPred = getNumberOfPrediffers();
+      for (int i = 2; i <= nrPred; i++)
+      {
+	WOPD->setWorkOrderID(getNewWorkOrderID());
+	char str[32];
+	sprintf(str, "%i", i);
+	WOPD->setKSType("Prediff"+string(str));
+	WOPD->insertDB(*itsOutWOPDConn);
+      }
+
+      WOSolve->insertDB(*itsOutWOSolveConn);
+
+      return (!finished);
+    }
 
-void SC_WritePredData::postprocess()
-{
-}
+    void SC_WritePredData::postprocess()
+    {
+    }
 
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/StrategyController.cc b/CEP/BB/BBSControl/src/StrategyController.cc
index c28351cc4963e09cd11df722f29bef90bff65bb0..8445f12be233cdc433d73726d3f0dd85cde17eb1 100644
--- a/CEP/BB/BBSControl/src/StrategyController.cc
+++ b/CEP/BB/BBSControl/src/StrategyController.cc
@@ -28,41 +28,55 @@
 
 namespace LOFAR
 {
+  namespace BBS
+  {
 
-int StrategyController::theirNextSCID=-1;
-int StrategyController::theirNextWOID=-1;
+    int StrategyController::theirNextSCID=-1;
+    int StrategyController::theirNextWOID=-1;
 
-StrategyController::StrategyController(Connection* inSolConn, 
-				       Connection* outWOPDConn, 
-				       Connection* outWOSolveConn,
-				       int nrPrediffers)
-  : itsInSolConn     (inSolConn),
-    itsOutWOPDConn   (outWOPDConn),
-    itsOutWOSolveConn(outWOSolveConn),
-    itsNrPrediffers(nrPrediffers)
+    StrategyController::StrategyController(Connection* inSolConn, 
+					   Connection* outWOPDConn, 
+					   Connection* outWOSolveConn,
+					   int nrPrediffers)
+      : itsInSolConn     (inSolConn),
+	itsOutWOPDConn   (outWOPDConn),
+	itsOutWOSolveConn(outWOSolveConn),
+	itsNrPrediffers(nrPrediffers)
     
-{
-  LOG_TRACE_FLOW("StrategyController constructor");
-  ASSERTSTR(itsInSolConn != 0, "Solution input has not been connected!");
-  ASSERTSTR(itsOutWOPDConn != 0, 
-	    "Output to Prediffer has not been connected!");
-  ASSERTSTR(itsOutWOSolveConn != 0, 
-	    "Output to Solver has not been connected!");
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+      ASSERTSTR(itsInSolConn != 0, "Solution input has not been connected!");
+      ASSERTSTR(itsOutWOPDConn != 0, 
+		"Output to Prediffer has not been connected!");
+      ASSERTSTR(itsOutWOSolveConn != 0, 
+		"Output to Solver has not been connected!");
 
-  if (theirNextSCID == -1)       // If first instance of StrategyController
-  {                              // Determine unique scid.
-    TH_DB* thDB = (TH_DB*)(itsOutWOPDConn->getTransportHolder());
-    ASSERT(thDB!=0);
-    theirNextSCID = getPrediffWorkOrder()->getMaxSCID(thDB) + 1;
-    theirNextWOID = getPrediffWorkOrder()->getMaxWOID(thDB) + 1;
-  }
-  itsID = theirNextSCID++;
-}
+      // If first instance of StrategyController, then determine unique scid.
+      if (theirNextSCID == -1)
+      {
+	TH_DB* thDB = (TH_DB*)(itsOutWOPDConn->getTransportHolder());
+	ASSERT(thDB!=0);
+	theirNextSCID = getPrediffWorkOrder()->getMaxSCID(thDB) + 1;
+	theirNextWOID = getPrediffWorkOrder()->getMaxWOID(thDB) + 1;
+      }
+      itsID = theirNextSCID++;
+    }
 
-StrategyController::~StrategyController()
-{
-  LOG_TRACE_FLOW("StrategyController destructor");
-}
+    StrategyController::~StrategyController()
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+    }
+
+    void StrategyController::preprocess()
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+    }
+
+    void StrategyController::postprocess()
+    {
+      LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+    }
 
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/WH_Control.cc b/CEP/BB/BBSControl/src/WH_Control.cc
index bc084d08a8f3a649e010a94f267f147ccb0da5fb..f1d0862cc3a8827d16b5ad0ac324526dc09648ba 100644
--- a/CEP/BB/BBSControl/src/WH_Control.cc
+++ b/CEP/BB/BBSControl/src/WH_Control.cc
@@ -1,32 +1,27 @@
-//  WH_Control.cc:
-//
-//  Copyright (C) 2000, 2001
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-//
-//////////////////////////////////////////////////////////////////////
+//#  WH_Control.cc:
+//#
+//#  Copyright (C) 2000, 2001
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
 
 #include <lofar_config.h>
 
-#include <stdio.h>             // for sprintf
-
 #include <BBSControl/WH_Control.h>
 #include <CEPFrame/Step.h>
 #include <BBSControl/DH_Solution.h>
@@ -37,136 +32,140 @@
 #include <BBSControl/SC_CompoundIter.h>
 #include <BBSControl/StrategyController.h>
 #include <BBS/BBSTestLogger.h>
+#include <Common/lofar_sstream.h>
 
 namespace LOFAR
 {
-string i2str(int i) {
-  char str[32];
-  sprintf(str, "%i", i);
-  return string(str);
-}
-
-  WH_Control::WH_Control (const string& name, int nrPrediffers,
-			  const ParameterSet& args)
-  : WorkHolder     (3, 3, name,"WH_Control"),
-    itsNrPrediffers(nrPrediffers),
-    itsArgs        (args),
-    itsFirstCall   (true)
-{
-  getDataManager().addInDataHolder(0, new DH_Solution("in_0")); 
-  getDataManager().addInDataHolder(1, new DH_WOPrediff("in_1")); // dummy
-  getDataManager().addInDataHolder(2, new DH_WOSolve("in_2")); // dummy
-  getDataManager().addOutDataHolder(0, new DH_Solution("out_0"));  // dummy
-  getDataManager().addOutDataHolder(1, new DH_WOPrediff("out_1"));
-  getDataManager().addOutDataHolder(2, new DH_WOSolve("out_2")); 
-  // switch output trigger of
-  getDataManager().setAutoTriggerIn(0, false);
-  getDataManager().setAutoTriggerOut(0, false);
-  getDataManager().setAutoTriggerIn(1, false);
-  getDataManager().setAutoTriggerOut(1, false);
-  getDataManager().setAutoTriggerIn(2, false);
-  getDataManager().setAutoTriggerOut(2, false);
-}
-
-WH_Control::~WH_Control()
-{
-  list<StrategyController*>::iterator iter;
-  for (iter=itsControllers.begin(); iter!=itsControllers.end(); iter++)
+  namespace BBS
   {
-    delete (*iter);
-  }
-  itsControllers.clear();
-}
-
-WorkHolder* WH_Control::construct (const string& name, int nrPrediffers,
-				    const ParameterSet& args)
-{
-  return new WH_Control (name, nrPrediffers,args);
-}
 
-void WH_Control::preprocess()
-{}
-
-WH_Control* WH_Control::make (const string& name)
-{
-  return new WH_Control(name, itsNrPrediffers, itsArgs);
-}
-
-void WH_Control::process()
-{
-  BBSTest::ScopedTimer st("C:total_WH_Control::process");
-  if (itsFirstCall)
-  {
-    itsFirstCall = false;
-    createStrategyControllers();
-    itsCtrlIter = itsControllers.begin();
-  }
-
-  if ((*itsCtrlIter)->execute() == false)  // Remove from list
-  {
-    delete (*itsCtrlIter);
-    itsCtrlIter = itsControllers.erase(itsCtrlIter); // Returns an iterator that designates 
-                                                     // the first element remaining beyond 
-                                                     // any elements removed, or end()
-    itsCtrlIter--;
-  }
-
-  if (++itsCtrlIter == itsControllers.end())  // Set the iterator to the next Controller.
-  {                                           // Restart at the beginning when at the end. 
-    itsCtrlIter = itsControllers.begin();
-  }
+    WH_Control::WH_Control (const string& name, int nrPrediffers,
+			    const ParameterSet& args)
+      : WorkHolder     (3, 3, name,"WH_Control"),
+	itsNrPrediffers(nrPrediffers),
+	itsArgs        (args)
+    {
+      getDataManager().addInDataHolder(0, new DH_Solution("in_0")); 
+      getDataManager().addInDataHolder(1, new DH_WOPrediff("in_1"));  // dummy
+      getDataManager().addInDataHolder(2, new DH_WOSolve("in_2"));    // dummy
+      getDataManager().addOutDataHolder(0, new DH_Solution("out_0")); // dummy
+      getDataManager().addOutDataHolder(1, new DH_WOPrediff("out_1"));
+      getDataManager().addOutDataHolder(2, new DH_WOSolve("out_2")); 
+      // switch output trigger of
+      getDataManager().setAutoTriggerIn(0, false);
+      getDataManager().setAutoTriggerOut(0, false);
+      getDataManager().setAutoTriggerIn(1, false);
+      getDataManager().setAutoTriggerOut(1, false);
+      getDataManager().setAutoTriggerIn(2, false);
+      getDataManager().setAutoTriggerOut(2, false);
+    }
 
-}
+    WH_Control::~WH_Control()
+    {
+      list<StrategyController*>::iterator iter;
+      for (iter=itsControllers.begin(); iter!=itsControllers.end(); iter++)
+      {
+	delete (*iter);
+      }
+      itsControllers.clear();
+    }
 
-void WH_Control::dump() const
-{
-}
+    WorkHolder* WH_Control::construct (const string& name, int nrPrediffers,
+				       const ParameterSet& args)
+    {
+      return new WH_Control (name, nrPrediffers,args);
+    }
 
-void WH_Control::postprocess()
-{
-  list<StrategyController*>::iterator iter;
-  for (iter=itsControllers.begin(); iter!=itsControllers.end(); iter++)
-  {
-    (*iter)->postprocess();
-  }
-}
+    void WH_Control::preprocess()
+    {
+      BBSTest::ScopedTimer st("C:total_WH_Control::process");
+      createStrategyControllers();
+      itsCtrlIter = itsControllers.begin();
+    }
 
-void WH_Control::createStrategyControllers()
-{
-  Connection* inSolConn = getDataManager().getInConnection(0);
-  Connection* outPDConn = getDataManager().getOutConnection(1);
-  Connection* outSVConn = getDataManager().getOutConnection(2);
-  int nrStrat = itsArgs.getInt32("nrStrategies");
+    WH_Control* WH_Control::make (const string& name)
+    {
+      return new WH_Control(name, itsNrPrediffers, itsArgs);
+    }
 
-  for (int i=1; i<=nrStrat; i++)
-  {
-    // Get strategy type
-    string nr = i2str(i);
-    string name = "SC" + nr + "params.";
-    ParameterSet params = itsArgs.makeSubset(name);
-    string stratType = params.getString("strategy");
-    // Create StrategyController and add to list
-    if (stratType == "Simple")
+    void WH_Control::process()
     {
-      SC_Simple* sc = new SC_Simple(inSolConn, outPDConn, outSVConn, itsNrPrediffers, params);  // Each StrategyController
-      itsControllers.push_back(sc);                           // must get an unique ID
+      if ((*itsCtrlIter)->execute() == false)  // Remove from list
+      {
+	delete (*itsCtrlIter);
+	// Return an iterator that designates the first element remaining
+	// beyond any elements removed, or end()
+	itsCtrlIter = itsControllers.erase(itsCtrlIter);
+	itsCtrlIter--;
+      }
+
+      // Set the iterator to the next Controller. Restart at the beginning
+      // when at the end.
+      if (++itsCtrlIter == itsControllers.end())
+      {
+	itsCtrlIter = itsControllers.begin();
+      }
+
     }
-    else if (stratType == "WritePredData")
+
+    void WH_Control::dump() const
     {
-      SC_WritePredData* sc = new SC_WritePredData(inSolConn, outPDConn, outSVConn, itsNrPrediffers, params);  // Each StrategyController
-      itsControllers.push_back(sc);                           // must get an unique ID      
     }
-    else if (stratType == "CompoundIter")
+
+    void WH_Control::postprocess()
     {
-      SC_CompoundIter* sc = new SC_CompoundIter(inSolConn, outPDConn, outSVConn, itsNrPrediffers, params);  // Each StrategyController
-      itsControllers.push_back(sc);                           // must get an unique ID
+      ControllerList::iterator iter;
+      for (iter=itsControllers.begin(); iter!=itsControllers.end(); iter++)
+      {
+	(*iter)->postprocess();
+      }
     }
-    else
+
+    void WH_Control::createStrategyControllers()
     {
-      THROW(LOFAR::Exception, "Strategy type " << stratType 
-	    << " unknown or not defined");
+      Connection* inSolConn = getDataManager().getInConnection(0);
+      Connection* outPDConn = getDataManager().getOutConnection(1);
+      Connection* outSVConn = getDataManager().getOutConnection(2);
+      int nrStrat = itsArgs.getInt32("nrStrategies");
+
+      for (int i=1; i<=nrStrat; i++)
+      {
+	// Get strategy type
+	ostringstream oss;
+	oss << "SC" << i << "params.";
+	ParameterSet params = itsArgs.makeSubset(oss.str());
+	string stratType = params.getString("strategy");
+	// Create StrategyController and add to list
+	// Each StrategyController must get an unique ID
+	if (stratType == "Simple")
+	{
+	  SC_Simple* sc = 
+	    new SC_Simple(inSolConn, outPDConn, outSVConn, 
+			  itsNrPrediffers, params);
+	  itsControllers.push_back(sc);
+	}
+	else if (stratType == "WritePredData")
+	{
+	  SC_WritePredData* sc = 
+	    new SC_WritePredData(inSolConn, outPDConn, outSVConn, 
+				 itsNrPrediffers, params);
+	  itsControllers.push_back(sc);
+	}
+	else if (stratType == "CompoundIter")
+	{
+	  SC_CompoundIter* sc = 
+	    new SC_CompoundIter(inSolConn, outPDConn, outSVConn, 
+				itsNrPrediffers, params);
+	  itsControllers.push_back(sc);
+	}
+	else
+	{
+	  THROW(LOFAR::Exception, "Strategy type " << stratType 
+		<< " unknown or not defined");
+	}
+      }
     }
-  }
-}
+
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/WH_Prediff.cc b/CEP/BB/BBSControl/src/WH_Prediff.cc
index 01ea62a6a7e124cd1bf46dc9b8ea9dab50e20e64..4c7577239f472d36f48e2a9298110020b9ca2966 100644
--- a/CEP/BB/BBSControl/src/WH_Prediff.cc
+++ b/CEP/BB/BBSControl/src/WH_Prediff.cc
@@ -33,391 +33,407 @@
 #include <BBS/MNS/MeqDomain.h>
 #include <BBS/BBSTestLogger.h>
 #include <Common/LofarLogger.h>
+#include <Common/StringUtil.h>
 
 namespace LOFAR
 {
-
-WH_Prediff::WH_Prediff(const string& name, const string& id, const ParameterSet& pset)
-  : WorkHolder   (2, 3, name, "WH_Prediff"),
-    itsID        (id),
-    itsArgs      (pset),
-    itsFirstCall (true)
-{
-  LOG_TRACE_FLOW("WH_Prediff constructor");
-  getDataManager().addInDataHolder(0, new DH_WOPrediff(name+"_in0"));
-  getDataManager().addOutDataHolder(0, new DH_WOPrediff(name+"_out0")); // dummy
-  getDataManager().addInDataHolder(1, new DH_Solution(name+"_in1"));
-  getDataManager().addOutDataHolder(1, new DH_Solution(name+"_out1")); // dummy
-  getDataManager().addOutDataHolder(2, new DH_Prediff(name+"_out2"));
-
-  // switch input and output channel trigger off
-  getDataManager().setAutoTriggerIn(0, false);
-  getDataManager().setAutoTriggerIn(1, false);
-  getDataManager().setAutoTriggerOut(0, false);
-  getDataManager().setAutoTriggerOut(1, false);
-  getDataManager().setAutoTriggerOut(2, false);
-}
-
-WH_Prediff::~WH_Prediff()
-{
-  LOG_TRACE_FLOW("WH_Prediff destructor");
-  // Clean up map with Prediffer objects
-  PrediffMap::iterator iter;
-  for (iter=itsPrediffs.begin(); iter!=itsPrediffs.end(); iter++)
+  namespace BBS
   {
-    delete (*iter).second;
-  }
-  itsPrediffs.clear();
-}
-
-WH_Prediff* WH_Prediff::make (const string& name)
-{
-  return new WH_Prediff (name, itsID, itsArgs);
-}
-
-void WH_Prediff::preprocess()
-{
-  LOG_TRACE_RTTI("WH_Prediff preprocess()");
-}
+    const uint woPrediffChanId = 0;
+    const uint solutionChanId  = 1;
+    const uint prediffChanId   = 2;
+
+    WH_Prediff::WH_Prediff(const string& name, const string& id, 
+			   const ParameterSet& pset)
+      : WorkHolder   (2, 3, name, "WH_Prediff"),
+	itsID        (id),
+	itsArgs      (pset),
+	itsFirstCall (true)
+    {
+      LOG_TRACE_FLOW("WH_Prediff constructor");
+      getDataManager().addInDataHolder
+	(woPrediffChanId, new DH_WOPrediff(name+"_in0"));
+      getDataManager().addOutDataHolder
+	(woPrediffChanId, new DH_WOPrediff(name+"_out0")); // dummy
+      getDataManager().addInDataHolder
+	(solutionChanId, new DH_Solution(name+"_in1"));
+      getDataManager().addOutDataHolder
+	(solutionChanId, new DH_Solution(name+"_out1")); // dummy
+      getDataManager().addOutDataHolder
+	(prediffChanId, new DH_Prediff(name+"_out2"));
+
+      // switch input and output channel trigger off
+      getDataManager().setAutoTriggerIn(woPrediffChanId, false);
+      getDataManager().setAutoTriggerIn(solutionChanId, false);
+      getDataManager().setAutoTriggerOut(woPrediffChanId, false);
+      getDataManager().setAutoTriggerOut(solutionChanId, false);
+      getDataManager().setAutoTriggerOut(prediffChanId, false);
+    }
 
-void WH_Prediff::process()
-{
-  LOG_TRACE_RTTI("WH_Prediff process()");
+    WH_Prediff::~WH_Prediff()
+    {
+      LOG_TRACE_FLOW("WH_Prediff destructor");
+      // Clean up map with Prediffer objects
+      PrediffMap::iterator iter;
+      for (iter=itsPrediffs.begin(); iter!=itsPrediffs.end(); iter++)
+      {
+	delete (*iter).second;
+      }
+      itsPrediffs.clear();
+    }
 
-  // Read next workorder
-  readWorkOrder();
-  DH_WOPrediff* wo =  dynamic_cast<DH_WOPrediff*>(getDataManager().getInHolder(0));
+    WH_Prediff* WH_Prediff::make (const string& name)
+    {
+      return new WH_Prediff (name, itsID, itsArgs);
+    }
 
-  if (wo->getDoNothing() == false)
-  {
-    DH_Prediff* dhRes = dynamic_cast<DH_Prediff*>(getDataManager().getOutHolder(2));
-    //  dhRes->clearData();
-
-    ParameterSet args;
-    vector<int> ant;
-    vector<string> pNames;
-    vector<string> exPNames;
-    vector<int> peelSrcs;
-    vector<int> corrs;
-    wo->getVarData(args, ant, pNames, exPNames, peelSrcs, corrs);
-    int contrID = wo->getStrategyControllerID();
-    bool isNew = false;
-    Prediffer* pred = getPrediffer(contrID, args, ant, isNew);
-    
-    // Execute workorder
-    if (wo->getWritePredData())
+    void WH_Prediff::preprocess()
     {
-      pred->setWorkDomain(wo->getStartChannel(), wo->getEndChannel(), 
-			  wo->getStartTime(), wo->getTimeLength());
-      pred->writePredictedData(wo->getWriteInDataCol() ? "DATA" : "CORRECTED_DATA");
+      LOG_TRACE_RTTI("WH_Prediff preprocess()");
     }
-    else
+
+    void WH_Prediff::process()
     {
-      if (wo->getNewBaselines())
-      {
-	pred->select(ant, ant, wo->getUseAutoCorrelations(), corrs);
-      
-	vector<int> emptyS(0);
-	if (peelSrcs.size() > 0)
-	{
-	  pred->setPeelGroups(peelSrcs, emptyS);
-	}
-	pred->clearSolvableParms();
-	pred->setSolvableParms(pNames, exPNames);
-	
-	pred->setWorkDomain(wo->getStartChannel(), wo->getEndChannel(), 
-			    wo->getStartTime(), wo->getTimeLength());
-	
-	///	dhRes->setBufferSize(size);              // Set data field of output DH_Prediff to correct size
-	
-	  ///	dhRes->setParmData(pred->getSolvableParmData());   
-      }
-      else if (wo->getNewDomain())
-      {
-	vector<int> emptyS(0);
-	if (peelSrcs.size() > 0)
-	{
-	  pred->setPeelGroups(peelSrcs, emptyS);
-	}
-	pred->clearSolvableParms();
-	pred->setSolvableParms(pNames, exPNames);
-      
-	pred->setWorkDomain(wo->getStartChannel(), wo->getEndChannel(), 
-			    wo->getStartTime(), wo->getTimeLength());
-	///	dhRes->setBufferSize(size);      // Set data field of output DH_Prediff to correct size
-	  ///      	dhRes->setParmData(pred->getSolvableParmData());
-      }
-      else if (wo->getNewPeelSources())
+      LOG_TRACE_RTTI("WH_Prediff process()");
+
+      // Read next workorder
+      readWorkOrder();
+      DH_WOPrediff* wo;
+      ASSERT(wo = dynamic_cast<DH_WOPrediff*>
+	     (getDataManager().getInHolder(woPrediffChanId)));
+
+      if (wo->getDoNothing() == false)
       {
-	vector<int> emptyS(0);
-	if (peelSrcs.size() > 0)
+	DH_Prediff* dhRes;
+	ASSERT(dhRes = dynamic_cast<DH_Prediff*>
+	       (getDataManager().getOutHolder(prediffChanId)));
+
+	//  dhRes->clearData();
+
+	ParameterSet args;
+	vector<int> ant;
+	vector<string> pNames;
+	vector<string> exPNames;
+	vector<int> peelSrcs;
+	vector<int> corrs;
+	wo->getVarData(args, ant, pNames, exPNames, peelSrcs, corrs);
+	int contrID = wo->getStrategyControllerID();
+	bool isNew = false;
+	Prediffer* pred = getPrediffer(contrID, args, ant, isNew);
+    
+	// Execute workorder
+	if (wo->getWritePredData())
 	{
-	  pred->setPeelGroups(peelSrcs, emptyS);
+	  pred->setWorkDomain(wo->getStartChannel(), wo->getEndChannel(), 
+			      wo->getStartTime(), wo->getTimeLength());
+	  pred->writePredictedData(wo->getWriteInDataCol() 
+				   ? "DATA" : "CORRECTED_DATA");
 	}
-	pred->clearSolvableParms();
-	pred->setSolvableParms(pNames, exPNames);
-      }
-
-      // Loop over iterations
-      for (int curIter=0; curIter < wo->getMaxIterations(); curIter++)
-      {
-	bool converged = false;
-	// Parameter update
-	if (curIter != 0) // If next iteration within the workorder, read solution
+	else
 	{
-	  BBSTest::ScopedTimer updatePTimer("P:update-parms");
-	  ParmDataInfo solVec;
-	  converged = readSolution(wo->getSolutionID(), curIter-1, solVec);
-	  if (readSolution(wo->getSolutionID(), curIter-1, solVec))
+	  if (wo->getNewBaselines())
 	  {
-	    break; // Skip prediffing and end iterating
+	    pred->select(ant, ant, wo->getUseAutoCorrelations(), corrs);
+      
+	    vector<int> emptyS(0);
+	    if (peelSrcs.size() > 0)
+	    {
+	      pred->setPeelGroups(peelSrcs, emptyS);
+	    }
+	    pred->clearSolvableParms();
+	    pred->setSolvableParms(pNames, exPNames);
+	
+	    pred->setWorkDomain(wo->getStartChannel(), wo->getEndChannel(), 
+				wo->getStartTime(), wo->getTimeLength());
 	  }
-	  else
+	  else if (wo->getNewDomain())
 	  {
-	    pred->updateSolvableParms(solVec);
+	    vector<int> emptyS(0);
+	    if (peelSrcs.size() > 0)
+	    {
+	      pred->setPeelGroups(peelSrcs, emptyS);
+	    }
+	    pred->clearSolvableParms();
+	    pred->setSolvableParms(pNames, exPNames);
+      
+	    pred->setWorkDomain(wo->getStartChannel(), wo->getEndChannel(), 
+				wo->getStartTime(), wo->getTimeLength());
 	  }
-	}
-	else if (wo->getUpdateParms())  // Read solution
-	{
-	  BBSTest::ScopedTimer updatePTimer("P:update-parms");
-	  int solID = wo->getSolutionID();
-	  if ((solID != -1))             // Read solution and update parameters
+	  else if (wo->getNewPeelSources())
 	  {
-	    ParmDataInfo solVec;
-	    readSolution(solID, solVec);
-	    pred->updateSolvableParms(solVec);
-	  }
-	  else
-	  {                            // Reread parameter values from table
-	    pred->updateSolvableParms();
+	    vector<int> emptyS(0);
+	    if (peelSrcs.size() > 0)
+	    {
+	      pred->setPeelGroups(peelSrcs, emptyS);
+	    }
+	    pred->clearSolvableParms();
+	    pred->setSolvableParms(pNames, exPNames);
 	  }
-	}
 
-	// Calculate, put in output dataholder buffer and send to solver
-	{
-	  BBSTest::ScopedTimer predifTimer("P:prediffer");
-	  dhRes = dynamic_cast<DH_Prediff*>(getDataManager().getOutHolder(2));
-	  vector<casa::LSQFit> fitters;
-	  pred->fillFitters (fitters, "DATA");
-	  dhRes->setFitters (fitters);
-	  MeqDomain domain = pred->getWorkDomain();
-	  dhRes->setDomain (domain.startX(), domain.endX(),
-			    domain.startY(), domain.endY());
-	  // send result to solver
-	  getDataManager().readyWithOutHolder(2);
-	}
+	  // Loop over iterations
+	  for (int curIter=0; curIter < wo->getMaxIterations(); curIter++)
+	  {
+	    bool converged = false;
+	    // Parameter update
+	    // If next iteration within the workorder, read solution
+	    if (curIter != 0)
+	    {
+	      BBSTest::ScopedTimer updatePTimer("P:update-parms");
+	      ParmDataInfo solVec;
+	      converged = readSolution(wo->getSolutionID(), curIter-1, solVec);
+	      if (readSolution(wo->getSolutionID(), curIter-1, solVec))
+	      {
+		break; // Skip prediffing and end iterating
+	      }
+	      else
+	      {
+		pred->updateSolvableParms(solVec);
+	      }
+	    }
+	    else if (wo->getUpdateParms())  // Read solution
+	    {
+	      BBSTest::ScopedTimer updatePTimer("P:update-parms");
+	      int solID = wo->getSolutionID();
+	      if ((solID != -1))
+	      {
+		// Read solution and update parameters
+		ParmDataInfo solVec;
+		readSolution(solID, solVec);
+		pred->updateSolvableParms(solVec);
+	      }
+	      else
+	      {
+		// Reread parameter values from table
+		pred->updateSolvableParms();
+	      }
+	    }
+
+	    // Calculate, put in output dataholder buffer and send to solver
+	    {
+	      BBSTest::ScopedTimer predifTimer("P:prediffer");
+	      dhRes = dynamic_cast<DH_Prediff*>
+		(getDataManager().getOutHolder(prediffChanId));
+	      vector<casa::LSQFit> fitters;
+	      pred->fillFitters (fitters, "DATA");
+	      dhRes->setFitters (fitters);
+	      MeqDomain domain = pred->getWorkDomain();
+	      dhRes->setDomain (domain.startX(), domain.endX(),
+				domain.startY(), domain.endY());
+	      // send result to solver
+	      getDataManager().readyWithOutHolder(prediffChanId);
+	    }
+
+	  } // End of loop over iterations
+
+
+	  if (wo->getSubtractSources())
+	  {
+	    // >>>For now: always write in new file 
+	    pred->subtractData("DATA", "CORRECTED_DATA");
+	  }
+      
+	} // end else
 
-      } // End of loop over iterations
+      } // end if (wo->getDoNothing==false)
 
 
-      if (wo->getSubtractSources())
+      // If Prediffer object is no longer needed: clean up  
+      if (wo->getCleanUp())
       {
-	pred->subtractData("DATA", "CORRECTED_DATA");   // >>>For now: always write in new file 
+	int contrID = wo->getStrategyControllerID();
+	deletePrediffer(contrID);
       }
       
-    } // end else
-
-  } // end if (wo->getDoNothing==false)
+      // Update workorder status
+      wo->setStatus(DH_WOPrediff::Executed);
+      Connection* conn = getDataManager().getInConnection(woPrediffChanId);
+      ASSERTSTR(conn!=0, "No connection set!");
+      BBSTest::ScopedTimer st("P:prediffer_updating_db");
+      wo->updateDB(*conn);
+    }
 
-  if (wo->getCleanUp())   // If Prediffer object is no longer needed: clean up  
-  {
-    int contrID = wo->getStrategyControllerID();
-    deletePrediffer(contrID);
-  }
-
-  // Update workorder status
-  wo->setStatus(DH_WOPrediff::Executed);
-  Connection* conn = getDataManager().getInConnection(0);
-  ASSERTSTR(conn!=0, "No connection set!");
-  BBSTest::ScopedTimer st("P:prediffer_updating_db");
-  wo->updateDB(*conn);
-}
-
-void WH_Prediff::dump() const
-{
-  LOG_TRACE_RTTI("WH_Prediff process()");
-}
+    void WH_Prediff::dump() const
+    {
+      LOG_TRACE_RTTI("WH_Prediff process()");
+    }
 
-Prediffer* WH_Prediff::getPrediffer(int id, const ParameterSet& args, 
-				    const vector<int>& antNrs, bool& isNew)
-{
-  PrediffMap::iterator iter;
-  iter = itsPrediffs.find(id);
-  if (iter != itsPrediffs.end())
-  {
-    isNew = false;
-    return (*iter).second;
-  }
-  else
-  {
-    // Create a Prediffer object
-    ParameterSet myargs = args;
-    myargs.add ("DBIsMaster", "F");
-    BBSTest::ScopedUSRTimer dbStartupTimer("C:DBStartup");
-    dbStartupTimer.end();
+    Prediffer* WH_Prediff::getPrediffer(int id, const ParameterSet& args, 
+					const vector<int>& antNrs, bool& isNew)
+    {
+      PrediffMap::iterator iter;
+      iter = itsPrediffs.find(id);
+      if (iter != itsPrediffs.end())
+      {
+	isNew = false;
+	return (*iter).second;
+      }
+      else
+      {
+	// Create a Prediffer object
+	ParameterSet myargs = args;
+	myargs.add ("DBIsMaster", "F");
+	BBSTest::ScopedUSRTimer dbStartupTimer("C:DBStartup");
+	dbStartupTimer.end();
   
-    string modelType = args.getString("modelType");
-    bool calcUVW = args.getBool("calcUVW");
-    string msName = args.getString("subsetMSPath") + "/" + args.getString("MSName")+ "_p" + itsID;
-
-    vector<vector<int> > srcgrp;
-    getSrcGrp (args, srcgrp);
-    Prediffer* pred = new Prediffer(msName,
-				    makePDM("meqTableName", myargs),
-				    makePDM("skyTableName", myargs),
-				    antNrs, modelType, srcgrp, calcUVW);
-    // add to map
-    itsPrediffs.insert(PrediffMap::value_type(id, pred));
-    isNew = true;
-    return pred;
-  }
-}
-
-void WH_Prediff::deletePrediffer(int id)
-{
-  PrediffMap::iterator iter;
-  iter = itsPrediffs.find(id);
-  if (iter != itsPrediffs.end())
-  {
-    delete iter->second;
-    itsPrediffs.erase(iter);
-  }
-}
-
-void WH_Prediff::readWorkOrder()
-{
-  // Query the database for a work order
-  DH_WOPrediff* wo =  dynamic_cast<DH_WOPrediff*>(getDataManager().getInHolder(0));
-  Connection* conn = getDataManager().getInConnection(0);
-  ASSERTSTR(conn!=0, "No connection set!");
- 
-  // Wait for workorder
-  bool firstTime = true;
-  ostringstream q;
-  q << "SELECT * FROM bbs3woprediffer WHERE STATUS=0 AND(KSTYPE='" 
-    << getName() << "') order by WOID ASC";
+	string modelType = args.getString("modelType");
+	bool calcUVW = args.getBool("calcUVW");
+	string msName = args.getString("subsetMSPath") + "/" + args.getString("MSName")+ "_p" + itsID;
+
+	vector<vector<int> > srcgrp;
+	getSrcGrp (args, srcgrp);
+	Prediffer* pred = new Prediffer(msName,
+					makePDM("meqTableName", myargs),
+					makePDM("skyTableName", myargs),
+					antNrs, modelType, srcgrp, calcUVW);
+	// add to map
+	itsPrediffs.insert(PrediffMap::value_type(id, pred));
+	isNew = true;
+	return pred;
+      }
+    }
 
-  while ((wo->queryDB(q.str(), *conn)) <= 0)
-  {
-    if (firstTime)
+    void WH_Prediff::deletePrediffer(int id)
     {
-      cout << "No workorder found by " << getName() << ". Waiting for work order..." << endl;
-      firstTime = false;
+      PrediffMap::iterator iter;
+      iter = itsPrediffs.find(id);
+      if (iter != itsPrediffs.end())
+      {
+	delete iter->second;
+	itsPrediffs.erase(iter);
+      }
     }
-  }
 
-  //  cout << "!!!!!! Prediffer read workorder: " << endl;
-  //wo->dump();
-  //  cout << "!!!!!!" << endl;
+    void WH_Prediff::readWorkOrder()
+    {
+      // Query the database for a work order
+      DH_WOPrediff* wo = dynamic_cast<DH_WOPrediff*>
+	(getDataManager().getInHolder(woPrediffChanId));
+      Connection* conn = getDataManager().getInConnection(woPrediffChanId);
+      ASSERTSTR(conn!=0, "No connection set!");
+ 
+      // Wait for workorder
+      bool firstTime = true;
+      ostringstream q;
+      q << "SELECT * FROM bbs3woprediffer WHERE STATUS=0 AND(KSTYPE='" 
+	<< getName() << "') order by WOID ASC";
+
+      while ((wo->queryDB(q.str(), *conn)) <= 0)
+      {
+	if (firstTime)
+	{
+	  cout << "No workorder found by " << getName() 
+	       << ". Waiting for work order..." << endl;
+	  firstTime = false;
+	}
+      }
 
-  // Update workorder status
-  wo->setStatus(DH_WOPrediff::Assigned);
-  wo->updateDB(*conn);
-}
+      //  cout << "!!!!!! Prediffer read workorder: " << endl;
+      //wo->dump();
+      //  cout << "!!!!!!" << endl;
 
-void WH_Prediff::getSrcGrp (const ParameterSet& args,
-			    vector<vector<int> >& srcgrp) const
-{
-  srcgrp.resize (0);
-  if (args.isDefined("sourceGroups")) {
-    vector<string> groupVectors = args.getStringVector("sourceGroups");
-    // each string in this vector holds a vector of source numbers (integers) in the format srcs=[0,1,2]
-    vector<string>::iterator git = groupVectors.begin();
-    for (; git != groupVectors.end(); git++) {
-      ParameterSet srcVectorSet;
-      // read the parameterSet from the string
-      srcVectorSet.adoptBuffer(*git);
-      // get the sources in this group
-      srcgrp.push_back(srcVectorSet.getInt32Vector("srcs"));
+      // Update workorder status
+      wo->setStatus(DH_WOPrediff::Assigned);
+      wo->updateDB(*conn);
     }
-  }
-}
 
-void WH_Prediff::readSolution(int woid, ParmDataInfo& solVec)
-{
-  LOG_TRACE_FLOW("WH_Prediff reading solution");
+    void WH_Prediff::getSrcGrp (const ParameterSet& args,
+				vector<vector<int> >& srcgrp) const
+    {
+      srcgrp.resize (0);
+      if (args.isDefined("sourceGroups")) {
+	vector<string> groupVectors = args.getStringVector("sourceGroups");
+	// each string in this vector holds a vector of source numbers
+	// (integers) in the format srcs=[0,1,2]
+	vector<string>::iterator git = groupVectors.begin();
+	for (; git != groupVectors.end(); git++) {
+	  ParameterSet srcVectorSet;
+	  // read the parameterSet from the string
+	  srcVectorSet.adoptBuffer(*git);
+	  // get the sources in this group
+	  srcgrp.push_back(srcVectorSet.getInt32Vector("srcs"));
+	}
+      }
+    }
 
-  DH_Solution* sol = dynamic_cast<DH_Solution*>(getDataManager().getInHolder(1));
-  Connection* conn = getDataManager().getInConnection(1);
-  ASSERTSTR(conn!=0, "No connection set!");
+    void WH_Prediff::readSolution(int woid, ParmDataInfo& solVec)
+    {
+      LOG_TRACE_FLOW("WH_Prediff reading solution");
 
-  // Wait for solution
-  char str[64];
-  sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i ORDER BY iteration DESC", woid);
-  string query(str);
+      DH_Solution* sol = dynamic_cast<DH_Solution*>
+	(getDataManager().getInHolder(solutionChanId));
+      Connection* conn = getDataManager().getInConnection(solutionChanId);
+      ASSERTSTR(conn!=0, "No connection set!");
 
-  bool firstTime = true;
-  while ((sol->queryDB(query, *conn)) <= 0)
-  {
-    if (firstTime)
-    {
-      cout << "No solution with WOID = " << woid << " found by WH_Prediff. Waiting for solution..." << endl;
-      firstTime = false;
-    }
-  }
+      // Wait for solution
+      char str[64];
+      sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i "
+	      "ORDER BY iteration DESC", woid);
+      string query(str);
+
+      bool firstTime = true;
+      while ((sol->queryDB(query, *conn)) <= 0)
+      {
+	if (firstTime)
+	{
+	  cout << "No solution with WOID = " << woid 
+	       << " found by WH_Prediff. Waiting for solution..." << endl;
+	  firstTime = false;
+	}
+      }
   
-  sol->getSolution(solVec);
-}
+      sol->getSolution(solVec);
+    }
 
-bool WH_Prediff::readSolution(int woid, int iteration, ParmDataInfo& solVec)
-{
-  LOG_TRACE_FLOW("WH_Prediff reading solution");
+    bool WH_Prediff::readSolution(int woid, int iteration, ParmDataInfo& solVec)
+    {
+      LOG_TRACE_FLOW("WH_Prediff reading solution");
 
-  DH_Solution* sol = dynamic_cast<DH_Solution*>(getDataManager().getInHolder(1));
-  Connection* conn = getDataManager().getInConnection(1);
-  ASSERTSTR(conn!=0, "No connection set!");
+      DH_Solution* sol = dynamic_cast<DH_Solution*>
+	(getDataManager().getInHolder(solutionChanId));
+      Connection* conn = getDataManager().getInConnection(solutionChanId);
+      ASSERTSTR(conn!=0, "No connection set!");
 
-  // Wait for solution
-  char str[64];
-  sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i AND iteration=%i", woid, iteration);
-  string query(str);
+      // Wait for solution
+      char str[64];
+      sprintf(str, "SELECT * FROM bbs3solutions WHERE WOID=%i "
+	      "AND iteration=%i", woid, iteration);
+      string query(str);
 
-  bool firstTime = true;
-  while ((sol->queryDB(query, *conn)) <= 0)
-  {
-    if (firstTime)
-    {
-      cout << "No solution with WOID = " << woid << " and ITERATION= " 
-	   << iteration << " found by WH_Prediff. Waiting for solution..." << endl;
-      firstTime = false;
-    }
-  }
+      bool firstTime = true;
+      while ((sol->queryDB(query, *conn)) <= 0)
+      {
+	if (firstTime)
+	{
+	  cout << "No solution with WOID = " << woid << " and ITERATION= " 
+	       << iteration << " found by WH_Prediff. Waiting for solution..."
+	       << endl;
+	  firstTime = false;
+	}
+      }
   
-  sol->getSolution(solVec);
+      sol->getSolution(solVec);
 
-  return (sol->hasConverged());
-}
+      return (sol->hasConverged());
+    }
 
-ParmDB::ParmDBMeta WH_Prediff::makePDM (const string& nameKey,
-					const ParameterSet& ps)
-{
-  ASSERTSTR(ps.isDefined("DBType"),
-	    "DBType is not defined in the ParameterSet");
-  string type = ps.getString("DBType");
-  ASSERTSTR(ps.isDefined(nameKey),
-	    nameKey << " is not defined in the ParameterSet");
-  string tableName = ps.getString(nameKey);
-  ParmDB::ParmDBMeta pdm(type, tableName);
-
-  if (type == "aips") {
-    // do nothing, we have all the info we need
-  } else {
-    // extract all information for other types
-    ASSERTSTR(ps.isDefined("DBName"),
-	      "DBName is not defined in the ParameterSet");
-    string dbName = ps.getString("DBName");
-    ASSERTSTR(ps.isDefined("DBUserName"),
-	      "DBUserName is not defined in the ParameterSet");
-    string userName = ps.getString("DBUserName");
-    ASSERTSTR(ps.isDefined("DBPwd"),
-	      "DBPwd is not defined in the ParameterSet");
-    string dbPwd = ps.getString("DBPwd");
-    ASSERTSTR(ps.isDefined("DBMasterHost"),
-	      "DBMasterHost is not defined in the ParameterSet");
-    string hostName = ps.getString("DBMasterHost");
-    pdm.setSQLMeta (dbName, userName, dbPwd, hostName);
-  }
-  return pdm;
-}
+    ParmDB::ParmDBMeta WH_Prediff::makePDM (const string& nameKey,
+					    const ParameterSet& ps)
+    {
+      string type = ps.getString("DBType");
+      string tableName = ps.getString(nameKey);
+      ParmDB::ParmDBMeta pdm(type, tableName);
+
+      if (toLower(type) != "aips") {
+	// extract all information for other types
+	string dbName = ps.getString("DBName");
+	string userName = ps.getString("DBUserName");
+	string dbPwd = ps.getString("DBPwd");
+	string hostName = ps.getString("DBMasterHost");
+	pdm.setSQLMeta (dbName, userName, dbPwd, hostName);
+      }
+      return pdm;
+    }
+
+  } // namespace BBS
 
 } // namespace LOFAR
diff --git a/CEP/BB/BBSControl/src/WH_Solve.cc b/CEP/BB/BBSControl/src/WH_Solve.cc
index e6803e548fd7d56e1f4effb27a4d1f41c251c692..643ac36b74378870f0e85774f9a96d65dac9653e 100644
--- a/CEP/BB/BBSControl/src/WH_Solve.cc
+++ b/CEP/BB/BBSControl/src/WH_Solve.cc
@@ -42,274 +42,265 @@ using namespace std;
 
 namespace LOFAR
 {
-
-WH_Solve::WH_Solve(const string& name, int nPrediffInputs, 
-		   bool writeIndivParms, const string& parmTableName)
-  : WorkHolder        (nPrediffInputs+2, 2, name, "WH_Solve"),
-    itsNPrediffers    (nPrediffInputs),
-    itsWriteIndivParms(writeIndivParms),
-    itsParmTableName  (parmTableName)
-{
-  LOG_TRACE_FLOW("WH_Solve constructor");
-  // Add workorder input
-  getDataManager().addInDataHolder(0, new DH_WOSolve(name+"_in0"));
-  getDataManager().addOutDataHolder(0, new DH_WOSolve(name+"_out0")); // dummy
-  // Add solution output
-  getDataManager().addInDataHolder(1, new DH_Solution(name+"_in1", 
-						      writeIndivParms,
-						      parmTableName));  // dummy
-  getDataManager().addOutDataHolder(1, new DH_Solution(name+"_out1", 
-						       writeIndivParms,
-						       parmTableName));
-  // Switch input channel trigger off
-  getDataManager().setAutoTriggerIn(0, false);
-  getDataManager().setAutoTriggerOut(0, false);
-  getDataManager().setAutoTriggerIn(1, false);
-  getDataManager().setAutoTriggerOut(1, false);
-
-  // Add prediffer inputs
-  for (int i=0; i<itsNPrediffers; i++)
+  namespace BBS
   {
-    getDataManager().addInDataHolder(i+2, new DH_Prediff(name+"_in"));
-    getDataManager().setAutoTriggerIn(i+2, false);
-  }
-
-}
 
-WH_Solve::~WH_Solve()
-{
-  LOG_TRACE_FLOW("WH_Solve destructor");
-  // Clean up map with Solver objects
-  SolverMap::iterator iter;
-  for (iter=itsSolvers.begin(); iter!=itsSolvers.end(); iter++)
-  {
-    delete (*iter).second;
-  }
-  itsSolvers.clear();
-}
+    WH_Solve::WH_Solve(const string& name, int nPrediffInputs, 
+		       bool writeIndivParms, const string& parmTableName)
+      : WorkHolder        (nPrediffInputs+2, 2, name, "WH_Solve"),
+	itsNPrediffers    (nPrediffInputs),
+	itsWriteIndivParms(writeIndivParms),
+	itsParmTableName  (parmTableName)
+    {
+      LOG_TRACE_FLOW("WH_Solve constructor");
+
+      // Add workorder input
+      getDataManager().addInDataHolder
+	(0, new DH_WOSolve(name+"_in0"));
+      getDataManager().addOutDataHolder    // dummy
+	(0, new DH_WOSolve(name+"_out0"));
+      // Add solution output
+      getDataManager().addInDataHolder     // dummy
+	(1, new DH_Solution(name+"_in1", writeIndivParms, parmTableName));
+      getDataManager().addOutDataHolder
+	(1, new DH_Solution(name+"_out1", writeIndivParms, parmTableName));
+
+      // Switch input channel trigger off
+      getDataManager().setAutoTriggerIn(0, false);
+      getDataManager().setAutoTriggerOut(0, false);
+      getDataManager().setAutoTriggerIn(1, false);
+      getDataManager().setAutoTriggerOut(1, false);
+
+      // Add prediffer inputs
+      for (int i=0; i<itsNPrediffers; i++)
+      {
+	getDataManager().addInDataHolder(i+2, new DH_Prediff(name+"_in"));
+	getDataManager().setAutoTriggerIn(i+2, false);
+      }
 
-WH_Solve* WH_Solve::make (const string& name)
-{
-  return new WH_Solve (name, itsNPrediffers, itsWriteIndivParms, itsParmTableName);
-}
+    }
 
-void WH_Solve::preprocess()
-{
-  LOG_TRACE_RTTI("WH_Solve preprocess()");
-}
+    WH_Solve::~WH_Solve()
+    {
+      LOG_TRACE_FLOW("WH_Solve destructor");
+      // Clean up map with Solver objects
+      SolverMap::iterator iter;
+      for (iter=itsSolvers.begin(); iter!=itsSolvers.end(); iter++)
+      {
+	delete (*iter).second;
+      }
+      itsSolvers.clear();
+    }
 
-void WH_Solve::process()
-{
-  LOG_TRACE_RTTI("WH_Solve process()");
-  BBSTest::ScopedTimer st("S:total_WH_Solve::process");
+    WH_Solve* WH_Solve::make (const string& name)
+    {
+      return new WH_Solve (name, itsNPrediffers, itsWriteIndivParms, 
+			   itsParmTableName);
+    }
 
-  // Query the database for a work order
-  DH_WOSolve* wo =  dynamic_cast<DH_WOSolve*>(getDataManager().getInHolder(0));
-  Connection* connWO = getDataManager().getInConnection(0);
-  ASSERTSTR(connWO!=0, "Input 0 not connected");
- 
-  // Wait for workorder
-  bool firstTime = true;
-  ostringstream q;
-  q << "SELECT * FROM bbs3wosolver WHERE STATUS=0 AND(KSTYPE='SOLVER' OR KSTYPE='" 
-    << getName() << "') order by KSTYPE DESC, WOID ASC";
-  while ((wo->queryDB(q.str(), *connWO)) <= 0)
-  {
-    if (firstTime)
+    void WH_Solve::preprocess()
     {
-      cout << "No workorder found by " << getName() << ". Waiting for work order..." << endl;
-      firstTime = false;
+      LOG_TRACE_RTTI("WH_Solve preprocess()");
     }
-  }
 
-  // Update workorder status
-  wo->setStatus(DH_WOSolve::Assigned);
-  BBSTest::ScopedTimer updateTimer("S:updateSolveWO");
-  wo->updateDB(*connWO);
-  updateTimer.end();
+    void WH_Solve::process()
+    {
+      LOG_TRACE_RTTI("WH_Solve process()");
+      BBSTest::ScopedTimer st("S:total_WH_Solve::process");
+
+      // Query the database for a work order
+      DH_WOSolve* wo = dynamic_cast<DH_WOSolve*>
+	(getDataManager().getInHolder(0));
+      Connection* connWO = getDataManager().getInConnection(0);
+      ASSERTSTR(connWO!=0, "Input 0 not connected");
+ 
+      // Wait for workorder
+      bool firstTime = true;
+      ostringstream q;
+      q << "SELECT * FROM bbs3wosolver WHERE STATUS=0 AND "
+	<< "(KSTYPE='SOLVER' OR KSTYPE='" << getName() 
+	<< "') order by KSTYPE DESC, WOID ASC";
+      while ((wo->queryDB(q.str(), *connWO)) <= 0)
+      {
+	if (firstTime)
+	{
+	  cout << "No workorder found by " << getName() 
+	       << ". Waiting for work order..." << endl;
+	  firstTime = false;
+	}
+      }
 
-//   cout << "!!!!!! Solver read workorder: " << endl;
-  //wo->dump();
-//   cout << "!!!!!! " << endl;
+      // Update workorder status
+      wo->setStatus(DH_WOSolve::Assigned);
+      BBSTest::ScopedTimer updateTimer("S:updateSolveWO");
+      wo->updateDB(*connWO);
+      updateTimer.end();
 
-  if (wo->getDoNothing() == false)
-  {
-    int contrID = wo->getStrategyControllerID();
-    Solver* solver = getSolver(contrID);
-    DBGASSERTSTR(solver!=0, "The solver has not been created and initialized.");
+      if (wo->getDoNothing() == false)
+      {
+	int contrID = wo->getStrategyControllerID();
+	Solver* solver = getSolver(contrID);
+	DBGASSERTSTR(solver!=0, 
+		     "The solver has not been created and initialized.");
+
+	if (wo->getNewDomain())         // New domain 
+	{
+	  setParmData(solver);
+	  readInputs(solver, false);   // Skip first read
+	}
+	else
+	{
+	  readInputs(solver, true);     // Read inputs first
+	}
+
+	// Get solution dataholder DH_Solution* sol;
+	DH_Solution* sol = dynamic_cast<DH_Solution*>
+	  (getDataManager().getOutHolder(1));
+	sol->clearData();
+	//>>>> For now: Assume all prediffer domains are equal!!
+	DH_Prediff* predInp1 = 
+	  dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(2));
+	sol->setDomain(predInp1->getStartFreq(), predInp1->getEndFreq(),
+		       predInp1->getStartTime(), predInp1->getEndTime());
+	sol->setWorkOrderID(wo->getWorkOrderID());
+
+	// Loop over iterations
+	for (int curIter=0; curIter < wo->getMaxIterations(); curIter++)
+	{
+	  if (curIter > 0)
+	  {
+	    readInputs(solver, true);   // Read inputs again
+	  }
+
+	  // Do the solve.
+	  BBSTest::ScopedTimer solveTimer("S:solve");
+	  solver->solve(wo->getUseSVD());
+	  solveTimer.end();
+
+	  // Determine if solution has converged
+	  Quality resultQuality;    ////
+	  bool converged = false;
+	  double fit = resultQuality.itsFit;
+	  if (fit<0)
+	  {
+	    fit = -fit;
+	  }
+	  if (fit < wo->getFitCriterion())
+	  {
+	    converged = true;
+	  }
+      
+	  // Write result
+	  Connection* connSol = getDataManager().getOutConnection(1);
+	  ASSERTSTR(connSol != 0, "Output 1 not connected!");
+	  sol->setSolution(solver->getSolvableParmData());
+	  sol->setQuality(resultQuality);
+	  sol->setIteration(wo->getIteration() + curIter);
+	  sol->setConverged(converged);
+
+	  // Add solution to database
+	  sol->insertDB(*connSol);
+
+	  if (converged) 
+	  {
+	    break;
+	  }
+
+	} // End loop iterations
+ 
+      }
+
+      // If Solver object is no longer needed: clean up  
+      if (wo->getCleanUp())
+      {
+	int contrID = wo->getStrategyControllerID();
+	deleteSolver(contrID);
+      }
+  
+      // Update workorder status
+      wo->setStatus(DH_WOSolve::Executed);
+      wo->updateDB(*connWO);
 
-    if (wo->getNewDomain())         // New domain 
-    {
-      setParmData(solver);
-      readInputs(solver, false);   // Skip first read
     }
-    else
+
+    void WH_Solve::dump() const
     {
-      readInputs(solver, true);     // Read inputs first
+      LOG_TRACE_RTTI("WH_Solve process()");
     }
 
-    // Get solution dataholder DH_Solution* sol;
-    DH_Solution* sol = dynamic_cast<DH_Solution*>(getDataManager().getOutHolder(1));
-    sol->clearData();
-    //>>>> For now: Assume all prediffer domains are equal!!
-    DH_Prediff* predInp1 = 
-      dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(2));
-    sol->setDomain(predInp1->getStartFreq(), predInp1->getEndFreq(),
-		   predInp1->getStartTime(), predInp1->getEndTime());
-    sol->setWorkOrderID(wo->getWorkOrderID());
-
-    // Loop over iterations
-    for (int curIter=0; curIter < wo->getMaxIterations(); curIter++)
+    Solver* WH_Solve::getSolver(int id)
     {
-      if (curIter > 0)
-      {
-	readInputs(solver, true);   // Read inputs again
-      }
-      // Do the solve
-      ////      vector<double> res = solver->getSolvableValues();
-//       char strVal[20];
-//       cout << "Iteration " << wo->getIteration()+ curIter << endl;
-//           cout << "Before: [ " ;
-//           for (unsigned int i = 0; i < res.size(); i++)
-//           {
-//             sprintf(strVal, "%1.10f ", res[i]);
-//             cout << strVal << " ";
-//           }
-//           cout << " ]" << endl;
-      
-      // Do the solve.
-      BBSTest::ScopedTimer solveTimer("S:solve");
-      solver->solve(wo->getUseSVD());
-      solveTimer.end();
-      ////      res = solver->getSolvableValues();
-//           cout << "After: [ ";
-//           for (unsigned int i = 0; i < res.size(); i++)
-//           {
-//             sprintf(strVal, "%1.14f ", res[i]);
-//             cout << strVal << " ";
-//           }
-//           cout << " ]" << endl;
-      
-      //>>>Temporary:
-      //     streamsize prec = cout.precision();
-      //     cout.precision(10);
-      //     cout << "Per prediffer: " << solver->getSolutions() << endl;
-      //     cout.precision (prec);
-
-      // Determine if solution has converged
-      Quality resultQuality;    ////
-      bool converged = false;
-      double fit = resultQuality.itsFit;
-      if (fit<0)
+      SolverMap::iterator iter;
+      iter = itsSolvers.find(id);
+      if (iter != itsSolvers.end())
       {
-	fit = -fit;
+	return (*iter).second;
       }
-      if (fit < wo->getFitCriterion())
+      else
       {
-	converged = true;
+	// Create a new Prediffer object
+	Solver* slv = new Solver();
+	// add to map
+	itsSolvers.insert(SolverMap::value_type(id, slv));
+	return slv;
       }
-      
-      // Write result
-      Connection* connSol = getDataManager().getOutConnection(1);
-      ASSERTSTR(connSol != 0, "Output 1 not connected!");
-      sol->setSolution(solver->getSolvableParmData());
-      sol->setQuality(resultQuality);
-      sol->setIteration(wo->getIteration() + curIter);
-      sol->setConverged(converged);
-
-      // Add solution to database
-      sol->insertDB(*connSol);
-
-      if (converged) 
+    }
+
+    void WH_Solve::deleteSolver(int id)
+    {
+      SolverMap::iterator iter;
+      iter = itsSolvers.find(id);
+      if (iter != itsSolvers.end())
       {
-	break;
+	delete (iter->second);
+	itsSolvers.erase(iter);
       }
+    }
 
-    } // End loop iterations
- 
-  }
+    void WH_Solve::readInputs(Solver* solver, bool firstRead)
+    {
+      BBSTest::ScopedTimer riTimer("S:ReadInputs");
+      LOG_TRACE_FLOW("WH_Solve::readInputs");
+      DH_Prediff* dh;
+      for (int i=0; i<itsNPrediffers; i++)
+      {
+	if (firstRead)   // Do a read before merging fitter data
+	{
+	  dh = dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(i+2));
+
+	  // Force input to be read. Necessary because auto-triggering is
+	  // switched off.
+	  getDataManager().readyWithInHolder(i+2);
+	}
+	dh = dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(i+2));
+	vector<casa::LSQFit> fitters;
+	dh->getFitters (fitters);
+	///    solver->mergeFitter (fitter, i);
+	  }
+    }
 
-  if (wo->getCleanUp())   // If Solver object is no longer needed: clean up  
-  {
-    int contrID = wo->getStrategyControllerID();
-    deleteSolver(contrID);
-  }
-  
-  // Update workorder status
-  wo->setStatus(DH_WOSolve::Executed);
-  wo->updateDB(*connWO);
+    void WH_Solve::setParmData(Solver* solver)
+    {
+      LOG_TRACE_FLOW("WH_Solve::readInputsAndSetParmData");
 
-}
+      ////  solver->initSolvableParmData(itsNPrediffers); 
+      DH_Prediff* dh;
+      for (int i=0; i<itsNPrediffers; i++)
+      {
+	getDataManager().getInHolder(i+2);
 
-void WH_Solve::dump() const
-{
-  LOG_TRACE_RTTI("WH_Solve process()");
-}
+	// Forces data to be read
+	getDataManager().readyWithInHolder(i+2);
 
-Solver* WH_Solve::getSolver(int id)
-{
-  SolverMap::iterator iter;
-  iter = itsSolvers.find(id);
-  if (iter != itsSolvers.end())
-  {
-    return (*iter).second;
-  }
-  else
-  {
-    // Create a new Prediffer object
-    Solver* slv = new Solver();
-    // add to map
-    itsSolvers.insert(SolverMap::value_type(id, slv));
-    return slv;
-  }
-}
-
-void WH_Solve::deleteSolver(int id)
-{
-  SolverMap::iterator iter;
-  iter = itsSolvers.find(id);
-  if (iter != itsSolvers.end())
-  {
-    delete (iter->second);
-    itsSolvers.erase(iter);
-  }
-}
+	dh = dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(i+2));
+	ParmDataInfo pData;
+	dh->getParmData(pData);
 
-void WH_Solve::readInputs(Solver* solver, bool firstRead)
-{
-  BBSTest::ScopedTimer riTimer("S:ReadInputs");
-  LOG_TRACE_FLOW("WH_Solve::readInputs");
-  DH_Prediff* dh;
-  for (int i=0; i<itsNPrediffers; i++)
-  {
-    if (firstRead)   // Do a read before merging fitter data
-    {
-      dh = dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(i+2));
-      getDataManager().readyWithInHolder(i+2);  // Cause input to be read
-    }                                           // Necessary because auto-triggering is 
-                                                // switched off.
-    dh = dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(i+2));
-    vector<casa::LSQFit> fitters;
-    dh->getFitters (fitters);
-    ///    solver->mergeFitter (fitter, i);
-  }
-}
-
-void WH_Solve::setParmData(Solver* solver)
-{
-  LOG_TRACE_FLOW("WH_Solve::readInputsAndSetParmData");
+	// id = i or from prediffer?
+	solver->setSolvableParmData(pData, i);
+      }
+    }
 
-  ////  solver->initSolvableParmData(itsNPrediffers); 
-  DH_Prediff* dh;
-  for (int i=0; i<itsNPrediffers; i++)
-  {
-    getDataManager().getInHolder(i+2);
-    getDataManager().readyWithInHolder(i+2);  // Causes data to be read
-    dh = dynamic_cast<DH_Prediff*>(getDataManager().getInHolder(i+2));
-    ParmDataInfo pData;
-    dh->getParmData(pData);
-    solver->setSolvableParmData(pData, i);    // id = i or from prediffer?
-  }
-}
+  } // namespace BBS
 
 } // namespace LOFAR