diff --git a/Common/Makefile b/Common/Makefile
index 5cf7ac0efca3673b87f0ff02a34e92c2d2dca5e3..59a2c9a29f3ca81ebe483637d315ce2e57f5337f 100644
--- a/Common/Makefile
+++ b/Common/Makefile
@@ -108,11 +108,9 @@ Gmsh.o: Gmsh.cpp GmshDefines.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Common/avl.h ../Common/ListUtils.h ../Geo/SPoint2.h \
   ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Post/PView.h Context.h \
   ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h ../Mesh/Partition.h \
-  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Common/Message.h ../Mesh/PartitionOptions.h \
   ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Options.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h
+  ../Common/Message.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h
 OS.o: OS.cpp Message.h
 OpenFile.o: OpenFile.cpp Message.h ../Geo/Geo.h ../Common/GmshDefines.h \
   ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp
index 69eda7a8cb9db0a20b86b89cda0ae067afaf7c73..c56eae50b16d27fca67f0a9985574c01c27c040b 100644
--- a/Common/StringUtils.cpp
+++ b/Common/StringUtils.cpp
@@ -60,12 +60,14 @@ std::string SanitizeTeXString(const char *in, int equation)
   return out;
 }
 
-void FixWindowsPath(const char *in, char *out)
+std::string FixWindowsPath(const char *in)
 {
 #if defined(__CYGWIN__)
-  cygwin_conv_to_win32_path(in, out);
+  char tmp[1024];
+  cygwin_conv_to_win32_path(in, tmp);
+  return std::string(tmp);
 #else
-  strcpy(out, in);
+  return std::string(in);
 #endif
 }
 
diff --git a/Common/StringUtils.h b/Common/StringUtils.h
index 3c9b56d4c962872e781f68e8debb6f82b8e459c3..3485bfb9da1610378d63bd576fa111abf9d30cda 100644
--- a/Common/StringUtils.h
+++ b/Common/StringUtils.h
@@ -12,7 +12,7 @@
 void SwapBytes(char *array, int size, int n);
 std::string ExtractDoubleQuotedString(const char *str, int len);
 std::string SanitizeTeXString(const char *in, int equation);
-void FixWindowsPath(const char *in, char *out);
+std::string FixWindowsPath(const char *in);
 void SplitFileName(const char *name, char *no_ext, char *ext, char *base);
 
 #endif
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index b304efbe38d596557e94fc35159c9d68b96e0c9e..c89f76d6ed5428472259bb9dd5029bdc5f774ec8 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -2572,25 +2572,25 @@ void _replace_multi_format(const char *in, const char *val, char *out)
 
 void help_online_cb(CALLBACK_ARGS)
 {
-  char prog[1024], cmd[1024];
-  FixWindowsPath(CTX.web_browser, prog);
-  _replace_multi_format(prog, "http://www.geuz.org/gmsh/doc/texinfo/", cmd);
+  std::string prog = FixWindowsPath(CTX.web_browser);
+  char cmd[1024];
+  _replace_multi_format(prog.c_str(), "http://geuz.org/gmsh/doc/texinfo/", cmd);
   SystemCall(cmd);
 }
 
 void help_license_cb(CALLBACK_ARGS)
 {
-  char prog[1024], cmd[1024];
-  FixWindowsPath(CTX.web_browser, prog);
-  _replace_multi_format(prog, "http://www.geuz.org/gmsh/doc/LICENSE.txt", cmd);
+  std::string prog = FixWindowsPath(CTX.web_browser);
+  char cmd[1024];
+  _replace_multi_format(prog.c_str(), "http://geuz.org/gmsh/doc/LICENSE.txt", cmd);
   SystemCall(cmd);
 }
 
 void help_credits_cb(CALLBACK_ARGS)
 {
-  char prog[1024], cmd[1024];
-  FixWindowsPath(CTX.web_browser, prog);
-  _replace_multi_format(prog, "http://www.geuz.org/gmsh/doc/CREDITS.txt", cmd);
+  std::string prog = FixWindowsPath(CTX.web_browser);
+  char cmd[1024];
+  _replace_multi_format(prog.c_str(), "http://geuz.org/gmsh/doc/CREDITS.txt", cmd);
   SystemCall(cmd);
 }
 
@@ -2645,10 +2645,10 @@ void geometry_physical_cb(CALLBACK_ARGS)
 
 void geometry_edit_cb(CALLBACK_ARGS)
 {
-  char prog[1024], file[1024], cmd[1024];
-  FixWindowsPath(CTX.editor, prog);
-  FixWindowsPath(CTX.filename, file);
-  _replace_multi_format(prog, file, cmd);
+  std::string prog = FixWindowsPath(CTX.editor);
+  std::string file = FixWindowsPath(CTX.filename);
+  char cmd[1024];
+  _replace_multi_format(prog.c_str(), file.c_str(), cmd);
   SystemCall(cmd);
 }
 
@@ -3952,11 +3952,11 @@ void solver_cb(CALLBACK_ARGS)
     WID->solver[num].input[0]->value(file);
   }
   if(SINFO[num].nboptions) {
-    char file[256], tmp[256];
-    FixWindowsPath(WID->solver[num].input[0]->value(), file);
-    sprintf(tmp, "\"%s\"", file);
-    sprintf(file, SINFO[num].name_command, tmp);
-    sprintf(tmp, "%s %s", SINFO[num].option_command, file);           
+    std::string file = FixWindowsPath(WID->solver[num].input[0]->value());
+    char tmp[256], tmp2[256];
+    sprintf(tmp, "\"%s\"", file.c_str());
+    sprintf(tmp2, SINFO[num].name_command, tmp);
+    sprintf(tmp, "%s %s", SINFO[num].option_command, tmp2);
     Solver(num, tmp);
   }
   WID->create_solver_window(num);
@@ -3964,7 +3964,7 @@ void solver_cb(CALLBACK_ARGS)
 
 void solver_file_open_cb(CALLBACK_ARGS)
 {
-  char tmp[256];
+  char tmp[256], tmp2[256];
   int num = (int)(long)data;
   sprintf(tmp, "*%s", SINFO[num].extension);
 
@@ -3973,11 +3973,10 @@ void solver_file_open_cb(CALLBACK_ARGS)
   if(file_chooser(0, 0, "Choose", tmp)) {
     WID->solver[num].input[0]->value(file_chooser_get_name(1).c_str());
     if(SINFO[num].nboptions) {
-      char file[1024];
-      FixWindowsPath(file_chooser_get_name(1).c_str(), file);
-      sprintf(tmp, "\"%s\"", file);
-      sprintf(file, SINFO[num].name_command, tmp);
-      sprintf(tmp, "%s %s", SINFO[num].option_command, file);
+      std::string file = FixWindowsPath(file_chooser_get_name(1).c_str());
+      sprintf(tmp, "\"%s\"", file.c_str());
+      sprintf(tmp2, SINFO[num].name_command, tmp);
+      sprintf(tmp, "%s %s", SINFO[num].option_command, tmp2);
       Solver(num, tmp);
     }
   }
@@ -3985,11 +3984,11 @@ void solver_file_open_cb(CALLBACK_ARGS)
 
 void solver_file_edit_cb(CALLBACK_ARGS)
 {
-  char prog[1024], file[1024], cmd[1024];
   int num = (int)(long)data;
-  FixWindowsPath(CTX.editor, prog);
-  FixWindowsPath(WID->solver[num].input[0]->value(), file);
-  _replace_multi_format(prog, file, cmd);
+  std::string prog = FixWindowsPath(CTX.editor);
+  std::string file = FixWindowsPath(WID->solver[num].input[0]->value());
+  char cmd[1024];
+  _replace_multi_format(prog.c_str(), file.c_str(), cmd);
   SystemCall(cmd);
 }
 
@@ -4014,7 +4013,7 @@ int nbs(char *str)
 
 void solver_command_cb(CALLBACK_ARGS)
 {
-  char tmp[256], arg[512], mesh[256], command[256];
+  char tmp[256], mesh[256], arg[512], command[256];
   int num = ((int *)data)[0];
   int idx = ((int *)data)[1];
   int i, usedopts = 0;
@@ -4023,8 +4022,8 @@ void solver_command_cb(CALLBACK_ARGS)
     WID->create_message_window(true);
 
   if(strlen(WID->solver[num].input[1]->value())) {
-    FixWindowsPath(WID->solver[num].input[1]->value(), mesh);
-    sprintf(tmp, "\"%s\"", mesh);
+    std::string m = FixWindowsPath(WID->solver[num].input[1]->value());
+    sprintf(tmp, "\"%s\"", m.c_str());
     sprintf(mesh, SINFO[num].mesh_command, tmp);
   }
   else {
@@ -4045,8 +4044,8 @@ void solver_command_cb(CALLBACK_ARGS)
     strcpy(command, SINFO[num].button_command[idx]);
   }
 
-  FixWindowsPath(WID->solver[num].input[0]->value(), tmp);
-  sprintf(arg, "\"%s\"", tmp);
+  std::string c = FixWindowsPath(WID->solver[num].input[0]->value());
+  sprintf(arg, "\"%s\"", c.c_str());
   sprintf(tmp, SINFO[num].name_command, arg);
   sprintf(arg, "%s %s %s", tmp, mesh, command);
   Solver(num, arg);
diff --git a/Fltk/GmshServer.h b/Fltk/GmshServer.h
index eaf771b41c2457c20256c7435d09b116c12f09b3..87eef0e5c7ddd1d62d398243cd2275ba27abf97d 100644
--- a/Fltk/GmshServer.h
+++ b/Fltk/GmshServer.h
@@ -66,7 +66,7 @@ class GmshServer {
 
  private:
   int _maxdelay, _portno, _sock;
-  char *_sockname;
+  const char *_sockname;
   int _ReceiveData(void *buffer, int bytes)
   {
     char *buf = (char *)buffer;
@@ -119,7 +119,7 @@ class GmshServer {
   GmshServer(int maxdelay = 4)
     : _maxdelay(maxdelay), _portno(-1), _sock(0), _sockname(NULL) {}
   ~GmshServer(){}
-  int StartClient(char *command, char *sockname = NULL)
+  int StartClient(const char *command, const char *sockname = NULL)
   {
     int justwait = 0;
 
diff --git a/Fltk/Makefile b/Fltk/Makefile
index 5e947dc6f3143fe3e2a9c930aa0552b2769b05d3..d0336243e738f935a466ec9225bcc88ccae4d150 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -118,10 +118,7 @@ GUI_Extras.o: GUI_Extras.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
   ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Mesh/Partition.h ../Geo/MElement.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Message.h ../Mesh/PartitionOptions.h File_Picker.h
+  ../Geo/SBoundingBox3d.h ../Mesh/Partition.h File_Picker.h
 GUI_Projection.o: GUI_Projection.cpp ../Geo/GModelIO_Fourier.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
diff --git a/Fltk/Solvers.cpp b/Fltk/Solvers.cpp
index 6ab3f7800c420a861b5da2503096d4dcad5a1bfe..3b884081e55d19a7f47347d53f7c80bc45d72849 100644
--- a/Fltk/Solvers.cpp
+++ b/Fltk/Solvers.cpp
@@ -4,6 +4,7 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include <string.h>
+#include <string>
 #include "Message.h"
 #include "StringUtils.h"
 #include "Solvers.h"
@@ -64,20 +65,20 @@ int WaitForData(int socket, int num, double waitint)
 
 int Solver(int num, const char *args)
 {
-  char command[1024], sockname[1024], prog[1024], tmp[1024], tmp2[1024];
+  std::string command, sockname, prog;
 
  new_connection:
 
   GmshServer server(CTX.solver.max_delay);
 
   if(num >= 0){
-    FixWindowsPath(SINFO[num].executable_name, prog);
+    prog = FixWindowsPath(SINFO[num].executable_name);
     if(!SINFO[num].client_server) {
-      sprintf(command, "%s %s", prog, args);
+      command = prog + " " + args;
 #if !defined(WIN32)
-      strcat(command, " &");
+      command += " &";
 #endif
-      server.StartClient(command);
+      server.StartClient(command.c_str());
       return 1;
     }
   }
@@ -87,51 +88,52 @@ int Solver(int num, const char *args)
       return 0;
     }
     // we don't know who will (maybe) contact us
-    strcpy(prog, "");
-    strcpy(command, "");
+    prog = command = "";
   }
 
   if(!strstr(CTX.solver.socket_name, ":")){
     // Unix socket
+    char tmp[1024];
     if(num >= 0)
       sprintf(tmp, "%s%s-%d", CTX.home_dir, CTX.solver.socket_name, num);
     else
       sprintf(tmp, "%s%s", CTX.home_dir, CTX.solver.socket_name);
-    FixWindowsPath(tmp, sockname);
+    sockname = FixWindowsPath(tmp);
   }
   else{
     // TCP/IP socket
-    strcpy(sockname, CTX.solver.socket_name);
+    sockname = CTX.solver.socket_name;
   }
 
   if(num >= 0){
-    sprintf(tmp, "\"%s\"", sockname);
-    sprintf(tmp2, SINFO[num].socket_command, tmp);
-    sprintf(command, "%s %s %s", prog, args, tmp2);
+    std::string tmp2 = "\"" + sockname + "\"";
+    char tmp[1024];
+    sprintf(tmp, SINFO[num].socket_command, tmp2.c_str());
+    command = prog + " " + args + " " + tmp;
 #if !defined(WIN32)
-    strcat(command, " &");
+    command += " &";
 #endif
   }
 
-  int sock = server.StartClient(command, sockname);
+  int sock = server.StartClient(command.c_str(), sockname.c_str());
 
   if(sock < 0) {
     switch (sock) {
     case -1:
-      Msg::Error("Couldn't create socket '%s'", sockname);
+      Msg::Error("Couldn't create socket '%s'", sockname.c_str());
       break;
     case -2:
-      Msg::Error("Couldn't bind socket to name '%s'", sockname);
+      Msg::Error("Couldn't bind socket to name '%s'", sockname.c_str());
       break;
     case -3:
-      Msg::Error("Socket listen failed on '%s'", sockname);
+      Msg::Error("Socket listen failed on '%s'", sockname.c_str());
       break;
     case -4:
-      Msg::Error("Socket listen timeout on '%s'", sockname);
-      Msg::Error("Is '%s' correctly installed?", prog);
+      Msg::Error("Socket listen timeout on '%s'", sockname.c_str());
+      Msg::Error("Is '%s' correctly installed?", prog.c_str());
       break;
     case -5:
-      Msg::Error("Socket accept failed on '%s'", sockname);
+      Msg::Error("Socket accept failed on '%s'", sockname.c_str());
       break;
     case -6:
       Msg::Info("Stopped listening for solver connections");
@@ -158,7 +160,7 @@ int Solver(int num, const char *args)
     SINFO[num].pid = 0;
   }
 
-  Msg::StatusBar(2, false, "Running '%s'", prog);
+  Msg::StatusBar(2, false, "Running '%s'", prog.c_str());
 
   while(1) {
 
@@ -266,7 +268,7 @@ int Solver(int num, const char *args)
   }
 
   if(server.StopClient() < 0)
-    Msg::Warning("Impossible to unlink the socket '%s'", sockname);
+    Msg::Warning("Impossible to unlink the socket '%s'", sockname.c_str());
 
   if(num >= 0){
     Msg::StatusBar(2, false, "");
diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp
index 9ea375feecad35a8cf7106d5b211fa898e372412..669550613f86ff6f768522d1f3c659f4b9ddbd7a 100644
--- a/Geo/GeoStringInterface.cpp
+++ b/Geo/GeoStringInterface.cpp
@@ -7,7 +7,6 @@
 #include <sstream>
 #include "Message.h"
 #include "Numeric.h"
-#include "MallocUtils.h"
 #include "StringUtils.h"
 #include "Geo.h"
 #include "GeoStringInterface.h"
diff --git a/Geo/Makefile b/Geo/Makefile
index 1e7b82862521120840196851cc2f442f048d04c9..9d272c1b8a4eb708b9d5a5cf6956f7989c60c89e 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -242,14 +242,14 @@ Geo.o: Geo.cpp ../Common/Message.h ../Numeric/Numeric.h \
   ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h
 GeoStringInterface.o: GeoStringInterface.cpp ../Common/Message.h \
   ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
-  ../Common/MallocUtils.h ../Common/StringUtils.h Geo.h \
-  ../Common/GmshDefines.h gmshSurface.h Pair.h Range.h SPoint2.h \
-  SPoint3.h SVector3.h SBoundingBox3d.h ../Common/ListUtils.h \
-  ../Common/TreeUtils.h ../Common/avl.h ../Common/ListUtils.h \
-  ExtrudeParams.h ../Common/SmoothData.h GeoStringInterface.h \
-  ../Common/OpenFile.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/PartitionOptions.h GModel.h GVertex.h GEntity.h GPoint.h \
-  GEdge.h GFace.h GEdgeLoop.h GRegion.h ../Parser/Parser.h
+  ../Common/StringUtils.h Geo.h ../Common/GmshDefines.h gmshSurface.h \
+  Pair.h Range.h SPoint2.h SPoint3.h SVector3.h SBoundingBox3d.h \
+  ../Common/ListUtils.h ../Common/TreeUtils.h ../Common/avl.h \
+  ../Common/ListUtils.h ExtrudeParams.h ../Common/SmoothData.h \
+  GeoStringInterface.h ../Common/OpenFile.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/PartitionOptions.h GModel.h GVertex.h \
+  GEntity.h GPoint.h GEdge.h GFace.h GEdgeLoop.h GRegion.h \
+  ../Parser/Parser.h
 GeoInterpolation.o: GeoInterpolation.cpp ../Common/Message.h Geo.h \
   ../Common/GmshDefines.h gmshSurface.h Pair.h Range.h SPoint2.h \
   SPoint3.h SVector3.h SBoundingBox3d.h ../Numeric/Numeric.h \
diff --git a/Mesh/Makefile b/Mesh/Makefile
index 9d5bfb0aa472fc9c833f0f72327c96a84c74feeb..0566d605466c6ca2ea7c7891f76e4cb32b73a961 100644
--- a/Mesh/Makefile
+++ b/Mesh/Makefile
@@ -391,16 +391,4 @@ HighOrder.o: HighOrder.cpp HighOrder.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Numeric/NumericEmbedded.h ../Common/Context.h ../Geo/CGNSOptions.h \
   ../Mesh/PartitionOptions.h ../Common/GmshMatrix.h \
   ../Numeric/FunctionSpace.h
-Partition.o: Partition.cpp ../Geo/ElementTraits.h ../Geo/MElement.h \
-  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/GFace.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h \
-  ../Geo/GRegion.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h Partition.h \
-  ../Common/Message.h PartitionOptions.h
+Partition.o: Partition.cpp