Index: trunk/BNC/src/combination/bncbiassnx.cpp
===================================================================
--- trunk/BNC/src/combination/bncbiassnx.cpp	(revision 10225)
+++ trunk/BNC/src/combination/bncbiassnx.cpp	(revision 10227)
@@ -73,4 +73,5 @@
     delete it.value();
   }
+  _snxSatCodeBiasMap.clear();
 }
 
@@ -101,5 +102,5 @@
 ////////////////////////////////////////////////////////////////////////////
 t_irc bncBiasSnx::readFile(const QString& fileName) {
-
+  clear();
   QFile inFile(fileName);
   inFile.open(QIODevice::ReadOnly | QIODevice::Text);
Index: trunk/BNC/src/combination/bnccomb.cpp
===================================================================
--- trunk/BNC/src/combination/bnccomb.cpp	(revision 10225)
+++ trunk/BNC/src/combination/bnccomb.cpp	(revision 10227)
@@ -123,4 +123,6 @@
 
   bncSettings settings;
+
+  _running = true;
 
   QStringList cmbStreams = settings.value("cmbStreams").toStringList();
@@ -291,5 +293,5 @@
   }
   if (_bsx) {
-    _ms = 6.0 * 3600 * 1000.0;
+    _ms = 3.0 * 3600 * 1000.0;
     QTimer::singleShot(_ms, this, SLOT(slotReadBiasSnxFile()));
   }
@@ -301,5 +303,5 @@
     _MAXRES = 999.0;
   }
-
+  _newCorr = 0;
 }
 
@@ -307,4 +309,7 @@
 ////////////////////////////////////////////////////////////////////////////
 bncComb::~bncComb() {
+
+  _running = false;
+  sleep(2);
 
   QListIterator<cmbAC*> icAC(_ACs);
@@ -317,4 +322,8 @@
   if (_ssrCorr) {
     delete _ssrCorr;
+  }
+
+  if (_newCorr) {
+    delete _newCorr;
   }
 
@@ -331,4 +340,5 @@
     _buffer.remove(sys);
   }
+  _cmbSysPrn.clear();
 
   while (!_epoClkData.empty()) {
@@ -645,16 +655,16 @@
     // Create new correction
     // ---------------------
-    cmbCorr* newCorr       = new cmbCorr();
-    newCorr->_prn          = prn;
-    newCorr->_time         = clkCorr._time;
-    newCorr->_iod          = clkCorr._iod;
-    newCorr->_acName       = acName;
-    newCorr->_weightFactor = weigthFactor;
-    newCorr->_clkCorr      = clkCorr;
+    _newCorr       = new cmbCorr();
+    _newCorr->_prn          = prn;
+    _newCorr->_time         = clkCorr._time;
+    _newCorr->_iod          = clkCorr._iod;
+    _newCorr->_acName       = acName;
+    _newCorr->_weightFactor = weigthFactor;
+    _newCorr->_clkCorr      = clkCorr;
 
     // Check orbit correction
     // ----------------------
     if (!_orbCorrections.contains(acName)) {
-      delete newCorr;
+      delete _newCorr; _newCorr = 0;
       continue;
     }
@@ -662,10 +672,10 @@
       QMap<t_prn, t_orbCorr>& storage = _orbCorrections[acName];
       if (!storage.contains(clkCorr._prn)  ||
-           storage[clkCorr._prn]._iod != newCorr->_iod) {
-        delete newCorr;
+           storage[clkCorr._prn]._iod != _newCorr->_iod) {
+        delete _newCorr; _newCorr = 0;
         continue;
       }
       else {
-        newCorr->_orbCorr = storage[clkCorr._prn];
+        _newCorr->_orbCorr = storage[clkCorr._prn];
       }
     }
@@ -679,5 +689,5 @@
       emit newMessage("bncComb: eph not found for "  + prn.mid(0,3).toLatin1(), true);
 #endif
-      delete newCorr;
+      delete _newCorr; _newCorr = 0;
       continue;
     }
@@ -688,22 +698,22 @@
       emit newMessage("bncComb: ephLast not ok (checkState: " +  ephLast->checkStateToString().toLatin1() + ") for "  + prn.mid(0,3).toLatin1(), true);
 #endif
-      delete newCorr;
+      delete _newCorr; _newCorr = 0;
       continue;
     }
     else {
-      if      (ephLast->IOD() == newCorr->_iod) {
-        newCorr->_eph = ephLast;
+      if      (ephLast->IOD() == _newCorr->_iod) {
+        _newCorr->_eph = ephLast;
       }
       else if (ephPrev && ephPrev->checkState() == t_eph::ok &&
-               ephPrev->IOD() == newCorr->_iod) {
-        newCorr->_eph = ephPrev;
-        switchToLastEph(ephLast, newCorr);
+               ephPrev->IOD() == _newCorr->_iod) {
+        _newCorr->_eph = ephPrev;
+        switchToLastEph(ephLast, _newCorr);
       }
       else {
 #ifdef BNC_DEBUG_CMB
         emit newMessage("bncComb: eph not found for "  + prn.mid(0,3).toLatin1() +
-                        QString(" with IOD %1").arg(newCorr->_iod).toLatin1(), true);
+                        QString(" with IOD %1").arg(_newCorr->_iod).toLatin1(), true);
 #endif
-        delete newCorr;
+        delete _newCorr; _newCorr = 0;
         continue;
       }
@@ -715,5 +725,5 @@
       QMap<t_prn, t_satCodeBias>& storage = _satCodeBiases[acName];
       if (storage.contains(clkCorr._prn)) {
-        newCorr->_satCodeBias = storage[clkCorr._prn];
+        _newCorr->_satCodeBias = storage[clkCorr._prn];
         QMap<t_frequency::type, double> codeBiasesRefSig;
         for (unsigned ii = 1; ii < cmbRefSig::cIF; ii++) {
@@ -722,6 +732,6 @@
           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;
@@ -731,13 +741,13 @@
         if (codeBiasesRefSig.size() == 2) {
           map<t_frequency::type, double> codeCoeff;
-          double channel = double(newCorr->_eph->slotNum());
+          double channel = double(_newCorr->_eph->slotNum());
           cmbRefSig::coeff(sys, cmbRefSig::cIF, channel, codeCoeff);
           map<t_frequency::type, double>::const_iterator it;
           for (it = codeCoeff.begin(); it != codeCoeff.end(); it++) {
             t_frequency::type frqType = it->first;
-            newCorr->_satCodeBiasIF += it->second * codeBiasesRefSig[frqType];
+            _newCorr->_satCodeBiasIF += it->second * codeBiasesRefSig[frqType];
           }
         }
-        newCorr->_satCodeBias._bias.clear();
+        _newCorr->_satCodeBias._bias.clear();
       }
     }
@@ -753,13 +763,14 @@
       QString  prn  = corr->_prn;
       QString  acName = corr->_acName;
-      if (newCorr->_acName == acName && newCorr->_prn == prn) {
+      if (_newCorr->_acName == acName && _newCorr->_prn == prn) {
         available = true;
       }
     }
+
     if (!available) {
-      corrs.push_back(newCorr);
+      corrs.push_back(_newCorr); _newCorr = 0;
     }
     else {
-      delete newCorr;
+      delete _newCorr; _newCorr = 0;
       continue;
     }
@@ -885,5 +896,4 @@
   }
 
-  //_buffer.remove(sys);
 }
 
@@ -921,5 +931,5 @@
   // ---------------------------------
   SymmetricMatrix QQ_sav = _QQ[sys];
-  while (true) {
+  while (_running) {
 
     Matrix         AA;
@@ -1236,5 +1246,5 @@
   // Outlier Detection Loop
   // ----------------------
-  while (true) {
+  while (_running) {
 
     // Remove Satellites that are not in Master
@@ -1422,5 +1432,5 @@
   }
 
-  while (true) {
+  while (_running) {
 
     // Compute Mean Corrections for all Satellites
Index: trunk/BNC/src/combination/bnccomb.h
===================================================================
--- trunk/BNC/src/combination/bnccomb.h	(revision 10225)
+++ trunk/BNC/src/combination/bnccomb.h	(revision 10227)
@@ -5,4 +5,5 @@
 #include <fstream>
 #include <iostream>
+#include <unistd.h>
 #include <map>
 #include <newmat.h>
@@ -244,4 +245,5 @@
   bncTime                                    _lastClkCorrTime;
   bncTime                                    _resTime;
+  cmbCorr*                                   _newCorr;
   QMap<char, cmbEpoch>                       _buffer;
   bncRtnetDecoder*                           _rtnetDecoder;
@@ -271,4 +273,5 @@
   bool                                       _useSbas;
   bool                                       _useIrnss;
+  bool                                       _running;
 };
 
