diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6d11116d7ce06d8548e5c99bc117bd5a0b51c35..43021af00d3f70ec5fd91b8d6285fced0641af14 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,6 +46,7 @@ opt(CAIRO "Enable Cairo to render fonts (experimental)" ${DEFAULT})
 opt(CHACO "Enable Chaco mesh partitioner (alternative to Metis)" ${DEFAULT})
 opt(COMPRESSED_IO "Enable compressed (gzip) input/output using zlib" OFF)
 opt(CXX11 "Enable C++11" ${DEFAULT})
+opt(DEPRECATED_API "Enable deprecated internal developer API" ON)
 opt(DINTEGRATION "Enable discrete integration (needed for levelsets)" ${DEFAULT})
 opt(FLTK "Enable FLTK graphical user interface (requires mesh/post)" ${DEFAULT})
 opt(FOURIER_MODEL "Enable Fourier geometrical models (experimental)" OFF)
@@ -88,8 +89,8 @@ opt(TAUCS "Enable Taucs linear solver" ${DEFAULT})
 opt(TCMALLOC "Enable libtcmalloc, a fast malloc implementation but that does not release memory" OFF)
 opt(TETGEN "Enable Tetgen 3D initial mesh generator" ${DEFAULT})
 opt(VORO3D "Enable Voro3D (for hex meshing, experimental)" ${DEFAULT})
-opt(WRAP_JAVA_DEPRECATED "Enable generation of Java wrappers (deprecated)" OFF)
-opt(WRAP_PYTHON_DEPRECATED "Enable generation of Python wrappers (deprecated)" OFF)
+opt(WRAP_JAVA "Enable generation of Java wrappers" OFF)
+opt(WRAP_PYTHON "Enable generation of Python wrappers" OFF)
 opt(ZIPPER "Enable Zip file compression/decompression" OFF)
 
 set(GMSH_MAJOR_VERSION 3)
@@ -101,15 +102,12 @@ set(GMSH_VERSION "${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}")
 set(GMSH_VERSION "${GMSH_VERSION}.${GMSH_PATCH_VERSION}${GMSH_EXTRA_VERSION}")
 set(GMSH_SHORT_LICENSE "GNU General Public License")
 
-set(GMSH_API
-  ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h
-  ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h
-  Common/GmshAPI.h)
+set(GMSH_API Common/gmsh.h)
 
-set(GMSH_API_DEPRECATED
+set(GMSH_DEPRECATED_API
   ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshConfig.h
   ${CMAKE_CURRENT_BINARY_DIR}/Common/GmshVersion.h
-  Common/Gmsh.h Common/Context.h Common/GmshDefines.h Common/GmshMessage.h
+  Common/GmshGlobal.h Common/Context.h Common/GmshDefines.h Common/GmshMessage.h
     Common/VertexArray.h Common/Octree.h Common/OctreeInternals.h
     Common/OS.h Common/StringUtils.h Common/OpenFile.h Common/Hash.h
     Common/onelab.h Common/GmshSocket.h Common/onelabUtils.h Common/Options.h
@@ -126,7 +124,7 @@ set(GMSH_API_DEPRECATED
     Geo/MEdgeHash.h Geo/MFaceHash.h
     Geo/MElement.h Geo/MElementOctree.h Geo/MPoint.h Geo/MLine.h
     Geo/MTriangle.h Geo/MQuadrangle.h Geo/MTetrahedron.h Geo/MHexahedron.h
-    Geo/MPrism.h Geo/MPyramid.h Geo/MTrihedron.h Geo/MElementCut.h Geo/MElementOctree.h
+    Geo/MPrism.h Geo/MPyramid.h Geo/MTrihedron.h Geo/MElementCut.h
     Geo/discreteVertex.h Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h
     Geo/SPoint2.h Geo/SPoint3.h Geo/SVector3.h Geo/STensor3.h Geo/SBoundingBox3d.h
     Geo/Pair.h Geo/Range.h Geo/SOrientedBoundingBox.h
@@ -236,9 +234,9 @@ if(NOT APPLE)
   endif(HAVE_64BIT_SIZE_T)
 endif(NOT APPLE)
 
-if(ENABLE_WRAP_PYTHON_DEPRECATED AND NOT ENABLE_BUILD_SHARED)
+if(ENABLE_WRAP_PYTHON AND NOT ENABLE_BUILD_SHARED)
   set(ENABLE_BUILD_DYNAMIC ON)
-endif(ENABLE_WRAP_PYTHON_DEPRECATED AND NOT ENABLE_BUILD_SHARED)
+endif(ENABLE_WRAP_PYTHON AND NOT ENABLE_BUILD_SHARED)
 
 if(MSVC)
   # remove annoying warning about bool/int cast performance
@@ -1248,51 +1246,69 @@ if(ENABLE_ZIPPER)
   endif(HAVE_LIBZ)
 endif(ENABLE_ZIPPER)
 
-if(ENABLE_WRAP_PYTHON_DEPRECATED)
-  find_package(SWIG)
+if(ENABLE_WRAP_PYTHON)
+  find_package(SWIG REQUIRED)
+  include(${SWIG_USE_FILE})
   find_package(PythonLibs)
-  find_package(PythonInterp)# ${PYTHONLIBS_VERSION_STRING} EXACT)
   if(SWIG_FOUND AND PYTHONLIBS_FOUND)
     message(STATUS "Found SWIG version " ${SWIG_VERSION})
-    string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION)
-    if(SWIG_MAJOR_VERSION EQUAL 1)
-      message(WARNING "Python bindings require SWIG >= 2: disabling Python")
-    else(SWIG_MAJOR_VERSION EQUAL 1)
-      set_config_option(HAVE_PYTHON "Python")
-      mark_as_advanced(CLEAR PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
-    endif(SWIG_MAJOR_VERSION EQUAL 1)
+    if(NOT DEPRECATED_API) # new bindings
+      include_directories(${PYTHON_INCLUDE_PATH})
+      include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+      set(CMAKE_SWIG_FLAGS "")
+      set_source_files_properties(Common/gmsh.i PROPERTIES CPLUSPLUS ON)
+      swig_add_module(gmsh python Common/gmsh.i)
+      swig_link_libraries(gmsh ${PYTHON_LIBRARIES} shared)
+      if(APPLE)
+        set_target_properties("_gmsh" PROPERTIES LINK_FLAGS
+                              "-undefined suppress -flat_namespace")
+      endif(APPLE)
+    else(NOT DEPRECATED_API) # old, deprecated internal developer bindings
+      find_package(PythonInterp)
+      string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION)
+      if(SWIG_MAJOR_VERSION EQUAL 1)
+        message(WARNING "Python bindings require SWIG >= 2: disabling Python")
+      else(SWIG_MAJOR_VERSION EQUAL 1)
+        set_config_option(HAVE_PYTHON "Python")
+        mark_as_advanced(CLEAR PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
+        add_subdirectory(wrappers/gmshpy)
+        if(ENABLE_NUMPY)
+          if (NOT NUMPY_INC)
+            EXEC_PROGRAM (${PYTHON_EXECUTABLE}
+              ARGS "-c \"import numpy; print(numpy.get_include())\""
+              OUTPUT_VARIABLE NUMPY_INC
+              RETURN_VALUE NUMPY_NOT_FOUND)
+          endif(NOT NUMPY_INC)
+          if(NUMPY_INC)
+            list(APPEND EXTERNAL_INCLUDES ${NUMPY_INC})
+            set_config_option(HAVE_NUMPY "Numpy")
+          endif(NUMPY_INC)
+        endif(ENABLE_NUMPY)
+        if(HAVE_PETSC)
+          if(ENABLE_PETSC4PY)
+            EXECUTE_PROCESS(
+              COMMAND ${PYTHON_EXECUTABLE} -c "import petsc4py; print(petsc4py.get_include())"
+              OUTPUT_VARIABLE PETSC4PY_INC
+              RESULT_VARIABLE PETSC4PY_NOT_FOUND
+              ERROR_QUIET
+              OUTPUT_STRIP_TRAILING_WHITESPACE)
+            if(PETSC4PY_INC)
+              list(APPEND EXTERNAL_INCLUDES ${PETSC4PY_INC})
+              set_config_option(HAVE_PETSC4PY "PETSc4py")
+            endif(PETSC4PY_INC)
+          endif(ENABLE_PETSC4PY)
+        endif(HAVE_PETSC)
+      endif(SWIG_MAJOR_VERSION EQUAL 1)
+    endif(NOT DEPRECATED_API)
   endif(SWIG_FOUND AND PYTHONLIBS_FOUND)
-endif(ENABLE_WRAP_PYTHON_DEPRECATED)
-
-if(HAVE_PYTHON)
-  if(ENABLE_NUMPY)
-    if (NOT NUMPY_INC)
-      EXEC_PROGRAM (${PYTHON_EXECUTABLE}
-        ARGS "-c \"import numpy; print(numpy.get_include())\""
-        OUTPUT_VARIABLE NUMPY_INC
-        RETURN_VALUE NUMPY_NOT_FOUND)
-    endif(NOT NUMPY_INC)
-    if(NUMPY_INC)
-      list(APPEND EXTERNAL_INCLUDES ${NUMPY_INC})
-      set_config_option(HAVE_NUMPY "Numpy")
-    endif(NUMPY_INC)
-  endif(ENABLE_NUMPY)
-  if(HAVE_PETSC)
-    if(ENABLE_PETSC4PY)
-      EXECUTE_PROCESS(
-        COMMAND ${PYTHON_EXECUTABLE} -c "import petsc4py; print(petsc4py.get_include())"
-        OUTPUT_VARIABLE PETSC4PY_INC
-        RESULT_VARIABLE PETSC4PY_NOT_FOUND
-        ERROR_QUIET
-        OUTPUT_STRIP_TRAILING_WHITESPACE
-      )
-      if(PETSC4PY_INC)
-        list(APPEND EXTERNAL_INCLUDES ${PETSC4PY_INC})
-        set_config_option(HAVE_PETSC4PY "PETSc4py")
-      endif(PETSC4PY_INC)
-    endif(ENABLE_PETSC4PY)
-  endif(HAVE_PETSC)
-endif(HAVE_PYTHON)
+endif(ENABLE_WRAP_PYTHON)
+
+if(ENABLE_WRAP_JAVA AND DEPRECATED_API)
+  if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+    message(WARNING "Java wrapping samples will not work without BLAS and LAPACK")
+  endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
+  add_subdirectory(wrappers/java)
+endif(ENABLE_WRAP_JAVA AND DEPRECATED_API)
 
 check_function_exists(vsnprintf HAVE_VSNPRINTF)
 if(NOT HAVE_VSNPRINTF AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID)
@@ -1502,7 +1518,7 @@ endforeach(DIR)
 # static library target
 if(ENABLE_BUILD_LIB)
   add_library(lib STATIC ${GMSH_SRC})
-  set_target_properties(lib PROPERTIES OUTPUT_NAME Gmsh)
+  set_target_properties(lib PROPERTIES OUTPUT_NAME gmsh)
   if(MSVC)
     set_target_properties(lib PROPERTIES DEBUG_POSTFIX d)
     if(ENABLE_MSVC_STATIC_RUNTIME)
@@ -1524,17 +1540,17 @@ if(ENABLE_BUILD_ANDROID)
   add_definitions(-DBUILD_ANDROID)
   add_definitions(-DPICOJSON_USE_LOCALE=0)
   add_library(androidGmsh SHARED ${GMSH_SRC})
-  set_target_properties(androidGmsh PROPERTIES OUTPUT_NAME Gmsh)
+  set_target_properties(androidGmsh PROPERTIES OUTPUT_NAME gmsh)
   target_link_libraries(androidGmsh ${EXTERNAL_LIBRARIES} ${LAPACK_LIBRARIES})
   add_custom_command(TARGET androidGmsh POST_BUILD COMMAND
-                     ${CMAKE_STRIP} ${LIBRARY_OUTPUT_PATH}/libGmsh.so)
+                     ${CMAKE_STRIP} ${LIBRARY_OUTPUT_PATH}/libgmsh.so)
 endif(ENABLE_BUILD_ANDROID)
 
 # shared library target
 if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC OR
-   ENABLE_WRAP_PYTHON_DEPRECATED OR ENABLE_WRAP_JAVA_DEPRECATED)
+   ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
   add_library(shared SHARED ${GMSH_SRC})
-  set_target_properties(shared PROPERTIES OUTPUT_NAME Gmsh)
+  set_target_properties(shared PROPERTIES OUTPUT_NAME gmsh)
   set_target_properties(shared PROPERTIES
     VERSION ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}
     SOVERSION ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION})
@@ -1547,7 +1563,7 @@ if(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC OR
   endif(MSVC AND ENABLE_MSVC_STATIC_RUNTIME)
   target_link_libraries(shared ${LINK_LIBRARIES})
 endif(ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC OR
-      ENABLE_WRAP_PYTHON_DEPRECATED OR ENABLE_WRAP_JAVA_DEPRECATED)
+      ENABLE_WRAP_PYTHON OR ENABLE_WRAP_JAVA)
 
 # binary targets
 if(HAVE_FLTK)
@@ -1582,7 +1598,7 @@ if(WIN32 AND NOT MSVC OR CYGWIN)
     set(FLAGS "${FLAGS} -Wl,-Bstatic -lgfortran")
     set_target_properties(gmsh PROPERTIES
       LINK_FLAGS "${FLAGS} -Wl,--enable-auto-import")
-    set(LIBGMSH_DEF "libGmsh-${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.def")
+    set(LIBGMSH_DEF "libgmsh-${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.def")
     # automatically export .def file with all symbols
     set_target_properties(shared PROPERTIES PREFIX "lib"
       LINK_FLAGS "${FLAGS} -Wl,--export-all-symbols,--output-def,${LIBGMSH_DEF}")
@@ -1672,7 +1688,7 @@ if(WIN32 OR CYGWIN)
   endif(ENABLE_OS_SPECIFIC_INSTALL)
   if(CYGWIN)
     unix2dos(GMSH_API)
-    unix2dos(GMSH_API_DEPREATED)
+    unix2dos(GMSH_DEPREATED_API)
     unix2dos(WELCOME_FILE)
     unix2dos(LICENSE_FILE)
     unix2dos(CREDITS_FILE)
@@ -1749,7 +1765,9 @@ if(ENABLE_ONELAB)
 endif(ENABLE_ONELAB)
 if(ENABLE_BUILD_LIB OR ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
   install(FILES ${GMSH_API} DESTINATION ${GMSH_INC})
-  install(FILES ${GMSH_API_DEPRECATED} DESTINATION ${GMSH_INC}/gmsh)
+  if(ENABLE_DEPRECATED_API)
+    install(FILES ${GMSH_DEPRECATED_API} DESTINATION ${GMSH_INC}/gmsh)
+  endif(ENABLE_DEPRECATED_API)
 endif(ENABLE_BUILD_LIB OR ENABLE_BUILD_SHARED OR ENABLE_BUILD_DYNAMIC)
 install(FILES ${WELCOME_FILE} DESTINATION ${GMSH_DOC} RENAME README.txt)
 install(FILES ${LICENSE_FILE} DESTINATION ${GMSH_DOC})
@@ -1773,11 +1791,13 @@ foreach(FILE ${GMSH_API})
     -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 endforeach(FILE)
-foreach(FILE ${GMSH_API_DEPRECATED})
-  add_custom_command(TARGET get_headers POST_BUILD COMMAND ${CMAKE_COMMAND}
-    -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/gmsh/
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-endforeach(FILE)
+if(ENABLE_DEPRECATED_API)
+  foreach(FILE ${GMSH_DEPRECATED_API})
+    add_custom_command(TARGET get_headers POST_BUILD COMMAND ${CMAKE_COMMAND}
+      -E copy_if_different ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Headers/gmsh/
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+  endforeach(FILE)
+endif(ENABLE_DEPRECATED_API)
 
 find_program(MAKEINFO makeinfo)
 if(MAKEINFO)
@@ -1835,24 +1855,26 @@ if(APPLE AND ENABLE_BUILD_LIB)
   get_target_property(LIBNAME lib LOCATION) # depracated
   #set(LIBNAME $<TARGET_FILE:lib>) # FIXME: use this in the future
   add_custom_target(framework DEPENDS lib
-    COMMAND ${CMAKE_COMMAND} -E remove_directory Gmsh.framework
-    COMMAND ${CMAKE_COMMAND} -E make_directory Gmsh.framework/Headers
-    COMMAND ${CMAKE_COMMAND} -E make_directory Gmsh.framework/Resources
-    COMMAND ${CMAKE_COMMAND} -E copy ${LIBNAME} Gmsh.framework/Gmsh
+    COMMAND ${CMAKE_COMMAND} -E remove_directory gmsh.framework
+    COMMAND ${CMAKE_COMMAND} -E make_directory gmsh.framework/Headers
+    COMMAND ${CMAKE_COMMAND} -E make_directory gmsh.framework/Resources
+    COMMAND ${CMAKE_COMMAND} -E copy ${LIBNAME} gmsh.framework/gmsh
     COMMAND ${CMAKE_COMMAND} -E copy Info_framework.plist
-                                     Gmsh.framework/Resources/Info.plist
-    COMMAND ${CMAKE_COMMAND} -E create_symlink . Gmsh.framework/Headers/gmsh
+                                     gmsh.framework/Resources/Info.plist
+    COMMAND ${CMAKE_COMMAND} -E create_symlink . gmsh.framework/Headers/gmsh
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
   foreach(FILE ${GMSH_API})
     add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-        ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Gmsh.framework/Headers/
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-  endforeach(FILE)
-  foreach(FILE ${GMSH_API_DEPRECATED})
-    add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
-        ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/Gmsh.framework/Headers/
+        ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/gmsh.framework/Headers/
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
   endforeach(FILE)
+  if(ENABLE_DEPRECATED_API)
+    foreach(FILE ${GMSH_DEPRECATED_API})
+      add_custom_command(TARGET framework POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
+          ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/gmsh.framework/Headers/
+          WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    endforeach(FILE)
+  endif(ENABLE_DEPRECATED_API)
 endif(APPLE AND ENABLE_BUILD_LIB)
 
 set(CPACK_PACKAGE_VENDOR "Christophe Geuzaine and Jean-Francois Remacle")
@@ -1869,11 +1891,11 @@ else(GMSH_EXTRA_VERSION MATCHES "-git.*")
   set(CPACK_PACKAGE_FILE_NAME gmsh-${GMSH_VERSION}-${GMSH_OS})
   set(CPACK_SOURCE_PACKAGE_FILE_NAME gmsh-${GMSH_VERSION}-source)
 endif(GMSH_EXTRA_VERSION MATCHES "-git.*")
-set(CPACK_PACKAGE_INSTALL_DIRECTORY "Gmsh")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "gmsh")
 set(CPACK_RESOURCE_FILE_LICENSE ${LICENSE_FILE})
 set(CPACK_RESOURCE_FILE_README ${WELCOME_FILE})
 set(CPACK_RESOURCE_FILE_WELCOME ${WELCOME_FILE})
-set(CPACK_PACKAGE_EXECUTABLE "gmsh;Gmsh")
+set(CPACK_PACKAGE_EXECUTABLE "gmsh")
 set(CPACK_STRIP_FILES TRUE)
 set(CPACK_SOURCE_GENERATOR TGZ)
 set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}" "/CVS/" "/.svn" "/.git"
@@ -1915,17 +1937,6 @@ else(APPLE AND ENABLE_OS_SPECIFIC_INSTALL)
   set(CPACK_GENERATOR TGZ)
 endif(APPLE AND ENABLE_OS_SPECIFIC_INSTALL)
 
-if(HAVE_PYTHON)
-  add_subdirectory(wrappers/gmshpy)
-endif(HAVE_PYTHON)
-
-if(ENABLE_WRAP_JAVA_DEPRECATED)
-  if(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
-    message(WARNING "Java wrapping samples will not work without BLAS and LAPACK")
-  endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK)
-  add_subdirectory(wrappers/java)
-endif(ENABLE_WRAP_JAVA_DEPRECATED)
-
 include(CPack)
 
 if(NOT DISABLE_GMSH_TESTS)
@@ -1942,15 +1953,6 @@ if(NOT DISABLE_GMSH_TESTS)
       add_test(${TEST} ./gmsh ${TEST} -3 -nopopup -o ./tmp.msh)
     endif(HAVE_OCC OR NOT ${TEST} MATCHES "boolean")
   endforeach()
-  # if(HAVE_PYTHON)
-  #   file(GLOB_RECURSE TESTFILES tutorial/*.py)
-  #   foreach(TESTFILE ${TESTFILES})
-  #     add_test(NAME ${TESTFILE}
-  #              COMMAND ${PYTHON_EXECUTABLE}
-  #                      ${TESTFILE} $<CONFIGURATION>)
-  #     # sys.path.insert(0, "path/to/your/package")
-  #   endforeach()
-  # endif(HAVE_PYTHON)
 endif(NOT DISABLE_GMSH_TESTS)
 
 message(STATUS "")
diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt
index 282e7218e8a37c50b7905fb648298bfd003f761b..6ea1266287c469e4de0f491a2740c6624b9e3955 100644
--- a/Common/CMakeLists.txt
+++ b/Common/CMakeLists.txt
@@ -4,8 +4,8 @@
 # bugs and problems to the public mailing list <gmsh@onelab.info>.
 
 set(SRC  
-  Gmsh.cpp
-    GmshMessage.cpp
+  GmshGlobal.cpp
+  GmshMessage.cpp
   gmshPopplerWrapper.cpp
   Context.cpp
   Options.cpp
@@ -24,7 +24,7 @@ set(SRC
   onelabUtils.cpp
   GamePad.cpp
   GmshRemote.cpp
-  GmshAPI.cpp
+  gmsh.cpp
 )
 
 if(ENABLE_ONELAB AND NOT ENABLE_ONELAB2)
diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp
index 103dee45b653c1a10412cb35fede545ee392d9f9..d5f59ca54b0e785dc9d7596bfc72b2513b96d8c8 100644
--- a/Common/Gmsh.cpp
+++ b/Common/Gmsh.cpp
@@ -3,434 +3,131 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
-#include <string>
-#include <time.h>
-#include "GmshConfig.h"
-#if !defined(HAVE_NO_STDINT_H)
-#include <stdint.h>
-#elif defined(HAVE_NO_INTPTR_T)
-typedef unsigned long intptr_t;
-#endif
-#include "GmshVersion.h"
-#include "GmshMessage.h"
-#include "GmshDefines.h"
-#include "GmshRemote.h"
+#include "gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
-#include "OpenFile.h"
-#include "CreateFile.h"
-#include "Options.h"
-#if defined(HAVE_PARSER)
-#include "Parser.h"
-#endif
-#include "CommandLine.h"
-#include "OS.h"
-#include "Context.h"
-#include "robustPredicates.h"
-#if defined(HAVE_POST)
-#include "PView.h"
-#include "PViewData.h"
-#include "PViewOptions.h"
-#endif
+#include "GModelIO_GEO.h"
+#include "GModelIO_OCC.h"
 
-#if defined(HAVE_ONELAB)
-#include "gmshLocalNetworkClient.h"
-#endif
+// Gmsh
 
-#if defined(HAVE_MESH)
-#include "Generator.h"
-#include "Field.h"
-#include "meshPartition.h"
-#endif
-
-#if defined(HAVE_PLUGINS)
-#include "PluginManager.h"
-#endif
-
-#if defined(HAVE_FLTK)
-#include "FlGui.h"
-#include "graphicWindow.h"
-#include "drawContext.h"
-#include "onelabGroup.h"
-#endif
-
-int GmshInitialize(int argc, char **argv)
-{
-  Msg::SetNumThreads(1);
-
-  static bool isInitialized = false;
-  if(isInitialized) return 1;
-  isInitialized = true;
-
-#if defined(HAVE_FLTK)
-  RedirectIOToConsole();
-#endif
-
-  // we need at least one model during option parsing
-  GModel *dummy = 0;
-  if(GModel::list.empty()) dummy = new GModel();
-
-  // Initialize messages (parallel stuff, etc.)
-  Msg::Init(argc, argv);
-
-  // Load default options
-  InitOptions(0);
-
-  // Read configuration files and command line options
-  GetOptions(argc, argv);
-
-  // Make sure we have enough resources (stack)
-  CheckResources();
-
-#if defined(HAVE_PLUGINS)
-  // Initialize the default plugins
-  PluginManager::instance()->registerDefaultPlugins();
-#endif
-
-  // Initialize robust predicates (no static filter for now, we do not know the
-  // size of the domain)
-  robustPredicates::exactinit(0, 1.0, 1.0, 1.0);
-
-  if(dummy) delete dummy;
-  return 1;
-}
-
-int GmshSetMessageHandler(GmshMessage *callback)
+int gmshInitialize(int argc, char **argv)
 {
-  Msg::SetCallback(callback);
-  return 1;
+  return !GmshInitialize(argc, argv);
 }
 
-GmshMessage *GmshGetMessageHandler()
+int gmshFinalize()
 {
-  return Msg::GetCallback();
+  return !GmshFinalize();
 }
 
-int GmshSetBoundingBox(double xmin, double xmax,
-                       double ymin, double ymax,
-                       double zmin, double zmax)
+int gmshOpen(const std::string &fileName)
 {
-  SetBoundingBox(xmin, xmax, ymin, ymax, zmin, zmax);
-  return 1;
+  return !GmshOpenProject(fileName);
 }
 
-int GmshSetOption(const std::string &category, const std::string &name,
-                  std::string value, int index)
+int gmshMerge(const std::string &fileName)
 {
-  return StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-                      value, false);
+  return !GmshMergeFile(fileName);
 }
 
-int GmshSetOption(const std::string &category, const std::string &name,
-                  double value, int index)
+int gmshExport(const std::string &fileName)
 {
-  return NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-                      value, false);
+  return !GmshWriteFile(fileName);
 }
 
-int GmshSetOption(const std::string &category, const std::string &name,
-                  unsigned int value, int index)
+int gmshClear()
 {
-  return ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-                     value, false);
+  return !GmshClearProject();
 }
 
-void GmshSetStringOption(const std::string &category, const std::string &name,
-                         std::string value, int index)
-{
-  StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-               value, false);
-}
+// GmshOption
 
-void GmshSetNumberOption(const std::string &category, const std::string &name,
-                         double value, int index)
+static void splitOptionName(const std::string &fullName, std::string &category,
+                            std::string &name, int &index)
 {
-  NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-               value, false);
-}
-
-void GmshSetColorOption(const std::string &category, const std::string &name,
-                        unsigned int value, int index)
-{
-  ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-              value, false);
-}
-
-int GmshGetOption(const std::string &category, const std::string &name,
-                  std::string &value, int index)
-{
-  return StringOption(GMSH_GET, category.c_str(), index, name.c_str(), value,
-                      false);
-}
-
-int GmshGetOption(const std::string &category, const std::string &name,
-                  double &value, int index)
-{
-  return NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), value,
-                      false);
-}
-
-int GmshGetOption(const std::string &category, const std::string &name,
-                  unsigned int &value, int index)
-{
-  return ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), value,
-                     false);
-}
-
-std::string GmshGetStringOption(const std::string &category, const std::string &name,
-                                int index)
-{
-  std::string value;
-  StringOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
-  return value;
-}
-
-double GmshGetNumberOption(const std::string &category, const std::string &name,
-                           int index)
-{
-  double value;
-  NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
-  return value;
-}
-
-unsigned int GmshGetColorOption(const std::string &category, const std::string &name,
-                       int index)
-{
-  unsigned int value;
-  ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
-  return value;
-}
-
-int GmshRestoreDefaultOptions()
-{
-  ReInitOptions(0);
-  InitOptionsGUI(0);
-  return 1;
+  std::string::size_type d = fullName.find_first_of('.');
+  category = fullName.substr(0, d);
+  std::string::size_type b1 = fullName.find_first_of('[');
+  std::string::size_type b2 = fullName.find_last_of(']');
+  if(b1 != std::string::npos && b2 != std::string::npos){
+    std::string id = fullName.substr(b1, b2 - b1);
+    name = fullName.substr(d, b1 - d);
+  }
+  else{
+    index = 0;
+    name = fullName.substr(d);
+  }
+  Msg::Debug("Decoded option name '%s' . '%s' '[%d]'", category.c_str(),
+             name.c_str(), index);
 }
 
-int GmshOpenProject(const std::string &fileName)
+int gmshOptionSetNumber(const std::string &name, double value)
 {
-  OpenProject(fileName);
-  return 1;
+  std::string c, n;
+  int i;
+  splitOptionName(name, c, n, i);
+  return !GmshSetOption(c, n, value, i);
 }
 
-int GmshClearProject()
+int gmshOptionGetNumber(const std::string &name, double &value)
 {
-  ClearProject();
-  return 1;
+  std::string c, n;
+  int i;
+  splitOptionName(name, c, n, i);
+  return !GmshGetOption(c, n, value, i);
 }
 
-int GmshMergeFile(const std::string &fileName)
+int gmshOptionSetString(const std::string &name, const std::string &value)
 {
-  return MergeFile(fileName, true);
+  std::string c, n;
+  int i;
+  splitOptionName(name, c, n, i);
+  return !GmshSetOption(c, n, value, i);
 }
 
-int GmshMergePostProcessingFile(const std::string &fileName)
+int gmshOptionGetString(const std::string &name, std::string &value)
 {
-  return MergePostProcessingFile(fileName, CTX::instance()->solver.autoShowViews,
-                                 CTX::instance()->solver.autoShowLastStep, true);
+  std::string c, n;
+  int i;
+  splitOptionName(name, c, n, i);
+  return !GmshGetOption(c, n, value, i);
 }
 
-int GmshWriteFile(const std::string &fileName)
-{
-  CreateOutputFile(fileName, FORMAT_AUTO);
-  return 1;
-}
+// GmshModel
 
-int GmshFinalize()
+int gmshModelCreate(const std::string &name)
 {
-#if defined(HAVE_POST)
-  // Delete all PViewData stored in static list of PView class
-  while(PView::list.size()>0) delete PView::list[PView::list.size()-1];
-  std::vector<PView*>().swap(PView::list);
-
-  // Delete static _interpolationSchemes of PViewData class
-  PViewData::removeAllInterpolationSchemes();
-#endif
-  
-  // Delete all Gmodels
-  while(GModel::list.size()>0) delete GModel::list[GModel::list.size()-1];
-  std::vector<GModel*>().swap(GModel::list);
-
-  return 1;
+  GModel *m = new GModel(name);
+  return m ? 0 : 1;
 }
 
-int GmshBatch()
+int gmshModelSetCurrent(const std::string &name)
 {
-  Msg::Info("Running '%s' [Gmsh %s, %d node%s, max. %d thread%s]",
-            Msg::GetCommandLineArgs().c_str(), GMSH_VERSION,
-            Msg::GetCommSize(), Msg::GetCommSize() > 1 ? "s" : "",
-            Msg::GetMaxThreads(), Msg::GetMaxThreads() > 1 ? "s" : "");
-  Msg::Info("Started on %s", Msg::GetLaunchDate().c_str());
-
-  OpenProject(GModel::current()->getFileName());
-  bool open = false;
-  for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
-    if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
-    if(CTX::instance()->files[i] == "-new")
-      new GModel();
-    else if(CTX::instance()->files[i] == "-merge")
-      open = false;
-    else if(CTX::instance()->files[i] == "-open")
-      open = true;
-    else if(open)
-      OpenProject(CTX::instance()->files[i]);
-    else
-      MergeFile(CTX::instance()->files[i]);
-  }
-
-
-#if defined(HAVE_POST) && defined(HAVE_MESH)
-  if(!CTX::instance()->bgmFileName.empty()) {
-    MergePostProcessingFile(CTX::instance()->bgmFileName);
-    if(PView::list.size())
-      GModel::current()->getFields()->setBackgroundMesh(PView::list.size() - 1);
-    else
-      Msg::Error("Invalid background mesh (no view)");
-  }
-#endif
-
-  if(CTX::instance()->batch == -3){
-    GmshRemote();
-  }
-  else if(CTX::instance()->batch == -2){
-    GModel::current()->checkMeshCoherence(CTX::instance()->geom.tolerance);
-#if defined(HAVE_PARSER)
-    std::vector<std::string> s;
-    PrintParserSymbols(0, s);
-    for(unsigned int i = 0; i < s.size(); i++)
-      Msg::Direct("%s", s[i].c_str());
-#endif
+  GModel *m = GModel::findByName(name);
+  if(m){
+    GModel::setCurrent(m);
+    return 0;
   }
-  else if(CTX::instance()->batch == -1){
-    CreateOutputFile(CTX::instance()->outputFileName,
-                     CTX::instance()->outputFileName.empty() ? FORMAT_GEO :
-                     FORMAT_AUTO);
-  }
-  else if(CTX::instance()->batch > 0){
-#if defined(HAVE_MESH)
-    if(CTX::instance()->batch < 4)
-      GModel::current()->mesh(CTX::instance()->batch);
-    else if(CTX::instance()->batch == 4)
-      AdaptMesh(GModel::current());
-    else if(CTX::instance()->batch == 5)
-      RefineMesh(GModel::current(), CTX::instance()->mesh.secondOrderLinear);
-    else if(CTX::instance()->batch == 6)
-      GModel::current()->classifyAllFaces();
-#if defined(HAVE_CHACO) || defined(HAVE_METIS)
-    if(CTX::instance()->batchAfterMesh == 1){
-      if (CTX::instance()->partitionOptions.num_partitions > 1)
-        PartitionMesh(GModel::current(), CTX::instance()->partitionOptions);
-      if (CTX::instance()->partitionOptions.renumber)
-        RenumberMesh(GModel::current(), CTX::instance()->partitionOptions);
-    }
-#endif
-#endif
-    std::string name = CTX::instance()->outputFileName;
-    if(name.empty()){
-      if(CTX::instance()->mesh.fileFormat == FORMAT_AUTO)
-        name = GetDefaultFileName(FORMAT_MSH);
-      else
-        name = GetDefaultFileName(CTX::instance()->mesh.fileFormat);
-    }
-    CreateOutputFile(name, CTX::instance()->mesh.fileFormat);
-  }
-
-  // launch solver (if requested)
-#if defined(HAVE_ONELAB)
-  solver_batch_cb((void*)(intptr_t)CTX::instance()->launchSolverAtStartup);
-#endif
-
-  time_t now;
-  time(&now);
-  std::string currtime = ctime(&now);
-  currtime.resize(currtime.size() - 1);
-  Msg::Info("Stopped on %s", currtime.c_str());
-
   return 1;
 }
 
-int GmshBatch(int argc, char **argv)
+int gmshModelDestroy()
 {
-  new GModel();
-  GmshInitialize(argc, argv);
-  if(!Msg::GetGmshClient()) CTX::instance()->terminal = 1;
-  CTX::instance()->noPopup = 1;
-  GmshBatch();
-  GmshFinalize();
+  GModel *m = GModel::current();
+  if(m){
+    delete m;
+    return 0;
+  }
   return 1;
 }
 
-int GmshFLTK(int argc, char **argv)
+int gmshModelMesh(int dim)
 {
-#if defined(HAVE_FLTK) && defined(HAVE_POST)
-  // create the GUI
-  FlGui::instance(argc, argv);
-
-  // display GUI immediately for quick launch time
-  FlGui::instance()->check();
-
-  // open project file and merge all other input files
-  if(FlGui::getOpenedThroughMacFinder().empty()){
-    OpenProject(GModel::current()->getFileName());
-    bool open = false;
-    for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
-      if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
-      if(CTX::instance()->files[i] == "-new"){
-        GModel::current()->setVisibility(0);
-        new GModel();
-      }
-      else if(CTX::instance()->files[i] == "-merge")
-        open = false;
-      else if(CTX::instance()->files[i] == "-open")
-        open = true;
-      else if(open)
-        OpenProject(CTX::instance()->files[i]);
-      else
-        MergeFile(CTX::instance()->files[i]);
-    }
+  GModel *m = GModel::current();
+  if(m){
+    m->mesh(dim);
+    return 0;
   }
-  else{
-    OpenProject(FlGui::getOpenedThroughMacFinder());
-  }
-
-  if(CTX::instance()->post.combineTime){
-    PView::combine(true, 2, CTX::instance()->post.combineRemoveOrig);
-    FlGui::instance()->updateViews(true, true);
-  }
-
-  // init first context
-  switch (CTX::instance()->initialContext) {
-  case 1: FlGui::instance()->openModule("Geometry"); break;
-  case 2: FlGui::instance()->openModule("Mesh"); break;
-  case 3: FlGui::instance()->openModule("Solver"); break;
-  case 4: FlGui::instance()->openModule("Post-processing"); break;
-  default: // automatic
-    if(PView::list.size()) FlGui::instance()->openModule("Post-processing");
-    break;
-  }
-
-  // read background mesh if any
-  if(!CTX::instance()->bgmFileName.empty()) {
-    MergePostProcessingFile(CTX::instance()->bgmFileName);
-    if(PView::list.size())
-      GModel::current()->getFields()->setBackgroundMesh(PView::list.size() - 1);
-    else
-      Msg::Error("Invalid background mesh (no view)");
-  }
-
-  // listen to external solvers
-  if(CTX::instance()->solver.listen){
-    gmshLocalNetworkClient *c = new gmshLocalNetworkClient("Listen", "");
-    c->run();
-  }
-
-  // launch solver (if requested) and fill onelab tree
-  solver_cb(0, (void*)(intptr_t)CTX::instance()->launchSolverAtStartup);
-
-  // loop
-  return FlGui::instance()->run();
-#else
-  Msg::Error("GmshFLTK unavailable: please recompile with FLTK support");
-  return 0;
-#endif
+  return 1;
 }
diff --git a/Common/Gmsh.h b/Common/Gmsh.h
index abbd644b71cccbce3124077a8c53642d2e791222..6ff1bda955a43755a74c289874db0faef5dc367f 100644
--- a/Common/Gmsh.h
+++ b/Common/Gmsh.h
@@ -6,48 +6,142 @@
 #ifndef _GMSH_H_
 #define _GMSH_H_
 
+// This is the embryo of what will become the Gmsh API.
+//
+// Don't use it yet, it's not ready :-) We plan to release a first version in
+// Gmsh 3.1, and something more complete in Gmsh 4.0.
+//
+// Your input is welcome: please contribute your ideas on
+// https://gitlab.onelab.info/gmsh/gmsh/issues/188
+//
+// By design, the API is purely functional, and only uses elementary C++ types
+// from the standard library. This design should not and will not change.
+
+// All functions return 0 on successful completion.
+
+#include <vector>
 #include <string>
-#include "GmshMessage.h"
-
-int GmshInitialize(int argc=0, char **argv=0);
-int GmshSetMessageHandler(GmshMessage *callback);
-GmshMessage *GmshGetMessageHandler();
-int GmshSetBoundingBox(double xmin, double xmax,
-                       double ymin, double ymax,
-                       double zmin, double zmax);
-int GmshSetOption(const std::string &category, const std::string &name,
-                  std::string value, int index=0);
-int GmshSetOption(const std::string &category, const std::string &name,
-                  double value, int index=0);
-int GmshSetOption(const std::string &category, const std::string &name,
-                  unsigned int value, int index=0);
-void GmshSetStringOption(const std::string &category, const std::string &name,
-                         std::string value, int index=0);
-void GmshSetNumberOption(const std::string &category, const std::string &name,
-                         double value, int index=0);
-void GmshSetColorOption(const std::string &category, const std::string &name,
-                        unsigned int value, int index=0);
-int GmshGetOption(const std::string &category, const std::string &name,
-                  std::string &value, int index=0);
-int GmshGetOption(const std::string &category, const std::string &name,
-                  double &value, int index=0);
-int GmshGetOption(const std::string &category, const std::string &name,
-                  unsigned int &value, int index=0);
-std::string GmshGetStringOption(const std::string &category, const std::string &name,
-                                int index=0);
-double GmshGetNumberOption(const std::string &category, const std::string &name,
-                           int index=0);
-unsigned int GmshGetColorOption(const std::string &category, const std::string &name,
-                                int index=0);
-int GmshRestoreDefaultOptions();
-int GmshOpenProject(const std::string &fileName);
-int GmshClearProject();
-int GmshMergeFile(const std::string &fileName);
-int GmshMergePostProcessingFile(const std::string &fileName);
-int GmshWriteFile(const std::string &fileName);
-int GmshFinalize();
-int GmshBatch();
-int GmshBatch(int argc, char **argv);
-int GmshFLTK(int argc=0, char **argv=0);
+
+#if defined(WIN32)
+#define GMSH_API __declspec(dllexport) int
+#else
+#define GMSH_API int
+#endif
+
+// Gmsh
+GMSH_API gmshInitialize(int argc, char **argv);
+GMSH_API gmshFinalize();
+GMSH_API gmshOpen(const std::string &fileName);
+GMSH_API gmshMerge(const std::string &fileName);
+GMSH_API gmshExport(const std::string &fileName);
+GMSH_API gmshClear();
+
+// GmshOption
+GMSH_API gmshOptionSetNumber(const std::string &name, double value);
+GMSH_API gmshOptionGetNumber(const std::string &name, double &value);
+GMSH_API gmshOptionSetString(const std::string &name, const std::string &value);
+GMSH_API gmshOptionGetString(const std::string &name, std::string &value);
+
+// GmshModel
+GMSH_API gmshModelCreate(const std::string &name);
+GMSH_API gmshModelSetCurrent(const std::string &name);
+GMSH_API gmshModelDestroy();
+GMSH_API gmshModelMesh(int dim);
+GMSH_API gmshModelGetElementaryTags(int dim, std::vector<int> &tags);
+GMSH_API gmshModelGetPhysicalTags(int dim, std::vector<int> &tags);
+GMSH_API gmshModelAddPhysicalGroup(int dim, int tag, const std::vector<int> &tags);
+GMSH_API gmshModelGetPhysicalGroup(int dim, int tag, std::vector<int> &tags);
+GMSH_API gmshModelSetPhysicalName(int dim, int tag, const std::string &name);
+GMSH_API gmshModelGetPhysicalName(int dim, int tag, std::string &name);
+GMSH_API gmshModelGetVertexCoordinates(int tag, double &x, std::vector<double> &coord);
+GMSH_API gmshModelGetMeshVertices(int dim, int tag, std::vector<int> &vertexTags,
+                                  std::vector<double> &coords,
+                                  std::vector<double> &parametricCoords);
+GMSH_API gmshModelGetMeshElements(int dim, int tag, std::vector<int> &types,
+                                  std::vector<std::vector<int> > &elementTags,
+                                  std::vector<std::vector<int> > &vertexTags);
+GMSH_API gmshModelGetBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags,
+                                  std::vector<std::pair<int, int> > &outDimTags,
+                                  bool combined, bool oriented, bool recursive);
+GMSH_API gmshModelSetMeshSize(int dim, int tag, double size);
+GMSH_API gmshModelSetCompoundMesh(int dim, const std::vector<int> &tags);
+GMSH_API gmshModelSetTransfiniteLine(int tag, int nPoints, int type, double coef);
+GMSH_API gmshModelSetTransfiniteSurface(int tag, int arrangement,
+                                        const std::vector<int> &cornerTags);
+GMSH_API gmshModelSetTransfiniteVolume(int tag, const std::vector<int> &cornerTags);
+GMSH_API gmshModelSetRecombine(int dim, int tag, double angle);
+GMSH_API gmshModelSetSmoothing(int tag, int val);
+GMSH_API gmshModelSetReverseMesh(int dim, int tag);
+GMSH_API gmshModelAddEmbeddedVertex(int tag, int inDim, int inTag);
+GMSH_API gmshModelRemove(const std::vector<std::pair<int, int> > &dimTags,
+                         bool recursive=false);
+
+// GmshModelGeo
+GMSH_API gmshModelGeoAddVertex(int &tag, double x, double y, double z, double lc);
+GMSH_API gmshModelGeoAddLine(int &tag, int startTag, int endTag);
+GMSH_API gmshModelGeoAddCircleArc(int &tag, int startTag, int centerTag, int endTag,
+                                  double nx=0., double ny=0., double nz=0.);
+GMSH_API gmshModelGeoAddEllipseArc(int &tag, int startTag, int centerTag, int majorTag,
+                                   int endTag, double nx=0., double ny=0., double nz=0.);
+GMSH_API gmshModelGeoAddSpline(int &tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelGeoAddBSpline(int &tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelGeoAddBezier(int &tag, const std::vector<int> &vertexTags);
+GMSH_API gmshModelGeoAddNurbs(int &tag, const std::vector<int> &vertexTags,
+                              const std::vector<double> &knots);
+GMSH_API gmshModelGeoAddLineLoop(int &tag, const std::vector<int> &edgeTags);
+GMSH_API gmshModelGeoAddPlaneSurface(int &tag, const std::vector<int> &wireTags);
+GMSH_API gmshModelGeoAddSurfaceFilling(int &tag, const std::vector<int> &wireTags,
+                                       int sphereCenterTag=-1);
+GMSH_API gmshModelGeoAddSurfaceLoop(int &tag, const std::vector<int> &faceTags);
+GMSH_API gmshModelGeoAddVolume(int &tag, const std::vector<int> &shellTags);
+GMSH_API gmshModelGeoExtrude(const std::vector<std::pair<int, int> > &inDimTags,
+                             double dx, double dy, double dz,
+                             std::vector<std::pair<int, int> > &outDimTags,
+                             const std::vector<int> &numElements,
+                             const std::vector<double> &heights, bool recombine);
+GMSH_API gmshModelGeoRevolve(const std::vector<std::pair<int, int> > &inDimTags,
+                             double x, double y, double z,
+                             double ax, double ay, double az, double angle,
+                             std::vector<std::pair<int, int> > &outDimTags,
+                             const std::vector<int> &numElements,
+                             const std::vector<double> &heights, bool recombine);
+GMSH_API gmshModelGeoTwist(const std::vector<std::pair<int, int> > &inDimTags,
+                           double x, double y, double z,
+                           double dx, double dy, double dz,
+                           double ax, double ay, double az, double angle,
+                           std::vector<std::pair<int, int> > &outDimTags,
+                           const std::vector<int> &numElements,
+                           const std::vector<double> &heights, bool recombine);
+GMSH_API gmshModelGeoTranslate(const std::vector<std::pair<int, int> > &dimTags,
+                               double dx, double dy, double dz);
+GMSH_API gmshModelGeoRotate(const std::vector<std::pair<int, int> > &dimTags,
+                            double x, double y, double z, double ax, double ay, double az,
+                            double angle);
+GMSH_API gmshModelGeoDilate(const std::vector<std::pair<int, int> > &dimTags,
+                            double x, double y, double z,
+                            double a, double b, double c);
+GMSH_API gmshModelGeoSymmetry(const std::vector<std::pair<int, int> > &dimTags,
+                              double a, double b, double c, double d);
+GMSH_API gmshModelGeoCopy(const std::vector<std::pair<int, int> > &inDimTags,
+                          std::vector<std::pair<int, int> > &outDimTags);
+GMSH_API gmshModelGeoRemove(const std::vector<std::pair<int, int> > &dimTags,
+                            bool recursive=false);
+GMSH_API gmshModelGeoRemoveAllDuplicates();
+GMSH_API gmshModelGeoSynchronize();
+
+// GmshModelOCC
+GMSH_API gmshModelOCCAddVertex(int &tag, double x, double y, double z, double lc);
+GMSH_API gmshModelOCCAddLine(int &tag, int startVertexTag, int endVertexTag);
+GMSH_API gmshModelOCCExtrude(const std::vector<std::pair<int, int> > &inDimTag,
+                             double dx, double dy, double dz,
+                             std::vector<std::pair<int, int> > &outDimTags);
+GMSH_API gmshModelOCCRemoveAllDuplicates();
+GMSH_API gmshModelOCCSynchronize();
+
+// GmshSolver
+
+// GmshPost
+
+// GmshPlugin
 
 #endif
diff --git a/Common/GmshAPI.cpp b/Common/GmshAPI.cpp
deleted file mode 100644
index b3e1585bc068b3b78ab3600a834d9f79d0237d65..0000000000000000000000000000000000000000
--- a/Common/GmshAPI.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
-//
-// See the LICENSE.txt file for license information. Please report all
-// bugs and problems to the public mailing list <gmsh@onelab.info>.
-
-#include "Gmsh.h"
-#include "GmshAPI.h"
-#include "GModel.h"
-#include "GModelIO_GEO.h"
-#include "GModelIO_OCC.h"
-
-// Gmsh
-
-int gmshInitialize(int argc, char **argv)
-{
-  return !GmshInitialize(argc, argv);
-}
-
-int gmshFinalize()
-{
-  return !GmshFinalize();
-}
-
-int gmshOpen(const std::string &fileName)
-{
-  return !GmshOpenProject(fileName);
-}
-
-int gmshMerge(const std::string &fileName)
-{
-  return !GmshMergeFile(fileName);
-}
-
-int gmshExport(const std::string &fileName)
-{
-  return !GmshWriteFile(fileName);
-}
-
-int gmshClear()
-{
-  return !GmshClearProject();
-}
-
-// GmshOption
-
-static void splitOptionName(const std::string &fullName, std::string &category,
-                            std::string &name, int &index)
-{
-  std::string::size_type d = fullName.find_first_of('.');
-  category = fullName.substr(0, d);
-  std::string::size_type b1 = fullName.find_first_of('[');
-  std::string::size_type b2 = fullName.find_last_of(']');
-  if(b1 != std::string::npos && b2 != std::string::npos){
-    std::string id = fullName.substr(b1, b2 - b1);
-    name = fullName.substr(d, b1 - d);
-  }
-  else{
-    index = 0;
-    name = fullName.substr(d);
-  }
-  Msg::Debug("Decoded option name '%s' . '%s' '[%d]'", category.c_str(),
-             name.c_str(), index);
-}
-
-int gmshOptionSetNumber(const std::string &name, double value)
-{
-  std::string c, n;
-  int i;
-  splitOptionName(name, c, n, i);
-  return !GmshSetOption(c, n, value, i);
-}
-
-int gmshOptionGetNumber(const std::string &name, double &value)
-{
-  std::string c, n;
-  int i;
-  splitOptionName(name, c, n, i);
-  return !GmshGetOption(c, n, value, i);
-}
-
-int gmshOptionSetString(const std::string &name, const std::string &value)
-{
-  std::string c, n;
-  int i;
-  splitOptionName(name, c, n, i);
-  return !GmshSetOption(c, n, value, i);
-}
-
-int gmshOptionGetString(const std::string &name, std::string &value)
-{
-  std::string c, n;
-  int i;
-  splitOptionName(name, c, n, i);
-  return !GmshGetOption(c, n, value, i);
-}
-
-// GmshModel
-
-int gmshModelCreate(const std::string &name)
-{
-  return 0;
-}
-
-int gmshModelSetCurrent(const std::string &name)
-{
-  return 0;
-}
-
-int gmshModelDestroy()
-{
-  return 0;
-}
-
-int gmshModelMesh(int dim)
-{
-  return 0;
-}
diff --git a/Common/GmshAPI.h b/Common/GmshAPI.h
deleted file mode 100644
index 7df62a691027fcfb86361db93d54d737e4a4ea58..0000000000000000000000000000000000000000
--- a/Common/GmshAPI.h
+++ /dev/null
@@ -1,145 +0,0 @@
-// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
-//
-// See the LICENSE.txt file for license information. Please report all
-// bugs and problems to the public mailing list <gmsh@onelab.info>.
-
-#ifndef _GMSH_API_H_
-#define _GMSH_API_H_
-
-// This is the embryo of what will become the Gmsh API.
-//
-// Don't use it yet, it's not ready :-) We plan to release a first version in
-// Gmsh 3.1, and something more complete in Gmsh 4.0.
-//
-// Your input is welcome: please contribute your ideas on
-// https://gitlab.onelab.info/gmsh/gmsh/issues/188
-//
-// By design, the API is purely functional, and only uses elementary C++ types
-// from the standard library. This design should not and will not change.
-
-// All functions return 0 on successful completion.
-
-#include <vector>
-#include <string>
-
-#if defined(WIN32)
-#define GMSH_API __declspec(dllexport) int
-#else
-#define GMSH_API int
-#endif
-
-// Gmsh
-GMSH_API gmshInitialize(int argc, char **argv);
-GMSH_API gmshFinalize();
-GMSH_API gmshOpen(const std::string &fileName);
-GMSH_API gmshMerge(const std::string &fileName);
-GMSH_API gmshExport(const std::string &fileName);
-GMSH_API gmshClear();
-
-// GmshOption
-GMSH_API gmshOptionSetNumber(const std::string &name, double value);
-GMSH_API gmshOptionGetNumber(const std::string &name, double &value);
-GMSH_API gmshOptionSetString(const std::string &name, const std::string &value);
-GMSH_API gmshOptionGetString(const std::string &name, std::string &value);
-
-// GmshModel
-GMSH_API gmshModelCreate(const std::string &name);
-GMSH_API gmshModelSetCurrent(const std::string &name);
-GMSH_API gmshModelDestroy();
-GMSH_API gmshModelMesh(int dim);
-GMSH_API gmshModelGetElementaryTags(int dim, std::vector<int> &tags);
-GMSH_API gmshModelGetPhysicalTags(int dim, std::vector<int> &tags);
-GMSH_API gmshModelAddPhysicalGroup(int dim, int tag, const std::vector<int> &tags);
-GMSH_API gmshModelGetPhysicalGroup(int dim, int tag, std::vector<int> &tags);
-GMSH_API gmshModelSetPhysicalName(int dim, int tag, const std::string &name);
-GMSH_API gmshModelGetPhysicalName(int dim, int tag, std::string &name);
-GMSH_API gmshModelGetVertexCoordinates(int tag, double &x, std::vector<double> &coord);
-GMSH_API gmshModelGetMeshVertices(int dim, int tag, std::vector<int> &vertexTags,
-                                  std::vector<double> &coords,
-                                  std::vector<double> &parametricCoords);
-GMSH_API gmshModelGetMeshElements(int dim, int tag, std::vector<int> &types,
-                                  std::vector<std::vector<int> > &elementTags,
-                                  std::vector<std::vector<int> > &vertexTags);
-GMSH_API gmshModelGetBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags,
-                                  std::vector<std::pair<int, int> > &outDimTags,
-                                  bool combined, bool oriented, bool recursive);
-GMSH_API gmshModelSetMeshSize(int dim, int tag, double size);
-GMSH_API gmshModelSetCompoundMesh(int dim, const std::vector<int> &tags);
-GMSH_API gmshModelSetTransfiniteLine(int tag, int nPoints, int type, double coef);
-GMSH_API gmshModelSetTransfiniteSurface(int tag, int arrangement,
-                                        const std::vector<int> &cornerTags);
-GMSH_API gmshModelSetTransfiniteVolume(int tag, const std::vector<int> &cornerTags);
-GMSH_API gmshModelSetRecombine(int dim, int tag, double angle);
-GMSH_API gmshModelSetSmoothing(int tag, int val);
-GMSH_API gmshModelSetReverseMesh(int dim, int tag);
-GMSH_API gmshModelAddEmbeddedVertex(int tag, int inDim, int inTag);
-
-// GmshModelGeo
-GMSH_API gmshModelGeoAddVertex(int &tag, double x, double y, double z, double lc);
-GMSH_API gmshModelGeoAddLine(int &tag, int startTag, int endTag);
-GMSH_API gmshModelGeoAddCircleArc(int &tag, int startTag, int centerTag, int endTag,
-                                  double nx=0., double ny=0., double nz=0.);
-GMSH_API gmshModelGeoAddEllipseArc(int &tag, int startTag, int centerTag, int majorTag,
-                                   int endTag, double nx=0., double ny=0., double nz=0.);
-GMSH_API gmshModelGeoAddSpline(int &tag, const std::vector<int> &vertexTags);
-GMSH_API gmshModelGeoAddBSpline(int &tag, const std::vector<int> &vertexTags);
-GMSH_API gmshModelGeoAddBezier(int &tag, const std::vector<int> &vertexTags);
-GMSH_API gmshModelGeoAddNurbs(int &tag, const std::vector<int> &vertexTags,
-                              const std::vector<double> &knots);
-GMSH_API gmshModelGeoAddLineLoop(int &tag, const std::vector<int> &edgeTags);
-GMSH_API gmshModelGeoAddPlaneSurface(int &tag, const std::vector<int> &wireTags);
-GMSH_API gmshModelGeoAddSurfaceFilling(int &tag, const std::vector<int> &wireTags,
-                                       int sphereCenterTag=-1);
-GMSH_API gmshModelGeoAddSurfaceLoop(int &tag, const std::vector<int> &faceTags);
-GMSH_API gmshModelGeoAddVolume(int &tag, const std::vector<int> &shellTags);
-GMSH_API gmshModelGeoExtrude(const std::vector<std::pair<int, int> > &inDimTags,
-                             double dx, double dy, double dz,
-                             std::vector<std::pair<int, int> > &outDimTags,
-                             const std::vector<int> &numElements,
-                             const std::vector<double> &heights, bool recombine);
-GMSH_API gmshModelGeoRevolve(const std::vector<std::pair<int, int> > &inDimTags,
-                             double x, double y, double z,
-                             double ax, double ay, double az, double angle,
-                             std::vector<std::pair<int, int> > &outDimTags,
-                             const std::vector<int> &numElements,
-                             const std::vector<double> &heights, bool recombine);
-GMSH_API gmshModelGeoTwist(const std::vector<std::pair<int, int> > &inDimTags,
-                           double x, double y, double z,
-                           double dx, double dy, double dz,
-                           double ax, double ay, double az, double angle,
-                           std::vector<std::pair<int, int> > &outDimTags,
-                           const std::vector<int> &numElements,
-                           const std::vector<double> &heights, bool recombine);
-GMSH_API gmshModelGeoTranslate(const std::vector<std::pair<int, int> > &dimTags,
-                               double dx, double dy, double dz);
-GMSH_API gmshModelGeoRotate(const std::vector<std::pair<int, int> > &dimTags,
-                            double x, double y, double z, double ax, double ay, double az,
-                            double angle);
-GMSH_API gmshModelGeoDilate(const std::vector<std::pair<int, int> > &dimTags,
-                            double x, double y, double z,
-                            double a, double b, double c);
-GMSH_API gmshModelGeoSymmetry(const std::vector<std::pair<int, int> > &dimTags,
-                              double a, double b, double c, double d);
-GMSH_API gmshModelGeoCopy(const std::vector<std::pair<int, int> > &inDimTags,
-                          std::vector<std::pair<int, int> > &outDimTags);
-GMSH_API gmshModelGeoRemove(const std::vector<std::pair<int, int> > &dimTags,
-                            bool recursive=false);
-GMSH_API gmshModelGeoRemoveAllDuplicates();
-GMSH_API gmshModelGeoSynchronize();
-
-// GmshModelOCC
-GMSH_API gmshModelOCCAddVertex(int &tag, double x, double y, double z, double lc);
-GMSH_API gmshModelOCCAddLine(int &tag, int startVertexTag, int endVertexTag);
-GMSH_API gmshModelOCCExtrude(const std::vector<std::pair<int, int> > &inDimTag,
-                             double dx, double dy, double dz,
-                             std::vector<std::pair<int, int> > &outDimTags);
-GMSH_API gmshModelOCCRemoveAllDuplicates();
-GMSH_API gmshModelOCCSynchronize();
-
-// GmshSolver
-
-// GmshPost
-
-// GmshPlugin
-
-#endif
diff --git a/Common/GmshGlobal.cpp b/Common/GmshGlobal.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..103dee45b653c1a10412cb35fede545ee392d9f9
--- /dev/null
+++ b/Common/GmshGlobal.cpp
@@ -0,0 +1,436 @@
+// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to the public mailing list <gmsh@onelab.info>.
+
+#include <string>
+#include <time.h>
+#include "GmshConfig.h"
+#if !defined(HAVE_NO_STDINT_H)
+#include <stdint.h>
+#elif defined(HAVE_NO_INTPTR_T)
+typedef unsigned long intptr_t;
+#endif
+#include "GmshVersion.h"
+#include "GmshMessage.h"
+#include "GmshDefines.h"
+#include "GmshRemote.h"
+#include "GModel.h"
+#include "OpenFile.h"
+#include "CreateFile.h"
+#include "Options.h"
+#if defined(HAVE_PARSER)
+#include "Parser.h"
+#endif
+#include "CommandLine.h"
+#include "OS.h"
+#include "Context.h"
+#include "robustPredicates.h"
+#if defined(HAVE_POST)
+#include "PView.h"
+#include "PViewData.h"
+#include "PViewOptions.h"
+#endif
+
+#if defined(HAVE_ONELAB)
+#include "gmshLocalNetworkClient.h"
+#endif
+
+#if defined(HAVE_MESH)
+#include "Generator.h"
+#include "Field.h"
+#include "meshPartition.h"
+#endif
+
+#if defined(HAVE_PLUGINS)
+#include "PluginManager.h"
+#endif
+
+#if defined(HAVE_FLTK)
+#include "FlGui.h"
+#include "graphicWindow.h"
+#include "drawContext.h"
+#include "onelabGroup.h"
+#endif
+
+int GmshInitialize(int argc, char **argv)
+{
+  Msg::SetNumThreads(1);
+
+  static bool isInitialized = false;
+  if(isInitialized) return 1;
+  isInitialized = true;
+
+#if defined(HAVE_FLTK)
+  RedirectIOToConsole();
+#endif
+
+  // we need at least one model during option parsing
+  GModel *dummy = 0;
+  if(GModel::list.empty()) dummy = new GModel();
+
+  // Initialize messages (parallel stuff, etc.)
+  Msg::Init(argc, argv);
+
+  // Load default options
+  InitOptions(0);
+
+  // Read configuration files and command line options
+  GetOptions(argc, argv);
+
+  // Make sure we have enough resources (stack)
+  CheckResources();
+
+#if defined(HAVE_PLUGINS)
+  // Initialize the default plugins
+  PluginManager::instance()->registerDefaultPlugins();
+#endif
+
+  // Initialize robust predicates (no static filter for now, we do not know the
+  // size of the domain)
+  robustPredicates::exactinit(0, 1.0, 1.0, 1.0);
+
+  if(dummy) delete dummy;
+  return 1;
+}
+
+int GmshSetMessageHandler(GmshMessage *callback)
+{
+  Msg::SetCallback(callback);
+  return 1;
+}
+
+GmshMessage *GmshGetMessageHandler()
+{
+  return Msg::GetCallback();
+}
+
+int GmshSetBoundingBox(double xmin, double xmax,
+                       double ymin, double ymax,
+                       double zmin, double zmax)
+{
+  SetBoundingBox(xmin, xmax, ymin, ymax, zmin, zmax);
+  return 1;
+}
+
+int GmshSetOption(const std::string &category, const std::string &name,
+                  std::string value, int index)
+{
+  return StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+                      value, false);
+}
+
+int GmshSetOption(const std::string &category, const std::string &name,
+                  double value, int index)
+{
+  return NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+                      value, false);
+}
+
+int GmshSetOption(const std::string &category, const std::string &name,
+                  unsigned int value, int index)
+{
+  return ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+                     value, false);
+}
+
+void GmshSetStringOption(const std::string &category, const std::string &name,
+                         std::string value, int index)
+{
+  StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+               value, false);
+}
+
+void GmshSetNumberOption(const std::string &category, const std::string &name,
+                         double value, int index)
+{
+  NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+               value, false);
+}
+
+void GmshSetColorOption(const std::string &category, const std::string &name,
+                        unsigned int value, int index)
+{
+  ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+              value, false);
+}
+
+int GmshGetOption(const std::string &category, const std::string &name,
+                  std::string &value, int index)
+{
+  return StringOption(GMSH_GET, category.c_str(), index, name.c_str(), value,
+                      false);
+}
+
+int GmshGetOption(const std::string &category, const std::string &name,
+                  double &value, int index)
+{
+  return NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), value,
+                      false);
+}
+
+int GmshGetOption(const std::string &category, const std::string &name,
+                  unsigned int &value, int index)
+{
+  return ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), value,
+                     false);
+}
+
+std::string GmshGetStringOption(const std::string &category, const std::string &name,
+                                int index)
+{
+  std::string value;
+  StringOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
+  return value;
+}
+
+double GmshGetNumberOption(const std::string &category, const std::string &name,
+                           int index)
+{
+  double value;
+  NumberOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
+  return value;
+}
+
+unsigned int GmshGetColorOption(const std::string &category, const std::string &name,
+                       int index)
+{
+  unsigned int value;
+  ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
+  return value;
+}
+
+int GmshRestoreDefaultOptions()
+{
+  ReInitOptions(0);
+  InitOptionsGUI(0);
+  return 1;
+}
+
+int GmshOpenProject(const std::string &fileName)
+{
+  OpenProject(fileName);
+  return 1;
+}
+
+int GmshClearProject()
+{
+  ClearProject();
+  return 1;
+}
+
+int GmshMergeFile(const std::string &fileName)
+{
+  return MergeFile(fileName, true);
+}
+
+int GmshMergePostProcessingFile(const std::string &fileName)
+{
+  return MergePostProcessingFile(fileName, CTX::instance()->solver.autoShowViews,
+                                 CTX::instance()->solver.autoShowLastStep, true);
+}
+
+int GmshWriteFile(const std::string &fileName)
+{
+  CreateOutputFile(fileName, FORMAT_AUTO);
+  return 1;
+}
+
+int GmshFinalize()
+{
+#if defined(HAVE_POST)
+  // Delete all PViewData stored in static list of PView class
+  while(PView::list.size()>0) delete PView::list[PView::list.size()-1];
+  std::vector<PView*>().swap(PView::list);
+
+  // Delete static _interpolationSchemes of PViewData class
+  PViewData::removeAllInterpolationSchemes();
+#endif
+  
+  // Delete all Gmodels
+  while(GModel::list.size()>0) delete GModel::list[GModel::list.size()-1];
+  std::vector<GModel*>().swap(GModel::list);
+
+  return 1;
+}
+
+int GmshBatch()
+{
+  Msg::Info("Running '%s' [Gmsh %s, %d node%s, max. %d thread%s]",
+            Msg::GetCommandLineArgs().c_str(), GMSH_VERSION,
+            Msg::GetCommSize(), Msg::GetCommSize() > 1 ? "s" : "",
+            Msg::GetMaxThreads(), Msg::GetMaxThreads() > 1 ? "s" : "");
+  Msg::Info("Started on %s", Msg::GetLaunchDate().c_str());
+
+  OpenProject(GModel::current()->getFileName());
+  bool open = false;
+  for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
+    if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
+    if(CTX::instance()->files[i] == "-new")
+      new GModel();
+    else if(CTX::instance()->files[i] == "-merge")
+      open = false;
+    else if(CTX::instance()->files[i] == "-open")
+      open = true;
+    else if(open)
+      OpenProject(CTX::instance()->files[i]);
+    else
+      MergeFile(CTX::instance()->files[i]);
+  }
+
+
+#if defined(HAVE_POST) && defined(HAVE_MESH)
+  if(!CTX::instance()->bgmFileName.empty()) {
+    MergePostProcessingFile(CTX::instance()->bgmFileName);
+    if(PView::list.size())
+      GModel::current()->getFields()->setBackgroundMesh(PView::list.size() - 1);
+    else
+      Msg::Error("Invalid background mesh (no view)");
+  }
+#endif
+
+  if(CTX::instance()->batch == -3){
+    GmshRemote();
+  }
+  else if(CTX::instance()->batch == -2){
+    GModel::current()->checkMeshCoherence(CTX::instance()->geom.tolerance);
+#if defined(HAVE_PARSER)
+    std::vector<std::string> s;
+    PrintParserSymbols(0, s);
+    for(unsigned int i = 0; i < s.size(); i++)
+      Msg::Direct("%s", s[i].c_str());
+#endif
+  }
+  else if(CTX::instance()->batch == -1){
+    CreateOutputFile(CTX::instance()->outputFileName,
+                     CTX::instance()->outputFileName.empty() ? FORMAT_GEO :
+                     FORMAT_AUTO);
+  }
+  else if(CTX::instance()->batch > 0){
+#if defined(HAVE_MESH)
+    if(CTX::instance()->batch < 4)
+      GModel::current()->mesh(CTX::instance()->batch);
+    else if(CTX::instance()->batch == 4)
+      AdaptMesh(GModel::current());
+    else if(CTX::instance()->batch == 5)
+      RefineMesh(GModel::current(), CTX::instance()->mesh.secondOrderLinear);
+    else if(CTX::instance()->batch == 6)
+      GModel::current()->classifyAllFaces();
+#if defined(HAVE_CHACO) || defined(HAVE_METIS)
+    if(CTX::instance()->batchAfterMesh == 1){
+      if (CTX::instance()->partitionOptions.num_partitions > 1)
+        PartitionMesh(GModel::current(), CTX::instance()->partitionOptions);
+      if (CTX::instance()->partitionOptions.renumber)
+        RenumberMesh(GModel::current(), CTX::instance()->partitionOptions);
+    }
+#endif
+#endif
+    std::string name = CTX::instance()->outputFileName;
+    if(name.empty()){
+      if(CTX::instance()->mesh.fileFormat == FORMAT_AUTO)
+        name = GetDefaultFileName(FORMAT_MSH);
+      else
+        name = GetDefaultFileName(CTX::instance()->mesh.fileFormat);
+    }
+    CreateOutputFile(name, CTX::instance()->mesh.fileFormat);
+  }
+
+  // launch solver (if requested)
+#if defined(HAVE_ONELAB)
+  solver_batch_cb((void*)(intptr_t)CTX::instance()->launchSolverAtStartup);
+#endif
+
+  time_t now;
+  time(&now);
+  std::string currtime = ctime(&now);
+  currtime.resize(currtime.size() - 1);
+  Msg::Info("Stopped on %s", currtime.c_str());
+
+  return 1;
+}
+
+int GmshBatch(int argc, char **argv)
+{
+  new GModel();
+  GmshInitialize(argc, argv);
+  if(!Msg::GetGmshClient()) CTX::instance()->terminal = 1;
+  CTX::instance()->noPopup = 1;
+  GmshBatch();
+  GmshFinalize();
+  return 1;
+}
+
+int GmshFLTK(int argc, char **argv)
+{
+#if defined(HAVE_FLTK) && defined(HAVE_POST)
+  // create the GUI
+  FlGui::instance(argc, argv);
+
+  // display GUI immediately for quick launch time
+  FlGui::instance()->check();
+
+  // open project file and merge all other input files
+  if(FlGui::getOpenedThroughMacFinder().empty()){
+    OpenProject(GModel::current()->getFileName());
+    bool open = false;
+    for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
+      if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
+      if(CTX::instance()->files[i] == "-new"){
+        GModel::current()->setVisibility(0);
+        new GModel();
+      }
+      else if(CTX::instance()->files[i] == "-merge")
+        open = false;
+      else if(CTX::instance()->files[i] == "-open")
+        open = true;
+      else if(open)
+        OpenProject(CTX::instance()->files[i]);
+      else
+        MergeFile(CTX::instance()->files[i]);
+    }
+  }
+  else{
+    OpenProject(FlGui::getOpenedThroughMacFinder());
+  }
+
+  if(CTX::instance()->post.combineTime){
+    PView::combine(true, 2, CTX::instance()->post.combineRemoveOrig);
+    FlGui::instance()->updateViews(true, true);
+  }
+
+  // init first context
+  switch (CTX::instance()->initialContext) {
+  case 1: FlGui::instance()->openModule("Geometry"); break;
+  case 2: FlGui::instance()->openModule("Mesh"); break;
+  case 3: FlGui::instance()->openModule("Solver"); break;
+  case 4: FlGui::instance()->openModule("Post-processing"); break;
+  default: // automatic
+    if(PView::list.size()) FlGui::instance()->openModule("Post-processing");
+    break;
+  }
+
+  // read background mesh if any
+  if(!CTX::instance()->bgmFileName.empty()) {
+    MergePostProcessingFile(CTX::instance()->bgmFileName);
+    if(PView::list.size())
+      GModel::current()->getFields()->setBackgroundMesh(PView::list.size() - 1);
+    else
+      Msg::Error("Invalid background mesh (no view)");
+  }
+
+  // listen to external solvers
+  if(CTX::instance()->solver.listen){
+    gmshLocalNetworkClient *c = new gmshLocalNetworkClient("Listen", "");
+    c->run();
+  }
+
+  // launch solver (if requested) and fill onelab tree
+  solver_cb(0, (void*)(intptr_t)CTX::instance()->launchSolverAtStartup);
+
+  // loop
+  return FlGui::instance()->run();
+#else
+  Msg::Error("GmshFLTK unavailable: please recompile with FLTK support");
+  return 0;
+#endif
+}
diff --git a/Common/GmshGlobal.h b/Common/GmshGlobal.h
new file mode 100644
index 0000000000000000000000000000000000000000..eca226fc905a0fc90ff51d98496926f9786f2e45
--- /dev/null
+++ b/Common/GmshGlobal.h
@@ -0,0 +1,53 @@
+// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to the public mailing list <gmsh@onelab.info>.
+
+#ifndef _GMSH_GLOBAL_H_
+#define _GMSH_GLOBAL_H_
+
+#include <string>
+#include "GmshMessage.h"
+
+int GmshInitialize(int argc=0, char **argv=0);
+int GmshSetMessageHandler(GmshMessage *callback);
+GmshMessage *GmshGetMessageHandler();
+int GmshSetBoundingBox(double xmin, double xmax,
+                       double ymin, double ymax,
+                       double zmin, double zmax);
+int GmshSetOption(const std::string &category, const std::string &name,
+                  std::string value, int index=0);
+int GmshSetOption(const std::string &category, const std::string &name,
+                  double value, int index=0);
+int GmshSetOption(const std::string &category, const std::string &name,
+                  unsigned int value, int index=0);
+void GmshSetStringOption(const std::string &category, const std::string &name,
+                         std::string value, int index=0);
+void GmshSetNumberOption(const std::string &category, const std::string &name,
+                         double value, int index=0);
+void GmshSetColorOption(const std::string &category, const std::string &name,
+                        unsigned int value, int index=0);
+int GmshGetOption(const std::string &category, const std::string &name,
+                  std::string &value, int index=0);
+int GmshGetOption(const std::string &category, const std::string &name,
+                  double &value, int index=0);
+int GmshGetOption(const std::string &category, const std::string &name,
+                  unsigned int &value, int index=0);
+std::string GmshGetStringOption(const std::string &category, const std::string &name,
+                                int index=0);
+double GmshGetNumberOption(const std::string &category, const std::string &name,
+                           int index=0);
+unsigned int GmshGetColorOption(const std::string &category, const std::string &name,
+                                int index=0);
+int GmshRestoreDefaultOptions();
+int GmshOpenProject(const std::string &fileName);
+int GmshClearProject();
+int GmshMergeFile(const std::string &fileName);
+int GmshMergePostProcessingFile(const std::string &fileName);
+int GmshWriteFile(const std::string &fileName);
+int GmshFinalize();
+int GmshBatch();
+int GmshBatch(int argc, char **argv);
+int GmshFLTK(int argc=0, char **argv=0);
+
+#endif
diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp
index cf296907cd3e5592f1fcc751d37ebe4c6c74f1b4..e09fa644e375c1a6ac3babd834a7d20e8cbd7fb8 100644
--- a/Common/GmshMessage.cpp
+++ b/Common/GmshMessage.cpp
@@ -17,7 +17,7 @@
 #include <sys/stat.h>
 #include "GmshMessage.h"
 #include "GmshSocket.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "Options.h"
 #include "Context.h"
diff --git a/Common/Main.cpp b/Common/Main.cpp
index 7c79f807dc259acf1290989c6dbabe175def00c5..7b9781764f1384855b655eafcacd3c32eed81233 100644
--- a/Common/Main.cpp
+++ b/Common/Main.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
 #include <stdlib.h>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "CommandLine.h"
 #include "GmshMessage.h"
diff --git a/Common/gmsh.i b/Common/gmsh.i
new file mode 100644
index 0000000000000000000000000000000000000000..8ecb365412e2934f63c342882aeabab3b6929d71
--- /dev/null
+++ b/Common/gmsh.i
@@ -0,0 +1,15 @@
+%module gmsh
+%{
+  #include "gmsh.h"
+%}
+
+%include std_string.i
+%include std_vector.i
+
+namespace std {
+  %template(DoubleVector) vector<double>;
+  %template(StringVector) vector<string>;
+  %template(PairVector) vector<std::pair<int, int> >;
+}
+
+%include "gmsh.h"
diff --git a/Common/gmshLocalNetworkClient.cpp b/Common/gmshLocalNetworkClient.cpp
index c8b785114f7e70af6e8335535d58836cd1f8ec79..4b78cf2fd8d7c88768bc135299ca29e8b11645e5 100644
--- a/Common/gmshLocalNetworkClient.cpp
+++ b/Common/gmshLocalNetworkClient.cpp
@@ -9,7 +9,7 @@
 #elif defined(HAVE_NO_INTPTR_T)
 typedef unsigned long intptr_t;
 #endif
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "Context.h"
 #include "OS.h"
 #include "StringUtils.h"
diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp
index 6de8ac243bbda458d3e2f5873bd4dd9ad8aeb1bb..0b2160326b8746a38404b91e704dead0e4420450 100644
--- a/Common/onelabUtils.cpp
+++ b/Common/onelabUtils.cpp
@@ -514,4 +514,5 @@ namespace onelabUtils {
   }
 
 }
+
 #endif
diff --git a/Common/picojson.h b/Common/picojson.h
index f75c399b7e7380bdac4fbb25019e6ce499714f26..2b2e634062c6fe9bd9e24cd581b6573640c52670 100644
--- a/Common/picojson.h
+++ b/Common/picojson.h
@@ -231,7 +231,7 @@ inline value::value(double n) : type_(number_type), u_() {
   if (
 #ifdef _MSC_VER
       !_finite(n)
-#elif __cplusplus >= 201103L || !(defined(isnan) && defined(isinf))
+#elif __cplusplus >= 201103L
       std::isnan(n) || std::isinf(n)
 #else
       isnan(n) || isinf(n)
diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp
index f52239ea3edd24ed9559fb917d6f65dace4a1160..ab420cd6bd5a2d9237ecfa0bc6993d6a926e6ba7 100644
--- a/Fltk/Main.cpp
+++ b/Fltk/Main.cpp
@@ -5,7 +5,7 @@
 
 #include <stdlib.h>
 #include <string>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshMessage.h"
 #include "Context.h"
 #include "Options.h"
diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp
index 4fa5be1fe0c59418c356fb4e9e8ba3049126303e..408d4cba72f9a46b5e0eb28bfe5d848714153ea5 100644
--- a/Fltk/onelabGroup.cpp
+++ b/Fltk/onelabGroup.cpp
@@ -32,7 +32,7 @@ typedef unsigned long intptr_t;
 #include "graphicWindow.h"
 #include "fileDialogs.h"
 #include "onelabGroup.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "FlGui.h"
 #include "Context.h"
 #include "GModel.h"
diff --git a/Graphics/Camera.cpp b/Graphics/Camera.cpp
index 9cdbe75a7fea39a32bc2ed9fe9567de55ccf124c..5f3acb08eab415b641a9903446f9e11f144ce701 100644
--- a/Graphics/Camera.cpp
+++ b/Graphics/Camera.cpp
@@ -11,7 +11,7 @@
 #include <math.h>
 #include <algorithm>
 #include "Camera.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "Trackball.h"
diff --git a/Graphics/drawAxes.cpp b/Graphics/drawAxes.cpp
index 28f8e13fd36983b3063cd22059dcf6989082bd2f..39ed39b1d0ea1770f7ded8718be9d40f258cbf50 100644
--- a/Graphics/drawAxes.cpp
+++ b/Graphics/drawAxes.cpp
@@ -5,7 +5,7 @@
 
 #include <string>
 #include <iostream>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include <string.h>
 #include "drawContext.h"
 #include "Trackball.h"
diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp
index 9bc6e0e41df76c398bea220f4029710f98afd946..a57946d046ccd1c9241ea023ae8c8a4e2d226c6b 100644
--- a/Graphics/drawContext.cpp
+++ b/Graphics/drawContext.cpp
@@ -5,7 +5,7 @@
 
 #include <string>
 #include <stdio.h>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "drawContext.h"
diff --git a/Plugin/Bubbles.cpp b/Plugin/Bubbles.cpp
index 77654ce0b95c2bbf3be78538bb8cc1672217e5b1..f73e075746e0929c697c93dbb07dd602819254ef 100644
--- a/Plugin/Bubbles.cpp
+++ b/Plugin/Bubbles.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
 #include <stdlib.h>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "MTriangle.h"
 #include "Numeric.h"
diff --git a/Plugin/CurvedBndDist.cpp b/Plugin/CurvedBndDist.cpp
index 43abb2118d26f38bf2355d77d9d94d691149b977..eb697fe656b7d633d5a4294c10d7b33530fd350c 100644
--- a/Plugin/CurvedBndDist.cpp
+++ b/Plugin/CurvedBndDist.cpp
@@ -3,7 +3,7 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GModel.h"
 #include "MElement.h"
diff --git a/Plugin/Distance.cpp b/Plugin/Distance.cpp
index 4386e15d5258442db6486340bcba4c2ed7a414f7..39ff6a8d6dafbad28afcd734038b76674530e3fa 100644
--- a/Plugin/Distance.cpp
+++ b/Plugin/Distance.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
 #include <stdlib.h>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GModel.h"
 #include "OS.h"
diff --git a/Plugin/FieldFromAmplitudePhase.cpp b/Plugin/FieldFromAmplitudePhase.cpp
index d8efd70d7ff1350d0b9904f463d5c95138062d2e..0094ec321ffbe3b2cfb79f71b20787aa53827ed5 100644
--- a/Plugin/FieldFromAmplitudePhase.cpp
+++ b/Plugin/FieldFromAmplitudePhase.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
 #include <stdlib.h>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GModel.h"
 #include "MElement.h"
diff --git a/Plugin/HomologyComputation.cpp b/Plugin/HomologyComputation.cpp
index 144e6b194bcdccced34f015d6ebbd0ba6ddb67f1..0cf8961e4f4572c6f1173308b835b839db92191a 100644
--- a/Plugin/HomologyComputation.cpp
+++ b/Plugin/HomologyComputation.cpp
@@ -9,7 +9,7 @@
 #include <string>
 #include <iostream>
 #include <sstream>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GModel.h"
 #include "Homology.h"
diff --git a/Plugin/HomologyPostProcessing.cpp b/Plugin/HomologyPostProcessing.cpp
index edb0f1456296e6fd57800e44083318689c11bb40..7ca3f0de13317e88fa8d005c617b1119b9f59f74 100644
--- a/Plugin/HomologyPostProcessing.cpp
+++ b/Plugin/HomologyPostProcessing.cpp
@@ -9,7 +9,7 @@
 #include <string>
 #include <iostream>
 #include <sstream>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshConfig.h"
 #include "GModel.h"
 #include "Chain.h"
diff --git a/Qt/GLWidget.h b/Qt/GLWidget.h
index 8c75fedfd0705e033980f842de3a464da7206def..7f5d8246909b15e239089af3b52070b217b409ab 100644
--- a/Qt/GLWidget.h
+++ b/Qt/GLWidget.h
@@ -7,7 +7,7 @@
 #define _GLWIDGET_H_
 
 #include <QGLWidget>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "drawContext.h"
 
 class GLWidget : public QGLWidget
diff --git a/Qt/Main.cpp b/Qt/Main.cpp
index dff10d87aa2c5dd641bbc6fb3a019baef87df91e..ef6f602e3b353059dd4cafad5d41f5c02a116529 100644
--- a/Qt/Main.cpp
+++ b/Qt/Main.cpp
@@ -4,7 +4,7 @@
 // bugs and problems to the public mailing list <gmsh@onelab.info>.
 
 #include <stdlib.h>
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GmshMessage.h"
 #include "GModel.h"
 #include "CommandLine.h"
diff --git a/Solver/convexCombinationTerm.h b/Solver/convexCombinationTerm.h
index 6532d57d54df2f1ca6069268c5ddeac2bd41454f..374d20eb57ef1103df704bf80f6536f80bc1a4c9 100644
--- a/Solver/convexCombinationTerm.h
+++ b/Solver/convexCombinationTerm.h
@@ -9,7 +9,7 @@
 #include <assert.h>
 #include "femTerm.h"
 #include "simpleFunction.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "SElement.h"
 #include "fullMatrix.h"
diff --git a/Solver/crossConfTerm.h b/Solver/crossConfTerm.h
index 5df0d5b49c94cc5071efcf538dce64cd4dde5dfd..cb8bdccc406b682985941510af14abe89d49a2b1 100644
--- a/Solver/crossConfTerm.h
+++ b/Solver/crossConfTerm.h
@@ -8,7 +8,7 @@
 
 #include "femTerm.h"
 #include "simpleFunction.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "SElement.h"
 #include "fullMatrix.h"
@@ -21,19 +21,19 @@ class crossConfTerm : public femTerm<double> {
   int _iFieldC;
   std::map<MVertex*, SPoint3> *_coordView;
  public:
-  crossConfTerm(GModel *gm, int iFieldR, int iFieldC, 
-                simpleFunction<double> *diffusivity, 
+  crossConfTerm(GModel *gm, int iFieldR, int iFieldC,
+                simpleFunction<double> *diffusivity,
 		std::map<MVertex*, SPoint3> *coord=NULL)
-    : femTerm<double>(gm), _diffusivity(diffusivity), _iFieldR(iFieldR), 
+    : femTerm<double>(gm), _diffusivity(diffusivity), _iFieldR(iFieldR),
     _iFieldC(iFieldC), _coordView(coord) {}
 
-  virtual int sizeOfR(SElement *se) const 
+  virtual int sizeOfR(SElement *se) const
   {
-    return se->getMeshElement()->getNumShapeFunctions(); 
+    return se->getMeshElement()->getNumShapeFunctions();
   }
   virtual int sizeOfC(SElement *se) const
   {
-    return se->getMeshElement()->getNumShapeFunctions(); 
+    return se->getMeshElement()->getNumShapeFunctions();
   }
   Dof getLocalDofR(SElement *se, int iRow) const
   {
@@ -49,7 +49,7 @@ class crossConfTerm : public femTerm<double> {
   {
     MElement *e = se->getMeshElement();
     int nbSF = e->getNumShapeFunctions();
-    int integrationOrder = 2 * (e->getPolynomialOrder() - 1); 
+    int integrationOrder = 2 * (e->getPolynomialOrder() - 1);
     int npts;
     IntPt *GP;
     double jac[3][3];
@@ -59,21 +59,21 @@ class crossConfTerm : public femTerm<double> {
     e->getIntegrationPoints(integrationOrder, &npts, &GP);
 
     m.setAll(0.);
-    
+
     for (int i = 0; i < npts; i++){
       const double u = GP[i].pt[0];
       const double v = GP[i].pt[1];
       const double w = GP[i].pt[2];
       const double weight = GP[i].weight;
-      const double detJ = e->getJacobian(u, v, w, jac);   
+      const double detJ = e->getJacobian(u, v, w, jac);
       SPoint3 p; e->pnt(u, v, w, p);
       const double _diff = (*_diffusivity)(p.x(), p.y(), p.z());
-      inv3x3(jac, invjac); 
+      inv3x3(jac, invjac);
       e->getGradShapeFunctions(u, v, w, grads);
       for (int j = 0; j < nbSF; j++){
-        Grads[j] = SVector3(invjac[0][0] * grads[j][0] + invjac[0][1] * grads[j][1] + 
+        Grads[j] = SVector3(invjac[0][0] * grads[j][0] + invjac[0][1] * grads[j][1] +
                             invjac[0][2] * grads[j][2],
-                            invjac[1][0] * grads[j][0] + invjac[1][1] * grads[j][1] + 
+                            invjac[1][0] * grads[j][0] + invjac[1][1] * grads[j][1] +
                             invjac[1][2] * grads[j][2],
                             invjac[2][0] * grads[j][0] + invjac[2][1] * grads[j][1] +
                             invjac[2][2] * grads[j][2]);
diff --git a/Solver/diagBCTerm.h b/Solver/diagBCTerm.h
index f3239540a4c3b0992c3893fbc31cc64fadeba22c..53a146bf8940660817dd41463f83d2219757801a 100644
--- a/Solver/diagBCTerm.h
+++ b/Solver/diagBCTerm.h
@@ -9,7 +9,7 @@
 #include <assert.h>
 #include "femTerm.h"
 #include "simpleFunction.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "SElement.h"
 #include "fullMatrix.h"
@@ -26,8 +26,8 @@ class diagBCTerm : public femTerm<double> {
   {
     return se->getMeshElement()->getNumShapeFunctions();
   }
-  virtual int sizeOfC(SElement *se) const 
-  { 
+  virtual int sizeOfC(SElement *se) const
+  {
     return se->getMeshElement()->getNumShapeFunctions();
   }
   Dof getLocalDofR(SElement *se, int iRow) const
@@ -47,7 +47,7 @@ class diagBCTerm : public femTerm<double> {
         m(k, j) = 0.0;
       }
       MVertex *v = e->getShapeFunctionNode(j);
-      if( v->onWhat()->dim() < 2 ) m(j, j) = 1.0; 
+      if( v->onWhat()->dim() < 2 ) m(j, j) = 1.0;
       else m(j, j) = 0.0;
     }
   }
diff --git a/Solver/elasticityTerm.h b/Solver/elasticityTerm.h
index 626a7a97e13b0f54c2097cab3dc3df14ea496ef2..d2159de38f96d3b8d18cc6df62cd603159026592 100644
--- a/Solver/elasticityTerm.h
+++ b/Solver/elasticityTerm.h
@@ -7,16 +7,16 @@
 #define _ELASTICITY_TERM_H_
 
 #include "femTerm.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "polynomialBasis.h"
 #include "SElement.h"
 #include "fullMatrix.h"
 
-struct elasticityDataAtGaussPoint 
-{  
+struct elasticityDataAtGaussPoint
+{
   std::vector< fullMatrix<double> > gradSF;
-  std::vector<double> u,v,w,weight;  
+  std::vector<double> u,v,w,weight;
 };
 
 class elasticityTerm : public femTerm<double> {
@@ -25,7 +25,7 @@ class elasticityTerm : public femTerm<double> {
   int _iFieldR, _iFieldC;
   SVector3 _volumeForce;
   mutable std::map<int,elasticityDataAtGaussPoint> _data;
-  void createData (MElement*) const;    
+  void createData (MElement*) const;
  public:
   void setFieldC(int i){_iFieldC = i;}
   void setFieldR(int i){_iFieldR = i;}
@@ -39,7 +39,7 @@ class elasticityTerm : public femTerm<double> {
     return 3 * se->getMeshElement()->getNumShapeFunctions();
   }
   // order dofs in the local matrix :
-  // dx1, dx2 ... dxn, dy1, ..., dyn, dz1, ... dzn 
+  // dx1, dx2 ... dxn, dy1, ..., dyn, dz1, ... dzn
   Dof getLocalDofR(SElement *se, int iRow) const
   {
     MElement *e = se->getMeshElement();
@@ -70,9 +70,9 @@ class elasticityTerm : public femTerm<double> {
   Formulation of elasticity with 3 fields
    -) displacement U
    -) lagrange multipliers p and g
-  
-   g = trace (epsilon) 
-   p = trace (epsilon) 
+
+   g = trace (epsilon)
+   p = trace (epsilon)
 
 
 */
@@ -103,7 +103,7 @@ public:
     return sizeOfR(se);
   }
   // order dofs in the local matrix :
-  // dx1, dx2 ... dxn, dy1, ..., dyn, dz1, ... dzn , 
+  // dx1, dx2 ... dxn, dy1, ..., dyn, dz1, ... dzn ,
   // p1,p2,...,pm, g1,g2,...,gm
   Dof getLocalDofR(SElement *se, int iRow) const
   {
@@ -118,7 +118,7 @@ public:
     else {
       iRow -= 3 * _sizeN;
       iComp = 3 + iRow / _sizeM;
-      ithLocalVertex = iRow % _sizeM;      
+      ithLocalVertex = iRow % _sizeM;
     }
     return Dof(e->getShapeFunctionNode(ithLocalVertex)->getNum(),
                Dof::createTypeWithTwoInts(iComp, _iField));
diff --git a/Solver/helmholtzTerm.h b/Solver/helmholtzTerm.h
index 8513b20ca6079768f1b00333fa9afbe338c05ad2..8133406cf168bf0df7d95c9ee0e453778bc5b978 100644
--- a/Solver/helmholtzTerm.h
+++ b/Solver/helmholtzTerm.h
@@ -9,13 +9,13 @@
 #include <assert.h>
 #include "femTerm.h"
 #include "simpleFunction.h"
-#include "Gmsh.h"
+#include "GmshGlobal.h"
 #include "GModel.h"
 #include "SElement.h"
 #include "fullMatrix.h"
 #include "Numeric.h"
 
-// \nabla \cdot k \nabla U - a U 
+// \nabla \cdot k \nabla U - a U
 template<class scalar>
 class helmholtzTerm : public femTerm<scalar> {
  protected:
@@ -24,16 +24,16 @@ class helmholtzTerm : public femTerm<scalar> {
   int _iFieldC ;
  public:
   helmholtzTerm(GModel *gm, int iFieldR, int iFieldC, simpleFunction<scalar> *k,
-                simpleFunction<scalar> *a) 
+                simpleFunction<scalar> *a)
     : femTerm<scalar>(gm), _k(k), _a(a), _iFieldR(iFieldR), _iFieldC(iFieldC) {}
   // one dof per vertex (nodal fem)
-  virtual int sizeOfR(SElement *se) const 
-  { 
-    return se->getMeshElement()->getNumShapeFunctions(); 
+  virtual int sizeOfR(SElement *se) const
+  {
+    return se->getMeshElement()->getNumShapeFunctions();
   }
-  virtual int sizeOfC(SElement *se) const 
-  { 
-    return se->getMeshElement()->getNumShapeFunctions(); 
+  virtual int sizeOfC(SElement *se) const
+  {
+    return se->getMeshElement()->getNumShapeFunctions();
   }
   Dof getLocalDofR(SElement *se, int iRow) const
   {
@@ -51,9 +51,9 @@ class helmholtzTerm : public femTerm<scalar> {
     if (_k)_k->setElement(e);
     if (_a)_a->setElement(e);
     // compute integration rule
-    // const int integrationOrder = (_a) ? 2 * e->getPolynomialOrder() : 
+    // const int integrationOrder = (_a) ? 2 * e->getPolynomialOrder() :
     //2 * (e->getPolynomialOrder() - 1);
-       const int integrationOrder = 2 * e->getPolynomialOrder() + 1; 
+       const int integrationOrder = 2 * e->getPolynomialOrder() + 1;
 
     int npts; IntPt *GP;
     e->getIntegrationPoints(integrationOrder, &npts, &GP);
@@ -63,9 +63,9 @@ class helmholtzTerm : public femTerm<scalar> {
     assert(nbSF < 100);
     double jac[3][3];
     double invjac[3][3];
-    double Grads[100][3], grads[100][3];  
+    double Grads[100][3], grads[100][3];
     double sf[100];
-    // set the local matrix to 0 
+    // set the local matrix to 0
     m.setAll(0.);
     // loop over integration points
     for (int i = 0; i < npts; i++){
@@ -73,7 +73,7 @@ class helmholtzTerm : public femTerm<scalar> {
       const double u = GP[i].pt[0];
       const double v = GP[i].pt[1];
       const double w = GP[i].pt[2];
-      const double weightDetJ = GP[i].weight * e->getJacobian(u, v, w, jac);   
+      const double weightDetJ = GP[i].weight * e->getJacobian(u, v, w, jac);
       SPoint3 p; e->pnt(u, v, w, p);
       const scalar K = _k ? (*_k)(p.x(), p.y(), p.z()) : 0.0;
       const scalar A = _a ? (*_a)(p.x(), p.y(), p.z()) : 0.0;
@@ -81,9 +81,9 @@ class helmholtzTerm : public femTerm<scalar> {
       e->getGradShapeFunctions(u, v, w, grads);
       if (_a) e->getShapeFunctions(u, v, w, sf);
       for (int j = 0; j < nbSF; j++){
-        Grads[j][0] = invjac[0][0] * grads[j][0] + invjac[0][1] * grads[j][1] + 
+        Grads[j][0] = invjac[0][0] * grads[j][0] + invjac[0][1] * grads[j][1] +
           invjac[0][2] * grads[j][2];
-        Grads[j][1] = invjac[1][0] * grads[j][0] + invjac[1][1] * grads[j][1] + 
+        Grads[j][1] = invjac[1][0] * grads[j][0] + invjac[1][1] * grads[j][1] +
           invjac[1][2] * grads[j][2];
         Grads[j][2] = invjac[2][0] * grads[j][0] + invjac[2][1] * grads[j][1] +
           invjac[2][2] * grads[j][2];
diff --git a/contrib/mobile/CMakeLists.txt b/contrib/mobile/CMakeLists.txt
index b0f555ced76408e23b01c56cac297d8b0613b840..bc407244080210c67d9330164b63f834ac3ebcb0 100644
--- a/contrib/mobile/CMakeLists.txt
+++ b/contrib/mobile/CMakeLists.txt
@@ -41,21 +41,21 @@ macro(append_src FILES)
 endmacro(append_src)
 
 if(ENABLE_BUILD_IOS_EMULATOR OR ENABLE_BUILD_IOS)
-  # GetDP framework
-  find_path(GETDP_FRAMEWORK GetDP.framework)
+  # getdp framework
+  find_path(GETDP_FRAMEWORK getdp.framework)
   if(GETDP_FRAMEWORK)
-    set(GETDP_FRAMEWORK ${GETDP_FRAMEWORK}/GetDP.framework)
+    set(GETDP_FRAMEWORK ${GETDP_FRAMEWORK}/getdp.framework)
     message(STATUS "Found framework " ${GETDP_FRAMEWORK})
   else(GETDP_FRAMEWORK)
-    message(SEND_ERROR "Could not find GetDP.framework")
+    message(SEND_ERROR "Could not find getdp.framework")
   endif(GETDP_FRAMEWORK)
-  # Gmsh framework
-  find_path(GMSH_FRAMEWORK Gmsh.framework)
+  # gmsh framework
+  find_path(GMSH_FRAMEWORK gmsh.framework)
   if(GMSH_FRAMEWORK)
-    set(GMSH_FRAMEWORK ${GMSH_FRAMEWORK}/Gmsh.framework)
+    set(GMSH_FRAMEWORK ${GMSH_FRAMEWORK}/gmsh.framework)
     message(STATUS "Found framework " ${GMSH_FRAMEWORK})
   else(GMSH_FRAMEWORK)
-    message(SEND_ERROR "Could not find Gmsh.framework")
+    message(SEND_ERROR "Could not find gmsh.framework")
   endif(GMSH_FRAMEWORK)
   # PETSc framework
   find_path(PETSC_FRAMEWORK petsc.framework)
@@ -74,12 +74,12 @@ if(ENABLE_BUILD_IOS_EMULATOR OR ENABLE_BUILD_IOS)
     message(SEND_ERROR "Could not find slepc.framework")
   endif(SLEPC_FRAMEWORK)
   # OpenCASCADE framework
-  find_path(OCCT_FRAMEWORK OCCT.framework)
+  find_path(OCCT_FRAMEWORK occt.framework)
   if(OCCT_FRAMEWORK)
-    set(OCCT_FRAMEWORK ${OCCT_FRAMEWORK}/OCCT.framework)
+    set(OCCT_FRAMEWORK ${OCCT_FRAMEWORK}/occt.framework)
     message(STATUS "Found framework " ${OCCT_FRAMEWORK})
   else(OCCT_FRAMEWORK)
-    message(SEND_ERROR "Could not find OCCT.framework")
+    message(SEND_ERROR "Could not find occt.framework")
   endif(OCCT_FRAMEWORK)
   # add target
   add_custom_target(xcodeProject
@@ -100,14 +100,14 @@ if(ENABLE_BUILD_IOS_EMULATOR OR ENABLE_BUILD_IOS)
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/iosUtils.h ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/iosUtils.cpp ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/
-    COMMAND ${CMAKE_COMMAND} -E copy_directory ${GETDP_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/GetDP.framework/
+    COMMAND ${CMAKE_COMMAND} -E copy_directory ${GETDP_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/getdp.framework/
     COMMAND ${CMAKE_COMMAND} -E remove ${GMSH_FRAMEWORK}/Headers/gmsh
-    COMMAND ${CMAKE_COMMAND} -E copy_directory ${GMSH_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/Gmsh.framework/
-    COMMAND ${CMAKE_COMMAND} -E create_symlink . ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/Gmsh.framework/Headers/gmsh
+    COMMAND ${CMAKE_COMMAND} -E copy_directory ${GMSH_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/gmsh.framework/
+    COMMAND ${CMAKE_COMMAND} -E create_symlink . ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/gmsh.framework/Headers/gmsh
     COMMAND ${CMAKE_COMMAND} -E create_symlink . ${GMSH_FRAMEWORK}/Headers/gmsh
     COMMAND ${CMAKE_COMMAND} -E copy_directory ${PETSC_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/petsc.framework/
     COMMAND ${CMAKE_COMMAND} -E copy_directory ${SLEPC_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/slepc.framework/
-    COMMAND ${CMAKE_COMMAND} -E copy_directory ${OCCT_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/OCCT.framework/
+    COMMAND ${CMAKE_COMMAND} -E copy_directory ${OCCT_FRAMEWORK}/ ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/frameworks/occt.framework/
   )
   add_custom_command(TARGET xcodeProject POST_BUILD COMMAND ${CMAKE_COMMAND} -E remove_directory
                     ${CMAKE_CURRENT_BINARY_DIR}/${APPNAME}/${APPNAME}/files)
@@ -152,23 +152,23 @@ if(ENABLE_BUILD_ANDROID)
   append_src(drawString.cpp)
   append_src(drawGeom.cpp)
   append_src(drawMesh.cpp)
-  # GetDP lib
+  # getdp lib
   find_library(GETDP_LIB Getdp PATH_SUFFIXES lib)
-  find_path(GETDP_INC "GetDP.h" PATH_SUFFIXES include getdp include/getdp)
+  find_path(GETDP_INC "getdp.h" PATH_SUFFIXES include getdp include/getdp)
   if(GETDP_LIB AND GETDP_INC)
     list(APPEND EXTERNAL_LIBRARIES ${GETDP_LIB})
     list(APPEND EXTERNAL_INCLUDES ${GETDP_INC})
   else(GETDP_LIB AND GETDP_INC)
-    message(SEND_ERROR "Could not find GetDP library")
+    message(SEND_ERROR "Could not find getdp library")
   endif(GETDP_LIB AND GETDP_INC)
-  # Gmsh lib
+  # gmsh lib
   find_library(GMSH_LIB Gmsh PATH_SUFFIXES lib)
-  find_path(GMSH_INC "Gmsh.h" PATH_SUFFIXES include gmsh include/gmsh)
+  find_path(GMSH_INC "GmshGlobal.h" PATH_SUFFIXES include gmsh include/gmsh)
   if(GMSH_LIB AND GMSH_INC)
     list(APPEND EXTERNAL_LIBRARIES ${GMSH_LIB})
     list(APPEND EXTERNAL_INCLUDES ${GMSH_INC})
   else(GMSH_LIB AND GMSH_INC)
-    message(SEND_ERROR "Could not find Gmsh library")
+    message(SEND_ERROR "Could not find gmsh library")
   endif(GMSH_LIB AND GMSH_INC)
   # Onelab android lib
   include_directories(${EXTERNAL_INCLUDES})
diff --git a/contrib/mobile/androidUtils.cpp b/contrib/mobile/androidUtils.cpp
index 53bdb54bc22a987115660d39b2aa8d7f0407dfc1..588ec54ab3c5b056cb0115f8b148d03dab478635 100644
--- a/contrib/mobile/androidUtils.cpp
+++ b/contrib/mobile/androidUtils.cpp
@@ -9,7 +9,7 @@
 
 #include <dlfcn.h>
 
-#include <gmsh/Gmsh.h>
+#include <gmsh/GmshGlobal.h>
 #include <gmsh/GmshConfig.h>
 #include <gmsh/GmshVersion.h>
 #include <gmsh/GModel.h>
diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp
index ec9917f0b69e62b046b1b5fa82a070bd06a0d7d9..dba13eb0ea73b3d4af7df0891af81c8e5f6f82f3 100644
--- a/contrib/mobile/drawContext.cpp
+++ b/contrib/mobile/drawContext.cpp
@@ -1,6 +1,6 @@
 #include <map>
 
-#include <gmsh/Gmsh.h>
+#include <gmsh/GmshGlobal.h>
 #include <gmsh/OpenFile.h>
 #include <gmsh/GModel.h>
 #include <gmsh/MElement.h>
@@ -1189,7 +1189,7 @@ int onelab_cb(std::string action)
     args.insert(args.end(), c.begin(), c.end());
     args.push_back("-onelab");
     args.push_back("GetDP");
-    GetDP(args, onelab::server::instance());
+    getdp(args, onelab::server::instance());
   } while(action == "compute" && !onelabStop && (onelabUtils::incrementLoop("3") ||
                                                  onelabUtils::incrementLoop("2") ||
                                                  onelabUtils::incrementLoop("1")));
diff --git a/contrib/mobile/drawGeom.cpp b/contrib/mobile/drawGeom.cpp
index 71e377ff281d0eaab0980961fcdfd0a8729e7e79..626f1fe3c2b0a79ebc6944d42943458fd1159eca 100644
--- a/contrib/mobile/drawGeom.cpp
+++ b/contrib/mobile/drawGeom.cpp
@@ -8,7 +8,7 @@
 #include <OpenGLES/ES1/glext.h>
 #endif
 
-#include <gmsh/Gmsh.h>
+#include <gmsh/GmshGlobal.h>
 #include <gmsh/GModel.h>
 #include <gmsh/Context.h>
 
diff --git a/contrib/mobile/drawMesh.cpp b/contrib/mobile/drawMesh.cpp
index 7d4be6a080909ef35a4c154df2cce44e0d921362..eb27954f986a32ef56106c8dc6c4aa7581ecb8cb 100644
--- a/contrib/mobile/drawMesh.cpp
+++ b/contrib/mobile/drawMesh.cpp
@@ -6,7 +6,7 @@
 #include <OpenGLES/ES1/glext.h>
 #endif
 
-#include <gmsh/Gmsh.h>
+#include <gmsh/GmshGlobal.h>
 #include <gmsh/GModel.h>
 #include <gmsh/GEdgeCompound.h>
 #include <gmsh/GFaceCompound.h>
diff --git a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj
index 873da030d7c2bcc40e5544233a9cb15606c4be24..16bd777c56e8ff266861c63e634dd4f7a558110b 100644
--- a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj
+++ b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj
@@ -9,7 +9,7 @@
 /* Begin PBXBuildFile section */
 		2901F1211BB0086C004C328B /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 2901F1201BB0086C004C328B /* libz.tbd */; };
 		2907CCEC193DE6560011341A /* icon_onelab.png in Resources */ = {isa = PBXBuildFile; fileRef = 2907CCEB193DE6560011341A /* icon_onelab.png */; };
-		291191DB1E93ACF700069C0C /* OCCT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 291191DA1E93ACF700069C0C /* OCCT.framework */; };
+		291191DB1E93ACF700069C0C /* occt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 291191DA1E93ACF700069C0C /* occt.framework */; };
 		295056611D9AF3D200B9D9C4 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 295056601D9AF3D200B9D9C4 /* MessageUI.framework */; };
 		2988FF1E18E59558001435B6 /* libf2cblas.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2988FF1C18E59558001435B6 /* libf2cblas.a */; };
 		2988FF1F18E59558001435B6 /* libf2clapack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2988FF1D18E59558001435B6 /* libf2clapack.a */; };
@@ -38,8 +38,8 @@
 		9CC6EBB917BA1CC7001CA21A /* drawMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CC6EBB817BA1CC7001CA21A /* drawMesh.cpp */; };
 		9CC85C021790286C00F241C4 /* files in Resources */ = {isa = PBXBuildFile; fileRef = 9CC85C011790286C00F241C4 /* files */; };
 		9CDCED2317D5C00500B39082 /* Model.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CDCED2217D5C00500B39082 /* Model.mm */; };
-		9CE08E10178AEB1600A83B4B /* GetDP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0D178AEB1600A83B4B /* GetDP.framework */; };
-		9CE08E11178AEB1600A83B4B /* Gmsh.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0E178AEB1600A83B4B /* Gmsh.framework */; };
+		9CE08E10178AEB1600A83B4B /* getdp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0D178AEB1600A83B4B /* getdp.framework */; };
+		9CE08E11178AEB1600A83B4B /* gmsh.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0E178AEB1600A83B4B /* gmsh.framework */; };
 		9CE08E12178AEB1600A83B4B /* petsc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0F178AEB1600A83B4B /* petsc.framework */; };
 		9CE08E13178AEC5F00A83B4B /* drawContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E01178AE6BE00A83B4B /* drawContext.cpp */; };
 		9CE08E17178AEC5F00A83B4B /* Trackball.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E04178AE6BE00A83B4B /* Trackball.cpp */; };
@@ -56,7 +56,7 @@
 /* Begin PBXFileReference section */
 		2901F1201BB0086C004C328B /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-tbd-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
 		2907CCEB193DE6560011341A /* icon_onelab.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon_onelab.png; sourceTree = "<group>"; };
-		291191DA1E93ACF700069C0C /* OCCT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCCT.framework; path = Onelab/frameworks/OCCT.framework; sourceTree = "<group>"; };
+		291191DA1E93ACF700069C0C /* occt.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = occt.framework; path = Onelab/frameworks/occt.framework; sourceTree = "<group>"; };
 		295056601D9AF3D200B9D9C4 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };
 		2988FF1C18E59558001435B6 /* libf2cblas.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libf2cblas.a; path = Onelab/frameworks/petsc.framework/libf2cblas.a; sourceTree = "<group>"; };
 		2988FF1D18E59558001435B6 /* libf2clapack.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libf2clapack.a; path = Onelab/frameworks/petsc.framework/libf2clapack.a; sourceTree = "<group>"; };
@@ -100,8 +100,8 @@
 		9CE08E02178AE6BE00A83B4B /* drawContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = drawContext.h; sourceTree = "<group>"; usesTabs = 1; };
 		9CE08E04178AE6BE00A83B4B /* Trackball.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Trackball.cpp; sourceTree = "<group>"; usesTabs = 1; };
 		9CE08E05178AE6BE00A83B4B /* Trackball.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Trackball.h; sourceTree = "<group>"; usesTabs = 1; };
-		9CE08E0D178AEB1600A83B4B /* GetDP.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GetDP.framework; path = Onelab/frameworks/GetDP.framework; sourceTree = "<group>"; };
-		9CE08E0E178AEB1600A83B4B /* Gmsh.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Gmsh.framework; path = Onelab/frameworks/Gmsh.framework; sourceTree = "<group>"; };
+		9CE08E0D178AEB1600A83B4B /* getdp.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = getdp.framework; path = Onelab/frameworks/getdp.framework; sourceTree = "<group>"; };
+		9CE08E0E178AEB1600A83B4B /* gmsh.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = gmsh.framework; path = Onelab/frameworks/gmsh.framework; sourceTree = "<group>"; };
 		9CE08E0F178AEB1600A83B4B /* petsc.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = petsc.framework; path = Onelab/frameworks/petsc.framework; sourceTree = "<group>"; };
 		9CE18C1E17B27EDB009BA06E /* Parameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Parameter.h; sourceTree = "<group>"; usesTabs = 1; };
 		9CE18C1F17B27EDB009BA06E /* Parameter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Parameter.mm; sourceTree = "<group>"; usesTabs = 1; };
@@ -137,11 +137,11 @@
 				9C96083F1712C16300E1D4A0 /* CoreGraphics.framework in Frameworks */,
 				9CE2773B17E197F50076E728 /* Social.framework in Frameworks */,
 				295056611D9AF3D200B9D9C4 /* MessageUI.framework in Frameworks */,
-				9CE08E10178AEB1600A83B4B /* GetDP.framework in Frameworks */,
-				9CE08E11178AEB1600A83B4B /* Gmsh.framework in Frameworks */,
+				9CE08E10178AEB1600A83B4B /* getdp.framework in Frameworks */,
+				9CE08E11178AEB1600A83B4B /* gmsh.framework in Frameworks */,
 				9CE08E12178AEB1600A83B4B /* petsc.framework in Frameworks */,
 				9C1B9912194F4E0400507EFD /* slepc.framework in Frameworks */,
-				291191DB1E93ACF700069C0C /* OCCT.framework in Frameworks */,
+				291191DB1E93ACF700069C0C /* occt.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -178,7 +178,7 @@
 		9C9608391712C16300E1D4A0 /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
-				291191DA1E93ACF700069C0C /* OCCT.framework */,
+				291191DA1E93ACF700069C0C /* occt.framework */,
 				295056601D9AF3D200B9D9C4 /* MessageUI.framework */,
 				2901F1201BB0086C004C328B /* libz.tbd */,
 				9C1B9911194F4E0400507EFD /* slepc.framework */,
@@ -187,8 +187,8 @@
 				9C2C3A1F187FDF9900E87F78 /* libstdc++.tbd */,
 				9C2C3A1D187FDF9200E87F78 /* libc++.tbd */,
 				9CE2773917E197DA0076E728 /* Social.framework */,
-				9CE08E0D178AEB1600A83B4B /* GetDP.framework */,
-				9CE08E0E178AEB1600A83B4B /* Gmsh.framework */,
+				9CE08E0D178AEB1600A83B4B /* getdp.framework */,
+				9CE08E0E178AEB1600A83B4B /* gmsh.framework */,
 				9CE08E0F178AEB1600A83B4B /* petsc.framework */,
 				9C96089C1712C7F600E1D4A0 /* QuartzCore.framework */,
 				9C96089A1712C7BE00E1D4A0 /* OpenGLES.framework */,
diff --git a/contrib/mobile/utils/android_build.sh b/contrib/mobile/utils/android_build.sh
index 4d21440c13efc0c10a84e8b13c42a5c55e970735..06ae6d7b969be8abe4846f46f721ea0f6c1abe57 100755
--- a/contrib/mobile/utils/android_build.sh
+++ b/contrib/mobile/utils/android_build.sh
@@ -87,7 +87,7 @@ if [ ! -d "$getdp_git/build_${android}" ] || [ ! -f "$getdp_git/build_${android}
   mkdir $getdp_git/build_${android}
 fi
 cd $getdp_git/build_${android}
-PETSC_DIR= PETSC_ARCH= SLEPC_DIR= cmake $cmake_default -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_SHARED=1 -DENABLE_GMSH=1 -DENABLE_KERNEL=1 -DENABLE_PETSC=1 -DPETSC_INC="$petsc_lib/Headers;$petsc_lib/Headers/mpiuni" -DPETSC_LIBS="$petsc_lib/libpetsc.so" -DENABLE_SLEPC=1 -DSLEPC_INC="$slepc_lib/Headers/" -DSLEPC_LIB="$slepc_lib/libslepc.so" -DGMSH_INC="$gmsh_git/build_${android}/Headers/" -DGMSH_LIB="$gmsh_git/build_${android}/libs/libGmsh.so" -DBLAS_LAPACK_LIBRARIES="$petsc_lib/libf2cblas.so;$petsc_lib/libf2clapack.so" ..
+PETSC_DIR= PETSC_ARCH= SLEPC_DIR= cmake $cmake_default -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_SHARED=1 -DENABLE_GMSH=1 -DENABLE_KERNEL=1 -DENABLE_PETSC=1 -DPETSC_INC="$petsc_lib/Headers;$petsc_lib/Headers/mpiuni" -DPETSC_LIBS="$petsc_lib/libpetsc.so" -DENABLE_SLEPC=1 -DSLEPC_INC="$slepc_lib/Headers/" -DSLEPC_LIB="$slepc_lib/libslepc.so" -DGMSH_INC="$gmsh_git/build_${android}/Headers/" -DGMSH_LIB="$gmsh_git/build_${android}/libs/libgmsh.so" -DBLAS_LAPACK_LIBRARIES="$petsc_lib/libf2cblas.so;$petsc_lib/libf2clapack.so" ..
 check
 make androidGetdp -j$cmake_thread
 check
@@ -104,9 +104,9 @@ cmake $cmake_default -DAPPNAME:STRING=${appname} \
       -DCMAKE_INCLUDE_PATH="$getdp_git/" \
       -DBLAS_LIB="$petsc_lib/libf2cblas.so" -DLAPACK_LIB="$petsc_lib/libf2clapack.so" \
       -DPETSC_LIB="$petsc_lib/libpetsc.so" -DSLEPC_LIB="$slepc_lib/libslepc.so" \
-      -DGMSH_INC="$gmsh_git/build_${android}/Headers" -DGMSH_LIB="$gmsh_git/build_${android}/libs/libGmsh.so" \
+      -DGMSH_INC="$gmsh_git/build_${android}/Headers" -DGMSH_LIB="$gmsh_git/build_${android}/libs/libgmsh.so" \
       -DBENCHMARKSDIR="$getdp_git/" \
-      -DGETDP_INC="$getdp_git/build_${android}/Headers" -DGETDP_LIB="$getdp_git/build_${android}/libs/libGetDP.so" ..
+      -DGETDP_INC="$getdp_git/build_${android}/Headers" -DGETDP_LIB="$getdp_git/build_${android}/libs/libgetdp.so" ..
 check
 make androidOnelab -j$cmake_thread
 check
diff --git a/contrib/mobile/utils/ios_build.sh b/contrib/mobile/utils/ios_build.sh
index bf6dbde1537a1785f86594fe256494fd3be8fce6..5f6c6065271db48c44f4443245b6025e6fb9fca3 100755
--- a/contrib/mobile/utils/ios_build.sh
+++ b/contrib/mobile/utils/ios_build.sh
@@ -49,9 +49,9 @@ fi
 
 petsc_framework="$frameworks_dir/petsc.framework"
 slepc_framework="$frameworks_dir/slepc.framework"
-gmsh_framework="$frameworks_dir/Gmsh.framework"
-getdp_framework="$frameworks_dir/GetDP.framework"
-occt_framework="$frameworks_dir/OCCT.framework"
+gmsh_framework="$frameworks_dir/gmsh.framework"
+getdp_framework="$frameworks_dir/getdp.framework"
+occt_framework="$frameworks_dir/occt.framework"
 
 if [ $enable_simulator != 0 ]; then
   cmake_default="-DDEFAULT=0 -DCMAKE_TOOLCHAIN_FILE=$gmsh_git/contrib/mobile/utils/iOS.cmake -DIOS_PLATFORM=SIMULATOR -DENABLE_BUILD_IOS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -GXcode"
@@ -74,13 +74,13 @@ function check {
 cd $gmsh_git && git pull
 mkdir -p $gmsh_git/build_${ios}
 cd $gmsh_git/build_${ios}
-cmake $cmake_default -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_LIB=1 -DENABLE_MATHEX=1 -DENABLE_MESH=1 -DENABLE_ONELAB=1 -DENABLE_PARSER=1 -DENABLE_POST=1 -DENABLE_PLUGINS=1 -DENABLE_ANN=1 -DENABLE_TETGEN=1 -DENABLE_KBIPACK=1 -DENABLE_GMP=0 -DENABLE_ZIPPER=1 -DENABLE_OCC=$enable_occ -DOCC_LIBS="$occt_framework/OCCT" -DOCC_INC="$occt_framework/Headers/" ..
+cmake $cmake_default -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_LIB=1 -DENABLE_MATHEX=1 -DENABLE_MESH=1 -DENABLE_ONELAB=1 -DENABLE_PARSER=1 -DENABLE_POST=1 -DENABLE_PLUGINS=1 -DENABLE_ANN=1 -DENABLE_TETGEN=1 -DENABLE_KBIPACK=1 -DENABLE_GMP=0 -DENABLE_ZIPPER=1 -DENABLE_OCC=$enable_occ -DOCC_LIBS="$occt_framework/occt" -DOCC_INC="$occt_framework/Headers/" ..
 check
 $build_cmd OTHER_CFLAGS="-m${iphoneos_version}-min=8.0 -fembed-bitcode" OTHER_CPLUSPLUSFLAGS="-m${iphoneos_version}-min=8.0 -fembed-bitcode -std=c++11"
 check
 $headers_cmd
 mkdir -p $gmsh_framework/Headers
-cp $gmsh_git/build_${ios}/Release-${iphoneos}/libGmsh.a $gmsh_framework/Gmsh
+cp $gmsh_git/build_${ios}/Release-${iphoneos}/libgmsh.a $gmsh_framework/gmsh
 cd $gmsh_framework/Headers
 cp $gmsh_git/build_${ios}/Headers/gmsh/* .
 ln -s . gmsh
@@ -89,13 +89,13 @@ ln -s . gmsh
 cd $getdp_git && git pull
 mkdir -p $getdp_git/build_${ios}
 cd $getdp_git/build_${ios}
-PETSC_DIR= PETSC_ARCH= SLEPC_DIR= cmake $cmake_default -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_LIB=1 -DENABLE_GMSH=1 -DENABLE_KERNEL=1 -DENABLE_PETSC=1 -DPETSC_INC="$petsc_framework/Headers/" -DPETSC_LIBS="$petsc_framework/petsc" -DENABLE_SLEPC=1 -DSLEPC_INC="$slepc_framework/Headers/" -DSLEPC_LIB="$slepc_framework/slepc" -DGMSH_INC="$gmsh_framework/Headers/" -DGMSH_LIB="$gmsh_framework/Gmsh" ..
+PETSC_DIR= PETSC_ARCH= SLEPC_DIR= cmake $cmake_default -DENABLE_BLAS_LAPACK=1 -DENABLE_BUILD_LIB=1 -DENABLE_GMSH=1 -DENABLE_KERNEL=1 -DENABLE_PETSC=1 -DPETSC_INC="$petsc_framework/Headers/" -DPETSC_LIBS="$petsc_framework/petsc" -DENABLE_SLEPC=1 -DSLEPC_INC="$slepc_framework/Headers/" -DSLEPC_LIB="$slepc_framework/slepc" -DGMSH_INC="$gmsh_framework/Headers/" -DGMSH_LIB="$gmsh_framework/gmsh" ..
 check
 $build_cmd OTHER_CFLAGS="-m${iphoneos_version}-min=8.0 -fembed-bitcode" OTHER_CPLUSPLUSFLAGS="-m${iphoneos_version}-min=8.0 -fembed-bitcode"
 check
 $headers_cmd
 mkdir -p $getdp_framework/Headers
-cp $getdp_git/build_${ios}/Release-${iphoneos}/libGetDP.a $getdp_framework/GetDP
+cp $getdp_git/build_${ios}/Release-${iphoneos}/libgetdp.a $getdp_framework/getdp
 cd $getdp_framework/Headers
 cp $getdp_git/build_${ios}/Headers/getdp/* .
 
diff --git a/utils/api_demos/mainSimple.cpp b/utils/api_demos/mainSimple.cpp
index a33724f2b61aa948fa753c935a366f46d9e6eecb..e7b875286640274551c305ff643b7dd763a858dd 100644
--- a/utils/api_demos/mainSimple.cpp
+++ b/utils/api_demos/mainSimple.cpp
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include "GmshAPI.h"
+#include <gmsh.h>
 
 int main(int argc, char **argv)
 {