Index: /trunk/Mars/mcore/checksum.h
===================================================================
--- /trunk/Mars/mcore/checksum.h	(revision 17263)
+++ /trunk/Mars/mcore/checksum.h	(revision 17264)
@@ -7,7 +7,4 @@
 
 #include <stdint.h>
-
-namespace std
-{
 
 class Checksum
@@ -43,4 +40,5 @@
         return *this;
     }
+
     Checksum operator+(Checksum sum) const
     {
@@ -60,9 +58,9 @@
         if (len%4>0)
         {
-            ostringstream sout;
-            sout << "Length " << len << " not dividable by 4." << endl;
+            std::ostringstream sout;
+            sout << "Length " << len << " not dividable by 4";
 
 #ifdef __EXCEPTIONS
-            throw runtime_error(sout.str());
+            throw std::runtime_error(sout.str());
 #else
             gLog << ___err___ << "ERROR - " << sout.str() << endl;
@@ -143,12 +141,12 @@
     }
 
-    bool add(const vector<char> &v, bool big_endian = true)
+    bool add(const std::vector<char> &v, bool big_endian = true)
     {
         return add(v.data(), v.size(), big_endian);
     }
 
-    string str(bool complm=true) const
-    {
-        string rc(16,0);
+    std::string str(bool complm=true) const
+    {
+        std::string rc(16,0);
 
         const uint8_t exclude[13] =
@@ -241,5 +239,4 @@
    }
 };
-}
 
 #endif
Index: /trunk/Mars/mcore/factfits.h
===================================================================
--- /trunk/Mars/mcore/factfits.h	(revision 17263)
+++ /trunk/Mars/mcore/factfits.h	(revision 17264)
@@ -11,14 +11,9 @@
 #include "zfits.h"
 
-#ifndef __MARS__
-namespace std
-{
-#endif
-
 class factfits : public zfits
 {
 public:
     // Default constructor
-    factfits(const string& fname, const string& tableName="", bool force=false) :
+    factfits(const std::string& fname, const std::string& tableName="", bool force=false) :
         zfits(fname, tableName, force),
         fOffsetCalibration(0),
@@ -32,5 +27,5 @@
 
     // Alternative constructor
-    factfits(const string& fname, const string& fout, const string& tableName, bool force=false) :
+    factfits(const std::string& fname, const std::string& fout, const std::string& tableName, bool force=false) :
         zfits(fname, fout, tableName, force),
         fOffsetCalibration(0),
@@ -48,13 +43,14 @@
     {
         zfits::StageRow(row, dest);
+
         // This file does not contain fact data or no calibration to be applied
-         if (fOffsetCalibration.empty())
-             return;
-
-         //re-get the pointer to the data to access the offsets
-         const uint8_t offset = (row*fTable.bytes_per_row)%4;
-
-         int16_t *startCell = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetStartCellData);
-         int16_t *data      = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetData);
+        if (fOffsetCalibration.empty())
+            return;
+
+        //re-get the pointer to the data to access the offsets
+        const uint8_t offset = (row*fTable.bytes_per_row)%4;
+
+        int16_t *startCell = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetStartCellData);
+        int16_t *data      = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetData);
 
          /*
@@ -71,32 +67,32 @@
          */
 
-         // This version is faster because the compilers optimization
-         // is not biased by the evaluation of %1024
-         for (int ch=0; ch<1440; ch++)
-         {
-             if (startCell[ch]<0)
-             {
-                 data += fNumRoi;
-                 continue;
-             }
-
-             const int16_t modStart = startCell[ch] % 1024;
-             const int16_t *off = fOffsetCalibration.data() + ch*1024;
-
-             const int16_t *cal = off+modStart;
-             const int16_t *end_stride = data+fNumRoi;
-
-             if (modStart+fNumRoi>1024)
-             {
-                 while (cal<off+1024)
-                     *data++ += *cal++;
-
-                 cal = off;
-             }
-             while (data<end_stride)
-                 *data++ += *cal++;
-         }
-
-}
+        // This version is faster because the compilers optimization
+        // is not biased by the evaluation of %1024
+        for (int ch=0; ch<1440; ch++)
+        {
+            if (startCell[ch]<0)
+            {
+                data += fNumRoi;
+                continue;
+            }
+
+            const int16_t modStart = startCell[ch] % 1024;
+            const int16_t *off = fOffsetCalibration.data() + ch*1024;
+
+            const int16_t *cal = off+modStart;
+            const int16_t *end_stride = data+fNumRoi;
+
+            if (modStart+fNumRoi>1024)
+            {
+                while (cal<off+1024)
+                    *data++ += *cal++;
+
+                cal = off;
+            }
+            while (data<end_stride)
+                *data++ += *cal++;
+        }
+
+    }
 
     bool init()
@@ -129,5 +125,5 @@
 
     //  Read the Drs calibration data
-    void readDrsCalib(const string& fileName)
+    void readDrsCalib(const std::string& fileName)
     {
         //should not be mandatory, but improves the perfs a lot when reading not compressed, gzipped files
@@ -205,7 +201,3 @@
 }; //class factfits
 
-#ifndef __MARS__
-}; //namespace std
-#endif
-
-#endif
+#endif
Index: /trunk/Mars/mcore/factofits.h
===================================================================
--- /trunk/Mars/mcore/factofits.h	(revision 17263)
+++ /trunk/Mars/mcore/factofits.h	(revision 17264)
@@ -12,12 +12,6 @@
 #include "DrsCalib.h"
 
-#ifndef __MARS__
-namespace std
-{
-#endif
-
 class factofits : public zofits
 {
-
     public:
 
@@ -50,5 +44,5 @@
 
         ///assign a given drs offset calibration
-        void SetDrsCalibration(const vector<float> &calib)
+        void SetDrsCalibration(const std::vector<float> &calib)
         {
             VerifyCalibrationSize(calib.size());
@@ -62,5 +56,5 @@
 
         ///assign a given drs offset calibration
-        void SetDrsCalibration(const vector<int16_t>& vec)
+        void SetDrsCalibration(const std::vector<int16_t>& vec)
         {
             VerifyCalibrationSize(vec.size());
@@ -110,7 +104,7 @@
                     {
 #ifdef __EXCEPTIONS
-                        throw runtime_error("Number of data samples not a multiple of 1440.");
+                        throw std::runtime_error("Number of data samples not a multiple of 1440.");
 #else
-                        gLog << ___warn___ << "WARNING - Number of data samples not a multiple of 1440. Doing it uncalibrated." << endl;
+                        gLog << ___warn___ << "WARNING - Number of data samples not a multiple of 1440. Doing it uncalibrated." << std::endl;
 #endif
                         fOffsetCalibration.resize(0);
@@ -123,7 +117,7 @@
             {
 #ifdef __EXCEPTIONS
-                throw runtime_error("FACT Calibration requested, but \"StartCellData\" column not found.");
+                throw std::runtime_error("FACT Calibration requested, but \"StartCellData\" column not found.");
 #else
-                gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"StartCellData\" column not found. Doing it uncalibrated." << endl;
+                gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"StartCellData\" column not found. Doing it uncalibrated." << std::endl;
 #endif
                 //throw away the calibration data
@@ -134,7 +128,7 @@
             {
 #ifdef __EXCEPTIONS
-                throw runtime_error("FACT Calibration requested, but \"Data\" column not found.");
+                throw std::runtime_error("FACT Calibration requested, but \"Data\" column not found.");
 #else
-                gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"Data\" column not found. Doing it uncalibrated." << endl;
+                gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"Data\" column not found. Doing it uncalibrated." << std::endl;
 #endif
                     //throw away the calibration data
@@ -174,5 +168,5 @@
             datasum.add(swappedOffsets.data(), sizeof(int16_t)*1024*1440);
 
-            ostringstream dataSumStr;
+            std::ostringstream dataSumStr;
             dataSumStr << datasum.val();
             c.SetStr("DATASUM", dataSumStr.str());
@@ -241,5 +235,5 @@
             Checksum rawsum;
             rawsum.add((char*)(fOffsetCalibration.data()), 1024*1440*sizeof(int16_t));
-            c.SetStr("RAWSUM", to_string(rawsum.val()));
+            c.SetStr("RAWSUM", std::to_string(rawsum.val()));
 
             //compress data and calculate final, compressed size
@@ -281,5 +275,5 @@
             c.SetFloat("ZRATIO", (float)(1024*1440*2)/(float)(compressed_size));
             c.SetInt("PCOUNT", compressed_size + catalog_size);
-            c.SetStr("DATASUM", to_string(datasum.val()));
+            c.SetStr("DATASUM", std::to_string(datasum.val()));
 
             datasum += c.WriteHeader(*this);
@@ -339,10 +333,10 @@
                 return true;
 
-            ostringstream str;
+            std::ostringstream str;
             str << "Cannot load calibration with anything else than 1440 pixels and 1024 samples per pixel. Got a total size of " << size;
 #ifdef __EXCEPTIONS
-            throw runtime_error(str.str());
+            throw std::runtime_error(str.str());
 #else
-            gLog << ___err___ << "ERROR - " << str.str() << endl;
+            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
             return false;
 #endif
@@ -350,5 +344,5 @@
 
         //Offsets calibration stuff.
-        vector<int16_t> fOffsetCalibration;  ///< The calibration itself
+        std::vector<int16_t> fOffsetCalibration;  ///< The calibration itself
         int32_t         fStartCellsOffset;   ///< Offset in bytes for the startcell data
         int32_t         fDataOffset;         ///< Offset in bytes for the data
@@ -357,7 +351,3 @@
 }; //class factofits
 
-#ifndef __MARS
-}; //namespace std
-#endif
-
 #endif /* FACTOFITS_H_ */
Index: /trunk/Mars/mcore/ofits.h
===================================================================
--- /trunk/Mars/mcore/ofits.h	(revision 17263)
+++ /trunk/Mars/mcore/ofits.h	(revision 17264)
@@ -33,9 +33,4 @@
 #include "checksum.h"
 
-#ifndef __MARS__
-namespace std
-{
-#endif
-
 // Sloppy:  allow / <--- left
 //          allow all characters (see specs for what is possible)
@@ -43,5 +38,5 @@
 // units: m kg s rad sr K A mol cd Hz J W V N Pa C Ohm S F Wb T Hlm lx
 
-class ofits : public ofstream
+class ofits : public std::ofstream
 {
 public:
@@ -81,5 +76,5 @@
                 throw std::runtime_error("Key name empty.");
 #else
-                gLog << ___err___ << "ERROR - Key name empty." << endl;
+                gLog << ___err___ << "ERROR - Key name empty." << std::endl;
                 return false;
 #endif
@@ -92,5 +87,5 @@
                 throw std::runtime_error(sout.str());
 #else
-                gLog << ___err___ << "ERROR - " << sout.str() << endl;
+                gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
                 return false;
 #endif
@@ -107,5 +102,5 @@
                     throw std::runtime_error(sout.str());
 #else
-                    gLog << ___err___ << "ERROR - " << sout.str() << endl;
+                    gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
                     return false;
 #endif
@@ -127,5 +122,5 @@
                     throw std::runtime_error(sout.str());
 #else
-                    gLog << ___err___ << "ERROR - " << sout.str() << endl;
+                    gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
                     return false;
 #endif
@@ -154,5 +149,5 @@
                 throw std::runtime_error(sout.str());
 #else
-                gLog << ___err___ << "ERROR - " << sout.str() << endl;
+                gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
 #endif
                 return false;
@@ -169,5 +164,5 @@
                 std::ostringstream sout;
                 sout << "Size " << sz << " of entry for key '" << key << "' exceeds 80 characters... removed comment.";
-                gLog << ___warn___ << "WARNING - " << sout.str() << endl;
+                gLog << ___warn___ << "WARNING - " << sout.str() << std::endl;
 #endif
                 return true;
@@ -179,5 +174,5 @@
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -199,5 +194,5 @@
 
             std::ostringstream sout;
-            sout << std::left << setw(8) << key;
+            sout << std::left << std::setw(8) << key;
 
             if (!delim)
@@ -209,5 +204,5 @@
             sout << "= ";
             sout << (!value.empty() && value[0]=='\''?std::left:std::right);
-            sout << setw(20) << value << std::left;
+            sout << std::setw(20) << value << std::left;
 
             if (!comment.empty())
@@ -219,5 +214,5 @@
         Checksum checksum;
 
-        void Out(ofstream &fout)
+        void Out(std::ofstream &fout)
         {
             if (!changed)
@@ -286,5 +281,5 @@
                 throw std::runtime_error(sout.str());
 #else
-                gLog << ___err___ << "ERROR - " << sout.str() << endl;
+                gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
                 return false;
 #endif
@@ -357,5 +352,5 @@
     {
     }
-    ofits(const char *fname) : ofstream(),
+    ofits(const char *fname) : std::ofstream(),
                                fCommentTrimming(false),
                                fManualExtName(false)
@@ -388,5 +383,5 @@
         SetStr("DATASUM",  "         0", "Checksum for the data block");
 
-        ofstream::open(filename);
+        std::ofstream::open(filename);
     }
 
@@ -414,5 +409,5 @@
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -462,9 +457,9 @@
 
         if (p<0)
-            sout << setprecision(-p) << fixed;
+            sout << std::setprecision(-p) << fixed;
         if (p>0)
-            sout << setprecision(p);
+            sout << std::setprecision(p);
         if (p==0)
-            sout << setprecision(f>1e-100 && f<1e100 ? 15 : 14);
+            sout << std::setprecision(f>1e-100 && f<1e100 ? 15 : 14);
 
         sout << f;
@@ -558,5 +553,5 @@
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -570,5 +565,5 @@
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -582,5 +577,5 @@
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -597,5 +592,5 @@
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -727,5 +722,5 @@
 
 
-    Checksum WriteHeader(ofstream &fout)
+    Checksum WriteHeader(std::ofstream &fout)
     {
         Checksum sum;
@@ -796,5 +791,5 @@
             throw std::runtime_error("File not empty anymore.");
 #else
-            gLog << ___err___ << "ERROR - File not empty anymore." << endl;
+            gLog << ___err___ << "ERROR - File not empty anymore." << std::endl;
             return false;
 #endif
@@ -824,5 +819,5 @@
         const char *pend = src + num*N;
         for (const char *ptr = src; ptr<pend; ptr+=N, dest+=N)
-            reverse_copy(ptr, ptr+N, dest);
+            std::reverse_copy(ptr, ptr+N, dest);
     }
 
@@ -835,10 +830,10 @@
         if (cnt!=fTable.bytes_per_row)
         {
-            ostringstream sout;
+            std::ostringstream sout;
             sout << "WriteRow - Size " << cnt << " does not match expected size " << fTable.bytes_per_row;
 #ifdef __EXCEPTIONS
             throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -918,5 +913,5 @@
     {
 
-        ostringstream dataSumStr;
+        std::ostringstream dataSumStr;
         dataSumStr << fDataSum.val();
         SetStr("DATASUM", dataSumStr.str());
@@ -943,20 +938,20 @@
         const Checksum chk = UpdateHeaderChecksum();
 
-        ofstream::close();
+        std::ofstream::close();
 
         if ((chk+fDataSum).valid())
             return true;
 
-        ostringstream sout;
+        std::ostringstream sout;
         sout << "Checksum (" << std::hex << chk.val() << ") invalid.";
 #ifdef __EXCEPTIONS
         throw std::runtime_error(sout.str());
 #else
-        gLog << ___err___ << "ERROR - " << sout.str() << endl;
+        gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
         return false;
 #endif
     }
 
-    pair<string, int> GetChecksumData()
+    std::pair<std::string, int> GetChecksumData()
     {
         std::string datasum;
@@ -972,5 +967,5 @@
         if (datasum[0] == '\'')
             datasum = datasum.substr(1, datasum.size()-2);
-        return make_pair(checksum, atoi(datasum.c_str()));
+        return std::make_pair(checksum, atoi(datasum.c_str()));
     }
 
@@ -997,8 +992,4 @@
     }
 };
-
-#ifndef __MARS__
-};
-#endif
 
 #if 0
Index: /trunk/Mars/mcore/zofits.h
===================================================================
--- /trunk/Mars/mcore/zofits.h	(revision 17263)
+++ /trunk/Mars/mcore/zofits.h	(revision 17264)
@@ -10,5 +10,5 @@
 
 #include "ofits.h"
-#include "zfits.h"
+#include "huffman.h"
 #include "Queue.h"
 #include "MemoryManager.h"
@@ -16,9 +16,4 @@
 #ifdef USE_BOOST_THREADS
 #include <boost/thread.hpp>
-#endif
-
-#ifndef __MARS__
-namespace std
-{
 #endif
 
@@ -39,11 +34,11 @@
         struct CatalogEntry
         {
-            CatalogEntry(int64_t f=0, int64_t s=0) : first(f), second(s) {};
+            CatalogEntry(int64_t f=0, int64_t s=0) : first(f), second(s) { }
             int64_t first;   ///< Size of this column in the tile
             int64_t second;  ///< offset of this column in the tile, from the start of the heap area
         } __attribute__((__packed__));
 
-        typedef vector<CatalogEntry> CatalogRow;
-        typedef list<CatalogRow>     CatalogType;
+        typedef std::vector<CatalogEntry> CatalogRow;
+        typedef std::list<CatalogRow>     CatalogType;
 
 
@@ -59,7 +54,7 @@
             WriteTarget(const WriteTarget &t, uint32_t sz) : tile_num(t.tile_num), size(sz), data(t.data) { }
 
-            uint32_t         tile_num; ///< Tile index of the data (to make sure that they are written in the correct order)
-            uint32_t         size;     ///< Size to write
-            shared_ptr<char> data;     ///< Memory block to write
+            uint32_t              tile_num; ///< Tile index of the data (to make sure that they are written in the correct order)
+            uint32_t              size;     ///< Size to write
+            std::shared_ptr<char> data;     ///< Memory block to write
         };
 
@@ -71,9 +66,9 @@
             {}
 
-            CatalogRow&      catalog_entry;   ///< Reference to the catalog entry to deal with
-            shared_ptr<char> src;             ///< Original data
-            shared_ptr<char> transposed_src;  ///< Transposed data
-            WriteTarget      target;          ///< Compressed data
-            uint32_t         num_rows;        ///< Number of rows to compress
+            CatalogRow&           catalog_entry;   ///< Reference to the catalog entry to deal with
+            std::shared_ptr<char> src;             ///< Original data
+            std::shared_ptr<char> transposed_src;  ///< Transposed data
+            WriteTarget           target;          ///< Compressed data
+            uint32_t              num_rows;        ///< Number of rows to compress
          };
 
@@ -92,6 +87,6 @@
                uint32_t rowPerTile  = DefaultNumRowsPerTile(),
                uint32_t maxUsableMem= DefaultMaxMemory()) : ofits(),
-                                                        fMemPool(0, maxUsableMem*1000),
-                                                        fWriteToDiskQueue(bind(&zofits::WriteBufferToDisk, this, placeholders::_1), false)
+            fMemPool(0, maxUsableMem*1000),
+            fWriteToDiskQueue(std::bind(&zofits::WriteBufferToDisk, this, std::placeholders::_1), false)
         {
             InitMemberVariables(numTiles, rowPerTile, maxUsableMem*1000);
@@ -107,6 +102,6 @@
                uint32_t rowPerTile  = DefaultNumRowsPerTile(),
                uint32_t maxUsableMem= DefaultMaxMemory()) : ofits(fname),
-                                                        fMemPool(0, maxUsableMem*1000),
-                                                        fWriteToDiskQueue(bind(&zofits::WriteBufferToDisk, this, placeholders::_1), false)
+                   fMemPool(0, maxUsableMem*1000),
+                   fWriteToDiskQueue(std::bind(&zofits::WriteBufferToDisk, this, std::placeholders::_1), false)
         {
             InitMemberVariables(numTiles, rowPerTile, maxUsableMem*1000);
@@ -132,5 +127,5 @@
             fMaxUsableMem = maxUsableMem;
 #ifdef __EXCEPTIONS
-            fThreadsException = exception_ptr();
+            fThreadsException = std::exception_ptr();
 #endif
             fErrno = 0;
@@ -208,5 +203,5 @@
 
             // swap the catalog bytes before writing
-            vector<char> swapped_catalog(total_catalog_size);
+            std::vector<char> swapped_catalog(total_catalog_size);
 
             uint32_t shift = 0;
@@ -272,7 +267,7 @@
             {
 #ifdef __EXCEPTIONS
-                throw runtime_error("Wrong size of row given to WriteRow");
+                throw std::runtime_error("Wrong size of row given to WriteRow");
 #else
-                gLog << ___err___ << "ERROR - Wrong size of row given to WriteRow" << endl;
+                gLog << ___err___ << "ERROR - Wrong size of row given to WriteRow" << std::endl;
                 return false;
 #endif
@@ -282,6 +277,6 @@
             //check if something hapenned while the compression threads were working
             //if so, re-throw the exception that was generated
-            if (fThreadsException != exception_ptr())
-                rethrow_exception(fThreadsException);
+            if (fThreadsException != std::exception_ptr())
+                std::rethrow_exception(fThreadsException);
 #endif
             //copy current row to pool or rows waiting for compression
@@ -331,5 +326,5 @@
                 const WriteTarget write_target(compress_target.target, size_to_write);
                 if (!WriteBufferToDisk(write_target))
-                    throw runtime_error("Unexpected tile number mismatch in WriteBufferToDisk in the main thread.");
+                    throw std::runtime_error("Unexpected tile number mismatch in WriteBufferToDisk in the main thread.");
 
                 // The correct 'errno' is set, because it is the main thread.
@@ -339,5 +334,5 @@
             //if all queues are empty, use queue 0
             uint32_t min_index     = 0;
-            uint32_t min_size      = numeric_limits<uint32_t>::max();
+            uint32_t min_size      = std::numeric_limits<uint32_t>::max();
             uint32_t current_index = 0;
 
@@ -353,5 +348,5 @@
 
             if (!fCompressionQueues[min_index].emplace(compress_target))
-                throw runtime_error("The compression queues are not started. Did you close the file before writing this row?");
+                throw std::runtime_error("The compression queues are not started. Did you close the file before writing this row?");
 
             errno = fErrno;
@@ -448,6 +443,6 @@
             //check if something hapenned while the compression threads were working
             //if so, re-throw the exception that was generated
-            if (fThreadsException != exception_ptr())
-                rethrow_exception(fThreadsException);
+            if (fThreadsException != std::exception_ptr())
+                std::rethrow_exception(fThreadsException);
 #endif
 
@@ -467,5 +462,5 @@
                 const WriteTarget write_target(compress_target.target, size_to_write);
                 if (!WriteBufferToDisk(write_target))
-                    throw runtime_error("Tile number mismatch in WriteBufferToDisk writing the last tile.");
+                    throw std::runtime_error("Tile number mismatch in WriteBufferToDisk writing the last tile.");
             }
 
@@ -502,5 +497,5 @@
             SetInt("NAXIS1", total_catalog_width);
             SetInt("NAXIS2", total_num_tiles_written);
-            SetStr("RAWSUM", to_string(fRawSum.val()));
+            SetStr("RAWSUM", std::to_string(fRawSum.val()));
 
             const float compression_ratio = (float)(fRealRowWidth*fTable.num_rows)/(float)heap_size;
@@ -519,15 +514,15 @@
             const Checksum checksm = UpdateHeaderChecksum();
 
-            ofstream::close();
+            std::ofstream::close();
 
             if ((checksm+fDataSum).valid())
                 return true;
 
-            ostringstream sout;
+            std::ostringstream sout;
             sout << "Checksum (" << std::hex << checksm.val() << ") invalid.";
 #ifdef __EXCEPTIONS
-            throw runtime_error(sout.str());
+            throw std::runtime_error(sout.str());
 #else
-            gLog << ___err___ << "ERROR - " << sout.str() << endl;
+            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
             return false;
 #endif
@@ -535,5 +530,6 @@
 
         /// Overload of the ofits method. Just calls the zofits specific one with default, uncompressed options for this column
-        bool AddColumn(uint32_t cnt, char typechar, const string& name, const string& unit, const string& comment="", bool addHeaderKeys=true)
+        bool AddColumn(uint32_t cnt, char typechar, const std::string& name, const std::string& unit,
+                       const std::string& comment="", bool addHeaderKeys=true)
         {
             return AddColumn(FITS::kFactRaw, cnt, typechar, name, unit, comment, addHeaderKeys);
@@ -541,5 +537,6 @@
 
         /// Overload of the simplified compressed version
-        bool AddColumn(const FITS::Compression &comp, uint32_t cnt, char typechar, const string& name, const string& unit, const string& comment="", bool addHeaderKeys=true)
+        bool AddColumn(const FITS::Compression &comp, uint32_t cnt, char typechar, const std::string& name,
+                       const std::string& unit, const std::string& comment="", bool addHeaderKeys=true)
         {
             if (!ofits::AddColumn(1, 'Q', name, unit, comment, addHeaderKeys))
@@ -559,6 +556,6 @@
             fRealColumns.emplace_back(col, comp);
 
-            SetStr("ZFORM"+to_string(fRealColumns.size()), to_string(cnt)+typechar, "format of "+name+" "+CommentFromType(typechar));
-            SetStr("ZCTYP"+to_string(fRealColumns.size()), "FACT", "Compression type: FACT");
+            SetStr("ZFORM"+std::to_string(fRealColumns.size()), std::to_string(cnt)+typechar, "format of "+name+" "+CommentFromType(typechar));
+            SetStr("ZCTYP"+std::to_string(fRealColumns.size()), "FACT", "Compression type: FACT");
 
             return true;
@@ -572,7 +569,7 @@
             {
 #ifdef __EXCEPTIONS
-                throw runtime_error("File must be closed before changing the number of compression threads");
+                throw std::runtime_error("File must be closed before changing the number of compression threads");
 #else
-                gLog << ___err___ << "ERROR - File must be closed before changing the number of compression threads" << endl;
+                gLog << ___err___ << "ERROR - File must be closed before changing the number of compression threads" << std::endl;
 #endif
                 return false;
@@ -583,5 +580,5 @@
             unsigned int num_available_cores = boost::thread::hardware_concurrency();
 #else
-            unsigned int num_available_cores = thread::hardware_concurrency();
+            unsigned int num_available_cores = std::thread::hardware_concurrency();
 #endif
             // could not detect number of available cores from system properties...
@@ -595,5 +592,5 @@
             if (fCompressionQueues.size() != uint32_t(num))
             {
-                fCompressionQueues.resize(num, Queue<CompressionTarget>(bind(&zofits::CompressBuffer, this, placeholders::_1), false));
+                fCompressionQueues.resize(num, Queue<CompressionTarget>(std::bind(&zofits::CompressBuffer, this, std::placeholders::_1), false));
                 fNumQueues = num;
             }
@@ -664,5 +661,5 @@
 //            for (uint32_t i=0;i<thisRoundNumRows;i++)
 //            {
-//                char* target_location = target.src.get()->get() + fRealRowWidth*i;
+//                char* target_location = target.src.get() + fRealRowWidth*i;
 //                cout << "Target Location there...." << hex << static_cast<void*>(target_location) << endl;
 //                DrsOffsetCalibrate(target_location);
@@ -682,7 +679,7 @@
             catch (...)
             {
-                fThreadsException = current_exception();
+                fThreadsException = std::current_exception();
                 if (fNumQueues == 0)
-                    rethrow_exception(fThreadsException);
+                    std::rethrow_exception(fThreadsException);
             }
 #endif
@@ -720,7 +717,7 @@
             catch (...)
             {
-                fThreadsException = current_exception();
+                fThreadsException = std::current_exception();
                 if (fNumQueues == 0)
-                    rethrow_exception(fThreadsException);
+                    std::rethrow_exception(fThreadsException);
             }
 #endif
@@ -871,5 +868,5 @@
         uint32_t compressHUFFMAN16(char* dest, const char* src, uint32_t numRows, uint32_t sizeOfElems, uint32_t numRowElems)
         {
-            string huffmanOutput;
+            std::string huffmanOutput;
             uint32_t previousHuffmanSize = 0;
 
@@ -881,7 +878,7 @@
             {
 #ifdef __EXCEPTIONS
-                throw runtime_error("HUFMANN16 can only encode columns with 16-bit or longer types");
+                throw std::runtime_error("HUFMANN16 can only encode columns with 16-bit or longer types");
 #else
-                gLog << ___err___ << "ERROR - HUFMANN16 can only encode columns with 16-bit or longer types" << endl;
+                gLog << ___err___ << "ERROR - HUFMANN16 can only encode columns with 16-bit or longer types" << std::endl;
                 return 0;
 #endif
@@ -942,5 +939,5 @@
         int32_t         fLatestWrittenTile; ///< Index of the last tile written to disk (for correct ordering while using several threads)
 
-        vector<Queue<CompressionTarget>>          fCompressionQueues;  ///< Processing queues (=threads)
+        std::vector<Queue<CompressionTarget>>          fCompressionQueues;  ///< Processing queues (=threads)
         Queue<WriteTarget, QueueMin<WriteTarget>> fWriteToDiskQueue;   ///< Writing queue (=thread)
 
@@ -967,20 +964,14 @@
             FITS::Compression block_head;  ///< the compression data associated with that column
         };
-        vector<CompressedColumn> fRealColumns;     ///< Vector hosting the columns of the file
-        uint32_t                 fRealRowWidth;    ///< Width in bytes of one uncompressed row
-        shared_ptr<char>         fSmartBuffer;     ///< Smart pointer to the buffer where the incoming rows are written
-        vector<char>             fRawSumBuffer;    ///< buffer used for checksuming the incoming data, before compression
-
-#ifdef __EXCEPTIONS
-        exception_ptr     fThreadsException; ///< exception pointer to store exceptions coming from the threads
-#endif
-        int               fErrno;            ///< propagate errno to main thread
-
-
+        std::vector<CompressedColumn> fRealColumns;     ///< Vector hosting the columns of the file
+        uint32_t                      fRealRowWidth;    ///< Width in bytes of one uncompressed row
+        std::shared_ptr<char>         fSmartBuffer;     ///< Smart pointer to the buffer where the incoming rows are written
+        std::vector<char>             fRawSumBuffer;    ///< buffer used for checksuming the incoming data, before compression
+
+#ifdef __EXCEPTIONS
+        std::exception_ptr fThreadsException; ///< exception pointer to store exceptions coming from the threads
+#endif
+        int                fErrno;            ///< propagate errno to main thread
 };
 
-#ifndef __MARS__
-}; //namespace std
-#endif
-
-#endif
+#endif
