diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp
index 98b06a49803b72cfcf16460d934939093850180f..10cbe00aa361d73f3f7f70499ecab07a884a4352 100644
--- a/Graphics/Graph2D.cpp
+++ b/Graphics/Graph2D.cpp
@@ -1,4 +1,4 @@
-// $Id: Graph2D.cpp,v 1.74 2008-02-24 14:55:36 geuzaine Exp $
+// $Id: Graph2D.cpp,v 1.75 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -95,8 +95,8 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
       int dim = data->getDimension(ent, i);
       if(dim < 2){
 	int numNodes = data->getNumNodes(ent, i);
-	int numComp = data->getNumComponents(ent, i);
 	for(int ts = space ? opt->TimeStep : 0; ts < opt->TimeStep + 1; ts++){
+	  int numComp = data->getNumComponents(ent, i, ts);
 	  for(int j = 0; j < numNodes; j++){
 	    double val[9], xyz[3];
 	    data->getNode(ent, i, j, xyz[0], xyz[1], xyz[2]);
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index 47e085ccf663347b36f1fbcdeff79d8df0d83a5e..1c34a9fae76a546c0af263854e313805b6487373 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,4 +1,4 @@
-// $Id: Post.cpp,v 1.155 2008-03-08 22:03:12 geuzaine Exp $
+// $Id: Post.cpp,v 1.156 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -142,7 +142,7 @@ bool getExternalValues(PView *p, int index, int ient, int iele, int numNodes,
 
   if(opt->TimeStep < data2->getNumTimeSteps() && iele < data2->getNumElements(ient)){
     if(data2->getNumNodes(ient, iele) == numNodes){
-      numComp2 = data2->getNumComponents(ient, iele);
+      numComp2 = data2->getNumComponents(ient, iele, opt->TimeStep);
       for(int i = 0; i < numNodes; i++)
 	for(int j = 0; j < numComp2; j++)
 	  data2->getValue(ient, iele, i, j, opt->TimeStep, val2[i][j]);
@@ -897,7 +897,7 @@ void addElementsInArrays(PView *p, bool preprocessNormalsOnly)
       if(data->skipElement(ent, i, opt->TimeStep)) continue;
       int numEdges = data->getNumEdges(ent, i);
       if(opt->skipElement(numEdges)) continue;
-      int numComp = data->getNumComponents(ent, i);
+      int numComp = data->getNumComponents(ent, i, opt->TimeStep);
       int numNodes = data->getNumNodes(ent, i);
       for(int j = 0; j < numNodes; j++){
 	data->getNode(ent, i, j, xyz[j][0], xyz[j][1], xyz[j][2]);
@@ -1137,7 +1137,7 @@ void drawGlyphs(PView *p)
       int numEdges = data->getNumEdges(ent, i);
       if(opt->skipElement(numEdges)) continue;
       int dim = data->getDimension(ent, i);
-      int numComp = data->getNumComponents(ent, i);
+      int numComp = data->getNumComponents(ent, i, opt->TimeStep);
       int numNodes = data->getNumNodes(ent, i);
       for(int j = 0; j < numNodes; j++){
 	data->getNode(ent, i, j, xyz[j][0], xyz[j][1], xyz[j][2]);
diff --git a/Post/PView.cpp b/Post/PView.cpp
index 7ebc06cfa3671c881ebbdca77e1fb10d5aaaef42..626cb03631c8305f7a95c1fa979869ab4d403faa 100644
--- a/Post/PView.cpp
+++ b/Post/PView.cpp
@@ -1,4 +1,4 @@
-// $Id: PView.cpp,v 1.21 2008-03-10 16:01:16 geuzaine Exp $
+// $Id: PView.cpp,v 1.22 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -223,11 +223,11 @@ PView *PView::getViewByName(std::string name, int timeStep, int partition)
   return 0;
 }
 
-bool PView::readPOS(std::string filename, int fileIndex)
+bool PView::readPOS(std::string fileName, int fileIndex)
 {
-  FILE *fp = fopen(filename.c_str(), "rb");
+  FILE *fp = fopen(fileName.c_str(), "rb");
   if(!fp){
-    Msg(GERROR, "Unable to open file '%s'", filename.c_str());
+    Msg(GERROR, "Unable to open file '%s'", fileName.c_str());
     return false;
   }
 
@@ -282,7 +282,7 @@ bool PView::readPOS(std::string filename, int fileIndex)
 	  return false;
 	}
 	else{
-	  d->setFileName(filename);
+	  d->setFileName(fileName);
 	  d->setFileIndex(index);
 	  new PView(d);
 	}
@@ -291,10 +291,8 @@ bool PView::readPOS(std::string filename, int fileIndex)
     }
 
     do {
-      if(!fgets(str, 256, fp) || feof(fp)){
-        Msg(GERROR, "Prematured end of file");
+      if(!fgets(str, 256, fp) || feof(fp))
 	break;
-      }
     } while(str[0] != '$');
 
   }
@@ -304,11 +302,11 @@ bool PView::readPOS(std::string filename, int fileIndex)
   return true;
 }
 
-bool PView::readMSH(std::string filename, int fileIndex)
+bool PView::readMSH(std::string fileName, int fileIndex)
 {
-  FILE *fp = fopen(filename.c_str(), "rb");
+  FILE *fp = fopen(fileName.c_str(), "rb");
   if(!fp){
-    Msg(GERROR, "Unable to open file '%s'", filename.c_str());
+    Msg(GERROR, "Unable to open file '%s'", fileName.c_str());
     return false;
   }
 
@@ -359,49 +357,47 @@ bool PView::readMSH(std::string filename, int fileIndex)
 	if(p) d = dynamic_cast<PViewDataGModel*>(p->getData());
 	bool create = d ? false : true;
 	if(create) d = new PViewDataGModel(GModel::current());
-	if(!d->readMSH(fp, binary, swap, timeStep, time, partition, 
-		       numComp, numNodes)){
+	if(!d->readMSH(fileName, fileIndex, fp, binary, swap, timeStep, 
+		       time, partition, numComp, numNodes)){
 	  Msg(GERROR, "Could not read data in msh file");
 	  if(create) delete d;
 	  return false;
 	}
 	else{
 	  d->setName(name);
-	  d->setFileName(filename);
+	  d->setFileName(fileName);
 	  d->setFileIndex(index);
 	  if(create) new PView(d);
 	}
       }
     }
-
+    
     do {
-      if(!fgets(str, 256, fp) || feof(fp)){
-        Msg(GERROR, "Prematured end of file");
+      if(!fgets(str, 256, fp) || feof(fp))
 	break;
-      }
     } while(str[0] != '$');
-
+    
   }
 
   fclose(fp);
   return true;
 }
 
-bool PView::write(std::string filename, int format, bool append)
+bool PView::write(std::string fileName, int format, bool append)
 {
-  Msg(STATUS2, "Writing '%s'", filename.c_str());
+  Msg(STATUS2, "Writing '%s'", fileName.c_str());
 
   bool ret;
   switch(format){
-  case 0: ret = _data->writePOS(filename, false, false, append); break; // ASCII
-  case 1: ret = _data->writePOS(filename, true, false, append); break; // binary
-  case 2: ret = _data->writePOS(filename, false, true, append); break; // parsed
-  case 3: ret = _data->writeSTL(filename); break;
-  case 4: ret = _data->writeTXT(filename); break;
-  case 5: ret = _data->writeMSH(filename); break;
+  case 0: ret = _data->writePOS(fileName, false, false, append); break; // ASCII
+  case 1: ret = _data->writePOS(fileName, true, false, append); break; // binary
+  case 2: ret = _data->writePOS(fileName, false, true, append); break; // parsed
+  case 3: ret = _data->writeSTL(fileName); break;
+  case 4: ret = _data->writeTXT(fileName); break;
+  case 5: ret = _data->writeMSH(fileName); break;
   default: ret = false; Msg(GERROR, "Unknown view format %d", format); break;
   }
 
-  Msg(STATUS2, "Wrote '%s'", filename.c_str());
+  Msg(STATUS2, "Wrote '%s'", fileName.c_str());
   return ret;
 }
diff --git a/Post/PView.h b/Post/PView.h
index 6a48bc18e8a32d8ccfa55235f48cd608242764c0..6a5de42f2832e30ec3aea8dfacf383a36ef357a5 100644
--- a/Post/PView.h
+++ b/Post/PView.h
@@ -87,12 +87,12 @@ class PView{
 			      int partition=-1);
 
   // read view(s) in list format from a file
-  static bool readPOS(std::string filename, int fileIndex=-1);
+  static bool readPOS(std::string fileName, int fileIndex=-1);
   // read view data from MSH file
-  static bool readMSH(std::string filename, int fileIndex=-1);
+  static bool readMSH(std::string fileName, int fileIndex=-1);
 
   // write view to file in given format
-  bool write(std::string filename, int format, bool append=false);
+  bool write(std::string fileName, int format, bool append=false);
 
   // vertex arrays to draw the elements efficiently
   VertexArray *va_points, *va_lines, *va_triangles, *va_vectors;
diff --git a/Post/PViewData.cpp b/Post/PViewData.cpp
index 610b0a928b2bbe7fdae2ab76202ed3197083fa1c..c153ca4c240e6f9966e9559b67d1346b5a0ecd4a 100644
--- a/Post/PViewData.cpp
+++ b/Post/PViewData.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewData.cpp,v 1.11 2008-02-17 08:48:08 geuzaine Exp $
+// $Id: PViewData.cpp,v 1.12 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -25,7 +25,7 @@
 #include "PViewData.h"
 
 PViewData::PViewData()
-  : _dirty(true), _name(""), _filename(""), _fileIndex(0)
+  : _dirty(true), _fileIndex(0)
 {
 }
 
diff --git a/Post/PViewData.h b/Post/PViewData.h
index 02ece472d6f6764c8c818b75f8f971bcf377059b..53ba037c6d626b1f93d239bd737d29a57d4facd7 100644
--- a/Post/PViewData.h
+++ b/Post/PViewData.h
@@ -36,7 +36,7 @@ class PViewData {
   // name of the view
   std::string _name;
   // name of the file the data was loaded from
-  std::string _filename;
+  std::string _fileName;
   // index of the view in the file
   int _fileIndex;
  public:
@@ -47,8 +47,8 @@ class PViewData {
   virtual bool finalize(){ _dirty = false; return true; }
   virtual std::string getName(){ return _name; }
   virtual void setName(std::string val){ _name = val; }
-  virtual std::string getFileName(){ return _filename; }
-  virtual void setFileName(std::string val){ _filename = val; }
+  virtual std::string getFileName(){ return _fileName; }
+  virtual void setFileName(std::string val){ _fileName = val; }
   virtual int getFileIndex(){ return _fileIndex; }
   virtual void setFileIndex(int val){ _fileIndex = val; }
   virtual int getNumTimeSteps() = 0;
@@ -83,7 +83,7 @@ class PViewData {
   virtual void getNode(int ent, int ele, int nod, double &x, double &y, double &z) = 0;
   // Returns the number of componts available for the ele-th element
   // in the ent-th entity
-  virtual int getNumComponents(int ent, int ele) = 0;
+  virtual int getNumComponents(int ent, int ele, int step) = 0;
   // Returns the comp-th component (at the step-th time step)
   // associated with the node-th node from the ele-th element in the
   // ent-th entity
diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp
index 088276f01b4b7911c543f9fb971218c17187864d..86afd52ec3d0bf05e8925cdb39ae5ce73c8130e0 100644
--- a/Post/PViewDataGModel.cpp
+++ b/Post/PViewDataGModel.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataGModel.cpp,v 1.25 2008-03-10 19:59:01 geuzaine Exp $
+// $Id: PViewDataGModel.cpp,v 1.26 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -114,12 +114,12 @@ void PViewDataGModel::getNode(int ent, int ele, int nod, double &x, double &y, d
   z = v->z();
 }
 
-int PViewDataGModel::getNumComponents(int ent, int ele)
+int PViewDataGModel::getNumComponents(int ent, int ele, int step)
 {
   MVertex *v = _entities[ent]->getMeshElement(ele)->getVertex(0);
   int index = v->getDataIndex();
   // no range check here: we assume this call is guarded by skipElement()
-  return _nodeData[0]->values[index].size();
+  return _nodeData[step]->values[index].size();
 }
 
 void PViewDataGModel::getValue(int ent, int ele, int nod, int comp, int step, double &val)
diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h
index b0ed770970c261b907645ef053018edefe642617..4447e860c61354f312a4bbf5af013b860d2cd8d1 100644
--- a/Post/PViewDataGModel.h
+++ b/Post/PViewDataGModel.h
@@ -28,10 +28,15 @@
 template<class real>
 class stepData{
  public:
+  // the file the data was read from
+  std::string fileName;
+  // the index in the file
+  int fileIndex;
+  // the value of the time step and associated min/max
   double time, min, max;
-  // vector of data, indexed by dataIndex
+  // the vector of data, indexed by dataIndex
   std::vector<std::vector<real> > values;
-  stepData() : time(0.), min(VAL_INF), max(-VAL_INF){}
+  stepData() : fileIndex(-1), time(0.), min(VAL_INF), max(-VAL_INF){}
   ~stepData() {}
 };
 
@@ -64,7 +69,7 @@ class PViewDataGModel : public PViewData {
   int getDimension(int ent, int ele);
   int getNumNodes(int ent, int ele);
   void getNode(int ent, int ele, int nod, double &x, double &y, double &z);
-  int getNumComponents(int ent, int ele);
+  int getNumComponents(int ent, int ele, int step);
   void getValue(int ent, int ele, int node, int comp, int step, double &val);
   int getNumEdges(int ent, int ele);
   bool skipEntity(int ent);
@@ -76,8 +81,9 @@ class PViewDataGModel : public PViewData {
   //PViewDataList *convertToPViewDataList();
 
   // I/O routines
-  bool readMSH(FILE *fp, bool binary, bool swap, int timeStep, double time,
-	       int partition, int numComp, int numNodes);
+  bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary, 
+	       bool swap, int timeStep, double time, int partition, 
+	       int numComp, int numNodes);
   bool writeMSH(std::string name, bool binary=false);
 };
 
diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp
index eb6f33aad4ecbee3521af9a82ed3caa9a7a57fa5..7ad18cac200b1a0afc9eed4278dee4ebc9709c60 100644
--- a/Post/PViewDataGModelIO.cpp
+++ b/Post/PViewDataGModelIO.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataGModelIO.cpp,v 1.6 2008-03-10 19:59:01 geuzaine Exp $
+// $Id: PViewDataGModelIO.cpp,v 1.7 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -29,8 +29,21 @@
 #include "Numeric.h"
 #include "StringUtils.h"
 
-bool PViewDataGModel::readMSH(FILE *fp, bool binary, bool swap, int timeStep, 
-			      double time, int partition, int numComp, int numNodes)
+// Todo: slightly change this as follows:
+// - always populate the _dataXX vector with stepData (for all time steps)
+// - make the actual data allocatable (e.g. ptr to vector<vector>>)
+// - only alloc data if...
+//     - e.g. only alloc data for first time step
+// in "skipElement": if no data, read it from file (using fileName/Index info
+// in stepData) and free another if...
+//
+// usage should be as simple as: "gmsh *.pos". This would not load all
+// time steps by default: only the 1st one(s). Then load/cache the
+// others as needed on the fly.
+
+bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
+			      bool binary, bool swap, int timeStep, double time, 
+			      int partition, int numComp, int numNodes)
 {
   Msg(INFO, "Reading step %d (time %g) partition %d: %d nodes", 
       timeStep, time, partition, numNodes);
@@ -39,6 +52,8 @@ bool PViewDataGModel::readMSH(FILE *fp, bool binary, bool swap, int timeStep,
 
   if(!_nodeData[timeStep]) _nodeData[timeStep] = new stepData<double>();
 
+  _nodeData[timeStep]->fileName = fileName;
+  _nodeData[timeStep]->fileIndex = fileIndex;
   _nodeData[timeStep]->time = time;
   _nodeData[timeStep]->values.resize(numNodes);
 
diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp
index 1f2c673effc6227a13d9ea0d69889cfc1548ef52..9647e240720e3683cc4799f1d0a292ba561413c3 100644
--- a/Post/PViewDataIO.cpp
+++ b/Post/PViewDataIO.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataIO.cpp,v 1.3 2008-02-24 21:43:17 geuzaine Exp $
+// $Id: PViewDataIO.cpp,v 1.4 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -98,7 +98,7 @@ bool PViewData::writeTXT(std::string name)
 	getNode(ent, ele, nod, x, y, z);
 	fprintf(fp, "%.16g %.16g %.16g ", x, y, z);
 	for(int step = 0; step < getNumTimeSteps(); step++){	
-	  for(int comp = 0; comp < getNumComponents(ent, ele); comp++){	
+	  for(int comp = 0; comp < getNumComponents(ent, ele, step); comp++){	
 	    double val;
 	    getValue(ent, ele, nod, comp, step, val);
 	    fprintf(fp, "%.16g ", val);
diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp
index eedc7560a3e0d8d60dca5dac0e651c2cd706343c..e116213563ac856f0619167651e2a7a04044ba58 100644
--- a/Post/PViewDataList.cpp
+++ b/Post/PViewDataList.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataList.cpp,v 1.16 2008-03-10 16:01:16 geuzaine Exp $
+// $Id: PViewDataList.cpp,v 1.17 2008-03-12 21:28:53 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -341,7 +341,7 @@ void PViewDataList::getNode(int ent, int ele, int nod, double &x, double &y, dou
   z = _lastXYZ[2 * _lastNumNodes + nod];
 }
 
-int PViewDataList::getNumComponents(int ent, int ele)
+int PViewDataList::getNumComponents(int ent, int ele, int step)
 {
   if(ele != _lastElement) _setLast(ele);
   return _lastNumComponents;
diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h
index 57505452ea0542440250d82b84e2f83ccd3c4418..0039a3bdc44593116c7db8ac1a28daeb79226c1c 100644
--- a/Post/PViewDataList.h
+++ b/Post/PViewDataList.h
@@ -95,7 +95,7 @@ class PViewDataList : public PViewData {
   int getDimension(int ent, int ele);
   int getNumNodes(int ent, int ele);
   void getNode(int ent, int ele, int nod, double &x, double &y, double &z);
-  int getNumComponents(int ent, int ele);
+  int getNumComponents(int ent, int ele, int step);
   void getValue(int ent, int ele, int nod, int comp, int step, double &val);
   int getNumEdges(int ent, int ele);
   int getNumStrings2D(){ return NbT2; }