Index: trunk/BNC/src/combination/bnccomb.cpp
===================================================================
--- trunk/BNC/src/combination/bnccomb.cpp	(revision 10035)
+++ trunk/BNC/src/combination/bnccomb.cpp	(revision 10038)
@@ -114,9 +114,16 @@
 }
 
+
+// Define the static Singleton pointer
+////////////////////////////////////////////////////////////////////////////
+bncComb* bncComb::_instPtr = NULL;
+
 // Singleton
 ////////////////////////////////////////////////////////////////////////////
 bncComb* bncComb::instance() {
-  static bncComb _bncComb;
-  return &_bncComb;
+  if (_instPtr == NULL) {
+    _instPtr = new bncComb();
+  }
+  return(_instPtr);
 }
 
@@ -318,4 +325,5 @@
   delete _antex;
   delete _bsx;
+
   QMapIterator<char, unsigned> itSys(_cmbSysPrn);
   while (itSys.hasNext()) {
@@ -325,11 +333,10 @@
       delete _params[sys][iPar-1];
     }
-    QListIterator<bncTime> itTime(_buffer[sys].keys());
-    while (itTime.hasNext()) {
-      bncTime epoTime = itTime.next();
-      _buffer[sys].remove(epoTime);
-    }
-  }
-
+    _buffer.remove(sys);
+  }
+  while (!_epoClkData.empty()) {
+    delete _epoClkData.front();
+    _epoClkData.pop_front();
+  }
 }
 
@@ -389,6 +396,9 @@
     // Store the correction
     // --------------------
-    QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
-    storage[orbCorr._prn] = orbCorr;
+    QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
+    if (storage[orbCorr._prn]) {
+      delete  storage[orbCorr._prn];
+    }
+    storage[orbCorr._prn] = new t_orbCorr(orbCorr);
   }
 }
@@ -425,6 +435,9 @@
     // Store the correction
     // --------------------
-    QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
-    storage[satCodeBias._prn] = satCodeBias;
+    QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
+    if (storage[satCodeBias._prn]) {
+      delete storage[satCodeBias._prn];
+    }
+    storage[satCodeBias._prn] = new t_satCodeBias(satCodeBias);
   }
 }
@@ -434,14 +447,39 @@
 void bncComb::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
   QMutexLocker locker(&_mutex);
-
-  bncTime lastTime;
-
+  const double outWait = 1.0 * _cmbSampl;
+
+  // Loop over all observations (possible different epochs)
+  // -----------------------------------------------------
   for (int ii = 0; ii < clkCorrections.size(); ii++) {
-    t_clkCorr& clkCorr = clkCorrections[ii];
-    QString    staID(clkCorr._staID.c_str());
-    QString    prn(clkCorr._prn.toInternalString().c_str());
-    char       sys = clkCorr._prn.system();
-
+    t_clkCorr* newClk = new t_clkCorr(clkCorrections[ii]);
+
+    char sys = newClk->_prn.system();
     if (!_cmbSysPrn.contains(sys)){
+      delete newClk;
+      continue;
+    }
+
+    // Check Modulo Time
+    // -----------------
+    int sec = int(nint(newClk->_time.gpssec()*10));
+    if (sec % (_cmbSampl*10) != 0.0) {
+      delete newClk;
+      continue;
+    }
+
+    // Find/Check the AC Name
+    // ----------------------
+    QString acName;
+    QString staID(newClk->_staID.c_str());
+    QListIterator<cmbAC*> icAC(_ACs);
+    while (icAC.hasNext()) {
+      cmbAC* AC = icAC.next();
+      if (AC->mountPoint == staID) {
+        acName = AC->name;
+        break;
+      }
+    }
+    if (acName.isEmpty()) {
+      delete newClk;
       continue;
     }
@@ -449,7 +487,133 @@
     // Set the last time
     // -----------------
-    if (lastTime.undef() || clkCorr._time > lastTime) {
-      lastTime = clkCorr._time;
-    }
+    if (_lastClkCorrTime.undef() || newClk->_time > _lastClkCorrTime) {
+      _lastClkCorrTime = newClk->_time;
+    }
+
+    // Check Correction Age
+    // --------------------
+    //if (_lastEpoTimeOK.valid() && newClk->_time <= _lastEpoTimeOK) {
+    if (_lastClkCorrTime.valid() && newClk->_time < _lastClkCorrTime) {
+      emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + newClk->_prn.toString().c_str() +
+                       //QString(" %1 ").arg(_lastEpoTimeOK.timestr().c_str()).toLatin1() + "vs. old" +
+                       QString(" %1 ").arg(_lastClkCorrTime.timestr().c_str()).toLatin1() + "vs. old" +
+                       QString(" %1 ").arg(newClk->_time.timestr().c_str()).toLatin1(), true);
+      delete newClk;
+      continue;
+    }
+
+    // Find the corresponding data epoch or create a new one
+    // -----------------------------------------------------
+    epoClkData* epoch = 0;
+    deque<epoClkData*>::const_iterator it;
+    for (it = _epoClkData.begin(); it != _epoClkData.end(); it++) {
+      if (newClk->_time == (*it)->_time) {
+      epoch = *it;
+        break;
+      }
+    }
+    if (epoch == 0) {
+      if (_epoClkData.empty() || newClk->_time > _epoClkData.back()->_time) {
+        epoch = new epoClkData;
+        epoch->_time = newClk->_time;
+        _epoClkData.push_back(epoch);
+      }
+    }
+
+    // Put data into the epoch
+    // -----------------------
+    if (epoch != 0) {
+      epoch->_clkCorr.push_back(newClk);
+    }
+    else {
+      delete newClk;
+    }
+  }
+
+  // Make sure the buffer does not grow beyond any limit
+  // ---------------------------------------------------
+  const unsigned MAX_EPODATA_SIZE = 10;
+  if (_epoClkData.size() > MAX_EPODATA_SIZE) {
+    delete _epoClkData.front();
+    _epoClkData.pop_front();
+  }
+
+  // Process the oldest epochs
+  // ------------------------
+  while (_epoClkData.size()) {
+
+    if(!_lastClkCorrTime.valid()) {
+      return;
+    }
+
+    const vector<t_clkCorr*>& clkCorrVec = _epoClkData.front()->_clkCorr;
+
+    bncTime epoTime = _epoClkData.front()->_time;
+
+    // Process the front epoch
+    // -----------------------
+    if (epoTime < (_lastClkCorrTime - outWait)) {
+      processEpoch(epoTime, clkCorrVec);
+      delete _epoClkData.front();
+      _epoClkData.pop_front();
+    }
+    else {
+      return;
+    }
+  }
+}
+
+// Change the correction so that it refers to last received ephemeris
+////////////////////////////////////////////////////////////////////////////
+void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
+
+  if (corr->_eph == lastEph) {
+    return;
+  }
+
+  ColumnVector oldXC(6);
+  ColumnVector oldVV(3);
+  if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
+    return;
+  }
+
+  ColumnVector newXC(6);
+  ColumnVector newVV(3);
+  if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
+    return;
+  }
+
+  ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
+  ColumnVector dV = newVV           - oldVV;
+  double       dC = newXC(4)        - oldXC(4);
+
+  ColumnVector dRAO(3);
+  XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
+
+  ColumnVector dDotRAO(3);
+  XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
+
+  QString msg = "switch corr " + corr->_prn.mid(0,3)
+    + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
+
+  emit newMessage(msg.toLatin1(), false);
+
+  corr->_iod = lastEph->IOD();
+  corr->_eph = lastEph;
+
+  corr->_orbCorr->_xr    += dRAO;
+  corr->_orbCorr->_dotXr += dDotRAO;
+  corr->_clkCorr->_dClk  -= dC;
+}
+
+// Process Epoch
+////////////////////////////////////////////////////////////////////////////
+void bncComb::processEpoch(bncTime epoTime, const vector<t_clkCorr*>& clkCorrVec) {
+
+  for (unsigned ii = 0; ii < clkCorrVec.size(); ii++) {
+    const t_clkCorr* clkCorr = clkCorrVec.at(ii);
+    QString    staID(clkCorr->_staID.c_str());
+    QString    prn(clkCorr->_prn.toInternalString().c_str());
+    char       sys = clkCorr->_prn.system();
 
     // Find/Check the AC Name
@@ -466,33 +630,14 @@
       }
     }
-    if (acName.isEmpty()) {
-      continue;
-    }
-
-    // Check Modulo Time
-    // -----------------
-    int sec = int(nint(clkCorr._time.gpssec()*10));
-    if (sec % (_cmbSampl*10) != 0.0) {
-      continue;
-    }
-
-    // Check Correction Age
-    // --------------------
-    if (_resTime.valid() && clkCorr._time <= _resTime) {
-      emit newMessage("bncComb: old correction: " + acName.toLatin1() + " " + prn.mid(0,3).toLatin1() +
-                       QString("%1").arg(_resTime.timestr().c_str()).toLatin1() + " vs. old " +
-                       QString("%1").arg(clkCorr._time.timestr().c_str()).toLatin1(), true);
-      continue;
-    }
 
     // Create new correction
     // ---------------------
-    cmbCorr* newCorr  = new cmbCorr();
-    newCorr->_prn     = prn;
-    newCorr->_time    = clkCorr._time;
-    newCorr->_iod     = clkCorr._iod;
-    newCorr->_acName  = acName;
-    newCorr->_clkCorr = clkCorr;
+    cmbCorr* newCorr       = new cmbCorr();
+    newCorr->_prn          = prn;
+    newCorr->_time         = clkCorr->_time;
+    newCorr->_iod          = clkCorr->_iod;
+    newCorr->_acName       = acName;
     newCorr->_weightFactor = weigthFactor;
+    newCorr->_clkCorr = new t_clkCorr(*clkCorrVec[ii]);
 
     // Check orbit correction
@@ -503,12 +648,12 @@
     }
     else {
-      QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
-      if (!storage.contains(clkCorr._prn)  ||
-           storage[clkCorr._prn]._iod != newCorr->_iod) {
+      QMap<t_prn, t_orbCorr*>& storage = _orbCorrections[acName];
+      if (!storage.contains(clkCorr->_prn)  ||
+           storage[clkCorr->_prn]->_iod != newCorr->_iod) {
         delete newCorr;
         continue;
       }
       else {
-        newCorr->_orbCorr = storage[clkCorr._prn];
+        newCorr->_orbCorr = storage[clkCorr->_prn];
       }
     }
@@ -556,15 +701,15 @@
     // ----------------------------
     if (_satCodeBiases.contains(acName)) {
-      QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
-      if (storage.contains(clkCorr._prn)) {
-        newCorr->_satCodeBias = storage[clkCorr._prn];
+      QMap<t_prn, t_satCodeBias*>& storage = _satCodeBiases[acName];
+      if (storage.contains(clkCorr->_prn)) {
+        newCorr->_satCodeBias = storage[clkCorr->_prn];
         QMap<t_frequency::type, double> codeBiasesRefSig;
         for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
-          t_frequency::type frqType = cmbRefSig::toFreq(sys,  static_cast<cmbRefSig::type>(ii));
+          t_frequency::type frqType = cmbRefSig::toFreq(sys, static_cast<cmbRefSig::type>(ii));
           char frqNum = t_frequency::toString(frqType)[1];
-          char attrib = cmbRefSig::toAttrib(sys,  static_cast<cmbRefSig::type>(ii));
+          char attrib = cmbRefSig::toAttrib(sys, static_cast<cmbRefSig::type>(ii));
           QString rnxType2ch = QString("%1%2").arg(frqNum).arg(attrib);
-          for (unsigned ii = 0; ii < newCorr->_satCodeBias._bias.size(); ii++) {
-            const t_frqCodeBias& bias = newCorr->_satCodeBias._bias[ii];
+          for (unsigned ii = 0; ii < newCorr->_satCodeBias->_bias.size(); ii++) {
+            const t_frqCodeBias& bias = newCorr->_satCodeBias->_bias[ii];
             if (rnxType2ch.toStdString() == bias._rnxType2ch) {
               codeBiasesRefSig[frqType] = bias._value;
@@ -582,5 +727,5 @@
           }
         }
-        newCorr->_satCodeBias._bias.clear();
+        newCorr->_satCodeBias->_bias.clear();
       }
     }
@@ -588,76 +733,39 @@
     // Store correction into the buffer
     // --------------------------------
-    QVector<cmbCorr*>& corrs = _buffer[sys][newCorr->_time].corrs;
-    corrs.push_back(newCorr);
-  }
-
-  // Process previous Epoch(s)
-  // -------------------------
-  const double outWait = 1.0 * _cmbSampl;
+    QVector<cmbCorr*>& corrs = _buffer[sys].corrs;
+
+    QVectorIterator<cmbCorr*> itCorr(corrs);
+    bool available = false;
+    while (itCorr.hasNext()) {
+      cmbCorr* corr = itCorr.next();
+      QString  prn  = corr->_prn;
+      QString  acName = corr->_acName;
+      if (newCorr->_acName == acName && newCorr->_prn == prn) {
+        available = true;
+      }
+    }
+    if (!available) {
+      corrs.push_back(newCorr);
+    }
+    else {
+      delete newCorr;
+      continue;
+    }
+  }
+
+  // Process Systems of this Epoch
+  // ------------------------------
   QMapIterator<char, unsigned> itSys(_cmbSysPrn);
   while (itSys.hasNext()) {
     itSys.next();
     char sys = itSys.key();
-    QListIterator<bncTime> itTime(_buffer[sys].keys());
-    while (itTime.hasNext()) {
-      bncTime epoTime = itTime.next();
-      if (epoTime < lastTime - outWait) {
-        _resTime = epoTime;
-        processEpoch(sys);
-      }
-    }
-  }
-}
-
-// Change the correction so that it refers to last received ephemeris
-////////////////////////////////////////////////////////////////////////////
-void bncComb::switchToLastEph(t_eph* lastEph, cmbCorr* corr) {
-
-  if (corr->_eph == lastEph) {
-    return;
-  }
-
-  ColumnVector oldXC(6);
-  ColumnVector oldVV(3);
-  if (corr->_eph->getCrd(corr->_time, oldXC, oldVV, false) != success) {
-    return;
-  }
-
-  ColumnVector newXC(6);
-  ColumnVector newVV(3);
-  if (lastEph->getCrd(corr->_time, newXC, newVV, false) != success) {
-    return;
-  }
-
-  ColumnVector dX = newXC.Rows(1,3) - oldXC.Rows(1,3);
-  ColumnVector dV = newVV           - oldVV;
-  double       dC = newXC(4)        - oldXC(4);
-
-  ColumnVector dRAO(3);
-  XYZ_to_RSW(newXC.Rows(1,3), newVV, dX, dRAO);
-
-  ColumnVector dDotRAO(3);
-  XYZ_to_RSW(newXC.Rows(1,3), newVV, dV, dDotRAO);
-
-  QString msg = "switch corr " + corr->_prn.mid(0,3)
-    + QString(" %1 -> %2 %3").arg(corr->_iod,3).arg(lastEph->IOD(),3).arg(dC*t_CST::c, 8, 'f', 4);
-
-  emit newMessage(msg.toLatin1(), false);
-
-  corr->_iod = lastEph->IOD();
-  corr->_eph = lastEph;
-
-  corr->_orbCorr._xr    += dRAO;
-  corr->_orbCorr._dotXr += dDotRAO;
-  corr->_clkCorr._dClk  -= dC;
-}
-
-// Process Epoch
-////////////////////////////////////////////////////////////////////////////
-void bncComb::processEpoch(char sys) {
-
-  _log.clear();
-
-  QTextStream out(&_log, QIODevice::WriteOnly);
+    _log.clear();
+    QTextStream out(&_log, QIODevice::WriteOnly);
+    processSystem(epoTime, sys, out);
+    emit newMessage(_log, false);
+  }
+}
+
+void bncComb::processSystem(bncTime epoTime, char sys, QTextStream& out) {
 
   out << "\n" <<           "Combination: " << sys << "\n"
@@ -694,5 +802,5 @@
     if (_masterMissingEpochs[sys] < switchMasterAfterGap) {
       out << "Missing Master, Epoch skipped" << "\n";
-      _buffer[sys].remove(_resTime);
+      _buffer.remove(sys);
       emit newMessage(_log, false);
       return;
@@ -707,6 +815,6 @@
               << _masterOrbitAC[sys].toLatin1().data() << " --> "
               << AC->name.toLatin1().data()   << " "
-              << _resTime.datestr().c_str()    << " "
-              << _resTime.timestr().c_str()    << "\n";
+              << epoTime.datestr().c_str()    << " "
+              << epoTime.timestr().c_str()    << "\n";
           _masterOrbitAC[sys] = AC->name;
           break;
@@ -723,8 +831,8 @@
   ColumnVector dx;
   if (_method == filter) {
-    irc = processEpoch_filter(sys, out, resCorr, dx);
+    irc = processEpoch_filter(epoTime, sys, out, resCorr, dx);
   }
   else {
-    irc = processEpoch_singleEpoch(sys, out, resCorr, dx);
+    irc = processEpoch_singleEpoch(epoTime, sys, out, resCorr, dx);
   }
 
@@ -746,10 +854,13 @@
             t_frequency::type fType1 = cmbRefSig::toFreq(sys, cmbRefSig::c1);
             t_frequency::type fType2 = cmbRefSig::toFreq(sys, cmbRefSig::c2);
+            if (resCorr[pp->prn]->_satCodeBias == 0) {
+              resCorr[pp->prn]->_satCodeBias = new t_satCodeBias();
+            }
             _bsx->determineSsrSatCodeBiases(pp->prn.mid(0,3), codeCoeff[fType1], codeCoeff[fType2], resCorr[pp->prn]->_satCodeBias);
           }
         }
       }
-      out << _resTime.datestr().c_str() << " "
-          << _resTime.timestr().c_str() << " ";
+      out << epoTime.datestr().c_str() << " "
+          << epoTime.timestr().c_str() << " ";
       out.setRealNumberNotation(QTextStream::FixedNotation);
       out.setFieldWidth(8);
@@ -759,17 +870,15 @@
       out.setFieldWidth(0);
     }
-    printResults(out, resCorr);
-    dumpResults(resCorr);
-  }
-
-  // Delete Data, emit Message
-  // -------------------------
-  _buffer[sys].remove(_resTime);
-  emit newMessage(_log, false);
+    printResults(epoTime, out, resCorr);
+    dumpResults(epoTime, resCorr);
+  }
+  // Delete Data
+  // -----------
+  _buffer.remove(sys);
 }
 
 // Process Epoch - Filter Method
 ////////////////////////////////////////////////////////////////////////////
-t_irc bncComb::processEpoch_filter(char sys, QTextStream& out,
+t_irc bncComb::processEpoch_filter(bncTime epoTime, char sys, QTextStream& out,
                                    QMap<QString, cmbCorr*>& resCorr,
                                    ColumnVector& dx) {
@@ -795,5 +904,5 @@
   // Check Satellite Positions for Outliers
   // --------------------------------------
-  if (checkOrbits(sys, out) != success) {
+  if (checkOrbits(epoTime, sys, out) != success) {
     return failure;
   }
@@ -821,5 +930,5 @@
     out.setRealNumberNotation(QTextStream::FixedNotation);
     out.setRealNumberPrecision(3);
-    out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
+    out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
         << " Maximum Residuum " << maxRes << ' '
         << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
@@ -846,6 +955,6 @@
       for (int ii = 0; ii < corrs(sys).size(); ii++) {
       const cmbCorr* corr = corrs(sys)[ii];
-        out << _resTime.datestr().c_str() << ' '
-            << _resTime.timestr().c_str() << " "
+        out << epoTime.datestr().c_str() << ' '
+            << epoTime.timestr().c_str() << " "
             << corr->_acName << ' ' << corr->_prn.mid(0,3);
         out.setFieldWidth(10);
@@ -862,5 +971,5 @@
 // Print results
 ////////////////////////////////////////////////////////////////////////////
-void bncComb::printResults(QTextStream& out,
+void bncComb::printResults(bncTime epoTime, QTextStream& out,
                            const QMap<QString, cmbCorr*>& resCorr) {
 
@@ -873,9 +982,9 @@
       ColumnVector xc(6);
       ColumnVector vv(3);
-      if (eph->getCrd(_resTime, xc, vv, false) != success) {
+      if (eph->getCrd(epoTime, xc, vv, false) != success) {
         continue;
       }
-      out << _resTime.datestr().c_str() << " "
-          << _resTime.timestr().c_str() << " ";
+      out << epoTime.datestr().c_str() << " "
+          << epoTime.timestr().c_str() << " ";
       out.setFieldWidth(3);
       out << "Full Clock " << corr->_prn.mid(0,3) << " " << corr->_iod << " ";
@@ -893,5 +1002,5 @@
 // Send results to RTNet Decoder and directly to PPP Client
 ////////////////////////////////////////////////////////////////////////////
-void bncComb::dumpResults(const QMap<QString, cmbCorr*>& resCorr) {
+void bncComb::dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr) {
 
   QList<t_orbCorr> orbCorrections;
@@ -901,6 +1010,6 @@
   unsigned year, month, day, hour, minute;
   double   sec;
-  _resTime.civil_date(year, month, day);
-  _resTime.civil_time(hour, minute, sec);
+  epoTime.civil_date(year, month, day);
+  epoTime.civil_time(hour, minute, sec);
 
   QString outLines = QString().asprintf("*  %4d %2d %2d %d %d %12.8f\n",
@@ -911,10 +1020,12 @@
     it.next();
     cmbCorr* corr = it.value();
+
     // ORBIT
-    t_orbCorr orbCorr(corr->_orbCorr);
+    t_orbCorr orbCorr(static_cast<t_orbCorr>(*corr->_orbCorr));
     orbCorr._staID = "INTERNAL";
     orbCorrections.push_back(orbCorr);
+
     // CLOCK
-    t_clkCorr clkCorr(corr->_clkCorr);
+    t_clkCorr clkCorr(static_cast<t_clkCorr>(*corr->_clkCorr));
     clkCorr._staID      = "INTERNAL";
     clkCorr._dClk       = corr->_dClkResult;
@@ -922,6 +1033,7 @@
     clkCorr._dotDotDClk = 0.0;
     clkCorrections.push_back(clkCorr);
+
     // CODE BIASES
-    t_satCodeBias satCodeBias(corr->_satCodeBias);
+    t_satCodeBias satCodeBias(static_cast<t_satCodeBias>(*corr->_satCodeBias));
     satCodeBias._staID = "INTERNAL";
     satCodeBiasList.push_back(satCodeBias);
@@ -931,5 +1043,5 @@
     corr->_eph->setClkCorr(dynamic_cast<const t_clkCorr*>(&clkCorr));
     corr->_eph->setOrbCorr(dynamic_cast<const t_orbCorr*>(&orbCorr));
-    if (corr->_eph->getCrd(_resTime, xc, vv, true) != success) {
+    if (corr->_eph->getCrd(epoTime, xc, vv, true) != success) {
       delete corr;
       continue;
@@ -940,5 +1052,5 @@
     ColumnVector dx(3); dx = 0.0;
     if (_antex) {
-      double Mjd = _resTime.mjd() + _resTime.daysec()/86400.0;
+      double Mjd = epoTime.mjd() + epoTime.daysec()/86400.0;
       if (_antex->satCoMcorrection(corr->_prn, Mjd, xc.Rows(1,3), dx) != success) {
         dx = 0;
@@ -1034,5 +1146,5 @@
     }
 
-    ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
+    ll(iObs) = (corr->_clkCorr->_dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
 
     PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
@@ -1081,5 +1193,5 @@
 // Process Epoch - Single-Epoch Method
 ////////////////////////////////////////////////////////////////////////////
-t_irc bncComb::processEpoch_singleEpoch(char sys, QTextStream& out,
+t_irc bncComb::processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out,
                                         QMap<QString, cmbCorr*>& resCorr,
                                         ColumnVector& dx) {
@@ -1087,5 +1199,5 @@
   // Check Satellite Positions for Outliers
   // --------------------------------------
-  if (checkOrbits(sys, out) != success) {
+  if (checkOrbits(epoTime, sys, out) != success) {
     return failure;
   }
@@ -1203,5 +1315,5 @@
     out.setRealNumberNotation(QTextStream::FixedNotation);
     out.setRealNumberPrecision(3);
-    out << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
+    out << epoTime.datestr().c_str() << " " << epoTime.timestr().c_str()
         << " Maximum Residuum " << maxRes << ' '
         << corrs(sys)[maxResIndex-1]->_acName << ' ' << corrs(sys)[maxResIndex-1]->_prn.mid(0,3);
@@ -1218,6 +1330,6 @@
       for (int ii = 0; ii < vv.Nrows(); ii++) {
         const cmbCorr* corr = corrs(sys)[ii];
-        out << _resTime.datestr().c_str() << ' '
-            << _resTime.timestr().c_str() << " "
+        out << epoTime.datestr().c_str() << ' '
+            << epoTime.timestr().c_str() << " "
             << corr->_acName << ' ' << corr->_prn.mid(0,3);
         out.setFieldWidth(6);
@@ -1235,5 +1347,5 @@
 // Check Satellite Positions for Outliers
 ////////////////////////////////////////////////////////////////////////////
-t_irc bncComb::checkOrbits(char sys, QTextStream& out) {
+t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out) {
 
   const double MAX_DISPLACEMENT = 0.20;
@@ -1283,9 +1395,9 @@
       if (meanRao.find(prn) == meanRao.end()) {
         meanRao[prn].ReSize(4);
-        meanRao[prn].Rows(1,3) = corr->_orbCorr._xr;
+        meanRao[prn].Rows(1,3) = corr->_orbCorr->_xr;
         meanRao[prn](4)        = 1;
       }
       else {
-        meanRao[prn].Rows(1,3) += corr->_orbCorr._xr;
+        meanRao[prn].Rows(1,3) += corr->_orbCorr->_xr;
         meanRao[prn](4)        += 1;
       }
@@ -1309,5 +1421,5 @@
         meanRao[prn](4) = 0;
       }
-      corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
+      corr->_diffRao = corr->_orbCorr->_xr - meanRao[prn].Rows(1,3);
       if (maxDiff.find(prn) == maxDiff.end()) {
         maxDiff[prn] = corr;
@@ -1340,6 +1452,6 @@
         double norm = corr->_diffRao.NormFrobenius();
         if (norm > MAX_DISPLACEMENT) {
-          out << _resTime.datestr().c_str()    << " "
-              << _resTime.timestr().c_str()    << " "
+          out << epoTime.datestr().c_str()    << " "
+              << epoTime.timestr().c_str()    << " "
               << "Orbit Outlier: "
               << corr->_acName.toLatin1().data() << " "
@@ -1374,10 +1486,10 @@
   QListIterator<cmbAC*> icAC(_ACs);
   while (icAC.hasNext()) {
-    cmbAC* AC = icAC.next();
+    cmbAC *AC = icAC.next();
     if (AC->mountPoint == mountPoint) {
       acName = AC->name;
-      out << "Provider ID changed: AC " << AC->name.toLatin1().data()   << " "
-          << _resTime.datestr().c_str()    << " "
-          << _resTime.timestr().c_str()    << "\n";
+      out << "Provider ID changed: AC " << AC->name.toLatin1().data() << " "
+//          << _resTime.datestr().c_str() << " " << _resTime.timestr().c_str()
+          << "\n";
       break;
     }
@@ -1392,28 +1504,23 @@
     // Remove all corrections of the corresponding AC
     // ----------------------------------------------
-    QListIterator<bncTime> itTime(_buffer[sys].keys());
-    while (itTime.hasNext()) {
-      bncTime epoTime = itTime.next();
-      QVector<cmbCorr*>& corrVec = _buffer[sys][epoTime].corrs;
-      QMutableVectorIterator<cmbCorr*> it(corrVec);
-      while (it.hasNext()) {
-        cmbCorr* corr = it.next();
-        if (acName == corr->_acName) {
-          delete corr;
-          it.remove();
-        }
-      }
-    }
-
+    QVector<cmbCorr*> &corrVec = _buffer[sys].corrs;
+    QMutableVectorIterator<cmbCorr*> it(corrVec);
+    while (it.hasNext()) {
+      cmbCorr *corr = it.next();
+      if (acName == corr->_acName) {
+        delete corr;
+        it.remove();
+      }
+    }
     // Reset Satellite Offsets
     // -----------------------
     if (_method == filter) {
       for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
-        cmbParam* pp = _params[sys][iPar-1];
+        cmbParam *pp = _params[sys][iPar - 1];
         if (pp->AC == acName && pp->type == cmbParam::offACSat) {
           pp->xx = 0.0;
-          _QQ[sys].Row(iPar)    = 0.0;
+          _QQ[sys].Row(iPar) = 0.0;
           _QQ[sys].Column(iPar) = 0.0;
-          _QQ[sys](iPar,iPar) = pp->sig0 * pp->sig0;
+          _QQ[sys](iPar, iPar) = pp->sig0 * pp->sig0;
         }
       }
