diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp
index a3df72026f5af7196118b9b2f80c12d0c8ebb730..38dd33f48b39a63bd43c9d7bea5779d62729e1e6 100644
--- a/Common/Gmsh.cpp
+++ b/Common/Gmsh.cpp
@@ -229,20 +229,9 @@ int GmshWriteFile(const std::string &fileName)
 
 int GmshFinalize()
 {
-  //michel.rasquin@cenaero.be:
-  // Cleaning routine critical for ParaView plugin,
-  // where GMSH can be called several time successively.
-  // For that purpose, static variables need to be cleared.
-  
-  // Clear all PViews 
-  PView::list.clear();  
-  
-  //  Clear all GModels
+  PView::list.clear();
   GModel::list.clear();
-  
-  // Clear files from CTX::instance()
-  CTX::instance()->files.clear(); 
-
+  CTX::instance()->files.clear();
   return 1;
 }
 
diff --git a/Mesh/periodical.cpp b/Mesh/periodical.cpp
index dedeaeed3cb7450e6c0da3dd4e2edc4b2b182e42..69516573d8a31a7af06df07e0fe51347b2d2c48a 100644
--- a/Mesh/periodical.cpp
+++ b/Mesh/periodical.cpp
@@ -596,104 +596,104 @@ void voroMetal3D::correspondance(double e, double xMax, double yMax, double zMax
           print_segment(p1,p2,file);
 
           //file2 << "PERIODIC\tSURFACE"<<faces[i]->tag() << "\tSURFACE" << faces[j]->tag() << "\t" << p2.x()-p1.x() << "\t" << p2.y()-p1.y() << "\t" << p2.z()-p1.z() << "\n";
-          if (abs((p2.x()-p1.x()-1.0))<0.0001){
-            if (abs((p2.y()-p1.y()))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+          if (fabs((p2.x()-p1.x()-1.0))<0.0001){
+            if (fabs((p2.y()-p1.y()))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tFRONT = FRONT + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACK = BACK + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if(abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if(fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<faces[i]->tag()<<"\n";
               }
-            }else if (abs((p2.y()-p1.y()-1.0))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+            }else if (fabs((p2.y()-p1.y()-1.0))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<faces[i]->tag()<<"\n";
               }
-            }else if (abs((p1.y()-p2.y()-1.0))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+            }else if (fabs((p1.y()-p2.y()-1.0))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<faces[i]->tag()<<"\n";
               }
             }
-          }else if (abs((p1.x()-p2.x()-1.0))<0.0001){
-            if (abs((p2.y()-p1.y()))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+          }else if (fabs((p1.x()-p2.x()-1.0))<0.0001){
+            if (fabs((p2.y()-p1.y()))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tFRONT = FRONT + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACK = BACK + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if(abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if(fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
               }
-            }else if (abs((p2.y()-p1.y()-1.0))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+            }else if (fabs((p2.y()-p1.y()-1.0))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
               }
-            }else if (abs((p1.y()-p2.y()-1.0))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+            }else if (fabs((p1.y()-p2.y()-1.0))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
               }
             }
-          }else if (abs((p1.x()-p2.x()))<0.0001){
-            if (abs((p2.y()-p1.y()-1.0))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+          }else if (fabs((p1.x()-p2.x()))<0.0001){
+            if (fabs((p2.y()-p1.y()-1.0))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tLEFT = LEFT + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<faces[i]->tag()<<"\n";
               }
-            }else if (abs((p1.y()-p2.y()-1.0))<0.0001){
-              if (abs((p2.z()-p1.z()))<0.0001){
+            }else if (fabs((p1.y()-p2.y()-1.0))<0.0001){
+              if (fabs((p2.z()-p1.z()))<0.0001){
                 file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tLEFT = LEFT + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p2.z()-p1.z()-1.0))<0.0001){
+              }else if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<faces[j]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
               }
-            }else if (abs((p1.y()-p2.y()))<0.0001){
-              if (abs((p2.z()-p1.z()-1.0))<0.0001){
+            }else if (fabs((p1.y()-p2.y()))<0.0001){
+              if (fabs((p2.z()-p1.z()-1.0))<0.0001){
                 file2 << "NSET\tTOP = TOP + SURFACE"<<faces[j]->tag()<<"\n";
                 file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<faces[i]->tag()<<"\n";
-              }else if (abs((p1.z()-p2.z()-1.0))<0.0001){
+              }else if (fabs((p1.z()-p2.z()-1.0))<0.0001){
                 file2 << "NSET\tTOP = TOP + SURFACE"<<faces[i]->tag()<<"\n";
                 file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<faces[j]->tag()<<"\n";
               }
@@ -1272,4 +1272,3 @@ void computeBestSeeds(const char *filename)
     }
   }
 }
-
diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt
index 4f3eb01bdd3903e28f7b0d0cd0a5deaed7b44553..e542921345ffaf8ea0e2c3f5ceadf9c8587a8903 100644
--- a/Plugin/CMakeLists.txt
+++ b/Plugin/CMakeLists.txt
@@ -16,7 +16,7 @@ set(SRC
   Triangulate.cpp Tetrahedralize.cpp
   Warp.cpp SphericalRaise.cpp
   Skin.cpp
-  MathEval.cpp ModifyComponent.cpp ExtractElements.cpp
+  MathEval.cpp ModifyComponents.cpp ExtractElements.cpp
   MakeSimplex.cpp
   Integrate.cpp Gradient.cpp Curl.cpp Divergence.cpp
   Annotate.cpp Remove.cpp
diff --git a/Plugin/ModifyComponent.cpp b/Plugin/ModifyComponents.cpp
similarity index 60%
rename from Plugin/ModifyComponent.cpp
rename to Plugin/ModifyComponents.cpp
index 692e76a63dc36a3720670951e78951641a34341b..83284f38b58c34dca3a99fd5d51257a900848497 100644
--- a/Plugin/ModifyComponent.cpp
+++ b/Plugin/ModifyComponents.cpp
@@ -6,12 +6,11 @@
 #include <vector>
 #include <algorithm>
 #include "GmshConfig.h"
-#include "ModifyComponent.h"
+#include "ModifyComponents.h"
 #include "OctreePost.h"
 #include "mathEvaluator.h"
 
-StringXNumber ModifyComponentOptions_Number[] = {
-  {GMSH_FULLRC, "Component", NULL, -1.},
+StringXNumber ModifyComponentsOptions_Number[] = {
   {GMSH_FULLRC, "TimeStep", NULL, -1.},
   {GMSH_FULLRC, "View", NULL, -1.},
   {GMSH_FULLRC, "OtherTimeStep", NULL, -1.},
@@ -19,8 +18,8 @@ StringXNumber ModifyComponentOptions_Number[] = {
   {GMSH_FULLRC, "ForceInterpolation", NULL, 0.}
 };
 
-StringXString ModifyComponentOptions_String[] = {
-  {GMSH_FULLRC, "Expression", NULL, "v0 * Sin(x)"},
+StringXString ModifyComponentsOptions_String[] = {
+  {GMSH_FULLRC, "Expression0", NULL, "v0 * Sin(x)"},
   {GMSH_FULLRC, "Expression1", NULL, ""},
   {GMSH_FULLRC, "Expression2", NULL, ""},
   {GMSH_FULLRC, "Expression3", NULL, ""},
@@ -33,87 +32,72 @@ StringXString ModifyComponentOptions_String[] = {
 
 extern "C"
 {
-  GMSH_Plugin *GMSH_RegisterModifyComponentPlugin()
+  GMSH_Plugin *GMSH_RegisterModifyComponentsPlugin()
   {
-    return new GMSH_ModifyComponentPlugin();
+    return new GMSH_ModifyComponentsPlugin();
   }
 }
 
-std::string GMSH_ModifyComponentPlugin::getHelp() const
+std::string GMSH_ModifyComponentsPlugin::getHelp() const
 {
-  return "Plugin(ModifyComponent) sets the `Component'-th "
-    "component of the `TimeStep'-th time step in the "
-    "view `View' to the expression `Expression'.\n\n"
-    "`Expression' can contain:\n\n"
+  return "Plugin(ModifyComponents) modifies the components of "
+    "the `TimeStep'-th time step in the view `View', using the "
+    "expressions provided in `Expression0', ..., `Expression8'. "
+    "If an expression is empty, the corresponding component in "
+    "the view is not modified.\n\n"
+    "The expressions can contain:\n\n"
     "- the usual mathematical functions (Log, Sqrt, "
     "Sin, Cos, Fabs, ...) and operators (+, -, *, /, ^);\n\n"
-    "If only `Expression' is given (and `Expression1', "
-    "..., `Expression8' are all empty), the plugin "
-    "creates a scalar view. If `Expression', `Expression1' "
-    "and/or `Expression2' are given (and `Expression3', "
-    "..., `Expression8' are all empty) the plugin creates "
-    "a vector view. Otherwise the plugin creates a tensor "
-    "view.\n\n"
     "- the symbols x, y and z, to retrieve the "
     "coordinates of the current node;\n\n"
     "- the symbols Time and TimeStep, to retrieve the "
     "current time and time step values;\n\n"
-    "- the symbol v, to retrieve the `Component'-th "
-    "component of the field in `View' at the "
-    "`TimeStep'-th time step;\n\n"
     "- the symbols v0, v1, v2, ..., v8, to retrieve each "
     "component of the field in `View' at the "
     "`TimeStep'-th time step;\n\n"
-    "- the symbol w, to retrieve the `Component'-th "
+    "- the symbols w0, w1, w2, ..., w8, to retrieve each "
     "component of the field in `OtherView' at the "
     "`OtherTimeStep'-th time step. If `OtherView' "
     "and `View' are based on different spatial grids, "
     "or if their data types are different, `OtherView' "
-    "is interpolated onto `View';\n\n"
-    "- the symbols w0, w1, w2, ..., w8, to retrieve each "
-    "component of the field in `OtherView' at the "
-    "`OtherTimeStep'-th time step.\n\n"
+    "is interpolated onto `View'.\n\n"
     "If `TimeStep' < 0, the plugin automatically loops "
     "over all the time steps in `View' and evaluates "
-    "`Expression' for each one.\n\n"
+    "the expressions for each one.\n\n"
     "If `OtherTimeStep' < 0, the plugin uses `TimeStep' "
     "instead.\n\n"
-    "If `Component' < 0, the plugin automatically  ops\n"
-    "over all the components in the view and "
-    "evaluates `Expression' for each one.\n\n"
     "If `View' < 0, the plugin is run on the current view.\n\n"
     "If `OtherView' < 0, the plugin uses `View' instead.\n\n"
-    "Plugin(ModifyComponent) is executed in-place.";
+    "Plugin(ModifyComponents) is executed in-place.";
 }
 
-int GMSH_ModifyComponentPlugin::getNbOptions() const
+int GMSH_ModifyComponentsPlugin::getNbOptions() const
 {
-  return sizeof(ModifyComponentOptions_Number) / sizeof(StringXNumber);
+  return sizeof(ModifyComponentsOptions_Number) / sizeof(StringXNumber);
 }
 
-StringXNumber *GMSH_ModifyComponentPlugin::getOption(int iopt)
+StringXNumber *GMSH_ModifyComponentsPlugin::getOption(int iopt)
 {
-  return &ModifyComponentOptions_Number[iopt];
+  return &ModifyComponentsOptions_Number[iopt];
 }
 
-int GMSH_ModifyComponentPlugin::getNbOptionsStr() const
+int GMSH_ModifyComponentsPlugin::getNbOptionsStr() const
 {
-  return sizeof(ModifyComponentOptions_String) / sizeof(StringXString);
+  return sizeof(ModifyComponentsOptions_String) / sizeof(StringXString);
 }
 
-StringXString *GMSH_ModifyComponentPlugin::getOptionStr(int iopt)
+StringXString *GMSH_ModifyComponentsPlugin::getOptionStr(int iopt)
 {
-  return &ModifyComponentOptions_String[iopt];
+  return &ModifyComponentsOptions_String[iopt];
 }
 
-PView *GMSH_ModifyComponentPlugin::execute(PView *view)
+PView *GMSH_ModifyComponentsPlugin::execute(PView *view)
 {
-  int component = (int)ModifyComponentOptions_Number[0].def;
-  int timeStep = (int)ModifyComponentOptions_Number[1].def;
-  int iView = (int)ModifyComponentOptions_Number[2].def;
-  int otherTimeStep = (int)ModifyComponentOptions_Number[3].def;
-  int otherView = (int)ModifyComponentOptions_Number[4].def;
-  int forceInterpolation = (int)ModifyComponentOptions_Number[5].def;
+  int timeStep = (int)ModifyComponentsOptions_Number[0].def;
+  int iView = (int)ModifyComponentsOptions_Number[1].def;
+  int otherTimeStep = (int)ModifyComponentsOptions_Number[2].def;
+  int otherView = (int)ModifyComponentsOptions_Number[3].def;
+  int forceInterpolation = (int)ModifyComponentsOptions_Number[4].def;
 
   PView *v1 = getView(iView, view);
   if(!v1) return view;
@@ -147,35 +131,25 @@ PView *GMSH_ModifyComponentPlugin::execute(PView *view)
     otherTimeStep = 0;
   }
 
-  std::vector<std::string> expressions(9);
-  for(int i = 0; i < 9; i++) expressions[i] = ModifyComponentOptions_String[i].def;
-  int numComp3;
-  if(expressions[3].size() || expressions[4].size() || expressions[5].size() ||
-     expressions[6].size() || expressions[7].size() || expressions[8].size()){
-    numComp3 = 9;
-    for(int i = 0; i < 9; i++)
-      if(expressions[i].empty()) expressions[i] = "0";
-  }
-  else if(expressions[1].size() || expressions[2].size()){
-    numComp3 = 3;
-    for(int i = 0; i < 3; i++)
-      if(expressions[i].empty()) expressions[i] = "0";
-  }
-  else{
-    numComp3 = 1;
+  std::vector<std::string> expressions(9), expressions0(9);
+  for(int i = 0; i < 9; i++){
+    expressions[i] = ModifyComponentsOptions_String[i].def;
+    if(expressions[i].size())
+      expressions0[i] = expressions[i];
+    else
+      expressions0[i] = "0.";
   }
-  expressions.resize(numComp3);
 
   const char *names[] =
     {"x", "y", "z", "Time", "TimeStep",
-     "v", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8",
-     "w", "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8"};
+     "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8",
+     "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8"};
   unsigned int numVariables = sizeof(names) / sizeof(names[0]);
   std::vector<std::string> variables(numVariables);
   for(unsigned int i = 0; i < numVariables; i++) variables[i] = names[i];
-  mathEvaluator f(expressions, variables);
-  if(expressions.empty()) return view;
-  std::vector<double> values(numVariables), res(numComp3);
+  mathEvaluator f(expressions0, variables);
+
+  std::vector<double> values(numVariables), res(9);
 
   OctreePost *octree = 0;
   if(forceInterpolation ||
@@ -227,22 +201,22 @@ PView *GMSH_ModifyComponentPlugin::execute(PView *view)
                 octree->searchTensor(x[nod], y[nod], z[nod], &w[0], step2,
                                      0, qn, &x[0], &y[0], &z[0]);
           }
-          else
+          else{
             for(int comp = 0; comp < numComp2; comp++)
               data2->getValue(step2, ent, ele, nod, comp, w[comp]);
-          for(int comp = 0; comp < numComp; comp++){
-            if(component >= 0 && component != comp) continue;
-            values[0] = x[nod]; values[1] = y[nod]; values[2] = z[nod];
-            values[3] = time; values[4] = step;
-            values[5] = v[comp];
-            for(int i = 0; i < 9; i++) values[6 + i] = v[i];
-            values[15] = w[comp];
-            for(int i = 0; i < 9; i++) values[16 + i] = w[i];
-            if(f.eval(values, res))
-	      for(int comp = 0; comp < numComp3; comp++)
+          }
+          values[0] = x[nod]; values[1] = y[nod]; values[2] = z[nod];
+          values[3] = time; values[4] = step;
+          for(int i = 0; i < 9; i++) values[5 + i] = v[i];
+          for(int i = 0; i < 9; i++) values[14 + i] = w[i];
+          if(f.eval(values, res)){
+            for(int comp = 0; comp < numComp; comp++){
+              if(expressions[comp].size()){
                 data1->setValue(step, ent, ele, nod, comp, res[comp]);
-            if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
+              }
+            }
           }
+          if(data1->isNodeData()) data1->tagNode(step, ent, ele, nod, 1);
         }
       }
     }
diff --git a/Plugin/ModifyComponent.h b/Plugin/ModifyComponents.h
similarity index 57%
rename from Plugin/ModifyComponent.h
rename to Plugin/ModifyComponents.h
index b24a33859b09f6ddc32c071918dcabfaebf94fef..77d06f7af4043dabfe6c8f99b8ae6ec5b6833186 100644
--- a/Plugin/ModifyComponent.h
+++ b/Plugin/ModifyComponents.h
@@ -10,23 +10,23 @@
 
 extern "C"
 {
-  GMSH_Plugin *GMSH_RegisterModifyComponentPlugin();
+  GMSH_Plugin *GMSH_RegisterModifyComponentsPlugin();
 }
 
-class GMSH_ModifyComponentPlugin : public GMSH_PostPlugin
+class GMSH_ModifyComponentsPlugin : public GMSH_PostPlugin
 {
  public:
-  GMSH_ModifyComponentPlugin(){}
-  std::string getName() const { return "ModifyComponent"; }
+  GMSH_ModifyComponentsPlugin(){}
+  std::string getName() const { return "ModifyComponents"; }
   std::string getShortHelp() const
   {
-    return "Modify a component using a mathematical expression";
+    return "Modify components in a view using mathematical expressions";
   }
   std::string getHelp() const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber* getOption(int iopt);
   int getNbOptionsStr() const;
-  StringXString* getOptionStr(int iopt);  
+  StringXString* getOptionStr(int iopt);
   PView *execute(PView *);
 };
 
diff --git a/Plugin/PluginManager.cpp b/Plugin/PluginManager.cpp
index 9cd3a9e0c5d2091837f2b24cd4a9dfe1e26591c9..14c1de6efc6fda92034f6981c798f16468bfc22e 100644
--- a/Plugin/PluginManager.cpp
+++ b/Plugin/PluginManager.cpp
@@ -48,7 +48,7 @@
 #include "Eigenvectors.h"
 #include "Eigenvalues.h"
 #include "Lambda2.h"
-#include "ModifyComponent.h"
+#include "ModifyComponents.h"
 #include "Probe.h"
 #include "HomologyComputation.h"
 #include "HomologyPostProcessing.h"
@@ -191,7 +191,7 @@ void PluginManager::registerDefaultPlugins()
     allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
                       ("CurvedBndDist", GMSH_RegisterCurvedBndDistPlugin()));
     allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
-                      ("ModifyComponent", GMSH_RegisterModifyComponentPlugin()));
+                      ("ModifyComponents", GMSH_RegisterModifyComponentsPlugin()));
     allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
                       ("ExtractElements", GMSH_RegisterExtractElementsPlugin()));
     allPlugins.insert(std::pair<std::string, GMSH_Plugin*>
diff --git a/Post/PView.h b/Post/PView.h
index 64a15f3afe3f4dcc61a627e1d2b6bd48c59006bc..9356c244f07932055d1c5750c640e5f108b56b11 100644
--- a/Post/PView.h
+++ b/Post/PView.h
@@ -41,7 +41,7 @@ class PView{
   PViewData *_data;
   // initialize private stuff
   void _init(int tag=-1);
- 
+
  public:
   // create a new view with list-based data
   PView(int tag=-1);
@@ -129,10 +129,10 @@ class PView{
   static bool writeX3D(const std::string &fileName );
   // IO write routine
   bool write(const std::string &fileName, int format, bool append=false);
-  
-  // michel.rasquin@cenaero.be:
-  // Routines for export of adapted views to pvtu file format for parallel visualization with paraview
-  bool writeAdapt(const std::string &fileName, int useDefaultName, bool isBinary, 
+
+  // Routines for export of adapted views to pvtu file format for parallel
+  // visualization with paraview
+  bool writeAdapt(const std::string &fileName, int useDefaultName, bool isBinary,
                   int adaptLev, double adaptErr, int npart, bool append=false);
 
   // vertex arrays to draw the elements efficiently
@@ -163,5 +163,3 @@ bool isElementVisible(PViewOptions *opt, int dim, int numNodes,
 
 
 #endif
-
-
diff --git a/Post/PViewData.cpp b/Post/PViewData.cpp
index 3cac8a552b25105efb40b283a6606468f33582e2..a4ca0a8c451ed8a81c03e028786b4ac8dbca7840 100644
--- a/Post/PViewData.cpp
+++ b/Post/PViewData.cpp
@@ -45,25 +45,29 @@ void PViewData::initAdaptiveDataLight(int step, int level, double tol)
 {
   if(!_adaptive){
     Msg::Info("Initializing adaptive data %p interp size=%d", this, _interpolation.size());
-    // michel.rasquin@cenaero.be:
-    // _outData in adaptive.h is only used for visualization of adapted views in the GMSH GUI.
-    // In some cases (export of adapted views under pvtu format, use of GMSH as external lib), 
-    // this object is not needed so avoid its allocation in order to limit memory consumption
+    // _outData in adaptive.h is only used for visualization of adapted views in
+    // the GMSH GUI.  In some cases (export of adapted views under pvtu format,
+    // use of GMSH as external lib), this object is not needed so avoid its
+    // allocation in order to limit memory consumption
     bool outDataInit = false;
     _adaptive = new adaptiveData(this,outDataInit);
   }
 }
 
-void PViewData::saveAdaptedViewForVTK(const std::string &guifileName, int useDefaultName, 
-                                      int step, int level, double tol, int npart, bool isBinary)
+void PViewData::saveAdaptedViewForVTK(const std::string &guifileName, int useDefaultName,
+                                      int step, int level, double tol, int npart,
+                                      bool isBinary)
 {
-  if(_adaptive) { 
-    // _adaptiveData has already been allocated from the adaptive view panel of the GUI for instance.
-    _adaptive->changeResolutionForVTK(step, level, tol, npart, isBinary, guifileName, useDefaultName);
+  if(_adaptive) {
+    // _adaptiveData has already been allocated from the adaptive view panel of
+    // the GUI for instance.
+    _adaptive->changeResolutionForVTK(step, level, tol, npart, isBinary, guifileName,
+                                      useDefaultName);
   }
-  else {    
+  else {
     initAdaptiveDataLight(step, level, tol);
-    _adaptive->changeResolutionForVTK(step, level, tol, npart, isBinary, guifileName, useDefaultName);
+    _adaptive->changeResolutionForVTK(step, level, tol, npart, isBinary, guifileName,
+                                      useDefaultName);
     destroyAdaptiveData();
   }
 }
diff --git a/Post/PViewData.h b/Post/PViewData.h
index bdaae1e2ea70889f5bfd1a80ad8be780a047bee0..fff10746d1df20541006dd7d088419c52029bdc2 100644
--- a/Post/PViewData.h
+++ b/Post/PViewData.h
@@ -198,15 +198,15 @@ class PViewData {
 
   // initialize/destroy adaptive data
   void initAdaptiveData(int step, int level, double tol);
-  
-  // michel.rasquin@cenaero.be:
-  // Routines for 
-  // - export of adapted views to pvtu file format for parallel visualization with paraview,
+
+  // Routines for
+  // - export of adapted views to pvtu file format for parallel visualization
+  //   with paraview,
   // - and/or generation of VTK data structure for ParaView plugin.
   void initAdaptiveDataLight(int step, int level, double tol);
-  void saveAdaptedViewForVTK(const std::string &guifileName, int useDefaultName, 
+  void saveAdaptedViewForVTK(const std::string &guifileName, int useDefaultName,
                              int step, int level, double tol, int npart, bool isBinary);
-  
+
   void destroyAdaptiveData();
 
   // return the adaptive data
diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp
index 7225b35b829a1acbe78089c37fa5a8054c91dbd8..3b00fc528b30660bd27cacd173390fec3129183e 100644
--- a/Post/PViewDataGModel.cpp
+++ b/Post/PViewDataGModel.cpp
@@ -127,8 +127,7 @@ bool PViewDataGModel::finalize(bool computeMinMax, const std::string &interpolat
   if(!haveInterpolationMatrices()){
 
     GModel *model = _steps[0]->getModel();
-    
-    // michel.rasquin@cenaero.be:
+
     // Required for ParaView plugin linked to GMSH as external library.
     setInterpolationSchemeName(interpolationScheme);
 
@@ -184,7 +183,7 @@ bool PViewDataGModel::finalize(bool computeMinMax, const std::string &interpolat
       if(!haveInterpolationMatrices(types[i])){
         MElement *e = _getOneElementOfGivenType(model, types[i]);
         if(e){
-          
+
           const polynomialBasis *fs = dynamic_cast<const polynomialBasis*> (e->getFunctionSpace());
           if(fs){
             if(e->getPolynomialOrder() > 1){
diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp
index 95224640a3903546e015d15c70f6aeac39ddaf02..b0ee584571967aaacb8f89a29174fc6e0376518b 100644
--- a/Post/PViewDataIO.cpp
+++ b/Post/PViewDataIO.cpp
@@ -104,8 +104,6 @@ bool PViewData::writeTXT(const std::string &fileName)
   return true;
 }
 
-
-
 bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed,
                          bool append)
 {
@@ -195,9 +193,6 @@ bool PViewData::writeMED(const std::string &fileName)
   return false;
 }
 
-
-
-
 bool PViewData::toVector(std::vector<std::vector<double> > &vec)
 {
   vec.resize(getNumTimeSteps());
diff --git a/Post/PViewIO.cpp b/Post/PViewIO.cpp
index 0435b91ae7707679db95c57f5b27d25473410eec..681f46490e8793e7f7736bc356fc5c8434995d03 100644
--- a/Post/PViewIO.cpp
+++ b/Post/PViewIO.cpp
@@ -332,12 +332,14 @@ bool PView::write(const std::string &fileName, int format, bool append)
   return ret;
 }
 
-// michel.rasquin@cenaero.be:
-// Routines for export of adapted views to pvtu file format for parallel visualization with paraview.
-bool PView::writeAdapt(const std::string &guifileName, int useDefaultName, bool isBinary,
-                       int adaptLev, double adaptErr, int npart, bool append)
+// Routines for export of adapted views to pvtu file format for parallel
+// visualization with paraview.
+bool PView::writeAdapt(const std::string &guifileName, int useDefaultName,
+                       bool isBinary, int adaptLev, double adaptErr, int npart,
+                       bool append)
 {
   Msg::StatusBar(true, "Writing '%s'...", guifileName.c_str());
-  _data->saveAdaptedViewForVTK(guifileName, useDefaultName, _options->timeStep, adaptLev, adaptErr, npart, isBinary);
+  _data->saveAdaptedViewForVTK(guifileName, useDefaultName, _options->timeStep,
+                               adaptLev, adaptErr, npart, isBinary);
   return true;
 }
diff --git a/Post/adaptiveData.cpp b/Post/adaptiveData.cpp
index d94b795c206404441df7a1663650692e367dd229..23b687e8cf71e46e1889a3132341604025d5d445 100644
--- a/Post/adaptiveData.cpp
+++ b/Post/adaptiveData.cpp
@@ -1264,7 +1264,7 @@ void adaptiveElements<T>::adapt(double tol, int numComp,
       return;
     }
   }
-  
+
   _interpolVal->mult(val, res);
 
   //minVal = VAL_INF;
@@ -1280,7 +1280,7 @@ void adaptiveElements<T>::adapt(double tol, int numComp,
     fullMatrix<double> valxyz(numVals,numComp);
     resxyz = new fullMatrix<double>(numVertices,numComp);
     for(int i = 0; i < numVals; i++){
-      for (int k=0;k<numComp;k++) { 
+      for (int k=0;k<numComp;k++) {
         valxyz(i,k) = values[i].v[k];
       }
     }
@@ -1364,7 +1364,7 @@ void adaptiveElements<T>::adapt(double tol, int numComp,
           values.push_back(PValues(p[i]->val, p[i]->valy, p[i]->valz));
           break;
         case 9:
-          values.push_back(PValues(p[i]->val, 
+          values.push_back(PValues(p[i]->val,
                                    p[i]->valy, p[i]->valz,
                                    p[i]->valyx,p[i]->valyy,p[i]->valyz,
                                    p[i]->valzx,p[i]->valzy,p[i]->valzz));
@@ -1445,7 +1445,7 @@ void adaptiveElements<T>::addInView(double tol, int step,
       }
       int numVal = in->getNumValues(step, ent, ele);
       std::vector<PValues> values;
-      
+
       switch (numComp) {
       case 1:
         for(int i = 0; i < numVal; i++){
@@ -1604,28 +1604,23 @@ void adaptiveData::changeResolution(int step, int level, double tol,
 #endif
 }
 
-// michel.rasquin@cenaero.be:
-// Routines for 
-// - export of adapted views to pvtu file format for parallel visualization with paraview,
-// - and/or generation of VTK data structure for ParaView plugin.
-
 bool VTKData::isLittleEndian()
 {
   int num = 1;
   if(*(char *)&num == 1)
     return true; // Little Endian
-  else 
+  else
     return false; // Big Endian
 }
 
 void VTKData::SwapArrayByteOrder( void* array, int nbytes, int nItems )
 {
   // This swaps the byte order for the array of nItems each of size nbytes
-  int i,j; 
+  int i,j;
   unsigned char* ucDst = (unsigned char*)array;
-  
+
   for(i=0; i < nItems; i++) {
-    for(j=0; j < (nbytes/2); j++) 
+    for(j=0; j < (nbytes/2); j++)
       std::swap( ucDst[j] , ucDst[(nbytes - 1) - j] );
     ucDst += nbytes;
   }
@@ -1633,12 +1628,13 @@ void VTKData::SwapArrayByteOrder( void* array, int nbytes, int nItems )
 
 void VTKData::writeVTKElmData()
 {
-  // This routine writes vtu files (ascii or binary) from a elemental data base of nodes coordinates, 
-  // cell connectivity, type and offset, and point data (either scalar or vector field)
-  
+  // This routine writes vtu files (ascii or binary) from a elemental data base
+  // of nodes coordinates, cell connectivity, type and offset, and point data
+  // (either scalar or vector field)
+
   // Format choice
   if(vtkFormat == "vtu") {
-      
+
     if(vtkCountTotElmLev0 <= numPartMinElm*minElmPerPart) {
       if( (vtkCountTotElmLev0-1)%minElmPerPart == 0) { //new filename
         vtkCountFile = (vtkCountTotElmLev0-1)/minElmPerPart;
@@ -1646,65 +1642,74 @@ void VTKData::writeVTKElmData()
       }
     }
     else {
-      if( (vtkCountTotElmLev0-1-numPartMinElm*minElmPerPart)%maxElmPerPart == 0) { //new filename
-        vtkCountFile = numPartMinElm+(vtkCountTotElmLev0-1-numPartMinElm*minElmPerPart)/maxElmPerPart;
+      if( (vtkCountTotElmLev0-1-numPartMinElm*minElmPerPart) % maxElmPerPart == 0) {
+        //new filename
+        vtkCountFile = numPartMinElm + (vtkCountTotElmLev0 - 1 -
+                                        numPartMinElm*minElmPerPart) / maxElmPerPart;
         initVTKFile();
       }
     }
-    
+
     if (vtkIsBinary == true) { // Use appended format for raw binary
-      
-      // Write raw binary data to separate files first. 
-      // Text headers will be added later, as wall as raw data size (needs to know the size before)
-      
+
+      // Write raw binary data to separate files first.  Text headers will be
+      // added later, as wall as raw data size (needs to know the size before)
+
       int counter;
       uint64_t *i64array;
       uint8_t *i8array;
       double *darray;
-      
+
       // Node value
       counter = 0;
       darray= new double[vtkNumComp*vtkLocalValues.size()];
-      for(std::vector<PValues>::iterator it = vtkLocalValues.begin();it != vtkLocalValues.end(); ++it) {
+      for(std::vector<PValues>::iterator it = vtkLocalValues.begin();
+          it != vtkLocalValues.end(); ++it) {
         for(int i=0;i<vtkNumComp;i++) {
           darray[counter+i] = it->v[i];
         }
         counter+=vtkNumComp;
         vtkCountTotVal+=vtkNumComp;
-      }  
+      }
       assert(counter==vtkNumComp* (int) vtkLocalValues.size());
       fwrite(darray,sizeof(double),vtkNumComp*vtkLocalValues.size(),vtkFileNodVal);
       delete[] darray;
-      
+
       // Points
       int sizeArray = (int) vtkLocalCoords.size();
       darray = new double[3*sizeArray];
       counter = 0;
-      for(std::vector<PCoords>::iterator it = vtkLocalCoords.begin();it != vtkLocalCoords.end(); ++it) {
+      for(std::vector<PCoords>::iterator it = vtkLocalCoords.begin();
+          it != vtkLocalCoords.end(); ++it) {
         for(int i=0;i<3;i++) {
           darray[counter+i] = (*it).c[i];
         }
         counter+=3;
         vtkCountCoord+=3;
-      }     
+      }
       fwrite(darray, sizeof(double),3*sizeArray,vtkFileCoord);
       delete[] darray;
-      
-      //Cells
-      
-      // First count the number of integers that described the cell data in vtkConnectivity
-      // See http://www.vtk.org/wp-content/uploads/2015/04/file-formats.pdf (page 4)
+
+      // Cells
+
+      // First count the number of integers that described the cell data in
+      // vtkConnectivity See
+      // http://www.vtk.org/wp-content/uploads/2015/04/file-formats.pdf (page 4)
       int cellSizeData = 0;
-      for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();it != vtkLocalConnectivity.end(); ++it) {
-        cellSizeData+= (int) it->size(); // Contrary to vtk format, no +1 required for the number of nodes in the element
+      for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();
+          it != vtkLocalConnectivity.end(); ++it) {
+        // Contrary to vtk format, no +1 required for the number of nodes in the
+        // element
+        cellSizeData += (int) it->size();
       }
-      
+
       // Connectivity (and build offset at the same time)
       counter = 0;
       int cellcounter = 0;
       i64array = new uint64_t[cellSizeData];
       uint64_t *cellOffset = new uint64_t[vtkLocalConnectivity.size()];
-      for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();it != vtkLocalConnectivity.end(); ++it) {
+      for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();
+          it != vtkLocalConnectivity.end(); ++it) {
         for(vectInt::iterator jt = it->begin(); jt != it->end(); ++jt) {
           i64array[counter] = *jt;
           counter++;
@@ -1712,18 +1717,19 @@ void VTKData::writeVTKElmData()
         }
         cellOffset[cellcounter] = vtkCountTotNodConnect; // build the offset
         cellcounter++;
-      }     
+      }
       fwrite(i64array,sizeof(uint64_t),cellSizeData,vtkFileConnect);
       delete[] i64array;
-      
-      // Cell offset 
+
+      // Cell offset
       fwrite(cellOffset,sizeof(uint64_t),vtkLocalConnectivity.size(),vtkFileCellOffset);
       delete[] cellOffset;
-      
+
       // Cell type
       counter = 0;
       i8array = new uint8_t[vtkLocalConnectivity.size()];
-      for(std::vector<int>::iterator it = vtkLocalCellType.begin();it != vtkLocalCellType.end(); it++) {
+      for(std::vector<int>::iterator it = vtkLocalCellType.begin();
+          it != vtkLocalCellType.end(); it++) {
         i8array[counter] = *it;
         counter++;
       }
@@ -1732,10 +1738,11 @@ void VTKData::writeVTKElmData()
 
     }
     else { // ascii
-            
+
       // Node values
-      for(std::vector<PValues>::iterator it = vtkLocalValues.begin();it != vtkLocalValues.end(); ++it) {
-          
+      for(std::vector<PValues>::iterator it = vtkLocalValues.begin();
+          it != vtkLocalValues.end(); ++it) {
+
         for(int i=0;i<vtkNumComp;i++) {
           fprintf(vtkFileNodVal,"%23.16e ",(*it).v[i]);
           vtkCountTotVal++;
@@ -1743,7 +1750,8 @@ void VTKData::writeVTKElmData()
         }
       }
 
-      for(std::vector<PCoords>::iterator it = vtkLocalCoords.begin();it != vtkLocalCoords.end(); it++) {
+      for(std::vector<PCoords>::iterator it = vtkLocalCoords.begin();
+          it != vtkLocalCoords.end(); it++) {
         fprintf(vtkFileCoord,"%23.16e %23.16e %23.16e ",(*it).c[0],(*it).c[1],(*it).c[2]);
         vtkCountCoord+=3;
         if(vtkCountCoord%6 == 0) fprintf(vtkFileCoord,"\n");
@@ -1753,11 +1761,12 @@ void VTKData::writeVTKElmData()
       // Connectivity
       int *cellOffset = new int[vtkLocalConnectivity.size()];
       int cellcounter = 0;
-      for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();it != vtkLocalConnectivity.end(); ++it) {
+      for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();
+          it != vtkLocalConnectivity.end(); ++it) {
         for(vectInt::iterator jt = it->begin(); jt != it->end(); ++jt) {
           fprintf(vtkFileConnect,"%d ",*jt);
           vtkCountTotNodConnect++;
-          if(vtkCountTotNodConnect%6 == 0) fprintf(vtkFileConnect,"\n");         
+          if(vtkCountTotNodConnect%6 == 0) fprintf(vtkFileConnect,"\n");
         }
         cellOffset[cellcounter] = vtkCountTotNodConnect; // build the offset
         cellcounter++;
@@ -1767,22 +1776,23 @@ void VTKData::writeVTKElmData()
       for(uint64_t i = 0 ; i<vtkLocalConnectivity.size(); i++) {
         fprintf(vtkFileCellOffset,"%d ",cellOffset[i]);
         vtkCountCellOffset++;
-        if(vtkCountCellOffset%6 == 0) fprintf(vtkFileCellOffset,"\n");         
+        if(vtkCountCellOffset%6 == 0) fprintf(vtkFileCellOffset,"\n");
       }
       delete[] cellOffset;
-    
+
       // Cell type
-      for(std::vector<int>::iterator it = vtkLocalCellType.begin();it != vtkLocalCellType.end(); it++) {
+      for(std::vector<int>::iterator it = vtkLocalCellType.begin();
+          it != vtkLocalCellType.end(); it++) {
         fprintf(vtkFileCellType,"%d ",*it);
         vtkCountCellType++;
-        if(vtkCountCellType%6 == 0) fprintf(vtkFileCellType,"\n");         
+        if(vtkCountCellType%6 == 0) fprintf(vtkFileCellType,"\n");
       }
 
     } //if ascii
-    
+
     //finalize and close current vtu file
     if(vtkCountTotElmLev0 <= numPartMinElm*minElmPerPart) {
-      if( vtkCountTotElmLev0%minElmPerPart == 0) { 
+      if( vtkCountTotElmLev0%minElmPerPart == 0) {
         finalizeVTKFile();
       }
     }
@@ -1791,15 +1801,15 @@ void VTKData::writeVTKElmData()
         finalizeVTKFile();
       }
     }
-        
+
   } // vtu format
-  else 
-    printf("ERROR: format unknown\n");
-  
+  else
+    Msg::Error("Unknown format");
+
   clearLocalData();
 }
 
-void VTKData::initVTKFile() 
+void VTKData::initVTKFile()
 {
   // Temporary files
   vtkFileCoord = fopen("vtkCoords.vtu","wb");
@@ -1807,11 +1817,12 @@ void VTKData::initVTKFile()
   vtkFileCellOffset = fopen("vtkCellOffset.vtu","wb");
   vtkFileCellType = fopen("vtkCellType.vtu","wb");
   vtkFileNodVal = fopen("vtkNodeValue.vtu","wb");
-  
-  if(vtkCountFile == 0) { // write the pvtu file and create the corresponding directory for vtu files
-    
+
+  if(vtkCountFile == 0) {
+    // write the pvtu file and create the corresponding directory for vtu files
+
     if (vtkUseDefaultName == 1) {
-      vtkDirName = vtkFieldName 
+      vtkDirName = vtkFieldName
                + "_step"  + ToString<int>(vtkStep)
                + "_level" + ToString<int>(vtkLevel)
                + "_tol"   + ToString<double>(vtkTol)
@@ -1820,41 +1831,43 @@ void VTKData::initVTKFile()
     else {
       // Remove existing extension here to avoid duplicate
       std::size_t found = vtkFileName.find_last_of(".");
-      if(found != std::string::npos) vtkFileName = vtkFileName.substr(0,found); //remove extension
-      vtkDirName = vtkFileName; 
+      // remove extension
+      if(found != std::string::npos) vtkFileName = vtkFileName.substr(0, found);
+      vtkDirName = vtkFileName;
     }
-    
+
     mkdir(vtkDirName.c_str(),S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); //755
 
     vtkFileName = vtkDirName + ".p" + vtkFormat; // add pvtu extension to file name
     vtkFile = fopen(vtkFileName.c_str(),"w");
-    
+
     bool littleEndian = isLittleEndian(); // Determine endianess
     if (littleEndian == true)
       fprintf(vtkFile,"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\">\n");
     else
       fprintf(vtkFile,"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"BigEndian\">\n");
-    
+
     fprintf(vtkFile,"<PUnstructuredGrid GhostLevel=\"0\">\n");
     fprintf(vtkFile,"<PPoints>\n");
     fprintf(vtkFile,"<DataArray type=\"Float64\" Name=\"Points\" NumberOfComponents=\"3\"/>\n");
     fprintf(vtkFile,"</PPoints>\n");
-    
+
     fprintf(vtkFile,"<PCells>\n");
     fprintf(vtkFile,"<PDataArray type=\"Int64\" Name=\"connectivity\" NumberOfComponents=\"1\"/>\n");
     fprintf(vtkFile,"<PDataArray type=\"Int64\" Name=\"offsets\" NumberOfComponents=\"1\"/>\n");
     fprintf(vtkFile,"<PDataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\"/>\n");
     fprintf(vtkFile,"</PCells>\n");
-    
+
     fprintf(vtkFile,"<PPointData>\n");
-    fprintf(vtkFile,"<PDataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\"/>\n",vtkFieldName.c_str(),vtkNumComp);
+    fprintf(vtkFile,"<PDataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\"/>\n",
+            vtkFieldName.c_str(), vtkNumComp);
     fprintf(vtkFile,"</PPointData>\n");
-    
+
     fprintf(vtkFile,"<PCellData>\n");
     fprintf(vtkFile,"</PCellData>\n");
-    
-    for(int i=0; i<vtkNpart; i++) 
-      fprintf(vtkFile,"<Piece Source=\"%s/data%d.vtu\"/>\n",vtkDirName.c_str(),i);
+
+    for(int i = 0; i < vtkNpart; i++)
+      fprintf(vtkFile,"<Piece Source=\"%s/data%d.vtu\"/>\n", vtkDirName.c_str(),i);
     fprintf(vtkFile,"</PUnstructuredGrid>\n");
     fprintf(vtkFile,"</VTKFile>\n");
     fclose(vtkFile);
@@ -1863,67 +1876,69 @@ void VTKData::initVTKFile()
 
 void VTKData::finalizeVTKFile()
 {
-  // This routine writes vtu files (ascii or binary) from a complete data base of nodes coordinates, 
-  // cell connectivity, type and offset, and point data (either scalar or vector field)
-  
-  // Close first temporary files.
-  // Todo: Avoid multiple open/close actions and keep the file open to write all information
+  // This routine writes vtu files (ascii or binary) from a complete data base
+  // of nodes coordinates, cell connectivity, type and offset, and point data
+  // (either scalar or vector field)
+
+  // Close first temporary files.  Todo: Avoid multiple open/close actions and
+  // keep the file open to write all information
   fclose(vtkFileCoord);
   fclose(vtkFileConnect);
   fclose(vtkFileCellOffset);
   fclose(vtkFileCellType);
   fclose(vtkFileNodVal);
-  
+
   bool littleEndian = isLittleEndian(); // Determine endianess
-  
+
   // Open final file
   std::string filename;
   filename = vtkDirName + "/data" + ToString(vtkCountFile) + "." + vtkFormat;
 
-  Msg::StatusBar(true,"Writing VTK data in %s: fieldname = %s - numElm = %d - numNod = %d nodes\n",
-            filename.c_str(), vtkFieldName.c_str(), vtkCountTotElm, vtkCountTotNod);
-  
-  assert(vtkCountTotNod == vtkCountCoord/3);  
-  
-  // Now concatenate headers with data files  
+  Msg::StatusBar(true, "Writing VTK data in %s: fieldname = %s - numElm = %d - numNod = %d nodes\n",
+                 filename.c_str(), vtkFieldName.c_str(), vtkCountTotElm, vtkCountTotNod);
+
+  assert(vtkCountTotNod == vtkCountCoord/3);
+
+  // Now concatenate headers with data files
   if(vtkFormat == "vtu") {   // Format choice
-    
+
     if (vtkIsBinary == true) { // Binary or ascii
-      
+
       vtkFile = fopen(filename.c_str(),"wb");
       if(vtkFile == NULL) {
         printf("Could not open file %s\n", filename.c_str());
         return;
       }
-      
+
       uint64_t byteoffset = 0;
-      
+
       // Headers first
-      
+
       if (littleEndian == true)
         fprintf(vtkFile,"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n");
       else
         fprintf(vtkFile,"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"BigEndian\" header_type=\"UInt64\">\n");
       fprintf(vtkFile,"<UnstructuredGrid>\n");
-      fprintf(vtkFile,"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n",vtkCountTotNod,vtkCountTotElm);
-      
-      
+      fprintf(vtkFile,"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n",
+              vtkCountTotNod,vtkCountTotElm);
+
+
       // Node value
       fprintf(vtkFile,"<PointData>\n");
-      fprintf(vtkFile,"<DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\" offset=\"%" PRIu64 "\"/>\n",vtkFieldName.c_str(),vtkNumComp,byteoffset);
+      fprintf(vtkFile,"<DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\" offset=\"%" PRIu64 "\"/>\n", vtkFieldName.c_str(), vtkNumComp,byteoffset);
       fprintf(vtkFile,"</PointData>\n");
       byteoffset = byteoffset + (vtkCountTotNod*vtkNumComp+1)*sizeof(double); // +1 for datasize in bytes
-      
+
       // Cell values (none here but may change)
       fprintf(vtkFile,"<CellData>\n");
       fprintf(vtkFile,"</CellData>\n"); // no offset here because empty cell data
-      
+
       // Nodes
       fprintf(vtkFile,"<Points>\n");
       fprintf(vtkFile,"<DataArray type=\"Float64\" Name=\"Points\" NumberOfComponents=\"3\" format=\"appended\" offset=\"%" PRIu64 "\"/>\n",byteoffset);
       fprintf(vtkFile,"</Points>\n");
       byteoffset = byteoffset + (vtkCountCoord+1)*sizeof(double); // +1 for datasize in bytes
-      
+
       // Cells
       fprintf(vtkFile,"<Cells>\n");
       fprintf(vtkFile,"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"appended\" offset=\"%" PRIu64 "\"/>\n",byteoffset);
@@ -1933,15 +1948,15 @@ void VTKData::finalizeVTKFile()
       fprintf(vtkFile,"<DataArray type=\"UInt8\" Name=\"types\" format=\"appended\" offset=\"%" PRIu64 "\"/>\n",byteoffset);
       byteoffset = byteoffset + (vtkCountTotElm+1)*sizeof(uint8_t);
       fprintf(vtkFile,"</Cells>\n");
-      
-      fprintf(vtkFile,"</Piece>\n"); 
+
+      fprintf(vtkFile,"</Piece>\n");
       fprintf(vtkFile,"</UnstructuredGrid>\n");
-      
+
       fprintf(vtkFile,"<AppendedData encoding=\"raw\">\n");
       fprintf(vtkFile,"_");
-      
+
       uint64_t datasize;
-      
+
       // Node values
       datasize = vtkNumComp*vtkCountTotNod*sizeof(double);
       fwrite(&datasize,sizeof(uint64_t),1,vtkFile);
@@ -1952,181 +1967,181 @@ void VTKData::finalizeVTKFile()
       of_vtkfile << if_vtkNodeValue.rdbuf();
       if_vtkNodeValue.close();
       of_vtkfile.close();
-      
+
       // Points
       vtkFile = fopen(filename.c_str(),"ab");
       datasize = vtkCountTotNod*3*sizeof(double);
       fwrite(&datasize,sizeof(uint64_t),1,vtkFile);
       fclose(vtkFile);
-      
+
       std::ifstream if_vtkCoords("vtkCoords.vtu", std::ios_base::binary);
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       of_vtkfile << if_vtkCoords.rdbuf();
       if_vtkCoords.close();
       of_vtkfile.close();
-      
+
       // Cells
       // Connectivity
       vtkFile = fopen(filename.c_str(),"ab");
       datasize = vtkCountTotNodConnect*sizeof(uint64_t);
       fwrite(&datasize,sizeof(uint64_t),1,vtkFile);
       fclose(vtkFile);
-      
+
       std::ifstream if_vtkConnectivity("vtkConnectivity.vtu", std::ios_base::binary);
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       of_vtkfile << if_vtkConnectivity.rdbuf();
       if_vtkConnectivity.close();
       of_vtkfile.close();
-      
+
       // Cell offset
       vtkFile = fopen(filename.c_str(),"ab");
       datasize = vtkCountTotElm*sizeof(uint64_t);
       fwrite(&datasize,sizeof(uint64_t),1,vtkFile);
       fclose(vtkFile);
-      
+
       std::ifstream if_vtkCellOffset("vtkCellOffset.vtu", std::ios_base::binary);
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       of_vtkfile << if_vtkCellOffset.rdbuf();
       if_vtkCellOffset.close();
       of_vtkfile.close();
-      
+
       // Cell type
       vtkFile = fopen(filename.c_str(),"ab");
       datasize = vtkCountTotElm*sizeof(uint8_t);
       fwrite(&datasize,sizeof(uint64_t),1,vtkFile);
       fclose(vtkFile);
-      
+
       std::ifstream if_vtkCellType("vtkCellType.vtu", std::ios_base::binary);
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       of_vtkfile << if_vtkCellType.rdbuf();
       if_vtkCellType.close();
       of_vtkfile.close();
-      
+
       vtkFile = fopen(filename.c_str(),"ab");
       fprintf(vtkFile,"\n");
       fprintf(vtkFile,"</AppendedData>\n");
       fprintf(vtkFile,"</VTKFile>\n"); // for both binary and ascii
-      fclose(vtkFile); 
-      
+      fclose(vtkFile);
+
     }
     else { // ascii
-      
+
       vtkFile = fopen(filename.c_str(),"w");
       if(vtkFile == NULL) {
         printf("Could not open file %s\n", filename.c_str());
         return;
-      } 
-      
+      }
+
       if (littleEndian == true)
         fprintf(vtkFile,"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n");
       else
         fprintf(vtkFile,"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"BigEndian\" header_type=\"UInt64\">\n");
       fprintf(vtkFile,"<UnstructuredGrid>\n");
       fprintf(vtkFile,"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n",vtkCountTotNod,vtkCountTotElm);
-      
+
       // Node values
       fprintf(vtkFile,"<PointData>\n");
       fprintf(vtkFile,"<DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",vtkFieldName.c_str(),vtkNumComp);
       fclose(vtkFile); //close file for binary concatenation
-      
+
       std::ifstream if_vtkNodeValue("vtkNodeValue.vtu", std::ios_base::binary);
       std::ofstream of_vtkfile(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       of_vtkfile << if_vtkNodeValue.rdbuf();
       if_vtkNodeValue.close();
       of_vtkfile.close();
-      
+
       vtkFile = fopen(filename.c_str(),"a");
       fprintf(vtkFile,"</DataArray>\n");
       fprintf(vtkFile,"</PointData>\n");
-      
+
       //Cell values
       fprintf(vtkFile,"<CellData>\n");
       fprintf(vtkFile,"</CellData>\n");
-      
+
       //Nodes
       fprintf(vtkFile,"<Points>\n");
       fprintf(vtkFile,"<DataArray type=\"Float64\" Name=\"Points\" NumberOfComponents=\"3\" format=\"ascii\">\n");
       fclose(vtkFile); //close file for binary concatenation
-      
+
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       std::ifstream if_vtkCoords("vtkCoords.vtu", std::ios_base::binary);
       of_vtkfile << if_vtkCoords.rdbuf();
       if_vtkCoords.close();
       of_vtkfile.close();
-      
+
       vtkFile = fopen(filename.c_str(),"a");
       fprintf(vtkFile,"</DataArray>\n");
       fprintf(vtkFile,"</Points>\n");
-      
+
       // Cells
       fprintf(vtkFile,"<Cells>\n");
       fprintf(vtkFile,"<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\">\n");
       fclose(vtkFile); //close file for binary concatenation
-      
+
       // Connectivity
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       std::ifstream if_vtkConnectivity("vtkConnectivity.vtu", std::ios_base::binary);
       of_vtkfile << if_vtkConnectivity.rdbuf();
       if_vtkConnectivity.close();
       of_vtkfile.close();
-      
+
       vtkFile = fopen(filename.c_str(),"a");
       fprintf(vtkFile,"</DataArray>\n");
-      
+
       // Cell offset
       fprintf(vtkFile,"<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">\n");
       fclose(vtkFile); //close file for binary concatenation
-      
+
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       std::ifstream if_vtkCellOffset("vtkCellOffset.vtu", std::ios_base::binary);
       of_vtkfile << if_vtkCellOffset.rdbuf();
       if_vtkCellOffset.close();
       of_vtkfile.close();
-      
+
       vtkFile = fopen(filename.c_str(),"a");
       fprintf(vtkFile,"</DataArray>\n");
-      
+
       // Cell type
       fprintf(vtkFile,"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n");
       fclose(vtkFile); //close file for binary concatenation
-      
+
       of_vtkfile.open(filename.c_str(), std::ios_base::binary | std::ios_base::app);
       std::ifstream if_vtkCellType("vtkCellType.vtu", std::ios_base::binary);
       of_vtkfile << if_vtkCellType.rdbuf();
       if_vtkCellType.close();
       of_vtkfile.close();
-      
+
       vtkFile = fopen(filename.c_str(),"a");
       fprintf(vtkFile,"</DataArray>\n");
       fprintf(vtkFile,"</Cells>\n");
-      
-      fprintf(vtkFile,"</Piece>\n"); 
+
+      fprintf(vtkFile,"</Piece>\n");
       fprintf(vtkFile,"</UnstructuredGrid>\n");
-      
-      
+
+
       fprintf(vtkFile,"</VTKFile>\n"); // for both binary and ascii
-      fclose(vtkFile); 
+      fclose(vtkFile);
     } // if binary/ascii
-    
+
     // Remove temporary files now
     if(remove("vtkCoords.vtu") !=0 ) printf("ERROR: Could not remove vtkCoords.vtu\n");
     if(remove("vtkConnectivity.vtu") !=0 ) printf("ERROR: Could not remove vtkConnectivity.vtu\n");
     if(remove("vtkCellOffset.vtu") !=0 ) printf("ERROR: Could not remove vtkCellOffset.vtu\n");
     if(remove("vtkCellType.vtu") !=0 ) printf("ERROR: Could not remove vtkCellType.vtu\n");
     if(remove("vtkNodeValue.vtu") !=0 ) printf("ERROR: Could not remove vtkNodeValue.vtu\n");
-    
+
     // Reset counters for next file
     vtkCountTotNod = 0;
-    vtkCountTotElm = 0;  
+    vtkCountTotElm = 0;
     vtkCountCoord = 0;
     vtkCountTotNodConnect = 0;
     vtkCountTotVal = 0;
     vtkCountCellOffset = 0;
-    vtkCountCellType = 0; 
+    vtkCountCellType = 0;
   }
-  
+
   else
-    Msg::Error("File format unknown: %s\n",vtkFormat.c_str());
+    Msg::Error("File format unknown: %s", vtkFormat.c_str());
 }
 
 int VTKData::getPVCellType(int numEdges)
@@ -2164,12 +2179,10 @@ int VTKData::getPVCellType(int numEdges)
       cellType = -1;
       break;
   }
-  
+
   return  cellType;
 }
 
-
-
 template <class T>
 void adaptiveElements<T>::adaptForVTK(double tol,
                                       int numComp,
@@ -2177,29 +2190,29 @@ void adaptiveElements<T>::adaptForVTK(double tol,
                                       std::vector<PValues> &values)
 {
   int numVertices = T::allVertices.size();
-  
+
   if(!numVertices){
     Msg::Error("No adapted vertices to interpolate");
     return;
   }
-  
+
   int numVals = _coeffsVal ? _coeffsVal->size1() : T::numNodes;
   if(numVals != (int)values.size()){
     Msg::Error("Wrong number of values in adaptation %d != %i",
                numVals, values.size());
     return;
   }
-  
+
   #ifdef TIMER
   double t1 = GetTimeInSeconds();
   #endif
-  
+
   fullVector<double> val(numVals), res(numVertices);
   switch (numComp) {
     case 1:
     {
       for(int i = 0; i < numVals; i++) val(i) = values[i].v[0];
-      break; 
+      break;
     }
     case 3:
     case 9:
@@ -2216,28 +2229,28 @@ void adaptiveElements<T>::adaptForVTK(double tol,
       return;
     }
   }
-  
+
   _interpolVal->mult(val, res);
-  
+
   double minVal = VAL_INF;
   double maxVal = -VAL_INF;
   for(int i = 0; i < numVertices; i++){
     minVal = std::min(minVal, res(i));
     maxVal = std::max(maxVal, res(i));
   }
-  
+
   fullMatrix<double> *resxyz = 0;
   if(numComp == 3 || numComp == 9){
     fullMatrix<double> valxyz(numVals, numComp);
     resxyz = new fullMatrix<double>(numVertices, numComp);
     for(int i = 0; i < numVals; i++){
-      for (int k = 0; k < numComp; k++) { 
+      for (int k = 0; k < numComp; k++) {
         valxyz(i,k) = values[i].v[k];
       }
     }
     _interpolVal->mult(valxyz, *resxyz);
   }
-  
+
   int numNodes = _coeffsGeom ? _coeffsGeom->size1() : T::numNodes;
   if(numNodes != (int)coords.size()){
     Msg::Error("Wrong number of nodes in adaptation %d != %i",
@@ -2245,7 +2258,7 @@ void adaptiveElements<T>::adaptForVTK(double tol,
     if(resxyz) delete resxyz;
     return;
   }
-  
+
   fullMatrix<double> xyz(numNodes, 3), XYZ(numVertices, 3);
   for(int i = 0; i < numNodes; i++){
     xyz(i, 0) = coords[i].c[0];
@@ -2253,14 +2266,15 @@ void adaptiveElements<T>::adaptForVTK(double tol,
     xyz(i, 2) = coords[i].c[2];
   }
   _interpolGeom->mult(xyz, XYZ);
-  
+
   #ifdef TIMER
   adaptiveData::timerAdapt += GetTimeInSeconds() - t1;
   return;
   #endif
-  
+
   int i = 0;
-  for(std::set<adaptiveVertex>::iterator it = T::allVertices.begin(); it != T::allVertices.end(); ++it) {
+  for(std::set<adaptiveVertex>::iterator it = T::allVertices.begin();
+      it != T::allVertices.end(); ++it) {
     // ok because we know this will not change the set ordering
     adaptiveVertex *p = (adaptiveVertex*)&(*it);
     p->val = res(i);
@@ -2282,18 +2296,18 @@ void adaptiveElements<T>::adaptForVTK(double tol,
     p->Z = XYZ(i, 2);
     i++;
   }
-  
+
   if(resxyz) delete resxyz;
-  
+
   for(typename std::list<T*>::iterator it = T::all.begin();it != T::all.end(); it++)
     (*it)->visible = false;
-  
+
   if(tol != 0.){
     double avg = fabs(maxVal - minVal);
     if(tol < 0) avg = 1.; // force visibility to the smallest subdivision
     T::error(avg, tol);
   }
-  
+
   coords.clear();
   values.clear();
   for(typename std::list<T*>::iterator it = T::all.begin();it != T::all.end(); it++){
@@ -2309,10 +2323,10 @@ void adaptiveElements<T>::adaptForVTK(double tol,
             values.push_back(PValues(p[i]->val, p[i]->valy, p[i]->valz));
             break;
           case 9:
-            values.push_back(PValues(p[i]->val, 
+            values.push_back(PValues(p[i]->val,
                                      p[i]->valy, p[i]->valz,
                                      p[i]->valyx,p[i]->valyy,p[i]->valyz,
-                                     p[i]->valzx,p[i]->valzy,p[i]->valzz)); 
+                                     p[i]->valzx,p[i]->valzy,p[i]->valzz));
             break;
         }
       }
@@ -2323,43 +2337,45 @@ void adaptiveElements<T>::adaptForVTK(double tol,
 
 template <class T>
 void adaptiveElements<T>::buildMapping(nodMap<T> &myNodMap, double tol, int &numNodInsert)
-{ 
-  
+{
+
   if (tol > 0.0 || myNodMap.getSize() == 0) {
-    // Either this is not a uniform refinement and we need to rebuild the whole mapping
-    // for each canonical element, or this is the first time we try to build the mapping
-    
-    myNodMap.cleanMapping(); // Required if tol > 0 (local error based adaptation) 
-    
-    for(typename std::list<T*>::iterator itleaf = T::all.begin();itleaf != T::all.end(); itleaf++) {
+    // Either this is not a uniform refinement and we need to rebuild the whole
+    // mapping for each canonical element, or this is the first time we try to
+    // build the mapping
+
+    myNodMap.cleanMapping(); // Required if tol > 0 (local error based adaptation)
+
+    for(typename std::list<T*>::iterator itleaf = T::all.begin();
+        itleaf != T::all.end(); itleaf++) {
       // Visit all the leaves of the refined canonical element
-      
+
       if ((*itleaf)->visible == true) {
         // Find the leaves that are flagged for visibility
-        
+
         for(int i=0;i<T::numNodes;i++) {
           // Visit each nodes of the leaf (3 for triangles,  4 for quadrangle,  etc)
           adaptiveVertex pquery;
           pquery.x = (*itleaf)->p[i]->x;
           pquery.y = (*itleaf)->p[i]->y;
           pquery.z = (*itleaf)->p[i]->z;
-          std::set<adaptiveVertex>::iterator it = T::allVertices.find(pquery);     
+          std::set<adaptiveVertex>::iterator it = T::allVertices.find(pquery);
           if(it == T::allVertices.end()){
-            printf("ERROR: Could not find adaptive Vertex in adaptiveElements<T>::buildMapping %f %f %f\n",
-                   pquery.x,pquery.y,pquery.z);
+            Msg::Error("Could not find adaptive Vertex in adaptiveElements<T>::buildMapping %f %f %f",
+                       pquery.x,pquery.y,pquery.z);
           }
           else{
-            // Compute the distance in the list to get the mapping for  
+            // Compute the distance in the list to get the mapping for
             // the canonical element (note std:distance returns long int
             int dist = (int) std::distance(T::allVertices.begin(),it);
             myNodMap.mapping.push_back(dist);
           }
           // quit properly if vertex not found - Should not happen though
-          assert(it != T::allVertices.end()); 
+          assert(it != T::allVertices.end());
         } //for
       } //if
     }//for
-    
+
     // Count number of unique nodes from the mapping
     // Use an ordered set for efficiency
     // This set is also used in case of partiel refinement
@@ -2368,7 +2384,7 @@ void adaptiveElements<T>::buildMapping(nodMap<T> &myNodMap, double tol, int &num
       uniqueNod.insert(*it);
     }
     numNodInsert = (int) uniqueNod.size();
-    
+
     // Renumber the elm in the mapping in case of partial refinement (when vis tolerance > 0)
     // so that we have a continuous numbering starting from 0 with no missing node id in the connectivity
     // This require a new local and temporary mapping, based on uniqueNod already generated above
@@ -2391,7 +2407,7 @@ void adaptiveElements<T>::addInViewForVTK(int step,
 {
   int numComp = in->getNumComponents(0, 0, 0);
   if(numComp != 1 && numComp != 3 && numComp != 9) return;
-  
+
   int numEle = 0;
   switch(T::numEdges){
     case 0:
@@ -2420,11 +2436,11 @@ void adaptiveElements<T>::addInViewForVTK(int step,
       break;
   }
   if(!numEle) return;
-  
+
   // New variables for high order visualiztion through vtk files
   int numNodInsert;
   nodMap<T> myNodMap;
-  
+
   for(int ent = 0; ent < in->getNumEntities(step); ent++){
     for(int ele = 0; ele < in->getNumElements(step, ent); ele++){
       if(in->skipElement(step, ent, ele) ||
@@ -2438,7 +2454,7 @@ void adaptiveElements<T>::addInViewForVTK(int step,
       }
       int numVal = in->getNumValues(step, ent, ele);
       std::vector<PValues> values;
-      
+
       switch (numComp) {
         case 1:
           for(int i = 0; i < numVal; i++){
@@ -2474,37 +2490,38 @@ void adaptiveElements<T>::addInViewForVTK(int step,
           }
           break;
       }
-          
+
       adaptForVTK(myVTKData.vtkTol, numComp, coords, values);//, out->Min, out->Max, plug);
-      
+
       // Inside initial element, after adapt() has been called
-      
-      // Build the mapping of the canonical element, 
+
+      // Build the mapping of the canonical element,
       // or recycle existing one in case  of uniform refinement
       buildMapping(myNodMap, myVTKData.vtkTol, numNodInsert);
-      
+
       // Pre-allocate some space for the local coordinates and connectivity
       // in order to write to any component of the vector later through vec[i]
-      
+
       myVTKData.vtkLocalCoords.resize(numNodInsert,PCoords(0.0,0.0,0.0));
       myVTKData.vtkLocalValues.resize(numNodInsert,PValues(numComp));
-      
+
       for(unsigned int i = 0; i < coords.size() / T::numNodes; i++){
-        
+
         // Loop over
         //  - all refined elements if refinement level > 0
-        //  - single initial element when refinement box is checked for the first time (ref level =0)
-        
+        //  - single initial element when refinement box is checked for the first
+        //    time (ref level =0)
+
         // local connectivity for the considered sub triangle
         vectInt vtkElmConnectivity;
-        
+
         for(int k = 0; k < T::numNodes; ++k) {
-          
+
           // Connectivity of the considered sub-element
           int countTotNodloc = T::numNodes * i + k; // Nodes are duplicate here
-          int vtkNodeId = myVTKData.vtkCountTotNod + myNodMap.mapping[countTotNodloc];            
+          int vtkNodeId = myVTKData.vtkCountTotNod + myNodMap.mapping[countTotNodloc];
           vtkElmConnectivity.push_back(vtkNodeId);
-          
+
           // Coordinates of the nodes of the considered sub-element
           double px, py, pz;
           px = coords[T::numNodes * i + k].c[0];
@@ -2512,48 +2529,48 @@ void adaptiveElements<T>::addInViewForVTK(int step,
           pz = coords[T::numNodes * i + k].c[2];
           PCoords tmpCoords = PCoords(px,py,pz);
           myVTKData.vtkLocalCoords[myNodMap.mapping[countTotNodloc]] = tmpCoords;
-          
+
           // Value associated with each nodes of the sub-element
           myVTKData.vtkLocalValues[myNodMap.mapping[countTotNodloc]] = values[T::numNodes * i + k];
-          
+
         }
-        
+
         // Add elm connectivity to vector
         myVTKData.vtkLocalConnectivity.push_back(vtkElmConnectivity);
-        
+
         // Increment global elm number
         myVTKData.incrementTotElm(1);
-        
+
         // Save element type
         myVTKData.vtkLocalCellType.push_back(myVTKData.getPVCellType(T::numEdges));
-        
-        
+
+
         // Global variables
         if(buildStaticData == true) {
           globalVTKData::vtkGlobalConnectivity.push_back(vtkElmConnectivity);
           globalVTKData::vtkGlobalCellType.push_back(myVTKData.getPVCellType(T::numEdges));
         }
-        
+
         // Clear existing structure (safer)
         vtkElmConnectivity.clear();
       }
-      
+
       // Increment global node and elm-lev0 number
       myVTKData.incrementTotNod(numNodInsert);
       myVTKData.incrementTotElmLev0(1);
-      
+
       // Write the VTK data structure of the consider element to vtu file
-      
+
       if(writeVTK == true) {
         myVTKData.writeVTKElmData();
       }
-      
+
       if(buildStaticData == true) {
-        
+
         for(int i=0;i<numNodInsert; i++) {
           globalVTKData::vtkGlobalCoords.push_back(myVTKData.vtkLocalCoords[i]);
         }
-        
+
         for(int i=0;i<numNodInsert; i++) {
           globalVTKData::vtkGlobalValues.push_back(myVTKData.vtkLocalValues[i]);
         }
@@ -2561,7 +2578,7 @@ void adaptiveElements<T>::addInViewForVTK(int step,
 
     } // loop over mesh element
   }
-  
+
 }
 
 template <class T>
@@ -2583,29 +2600,29 @@ int adaptiveData::countTotElmLev0(int step, PViewData *in)
 {
 
   int sumElm = 0;
-  
+
   if(_triangles) sumElm+=_triangles->countElmLev0(step, in);
   if(_quadrangles) sumElm+=_quadrangles->countElmLev0(step, in);
   if(_tetrahedra) sumElm+=_tetrahedra->countElmLev0(step, in);
   if(_prisms) sumElm+=_prisms->countElmLev0(step, in);
   if(_hexahedra) sumElm+=_hexahedra->countElmLev0(step, in);
   if(_pyramids)  sumElm+=_pyramids->countElmLev0(step, in);
-  
+
   return sumElm;
 }
 
 
-void adaptiveData::changeResolutionForVTK(int step, int level, double tol, int npart, bool isBinary, 
+void adaptiveData::changeResolutionForVTK(int step, int level, double tol, int npart, bool isBinary,
                                           const std::string &guiFileName, int useDefaultName)
 {
   //clean global VTK data structure before (re)generating it
   if(buildStaticData == true) globalVTKData::clearGlobalData();
-    
-  VTKData myVTKData(_inData->getName(), _inData->getNumComponents(0, 0, 0), 
+
+  VTKData myVTKData(_inData->getName(), _inData->getNumComponents(0, 0, 0),
                     step, level, tol, guiFileName, useDefaultName, npart, isBinary);
   myVTKData.vtkTotNumElmLev0 = countTotElmLev0(step, _inData);
-  myVTKData.setFileDistribution();  
-  
+  myVTKData.setFileDistribution();
+
   // Views of 2D and 3D elements only supported for VTK. _points and _lines are currently ignored.
   if(_triangles) _triangles->init(myVTKData.vtkLevel);
   if(_quadrangles) _quadrangles->init(myVTKData.vtkLevel);
@@ -2613,13 +2630,13 @@ void adaptiveData::changeResolutionForVTK(int step, int level, double tol, int n
   if(_prisms) _prisms->init(myVTKData.vtkLevel);
   if(_hexahedra) _hexahedra->init(myVTKData.vtkLevel);
   if(_pyramids)  _pyramids->init(myVTKData.vtkLevel);
-  
+
   if(_triangles) _triangles->addInViewForVTK(step, _inData, myVTKData, writeVTK, buildStaticData);
   if(_quadrangles) _quadrangles->addInViewForVTK(step, _inData, myVTKData, writeVTK, buildStaticData);
   if(_tetrahedra) _tetrahedra->addInViewForVTK(step, _inData, myVTKData, writeVTK, buildStaticData);
   if(_prisms) _prisms->addInViewForVTK(step, _inData, myVTKData, writeVTK, buildStaticData);
   if(_hexahedra) _hexahedra->addInViewForVTK(step, _inData, myVTKData, writeVTK, buildStaticData);
   if(_pyramids) _pyramids->addInViewForVTK(step, _inData, myVTKData, writeVTK, buildStaticData);
-  
+
   Msg::StatusBar(true,"Done writing VTK data");
 }
diff --git a/Post/adaptiveData.h b/Post/adaptiveData.h
index 80a3399a92efb66d1861c760fc5aebb288b36889..53bb6c52f27afc5dd5958458df2764c5d2bd4270 100644
--- a/Post/adaptiveData.h
+++ b/Post/adaptiveData.h
@@ -62,14 +62,14 @@ template <class T>
 class nodMap {
 public:
   std::vector<int> mapping;
-  
+
 public:
   void cleanMapping()
-  { 
-    mapping.clear(); 
+  {
+    mapping.clear();
   }
   ~nodMap()
-  { 
+  {
     cleanMapping();
   }
   int getSize() {return (int) mapping.size();}
@@ -432,7 +432,7 @@ class PValues{
     delete[] v;
   }
   void operator = (const PValues& obj) {
-    // Assume PValues object has already been generated 
+    // Assume PValues object has already been generated
     // and v allocated when the operator = is called
     if(sizev != obj.sizev) Msg::Error("In PValues overlodaing operator: size mistmatch %d %d",sizev);
     for(int i=0;i<sizev;i++) {
@@ -443,44 +443,44 @@ class PValues{
 
 class globalVTKData {
  public:
-  
+
   static std::vector<vectInt> vtkGlobalConnectivity; // conectivity (vector of vector)
   static std::vector<int> vtkGlobalCellType; // topology
   static std::vector<PCoords> vtkGlobalCoords; // coordinates
   static std::vector<PValues> vtkGlobalValues; // nodal values (either scalar or vector)
 
   globalVTKData();
-  
+
   static void clearGlobalConnectivity() {
     for(std::vector<vectInt>::iterator it = vtkGlobalConnectivity.begin();it != vtkGlobalConnectivity.end(); ++it) {
       it->clear();
     }
     vtkGlobalConnectivity.clear();
   }
-  
+
   static void clearGlobalCellType() {
     vtkGlobalCellType.clear();
-  }  
-  
+  }
+
   static void clearGlobalCoords() {
     vtkGlobalCoords.clear();
-  } 
-  
+  }
+
   static void clearGlobalValues() {
     vtkGlobalValues.clear();
-  } 
-  
-  static void clearGlobalData() {     
+  }
+
+  static void clearGlobalData() {
     clearGlobalConnectivity();
     clearGlobalCellType();
     clearGlobalCoords();
     clearGlobalValues();
   }
-  
+
   ~globalVTKData() {
     clearGlobalData();
   }
-  
+
 };
 
 class VTKData {
@@ -491,13 +491,13 @@ class VTKData {
   std::string vtkFileName;
   std::string vtkFormat;
   std::string vtkDirName;
-  
+
   int vtkStep;
   int vtkLevel;
   int vtkNumComp;
   double vtkTol;
   int vtkNpart;
-  
+
   bool vtkIsBinary;
   int vtkUseDefaultName;
   int minElmPerPart, maxElmPerPart, numPartMinElm, numPartMaxElm;
@@ -510,17 +510,17 @@ class VTKData {
   FILE *vtkFileCellType;
   FILE *vtkFileNodVal;
   int vtkCountFile;
-  
+
   int vtkTotNumElmLev0;
   int vtkCountTotElmLev0;
   int vtkCountTotNod;
-  int vtkCountTotElm;  
+  int vtkCountTotElm;
   int vtkCountCoord;
   int vtkCountTotNodConnect;
   int vtkCountTotVal;
   int vtkCountCellOffset; //used only for ascii output
   int vtkCountCellType;  //used only for ascii output
-  
+
   std::vector<vectInt> vtkLocalConnectivity; // conectivity (vector of vector)
   std::vector<int> vtkLocalCellType; // topology
   std::vector<PCoords> vtkLocalCoords; // coordinates
@@ -530,10 +530,10 @@ class VTKData {
 public:
   VTKData(std::string fieldName="unknown", int numComp = -1, int step = -1, int level = -1, double tol=0.0,
           std::string filename="unknown", int useDefaultName = 1, int npart = -1, bool isBinary = true) {
-    
+
     vtkIsBinary = isBinary;                    // choice: true, false
-    vtkFormat = std::string("vtu");      // choice: vtk (VTK legacy), vtu (XML appended)     
-    
+    vtkFormat = std::string("vtu");      // choice: vtk (VTK legacy), vtu (XML appended)
+
     vtkFieldName = fieldName;
     vtkFileName = filename;
     vtkUseDefaultName = useDefaultName;
@@ -542,19 +542,19 @@ public:
     vtkLevel = level;
     vtkTol = tol;
     vtkNpart = npart;
-    
+
     vtkCountFile = 0;
     vtkTotNumElmLev0 = 0;
     vtkCountTotElmLev0 = 0;
     vtkCountTotNod = 0;
-    vtkCountTotElm = 0;  
+    vtkCountTotElm = 0;
     vtkCountCoord = 0;
     vtkCountTotNodConnect = 0;
     vtkCountTotVal = 0;
     vtkCountCellOffset = 0; //used only for ascii output
     vtkCountCellType = 0;
   }
-  
+
   void clearLocalData()
   {
     for(std::vector<vectInt>::iterator it = vtkLocalConnectivity.begin();it != vtkLocalConnectivity.end(); ++it) {
@@ -565,7 +565,7 @@ public:
     vtkLocalCoords.clear();
     vtkLocalValues.clear();
   }
-  
+
   ~VTKData()
   {
     clearLocalData();
@@ -574,10 +574,10 @@ public:
   void incrementTotNod(int increment) {vtkCountTotNod+=increment;}
   void incrementTotElm(int increment) {vtkCountTotElm+=increment;}
   void incrementTotElmLev0(int increment) {vtkCountTotElmLev0+=increment;}
-  
+
   bool isLittleEndian();
   void SwapArrayByteOrder(void* array, int nbytes, int nItems); // used only for VTK
-  int getPVCellType(int numEdges); 
+  int getPVCellType(int numEdges);
 //   void writeParaViewData();
   void writeVTKElmData();
   void initVTKFile();
@@ -586,12 +586,12 @@ public:
     int tmpmod = vtkTotNumElmLev0 % vtkNpart;
     minElmPerPart = (vtkTotNumElmLev0-tmpmod)/vtkNpart;
     numPartMinElm = vtkNpart - tmpmod;
-    
+
     if(tmpmod == 0 ) maxElmPerPart = minElmPerPart;
     else maxElmPerPart = minElmPerPart+1;
     numPartMaxElm = tmpmod;
     assert(vtkTotNumElmLev0 == minElmPerPart*numPartMinElm+maxElmPerPart*numPartMaxElm);
-    
+
   }
 };
 
@@ -617,24 +617,24 @@ class adaptiveElements {
   // switch to true on-the-fly local refinement in drawPost())
   void addInView(double tol, int step, PViewData *in, PViewDataList *out,
                  GMSH_PostPlugin *plug=0);
-  
-  // michel.rasquin@cenaero.be:
-  // Routines for 
-  // - export of adapted views to pvtu file format for parallel visualization with paraview,
+
+  // Routines for
+  // - export of adapted views to pvtu file format for parallel visualization
+  //   with paraview,
   // - and/or generation of VTK data structure for ParaView plugin.
-  
+
   // Clone of adapt for VTK output files
   void adaptForVTK(double tol, int numComp,
                    std::vector<PCoords> &coords, std::vector<PValues> &values);
-  
+
   // Clone of addInView for VTK output files
-  void addInViewForVTK(int step, PViewData *in, VTKData &myVTKData, 
+  void addInViewForVTK(int step, PViewData *in, VTKData &myVTKData,
                        bool writeVtk=true, bool buildStaticData=false);
-  
+
   int countElmLev0(int step, PViewData *in);
-  
-  // Build a mapping between all the nodes of the refined element 
-  // and the node of the canonical refined element in order to 
+
+  // Build a mapping between all the nodes of the refined element
+  // and the node of the canonical refined element in order to
   // generate a connectivity related to the canonical element
   void buildMapping(nodMap<T> &myNodMap, double tol, int &numNodInsert);
 };
@@ -659,14 +659,14 @@ class adaptiveData {
   // Usefull  when GMSH is used as an external library to provide for instance a GMSH reader in a ParaView plugin.
   // By default, set to false in the constructor.
   bool buildStaticData;
-  
-  // This variable helps limit memory consumption (no global data structure) when GMSH is requested to 
+
+  // This variable helps limit memory consumption (no global data structure) when GMSH is requested to
   // write the data structure of adapted view under pvtu format
-  // In this case, one adapted element is considered at a time so that it can generate 
+  // In this case, one adapted element is considered at a time so that it can generate
   // billions of adapted elements on a single core, as long as disk space allows it.
   // This variable is set to true by default in the constructor.
   bool writeVTK;
-  
+
  public:
   static double timerInit, timerAdapt;
   adaptiveData(PViewData *data, bool outDataInit=true);
@@ -674,11 +674,11 @@ class adaptiveData {
   PViewData *getData(){ return (PViewData*)_outData; }
   void changeResolution(int step, int level, double tol, GMSH_PostPlugin *plug=0);
   int countTotElmLev0(int step, PViewData *in);
-  void changeResolutionForVTK(int step, int level, double tol, int npart = 1, bool isBinary = true, 
+  void changeResolutionForVTK(int step, int level, double tol, int npart = 1, bool isBinary = true,
                               const std::string &guifileName = "unknown", int useDefaultName = 1);
   void upBuildStaticData(bool newValue) { buildStaticData = newValue; }
   void upWriteVTK(bool newValue) { writeVTK = newValue; }
-  
+
 };
 
 #endif
diff --git a/contrib/mobile/utils/ios_build.sh b/contrib/mobile/utils/ios_build.sh
index 6799ee2c2a915d840b3cfbed9255986834dd09cc..1673a17b8d463a3a7fb89ad8de7ed51ae4f88130 100755
--- a/contrib/mobile/utils/ios_build.sh
+++ b/contrib/mobile/utils/ios_build.sh
@@ -13,7 +13,7 @@ frameworks_dir="${HOME}/src/gmsh/contrib/mobile/frameworks_ios/"
 petsc_framework="$frameworks_dir/petsc.framework"
 slepc_framework="$frameworks_dir/slepc.framework"
 
-cmake_default="-DDEFAULT=0 -DCMAKE_TOOLCHAIN_FILE=$gmsh_svn/contrib/mobile/utils/iOS.cmake -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -GXcode"
+cmake_default="-DDEFAULT=0 -DCMAKE_TOOLCHAIN_FILE=$gmsh_svn/contrib/mobile/utils/iOS.cmake -DIOS_PLATFORM=OS -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -GXcode"
 
 build_cmd="xcodebuild -verbose -target lib -configuration Release"
 headers_cmd="xcodebuild -verbose -target get_headers -configuration Release"