Index: trunk/BNC/bncmodel.cpp
===================================================================
--- trunk/BNC/bncmodel.cpp	(revision 3385)
+++ trunk/BNC/bncmodel.cpp	(revision 3386)
@@ -271,4 +271,5 @@
     delete _params[iPar-1];
   }
+  delete _epoData_sav;
 }
 
@@ -906,42 +907,16 @@
   Tracer tracer("bncModel::outlierDetection");
 
-  QString prnCode;
-  QString prnPhase;
-  double  maxResCode  = 0.0;
-  double  maxResPhase = 0.0;
-
-  QString prnRemoved;
-  double  maxRes;
-
-  bool irc = false;
-
-  // Check Code
-  // ----------
-  if (iPhase == 0) {
-    findMaxRes(iPhase, vv, satData, prnCode, maxResCode, prnPhase, maxResPhase);
-    if (maxResCode > MAXRES_CODE) {
-      prnRemoved = prnCode;
-      maxRes     = maxResCode;
-      irc        = true;
-    }
-  }
-
-  // Check Phase
-  // -----------
+  QString prn;
+  double  maxRes  = 0.0;
+  findMaxRes(vv, satData, prn, maxRes);
+
+  if ( maxRes > (iPhase == 1 ? MAXRES_PHASE : MAXRES_CODE) ) {
+    _log += "Outlier " + prn + " " 
+          + QByteArray::number(maxRes, 'f', 3) + "\n"; 
+    return true;
+  }
   else {
-    findMaxRes(iPhase, vv, satData, prnCode, maxResCode, prnPhase, maxResPhase);
-    if (maxResPhase > MAXRES_PHASE) {
-      prnRemoved = prnPhase;
-      maxRes     = maxResPhase;
-      irc        = true;
-    }
-  }
- 
-  if (irc) {
-    _log += "Outlier " + prnRemoved.toAscii() + " " 
-          + QByteArray::number(maxRes, 'f', 3) + "\n"; 
-  }
-
-  return irc;
+    return false;
+  }
 }
 
@@ -968,5 +943,5 @@
 }
 
-//// 
+//
 //////////////////////////////////////////////////////////////////////////////
 void bncModel::kalman(const Matrix& AA, const ColumnVector& ll, 
@@ -1140,8 +1115,12 @@
   }
 
+  // Remember Observation Index
+  // --------------------------
+  ++iObs;
+  satData->index = iObs;
+
   // Phase Observations
   // ------------------
   if (iPhase == 1) {
-    ++iObs;
     ll(iObs)      = satData->L3 - cmpValue(satData, true);
     PP(iObs,iObs) = 1.0 / (_sigL3 * _sigL3) / (ellWgtCoef * ellWgtCoef);
@@ -1156,5 +1135,4 @@
       AA(iObs, iPar) = _params[iPar-1]->partial(satData, true);
     }
-    satData->indexPhase = iObs;
   }
 
@@ -1162,5 +1140,4 @@
   // -----------------
   else {
-    ++iObs;
     ll(iObs)      = satData->P3 - cmpValue(satData, false);
     PP(iObs,iObs) = 1.0 / (_sigP3 * _sigP3) / (ellWgtCoef * ellWgtCoef);
@@ -1168,5 +1145,4 @@
       AA(iObs, iPar) = _params[iPar-1]->partial(satData, false);
     }
-    satData->indexCode = iObs;
   }
 }
@@ -1177,13 +1153,10 @@
                         ostringstream& str, t_satData* satData) {
   Tracer tracer("bncModel::printRes");
-  if (iPhase == 1) {
+
+  if (satData->index != 0) {
     str << _time.timestr(1)
-        << " RES " << satData->prn.toAscii().data() << "   L3 "
-        << setw(9) << setprecision(4) << vv(satData->indexPhase) << endl;
-  }
-  else {
-    str << _time.timestr(1)
-        << " RES " << satData->prn.toAscii().data() << "   P3 "
-        << setw(9) << setprecision(4) << vv(satData->indexCode) << endl;
+        << " RES " << satData->prn.toAscii().data() 
+        << (iPhase ? "   L3 " : "   P3 ")
+        << setw(9) << setprecision(4) << vv(satData->index) << endl;
   }
 }
@@ -1191,11 +1164,11 @@
 // 
 ///////////////////////////////////////////////////////////////////////////
-void bncModel::findMaxRes(int iPhase, const ColumnVector& vv,
+void bncModel::findMaxRes(const ColumnVector& vv,
                           const QMap<QString, t_satData*>& satData,
-                          QString& prnCode,  double& maxResCode, 
-                          QString& prnPhase, double& maxResPhase) {
+                          QString& prn,  double& maxRes) { 
+
   Tracer tracer("bncModel::findMaxRes");
-  maxResCode  = 0.0;
-  maxResPhase = 0.0;
+
+  maxRes  = 0.0;
 
   QMapIterator<QString, t_satData*> it(satData);
@@ -1203,19 +1176,7 @@
     it.next();
     t_satData* satData = it.value();
-    if (iPhase == 0) {
-      if (satData->indexCode) {
-        if (fabs(vv(satData->indexCode)) > maxResCode) {
-          maxResCode = fabs(vv(satData->indexCode));
-          prnCode    = satData->prn;
-        }
-      }
-    }
-    else {
-      if (satData->indexPhase) {
-        if (fabs(vv(satData->indexPhase)) > maxResPhase) {
-          maxResPhase = fabs(vv(satData->indexPhase));
-          prnPhase    = satData->prn;
-        }
-      }
+    if (satData->index != 0 && fabs(vv(satData->index)) > maxRes) {
+      maxRes = fabs(vv(satData->index));
+      prn    = satData->prn;
     }
   }
@@ -1280,5 +1241,5 @@
       }
 
-      // Remove Neglected Satellites form epoData
+      // Remove Neglected Satellites from epoData
       // ----------------------------------------
       for (unsigned ip = 0; ip < allPrns.size(); ip++) {
Index: trunk/BNC/bncmodel.h
===================================================================
--- trunk/BNC/bncmodel.h	(revision 3385)
+++ trunk/BNC/bncmodel.h	(revision 3386)
@@ -102,8 +102,7 @@
   void   printRes(int iPhase, const ColumnVector& vv, 
                   std::ostringstream& str, t_satData* satData);
-  void   findMaxRes(int iPhase, const ColumnVector& vv,
+  void   findMaxRes(const ColumnVector& vv,
                     const QMap<QString, t_satData*>& satData,
-                    QString& prnCode,  double& maxResCode, 
-                    QString& prnPhase, double& maxResPhase);
+                    QString& prn,  double& maxRes); 
   double cmpValue(t_satData* satData, bool phase);
   double delay_saast(double Ele);
Index: trunk/BNC/bncpppclient.h
===================================================================
--- trunk/BNC/bncpppclient.h	(revision 3385)
+++ trunk/BNC/bncpppclient.h	(revision 3386)
@@ -35,6 +35,5 @@
  public:
   t_satData() {
-    indexCode  = 0;
-    indexPhase = 0;
+    index = 0;
   }
   ~t_satData() {}
@@ -57,6 +56,5 @@
   bool         slipFlag;
   double       lambda3;
-  unsigned     indexCode;
-  unsigned     indexPhase;
+  unsigned     index;
   char system() const {return prn.toAscii()[0];}
 };
