diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp
index 2d9c0c60250e5f6eea0b3c7e5060f3617b61b590..055c2a797262e54e2380a9b50cd96207f2afd4ca 100644
--- a/Geo/GEdge.cpp
+++ b/Geo/GEdge.cpp
@@ -13,10 +13,12 @@
 #include "GEdge.h"
 #include "GFace.h"
 #include "MLine.h"
-#include "Context.h"
 
-#if !defined(HAVE_GMSH_EMBEDDED)
+#if defined(HAVE_GMSH_EMBEDDED)
+#include "GmshEmbedded.h"
+#else
 #include "GaussLegendre1D.h"
+#include "Context.h"
 #endif
 
 GEdge::GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1)
diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp
index 457a24b22fd3efa22c232d03270dd1ff0a23050e..0e17d2e08e41749c1f36045564eff77c89a253b5 100644
--- a/Geo/GModelIO_Mesh.cpp
+++ b/Geo/GModelIO_Mesh.cpp
@@ -566,7 +566,8 @@ int GModel::writeMSH(const std::string &name, double version, bool binary,
   for(viter it = firstVertex(); it != lastVertex(); ++it)
     writeElementsMSH(fp, (*it)->points, saveAll, version, binary, num,
                      (*it)->tag(), (*it)->physicals);
-  writeElementHeaderMSH(binary, fp, elements, MSH_LIN_2, MSH_LIN_3, MSH_LIN_4, MSH_LIN_5);
+  writeElementHeaderMSH
+    (binary, fp, elements, MSH_LIN_2, MSH_LIN_3, MSH_LIN_4, MSH_LIN_5);
   for(eiter it = firstEdge(); it != lastEdge(); ++it)
     writeElementsMSH(fp, (*it)->lines, saveAll, version, binary, num,
                      (*it)->tag(), (*it)->physicals);
@@ -612,7 +613,8 @@ int GModel::writeMSH(const std::string &name, double version, bool binary,
 
 int GModel::writePOS(const std::string &name, bool printElementary, 
                      bool printElementNumber, bool printGamma, bool printEta, 
-                     bool printRho, bool printDisto, bool saveAll, double scalingFactor)
+                     bool printRho, bool printDisto, bool saveAll, 
+                     double scalingFactor)
 {
   FILE *fp = fopen(name.c_str(), "w");
   if(!fp){
@@ -620,7 +622,8 @@ int GModel::writePOS(const std::string &name, bool printElementary,
     return 0;
   }
 
-  bool f[6] = {printElementary, printElementNumber, printGamma, printEta, printRho,printDisto};
+  bool f[6] = {printElementary, printElementNumber, printGamma, printEta, printRho,
+               printDisto};
 
   bool first = true;  
   std::string names;
@@ -661,9 +664,8 @@ int GModel::writePOS(const std::string &name, bool printElementary,
   for(unsigned int i = 0; i < entities.size(); i++)
     if(saveAll || entities[i]->physicals.size())
       for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++)
-        entities[i]->getMeshElement(j)->writePOS(fp, f[0], f[1], f[2], f[3],
-                                                 f[4], f[5], scalingFactor, 
-                                                 entities[i]->tag());
+        entities[i]->getMeshElement(j)->writePOS
+          (fp, f[0], f[1], f[2], f[3], f[4], f[5], scalingFactor, entities[i]->tag());
   fprintf(fp, "};\n");
 
   fclose(fp);
diff --git a/Geo/MTetrahedron.cpp b/Geo/MTetrahedron.cpp
index 8d2272e7e16c9aa193932c8a7089db92685a406f..9e932d9e4bbfde2b299f0ae68740d20f01350e4e 100644
--- a/Geo/MTetrahedron.cpp
+++ b/Geo/MTetrahedron.cpp
@@ -4,6 +4,7 @@
 // bugs and problems to <gmsh@geuz.org>.
 
 #include "MTetrahedron.h"
+#include "Numeric.h"
 
 #if defined(HAVE_GMSH_EMBEDDED)
 #include "GmshEmbedded.h"
diff --git a/Geo/Makefile b/Geo/Makefile
index 4d350d101f1f1348bcbbd72ee517ee369b1e0349..7c84e081cd993ee9f918233e7f8d425bcfbca8ab 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -83,8 +83,8 @@ GEdge${OBJEXT}: GEdge.cpp ../Common/GmshConfig.h ../Common/GmshDefines.h \
   SBoundingBox3d.h GPoint.h SPoint2.h GEdge.h SVector3.h GFace.h \
   GEdgeLoop.h Pair.h GRegion.h MLine.h MElement.h MVertex.h MEdge.h \
   MFace.h ../Numeric/FunctionSpace.h ../Numeric/GmshMatrix.h \
-  ../Numeric/Gauss.h ../Common/Context.h ../Geo/CGNSOptions.h \
-  ../Mesh/meshPartitionOptions.h ../Numeric/GaussLegendre1D.h
+  ../Numeric/Gauss.h ../Numeric/GaussLegendre1D.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h
 GFace${OBJEXT}: GFace.cpp ../Common/GmshConfig.h ../Common/GmshMessage.h \
   GModel.h GVertex.h GEntity.h Range.h SPoint3.h SBoundingBox3d.h \
   GPoint.h SPoint2.h GEdge.h SVector3.h GFace.h GEdgeLoop.h Pair.h \
@@ -352,12 +352,12 @@ MTetrahedron${OBJEXT}: MTetrahedron.cpp MTetrahedron.h MElement.h \
   ../Common/GmshDefines.h MVertex.h SPoint2.h SPoint3.h MEdge.h \
   SVector3.h MFace.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
   ../Numeric/GmshMatrix.h ../Common/GmshConfig.h ../Numeric/Gauss.h \
-  ../Common/Context.h ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
+  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Common/Context.h \
+  ../Geo/CGNSOptions.h ../Mesh/meshPartitionOptions.h \
   ../Mesh/qualityMeasures.h ../Mesh/meshGFaceDelaunayInsertion.h \
   ../Geo/MTriangle.h ../Geo/MElement.h \
   ../Mesh/meshGRegionDelaunayInsertion.h ../Geo/MTetrahedron.h \
-  ../Numeric/Numeric.h ../Numeric/GmshMatrix.h ../Mesh/BackgroundMesh.h \
-  ../Mesh/qualityMeasures.h
+  ../Mesh/BackgroundMesh.h ../Mesh/qualityMeasures.h
 MHexahedron${OBJEXT}: MHexahedron.cpp MHexahedron.h MElement.h \
   ../Common/GmshDefines.h MVertex.h SPoint2.h SPoint3.h MEdge.h \
   SVector3.h MFace.h ../Common/GmshMessage.h ../Numeric/FunctionSpace.h \
diff --git a/Makefile b/Makefile
index 46059a80a81773d207bd29c66206b368ca2b050d..19bb500c63538729b630e1d75f42ec9d4f365b46 100644
--- a/Makefile
+++ b/Makefile
@@ -10,36 +10,37 @@ GMSH_MINOR_VERSION = 3
 GMSH_PATCH_VERSION = 1
 GMSH_EXTRA_VERSION =
 
-GMSH_VERSION = ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}${GMSH_EXTRA_VERSION}
+GMSH_VERSION =\
+  ${GMSH_MAJOR_VERSION}.${GMSH_MINOR_VERSION}.${GMSH_PATCH_VERSION}${GMSH_EXTRA_VERSION}
 
 GMSH_SHORT_LICENSE = "GNU General Public License"
 
 GMSH_VERSION_FILE = Common/GmshVersion.h
 GMSH_DATE = `date "+%Y%m%d"`
 
-GMSH_API = Geo/GModel.h Geo/GEntity.h Geo/GPoint.h\
-           Geo/GVertex.h Geo/GEdge.h Geo/GFace.h Geo/GRegion.h\
-           Geo/GEdgeLoop.h Geo/GFaceCompound.h\
-           Geo/MVertex.h Geo/MEdge.h Geo/MFace.h Geo/MElement.h Geo/MTriangle.h Geo/MQuadrangle.h Geo/MTetrahedron.h Geo/MHexahedron.h Geo/MPyramid.h Geo/MPrism.h Geo/MLine.h \
-           Geo/discreteVertex.h Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h\
-           Geo/SPoint2.h Geo/SPoint3.h Geo/SVector3.h Geo/SBoundingBox3d.h\
-           Geo/Pair.h Geo/Range.h\
-           Numeric/Gauss.h Numeric/FunctionSpace.h Numeric/GmshMatrix.h\
-           Numeric/gmshAssembler.h Numeric/gmshTermOfFormulation.h Numeric/gmshLaplace.h\
-           Numeric/gmshElasticity.h Numeric/gmshLinearSystem.h Numeric/gmshLinearSystemGmm.h\
-           Numeric/gmshLinearSystemFull.h Numeric/gmshFunction.h\
-           Post/PView.h Post/PViewData.h Plugin/PluginManager.h\
-           Common/VertexArray.h Common/GmshMessage.h\
-           Common/Gmsh.h Common/GmshConfig.h Common/GmshDefines.h Common/GmshVersion.h 
-
-GMSH_EMBEDDED = ${GMSH_API} Geo/discrete*.cpp\
-                Geo/GModel.cpp Geo/GModelIO_Mesh.cpp\
-                Geo/GEntity.cpp Geo/GVertex.cpp Geo/GEdge.cpp\
-                Geo/GEdgeLoop.cpp Geo/GFace.cpp Geo/GRegion.cpp\
-                Geo/MElement.cpp Geo/MFace.cpp Geo/MVertex.cpp\
-                Common/StringUtils.{cpp,h}\
-                Numeric/Numeric.{cpp,h} Numeric/FunctionSpace.cpp\
-                utils/embed/GmshEmbedded.{cpp,h} utils/embed/Makefile
+GMSH_API =\
+  Geo/GModel.h Geo/GEntity.h Geo/GPoint.h Geo/GVertex.h Geo/GEdge.h Geo/GFace.h\
+  Geo/GRegion.h Geo/GEdgeLoop.h Geo/GFaceCompound.h\
+  Geo/MVertex.h Geo/MEdge.h Geo/MFace.h Geo/MElement.h\
+  Geo/discreteVertex.h Geo/discreteEdge.h Geo/discreteFace.h Geo/discreteRegion.h\
+  Geo/SPoint2.h Geo/SPoint3.h Geo/SVector3.h Geo/SBoundingBox3d.h Geo/Pair.h Geo/Range.h\
+  Numeric/Gauss.h Numeric/FunctionSpace.h Numeric/GmshMatrix.h\
+  Numeric/gmshAssembler.h Numeric/gmshTermOfFormulation.h Numeric/gmshLaplace.h\
+  Numeric/gmshElasticity.h Numeric/gmshLinearSystem.h Numeric/gmshLinearSystemGmm.h\
+  Numeric/gmshLinearSystemFull.h Numeric/gmshFunction.h\
+  Post/PView.h Post/PViewData.h Plugin/PluginManager.h\
+  Common/VertexArray.h Common/GmshMessage.h\
+  Common/Gmsh.h Common/GmshConfig.h Common/GmshDefines.h Common/GmshVersion.h 
+
+GMSH_EMBEDDED = ${GMSH_API}\
+  Geo/GModel.cpp Geo/GModelIO_Mesh.cpp Geo/GEntity.cpp\
+  Geo/GVertex.cpp Geo/GEdge.cpp Geo/GEdgeLoop.cpp Geo/GFace.cpp Geo/GRegion.cpp\
+  Geo/discreteEdge.cpp Geo/discreteFace.cpp Geo/discreteRegion.cpp\
+  Geo/MVertex.cpp Geo/MFace.cpp Geo/MElement.cpp Geo/MPoint.h Geo/MLine.{cpp,h}\
+  Geo/MTriangle.{cpp,h} Geo/MQuadrangle.{cpp,h} Geo/MTetrahedron.{cpp,h}\
+  Geo/MHexahedron.{cpp,h} Geo/MPrism.{cpp,h} Geo/MPyramid.{cpp,h}\
+  Numeric/Numeric.{cpp,h} Numeric/FunctionSpace.cpp Common/StringUtils.{cpp,h}\
+  utils/embed/GmshEmbedded.{cpp,h} utils/embed/Makefile
 
 # Main building rules
 
@@ -127,7 +128,7 @@ uninstall-lib:
 	rm -rf ${libdir}/libGmsh${LIBSUFFIX}${LIBEXT}
 
 embed:
-	@if [ -r ../getdp/contrib/gmsh/Makefile ]; then \
+	@if [ -r ../getdp/contrib/gmsh/Makefile ]; then\
           rsync -av ${GMSH_EMBEDDED} ../getdp/contrib/gmsh;\
         fi
 
@@ -216,11 +217,11 @@ depend: initialtag
 	mv -f GmshConfig.h Common/
 
 nodepend:
-	for i in ${GMSH_DIRS} ; do \
-          (cd $$i && (sed '/^# DO NOT DELETE THIS LINE/q' Makefile) > Makefile.new \
-          && cp Makefile Makefile.bak \
-          && cp Makefile.new Makefile \
-          && rm -f Makefile.new); \
+	for i in ${GMSH_DIRS} ; do\
+          (cd $$i && (sed '/^# DO NOT DELETE THIS LINE/q' Makefile) > Makefile.new\
+          && cp Makefile Makefile.bak\
+          && cp Makefile.new Makefile\
+          && rm -f Makefile.new);\
         done 
 
 initialtag:
diff --git a/Numeric/Makefile b/Numeric/Makefile
index dcb5059fb766fd6e553eaae7221be9d6031e1739..410f88fceb274db1b7ff82246a635b0a9f835955 100644
--- a/Numeric/Makefile
+++ b/Numeric/Makefile
@@ -41,6 +41,11 @@ cpobj: ${OBJ}
 .cpp${OBJEXT}:
 	${CXX} ${CFLAGS} ${DASH}c $<
 
+# Don't optimize J. Shewchuk's predicates. Otherwise, Gmsh may not
+# work properly.
+GmshPredicates${OBJEXT}:
+	${CXX} ${FLAGS} ${INC} ${SYSINCLUDE} ${DASH}c GmshPredicates.cpp
+
 clean:
 	${RM} *.o *.obj 
 
diff --git a/configure b/configure
index e857dbab39b82d8212fb21fe45c994642a27e422..334641fefd6e177b928ef7bfe753574a4346131d 100755
--- a/configure
+++ b/configure
@@ -5763,6 +5763,10 @@ if test "x${BLAS_LIBS}" != "x"; then
   fi
   GMSH_LIBS="${GMSH_LIBS} ${FCLIB}"
 fi
+if test "x${BLAS}" != "xyes" -o "x${LAPACK}" != "xyes"; then
+  { echo "$as_me:$LINENO: WARNING: Could not find BLAS and/or LAPACK: some Gmsh features will not work." >&5
+echo "$as_me: WARNING: Could not find BLAS and/or LAPACK: some Gmsh features will not work." >&2;}
+fi
 
 if test "x${LAPACK}" = "xyes" -a "x$enable_fm" != "xno"; then
   if test "x${FM_PREFIX}" != "x"; then
diff --git a/configure.in b/configure.in
index 2a440c34fa150ad50899971a433c515f4581130b..e10e4fc0bbc8147d4d40efa8eb09b4f1f913c900 100644
--- a/configure.in
+++ b/configure.in
@@ -680,6 +680,9 @@ if test "x${BLAS_LIBS}" != "x"; then
   fi
   GMSH_LIBS="${GMSH_LIBS} ${FCLIB}"
 fi
+if test "x${BLAS}" != "xyes" -o "x${LAPACK}" != "xyes"; then
+  AC_MSG_WARN([Could not find BLAS and/or LAPACK: some Gmsh features will not work.])
+fi
 
 dnl Check for FourierModel (if we have lapack)
 if test "x${LAPACK}" = "xyes" -a "x$enable_fm" != "xno"; then
diff --git a/utils/embed/GmshEmbedded.h b/utils/embed/GmshEmbedded.h
index 779904bb7522644174aa5313e60774439a6c537c..56d16f0aed2ef0b53bc7b61cca1d36eb36eee4f8 100644
--- a/utils/embed/GmshEmbedded.h
+++ b/utils/embed/GmshEmbedded.h
@@ -19,6 +19,7 @@ class CTX{
   struct{
     int reverseAllNormals;
     int secondOrderExperimental;
+    int numSubEdges;
   } mesh;
   CTX()
   {
diff --git a/utils/embed/Makefile b/utils/embed/Makefile
index 59b5a50841054720c960a2ad7d78c2e354854d10..8b0fd5982175d67d8b5f570d7657f49456e9c3d5 100644
--- a/utils/embed/Makefile
+++ b/utils/embed/Makefile
@@ -16,8 +16,9 @@ SRC = GModel.cpp\
       GEntity.cpp\
         GVertex.cpp GEdge.cpp GEdgeLoop.cpp GFace.cpp GRegion.cpp\
         discreteEdge.cpp discreteFace.cpp discreteRegion.cpp\
-      MElement.cpp\
-        MFace.cpp MVertex.cpp\
+      MVertex.cpp MFace.cpp MElement.cpp\
+        MLine.cpp MTriangle.cpp MQuadrangle.cpp MTetrahedron.cpp\
+        MHexahedron.cpp MPrism.cpp MPyramid.cpp\
       Numeric.cpp\
         FunctionSpace.cpp\
       StringUtils.cpp\