Index: trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_igs.cpp
===================================================================
--- trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_igs.cpp	(revision 10225)
+++ trunk/BNC/src/RTCM3/clock_and_orbit/clock_orbit_igs.cpp	(revision 10227)
@@ -23,6 +23,4 @@
   std::vector< std::vector<unsigned int> > status(CLOCKORBIT_SATNUM, std::vector<unsigned int>(COBOFS_NUM));
   unsigned int i, s;
-
-  //memset(status, 0, sizeof(status));
 
   STARTDATA
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;
 };
 
Index: trunk/BNC/src/upload/bncrtnetuploadcaster.cpp
===================================================================
--- trunk/BNC/src/upload/bncrtnetuploadcaster.cpp	(revision 10225)
+++ trunk/BNC/src/upload/bncrtnetuploadcaster.cpp	(revision 10227)
@@ -828,5 +828,5 @@
         || co.NumberOfSat[CLOCKORBIT_SATSBAS] > 0
         || co.NumberOfSat[CLOCKORBIT_SATBDS] > 0) {
-      char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
+      char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
       int len = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_AUTO, 0, obuffer, sizeof(obuffer));
       if (len > 0) {
@@ -840,9 +840,8 @@
   else {
     if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0) {
-      char obuffer[CLOCKORBIT_BUFFERSIZE] = {0};
+      char obuffer[CLOCKORBIT_BUFFERSIZE] = {'\0'};
       if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
         co.UpdateInterval = ephUpdInd;
-        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer,
-            sizeof(obuffer));
+        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSORBIT, 1, obuffer, sizeof(obuffer));
         co.UpdateInterval = clkUpdInd;
         if (len1 > 0) {
@@ -855,6 +854,5 @@
                   co.NumberOfSat[CLOCKORBIT_SATSBAS]    > 0 ||
                   co.NumberOfSat[CLOCKORBIT_SATBDS]     > 0   ) ? 1 : 0;
-      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer,
-          sizeof(obuffer));
+      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GPSCLOCK, mmsg, obuffer, sizeof(obuffer));
       if (len2 > 0) {
         hlpBufferCo += QByteArray(obuffer, len2);
@@ -865,6 +863,5 @@
       if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
         co.UpdateInterval = ephUpdInd;
-        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer,
-            sizeof(obuffer));
+        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSORBIT, 1, obuffer, sizeof(obuffer));
         co.UpdateInterval = clkUpdInd;
         if (len1 > 0) {
@@ -876,6 +873,5 @@
                   co.NumberOfSat[CLOCKORBIT_SATSBAS]    > 0 ||
                   co.NumberOfSat[CLOCKORBIT_SATBDS]     > 0   ) ? 1 : 0;
-      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer,
-          sizeof(obuffer));
+      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GLONASSCLOCK, mmsg, obuffer, sizeof(obuffer));
       if (len2 > 0) {
         hlpBufferCo += QByteArray(obuffer, len2);
@@ -886,6 +882,5 @@
       if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
         co.UpdateInterval = ephUpdInd;
-        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer,
-            sizeof(obuffer));
+        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOORBIT, 1, obuffer, sizeof(obuffer));
         co.UpdateInterval = clkUpdInd;
         if (len1 > 0) {
@@ -896,6 +891,5 @@
                   co.NumberOfSat[CLOCKORBIT_SATSBAS]    > 0 ||
                   co.NumberOfSat[CLOCKORBIT_SATBDS]     > 0   ) ? 1 : 0;
-      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer,
-          sizeof(obuffer));
+      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_GALILEOCLOCK, mmsg, obuffer, sizeof(obuffer));
       if (len2 > 0) {
         hlpBufferCo += QByteArray(obuffer, len2);
@@ -906,6 +900,5 @@
       if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
         co.UpdateInterval = ephUpdInd;
-        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer,
-            sizeof(obuffer));
+        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSORBIT, 1, obuffer, sizeof(obuffer));
         co.UpdateInterval = clkUpdInd;
         if (len1 > 0) {
@@ -915,6 +908,5 @@
       int mmsg = (co.NumberOfSat[CLOCKORBIT_SATSBAS]    > 0 ||
                   co.NumberOfSat[CLOCKORBIT_SATBDS]     > 0   ) ? 1 : 0;
-      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer,
-          sizeof(obuffer));
+      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_QZSSCLOCK, mmsg, obuffer, sizeof(obuffer));
       if (len2 > 0) {
         hlpBufferCo += QByteArray(obuffer, len2);
@@ -925,6 +917,5 @@
       if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
         co.UpdateInterval = ephUpdInd;
-        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer,
-            sizeof(obuffer));
+        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_SBASORBIT, 1, obuffer, sizeof(obuffer));
         co.UpdateInterval = clkUpdInd;
         if (len1 > 0) {
@@ -943,6 +934,5 @@
       if (fmod(epoTime.gpssec(), _samplRtcmEphCorr) == 0.0) {
         co.UpdateInterval = ephUpdInd;
-        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer,
-            sizeof(obuffer));
+        int len1 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSORBIT, 1, obuffer, sizeof(obuffer));
         co.UpdateInterval = clkUpdInd;
         if (len1 > 0) {
@@ -951,6 +941,5 @@
       }
       int mmsg = 0;
-      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer,
-          sizeof(obuffer));
+      int len2 = _ssrCorr->MakeClockOrbit(&co, _ssrCorr->COTYPE_BDSCLOCK, mmsg, obuffer, sizeof(obuffer));
       if (len2 > 0) {
         hlpBufferCo += QByteArray(obuffer, len2);
Index: trunk/BNC/src/upload/bncuploadcaster.cpp
===================================================================
--- trunk/BNC/src/upload/bncuploadcaster.cpp	(revision 10225)
+++ trunk/BNC/src/upload/bncuploadcaster.cpp	(revision 10227)
@@ -163,10 +163,11 @@
         if (_ntripVersion == "1") {
           _outSocket->write(_outBuffer);
+          _outSocket->flush();
         } else {
           QString chunkSize = QString("%1").arg(_outBuffer.size(), 0, 16,  QLatin1Char('0'));
           QByteArray chunkedData = chunkSize.toLatin1() + "\r\n" + _outBuffer  + "\r\n";
           _outSocket->write(chunkedData);
+          _outSocket->flush();
         }
-        _outSocket->flush();
         emit newBytes(_mountpoint.toLatin1(), _outBuffer.size());
       }
