Index: trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp
===================================================================
--- trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp	(revision 6454)
+++ trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp	(revision 6455)
@@ -262,9 +262,9 @@
 void RTCM3coDecoder::sendResults() {
 
-  QList<t_orbCorr> orbCorrections;
-  QList<t_clkCorr> clkCorrections;
-
-  // Loop over all satellites (GPS and Glonass)
-  // ------------------------------------------
+  QList<t_orbCorr>& orbCorrections = _orbCorrections[_lastTime];
+  QList<t_clkCorr>& clkCorrections = _clkCorrections[_lastTime];
+
+  // Orbit and clock corrections of all satellites
+  // ---------------------------------------------
   for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
     char sysCh = ' ';
@@ -304,4 +304,6 @@
     }
 
+    // Clock Corrections
+    // -----------------
     if ( _clkOrb.messageType == COTYPE_GPSCOMBINED     ||
          _clkOrb.messageType == COTYPE_GLONASSCOMBINED ||
@@ -331,6 +333,6 @@
   }
 
-  // Loop over all satellites (GPS and Glonass)
-  // ------------------------------------------
+  // Code Biases
+  // -----------
   QList<t_satBias> satBiases;
   for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) {
@@ -354,21 +356,30 @@
   }
 
-  if (orbCorrections.size() > 0) {
-    emit newOrbCorrections(orbCorrections);
-  }
-  if (clkCorrections.size() > 0) {
-    emit newClkCorrections(clkCorrections);
-  }
+  // Dump all older epochs
+  // ---------------------
+  QMutableMapIterator<bncTime, QList<t_orbCorr> > itOrb(_orbCorrections);
+  while (itOrb.hasNext()) {
+    itOrb.next();
+    if (itOrb.key() < _lastTime) {
+      emit newOrbCorrections(itOrb.value());
+      if (_out) {
+        t_orbCorr::writeEpoch(_out, itOrb.value());
+      }
+      itOrb.remove();
+    } 
+  }
+  QMutableMapIterator<bncTime, QList<t_clkCorr> > itClk(_clkCorrections);
+  while (itClk.hasNext()) {
+    itClk.next();
+    if (itClk.key() < _lastTime) {
+      emit newClkCorrections(itClk.value());
+      if (_out) {
+        t_clkCorr::writeEpoch(_out, itClk.value());
+      }
+      itClk.remove();
+    } 
+  }
+
   if (_out) {
-    QListIterator<t_orbCorr> itOrb(orbCorrections);
-    while (itOrb.hasNext()) {
-      const t_orbCorr& orbCorr = itOrb.next();
-      *_out << orbCorr.toLine();
-    }
-    QListIterator<t_clkCorr> itClk(clkCorrections);
-    while (itClk.hasNext()) {
-      const t_clkCorr& clkCorr = itClk.next();
-      *_out << clkCorr.toLine();
-    }
     _out->flush();
   }
Index: trunk/BNC/src/RTCM3/RTCM3coDecoder.h
===================================================================
--- trunk/BNC/src/RTCM3/RTCM3coDecoder.h	(revision 6454)
+++ trunk/BNC/src/RTCM3/RTCM3coDecoder.h	(revision 6455)
@@ -44,7 +44,6 @@
 
  signals:
-  void newOrbCorrections(QList<t_orbCorr> orbCorr);
-  void newClkCorrections(QList<t_clkCorr> clkCorr);
-  void newBiases(QList<t_satBias> biases);
+  void newOrbCorrections(QList<t_orbCorr>);
+  void newClkCorrections(QList<t_clkCorr>);
   void newMessage(QByteArray msg, bool showOnScreen);
   void providerIDChanged(QString staID);
@@ -66,4 +65,6 @@
   bncTime        _lastTime;
   QMap<std::string, unsigned short> _IODs;
+  QMap<bncTime, QList<t_orbCorr> >  _orbCorrections;
+  QMap<bncTime, QList<t_clkCorr> >  _clkCorrections;
 };
 
Index: trunk/BNC/src/bnccore.cpp
===================================================================
--- trunk/BNC/src/bnccore.cpp	(revision 6454)
+++ trunk/BNC/src/bnccore.cpp	(revision 6455)
@@ -534,20 +534,18 @@
   emit newOrbCorrections(orbCorrections);
   if (_socketsCorr) {
-    QListIterator<t_orbCorr> it(orbCorrections);
-    while (it.hasNext()) {
-      const t_orbCorr& corr = it.next();
-      QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
-      while (is.hasNext()) {
-        QTcpSocket* sock = is.next();
-        if (sock->state() == QAbstractSocket::ConnectedState) {
-          if (sock->write(corr.toLine().c_str()) == -1) {
-            delete sock;
-            is.remove();
-          }
-        }
-        else if (sock->state() != QAbstractSocket::ConnectingState) {
+    ostringstream out;
+    t_orbCorr::writeEpoch(&out, orbCorrections);   
+    QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
+    while (is.hasNext()) {
+      QTcpSocket* sock = is.next();
+      if (sock->state() == QAbstractSocket::ConnectedState) {
+        if (sock->write(out.str().c_str()) == -1) {
           delete sock;
           is.remove();
         }
+      }
+      else if (sock->state() != QAbstractSocket::ConnectingState) {
+        delete sock;
+        is.remove();
       }
     }
@@ -561,20 +559,18 @@
   emit newClkCorrections(clkCorrections);
   if (_socketsCorr) {
-    QListIterator<t_clkCorr> it(clkCorrections);
-    while (it.hasNext()) {
-      const t_clkCorr& corr = it.next();
-      QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
-      while (is.hasNext()) {
-        QTcpSocket* sock = is.next();
-        if (sock->state() == QAbstractSocket::ConnectedState) {
-          if (sock->write(corr.toLine().c_str()) == -1) {
-            delete sock;
-            is.remove();
-          }
-        }
-        else if (sock->state() != QAbstractSocket::ConnectingState) {
+    ostringstream out;
+    t_clkCorr::writeEpoch(&out, clkCorrections);   
+    QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
+    while (is.hasNext()) {
+      QTcpSocket* sock = is.next();
+      if (sock->state() == QAbstractSocket::ConnectedState) {
+        if (sock->write(out.str().c_str()) == -1) {
           delete sock;
           is.remove();
         }
+      }
+      else if (sock->state() != QAbstractSocket::ConnectingState) {
+        delete sock;
+        is.remove();
       }
     }
Index: trunk/BNC/src/rinex/corrfile.cpp
===================================================================
--- trunk/BNC/src/rinex/corrfile.cpp	(revision 6454)
+++ trunk/BNC/src/rinex/corrfile.cpp	(revision 6455)
@@ -50,10 +50,5 @@
 t_corrFile::t_corrFile(QString fileName) {
   expandEnvVar(fileName);
-  _file   = new QFile(fileName);
-  _file->open(QIODevice::ReadOnly | QIODevice::Text);
-  _stream = new QTextStream();
-  _stream->setDevice(_file);
-  _lastOrbCorr = 0;
-  _lastClkCorr = 0;
+  _stream.open(fileName.toAscii().data());
 }
 
@@ -61,6 +56,4 @@
 ////////////////////////////////////////////////////////////////////////////
 t_corrFile::~t_corrFile() {
-  delete _stream;
-  delete _file;
 }
 
@@ -72,15 +65,5 @@
   _clkCorr.clear();
 
-  while (!stopRead(tt) && _stream->status() == QTextStream::Ok && !_stream->atEnd()) {
-    QString line = _stream->readLine().trimmed();
-    if (line.isEmpty() || line[0] == '!') {
-      continue;
-    }
-    if      (line[0] == 'O') {
-      delete _lastOrbCorr; _lastOrbCorr = new t_orbCorr(line.toAscii().data());
-    }
-    else if (line[0] == 'C') {
-      delete _lastClkCorr; _lastClkCorr = new t_clkCorr(line.toAscii().data());
-    }
+  while (!stopRead(tt) && _stream.good()) {
     if (stopRead(tt)) {
       break;
@@ -101,24 +84,4 @@
 ////////////////////////////////////////////////////////////////////////////
 bool t_corrFile::stopRead(const bncTime& tt) {
-  if (_lastOrbCorr) {
-    if (_lastOrbCorr->_time > tt) {
-      return true;
-    }
-    else {
-      _orbCorr.push_back(*_lastOrbCorr);
-      _corrIODs[QString(_lastOrbCorr->_prn.toString().c_str())] = _lastOrbCorr->_iod;
-      delete _lastOrbCorr; _lastOrbCorr = 0;
-    }
-  }
-  if (_lastClkCorr) {
-    if (_lastClkCorr->_time > tt) {
-      return true;
-    }
-    else {
-      _clkCorr.push_back(*_lastClkCorr);
-      _corrIODs[QString(_lastClkCorr->_prn.toString().c_str())] = _lastClkCorr->_iod;
-      delete _lastClkCorr; _lastClkCorr = 0;
-    }
-  }
-  return false;
+  return true;
 }
Index: trunk/BNC/src/rinex/corrfile.h
===================================================================
--- trunk/BNC/src/rinex/corrfile.h	(revision 6454)
+++ trunk/BNC/src/rinex/corrfile.h	(revision 6455)
@@ -26,4 +26,5 @@
 #define CORRFILE_H
 
+#include <fstream>
 #include <QtCore>
 #include "bncconst.h"
@@ -46,10 +47,7 @@
  private:
   bool stopRead(const bncTime& tt);
-  QFile*             _file;
-  QTextStream*       _stream;
+  std::fstream       _stream;
   QList<t_orbCorr>   _orbCorr;
   QList<t_clkCorr>   _clkCorr;
-  t_orbCorr*         _lastOrbCorr;
-  t_clkCorr*         _lastClkCorr;
   QMap<QString, int> _corrIODs;
 };
Index: trunk/BNC/src/satObs.cpp
===================================================================
--- trunk/BNC/src/satObs.cpp	(revision 6454)
+++ trunk/BNC/src/satObs.cpp	(revision 6455)
@@ -6,19 +6,4 @@
 
 using namespace std;
-
-// 
-////////////////////////////////////////////////////////////////////////////
-t_clkCorr::t_clkCorr(const string& line) {
-  reset();
-  istringstream in(line);
-  char ch; in >> ch; if (ch != 'C') return;
-  int    gpsw;
-  double gpssec;
-  in >> gpsw >> gpssec >> _prn >> _iod >> _dClk >> _dotDClk >> _dotDotDClk;
-  _time.set(gpsw, gpssec);
-  _dClk       /= t_CST::c;
-  _dotDClk    /= t_CST::c;
-  _dotDotDClk /= t_CST::c;
-}
 
 // 
@@ -36,27 +21,11 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-string t_clkCorr::toLine() const {
-  ostringstream str;
-  str.setf(ios::showpoint | ios::fixed);
-  str << "C " << _time.gpsw() << ' ' << setprecision(2) << _time.gpssec() << ' '
-      << _prn.toString() << ' ' << setw(3) << _iod << ' '
-      << setw(10) << setprecision(4) << _dClk       * t_CST::c << ' '
-      << setw(10) << setprecision(4) << _dotDClk    * t_CST::c << ' '
-      << setw(10) << setprecision(4) << _dotDotDClk * t_CST::c << endl;
-  return str.str();
+void t_clkCorr::writeEpoch(std::ostream* out, const QList<t_clkCorr>& corrList) {
+  *out << "CLOCK CORRECTIONS: " << corrList.size() << endl;
 }
 
 // 
 ////////////////////////////////////////////////////////////////////////////
-t_orbCorr::t_orbCorr(const string& line) {
-  reset();
-  istringstream in(line);
-  char ch; in >> ch; if (ch != 'O') return;
-  int    gpsw;
-  double gpssec;
-  in >> gpsw >> gpssec >> _prn >> _iod 
-     >> _xr[0]    >> _xr[1]    >> _xr[2]
-     >> _dotXr[0] >> _dotXr[1] >> _dotXr[2];
-  _time.set(gpsw, gpssec);
+void t_clkCorr::readEpoch(std::istream* in, QList<t_clkCorr>& corrList) {
 }
 
@@ -74,16 +43,10 @@
 // 
 ////////////////////////////////////////////////////////////////////////////
-string t_orbCorr::toLine() const {
-  ostringstream str;
-  str.setf(ios::showpoint | ios::fixed);
-  str << "O " << _time.gpsw() << ' ' << setprecision(2) << _time.gpssec() << ' '
-      << _prn.toString() << ' ' << setw(3) << _iod << ' '
-      << setw(10) << setprecision(4) << _xr[0]     << ' '
-      << setw(10) << setprecision(4) << _xr[1]     << ' '
-      << setw(10) << setprecision(4) << _xr[2]     << "    "
-      << setw(10) << setprecision(4) << _dotXr[0]  << ' '
-      << setw(10) << setprecision(4) << _dotXr[1]  << ' '
-      << setw(10) << setprecision(4) << _dotXr[2]  << endl;
-  return str.str();
+void t_orbCorr::writeEpoch(std::ostream* out, const QList<t_orbCorr>& corrList) {
+  *out << "ORB CORRECTIONS: " << corrList.size() << endl;
 }
 
+// 
+////////////////////////////////////////////////////////////////////////////
+void t_orbCorr::readEpoch(std::istream* in, QList<t_orbCorr>& corrList) {
+}
Index: trunk/BNC/src/satObs.h
===================================================================
--- trunk/BNC/src/satObs.h	(revision 6454)
+++ trunk/BNC/src/satObs.h	(revision 6455)
@@ -5,4 +5,6 @@
 #include <vector>
 #include <newmat.h>
+
+#include <QtCore>
 
 #include "bncconst.h"
@@ -60,9 +62,9 @@
  public:
   t_orbCorr() {reset();}
-  t_orbCorr(const std::string& line);
+  static void writeEpoch(std::ostream* out, const QList<t_orbCorr>& corrList);
+  static void readEpoch(std::istream* in, QList<t_orbCorr>& corrList);
   void           reset();
   t_prn          prn() const {return _prn;}
   unsigned short IOD() const {return _iod;}
-  std::string    toLine() const;
   std::string    _staID;
   t_prn          _prn;
@@ -77,9 +79,9 @@
  public:
   t_clkCorr() {reset();}
-  t_clkCorr(const std::string& line);
+  static void writeEpoch(std::ostream* out, const QList<t_clkCorr>& corrList);
+  static void readEpoch(std::istream* in, QList<t_clkCorr>& corrList);
   void           reset();
   t_prn          prn() const {return _prn;}
   unsigned short IOD() const {return _iod;}
-  std::string    toLine() const;
   std::string    _staID;
   t_prn          _prn;
