Index: trunk/BNC/src/combination/bnccomb.cpp
===================================================================
--- trunk/BNC/src/combination/bnccomb.cpp	(revision 10664)
+++ trunk/BNC/src/combination/bnccomb.cpp	(revision 10665)
@@ -976,5 +976,5 @@
   // Check Satellite Positions for Outliers
   // --------------------------------------
-  if (checkOrbits(epoTime, sys, out) != success) {
+  if (checkOrbits(epoTime, sys, out, resCorr) != success) {
     return failure;
   }
@@ -1229,14 +1229,14 @@
     ++iObs;
 
-    if (corr->_acName == _masterOrbitAC[sys] && resCorr.find(prn) == resCorr.end()) {
-      resCorr[prn] = new cmbCorr(*corr);
-    }
-
     for (int iPar = 1; iPar <= _params[sys].size(); iPar++) {
       cmbParam* pp = _params[sys][iPar-1];
       AA(iObs, iPar) = pp->partial(sys, corr->_acName, prn);
     }
-
-    ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_satCodeBiasIF) - DotProduct(AA.Row(iObs), x0);
+    // Consistency correction to keep the combined clock consistent to MeanOrb
+    // -----------------------------------------------------------------------
+    double dC_radial = (corr->_diffRao.t() * resCorr[prn]->_orbCorr._xr).AsScalar()
+                     / (resCorr[prn]->_orbCorr._xr).norm_Frobenius();
+
+    ll(iObs) = (corr->_clkCorr._dClk * t_CST::c - corr->_satCodeBiasIF + dC_radial) - DotProduct(AA.Row(iObs), x0);
 
     PP(iObs, iObs) *= 1.0 / (corr->_weightFactor * corr->_weightFactor);
@@ -1288,5 +1288,5 @@
   // Check Satellite Positions for Outliers
   // --------------------------------------
-  if (checkOrbits(epoTime, sys, out) != success) {
+  if (checkOrbits(epoTime, sys, out, resCorr) != success) {
     return failure;
   }
@@ -1295,28 +1295,4 @@
   // ----------------------
   while (_running) {
-
-    // Remove Satellites that are not in Master
-    // ----------------------------------------
-    QMutableVectorIterator<cmbCorr*> it(corrs(sys));
-    while (it.hasNext()) {
-      cmbCorr* corr    = it.next();
-      QString  prnStr  = corr->_prn;
-      bool foundMaster = false;
-      QVectorIterator<cmbCorr*> itHlp(corrs(sys));
-      while (itHlp.hasNext()) {
-        cmbCorr* corrHlp = itHlp.next();
-        QString  prnHlp  = corrHlp->_prn;
-        QString  ACHlp   = corrHlp->_acName;
-        if (ACHlp == _masterOrbitAC[sys] && prnStr == prnHlp) {
-          foundMaster = true;
-          break;
-        }
-      }
-      if (!foundMaster) {
-        delete corr;
-        it.remove();
-      }
-    }
-
     // Count Number of Observations per Satellite and per AC
     // -----------------------------------------------------
@@ -1436,5 +1412,5 @@
 // Check Satellite Positions for Outliers
 ////////////////////////////////////////////////////////////////////////////
-t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out) {
+t_irc bncComb::checkOrbits(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr) {
 
   // Switch to last ephemeris (if possible)
@@ -1510,4 +1486,5 @@
       }
       corr->_diffRao = corr->_orbCorr._xr - meanRao[prn].Rows(1,3);
+
       if (maxDiff.find(prn) == maxDiff.end()) {
         maxDiff[prn] = corr;
@@ -1523,4 +1500,28 @@
 
     if (_ACs.size() == 1) {
+      QVectorIterator<cmbCorr*> it(corrs(sys));
+      while (it.hasNext()) {
+        cmbCorr* corr = it.next();
+        QString  prn  = corr->_prn;
+        if (corr->_acName == _masterOrbitAC[sys] &&
+            resCorr.find(prn) == resCorr.end()) {
+          resCorr[prn] = new cmbCorr(*corr);
+        }
+      }
+      // Remove satellites that are not in masterOrbit
+      // and compute differences wrt. masterOrbit
+      // ----------------------------------------------
+      QMutableVectorIterator<cmbCorr*> im(corrs(sys));
+      while (im.hasNext()) {
+        cmbCorr* corr = im.next();
+        QString  prn  = corr->_prn;
+        if (resCorr.find(prn) == resCorr.end()) {
+          delete corr;
+          im.remove();
+        }
+        else {
+          corr->_diffRao = resCorr[prn]->_orbCorr._xr - corr->_orbCorr._xr;
+        }
+      }
       break;
     }
@@ -1539,5 +1540,9 @@
       else if (corr == maxDiff[prn]) {
         double norm = corr->_diffRao.NormFrobenius();
-        if (norm > (_MAX_DISPLACEMENT)) {
+        double facSys = 1.0;
+        if (sys == 'C' && prn.mid(1,2).toInt() <= 16) { // BDS-2
+          facSys *= 5.0;
+        }
+        if (norm > (_MAX_DISPLACEMENT * facSys)) {
           out << epoTime.datestr().c_str()    << " "
               << epoTime.timestr().c_str()    << " "
@@ -1553,6 +1558,31 @@
       }
     }
-
+    // Set master orbit
+    // -----------------------------------------
     if (!removed) {
+      QVectorIterator<cmbCorr*> it(corrs(sys));
+      while (it.hasNext()) {
+        cmbCorr* corr = it.next();
+        QString  prn  = corr->_prn;
+        if (corr->_acName == _masterOrbitAC[sys] &&
+            resCorr.find(prn) == resCorr.end()) {
+          resCorr[prn] = new cmbCorr(*corr);
+        }
+      }
+      // Remove satellites that are not in masterOrbit
+      // and compute differences wrt. masterOrbit
+      // ----------------------------------------------
+      QMutableVectorIterator<cmbCorr*> im(corrs(sys));
+      while (im.hasNext()) {
+        cmbCorr* corr = im.next();
+        QString  prn  = corr->_prn;
+        if (resCorr.find(prn) == resCorr.end()) {
+          delete corr;
+          im.remove();
+        }
+        else {
+          corr->_diffRao = resCorr[prn]->_orbCorr._xr - corr->_orbCorr._xr;
+        }
+      }
       break;
     }
Index: trunk/BNC/src/combination/bnccomb.h
===================================================================
--- trunk/BNC/src/combination/bnccomb.h	(revision 10664)
+++ trunk/BNC/src/combination/bnccomb.h	(revision 10665)
@@ -244,5 +244,5 @@
   void  printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
   void  switchToLastEph(t_eph* lastEph, cmbCorr* corr);
-  t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out);
+  t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr);
   bool excludeSat(const t_prn& prn, const QStringList excludeSats) const;
   QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
