Index: /trunk/Mars/mcore/fits.h
===================================================================
--- /trunk/Mars/mcore/fits.h	(revision 17391)
+++ /trunk/Mars/mcore/fits.h	(revision 17392)
@@ -485,4 +485,5 @@
 protected:
     std::ofstream fCopy;
+    std::vector<std::string> fListOfTables; // List of skipped tables. Last table is open table
 
     Table fTable;
@@ -558,5 +559,5 @@
     }
 
-    void Constructor(const std::string &fname, std::string fout, const std::string& tableName, bool force, int tableNumber=-1)
+    void Constructor(const std::string &fname, std::string fout="", const std::string& tableName="", bool force=false)
     {
         char simple[10];
@@ -564,6 +565,4 @@
         if (!good())
             return;
-
-        int current_table = 0;
 
         if (memcmp(simple, "SIMPLE  = ", 10))
@@ -642,22 +641,16 @@
                 }
 
+                const std::string &tname = fTable.Get<std::string>("EXTNAME");
+
+                fListOfTables.emplace_back(tname);
+
                 // Check for table name. Skip until eof or requested table are found.
                 // skip the current table?
-                if ((!tableName.empty() &&         tableName!=fTable.Get<std::string>("EXTNAME")) ||
-                    ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<std::string>("EXTNAME")) ||
-                    (tableNumber != -1))
+                if ((!tableName.empty() && tableName!=tname) || (tableName.empty() && "ZDrsCellOffsets"==tname))
                 {
-                    if (current_table == tableNumber)
-                    {
-                        fBufferRow.resize(fTable.bytes_per_row + 8-fTable.bytes_per_row%4);
-                        fBufferDat.resize(fTable.bytes_per_row);
-
-                        break;
-                    }
                     const streamoff skip = fTable.GetTotalBytes();
                     seekg(skip, std::ios_base::cur);
 
                     fChkHeader.reset();
-                    current_table++;
 
                     continue;
@@ -688,4 +681,5 @@
 #else
             gLog << ___err___ << "ERROR - Failed to open output file." << std::endl;
+            return;
 #endif
         }
@@ -1043,4 +1037,9 @@
         return fTable.Get<size_t>("NAXIS1");
     }
+
+    const std::vector<std::string> &GetTables() const
+    {
+        return fListOfTables;
+    }
 };
 
