diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp
index da226984d9962715116483617a62400f60b7a8c6..7b63332cb85ba7bdecefc9fdf17db7f3cfecbe18 100644
--- a/Common/gmsh.cpp
+++ b/Common/gmsh.cpp
@@ -651,7 +651,13 @@ static ExtrudeParams *getExtrudeParams(const std::vector<int> &numElements,
     e->mesh.ExtrudeMesh = true;
     e->mesh.NbElmLayer = numElements;
     e->mesh.hLayer = heights;
-    if(e->mesh.hLayer.empty()) e->mesh.hLayer.push_back(1.);
+    if(e->mesh.hLayer.empty()){
+      e->mesh.NbLayer = 1;
+      e->mesh.hLayer.push_back(1.);
+    }
+    else{
+      e->mesh.NbLayer = heights.size();
+    }
     e->mesh.Recombine = recombine;
   }
   return e;
diff --git a/demos/api/t16.cpp b/demos/api/t16.cpp
index d97e4294f40e58f0a3538d9beb3ca4a5f64cf39c..9d13e8175939ebdfe2543669444f992b9f0cffbe 100644
--- a/demos/api/t16.cpp
+++ b/demos/api/t16.cpp
@@ -31,8 +31,9 @@ int main(int argc, char **argv)
   double lcar2 = .0005;
   double lcar3 = .055;
 
-  gmshModelGetEntities(ov);
+  gmshModelGetEntities(ov, 0);
   gmshModelSetMeshSize(ov, lcar1);
+
   gmshModelGetBoundary(holes, ov, false, false, true);
   gmshModelSetMeshSize(ov, lcar3);
 
diff --git a/demos/api/t3.cpp b/demos/api/t3.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d615534108737e84b4f1460b15b8fc54dc2a6d69
--- /dev/null
+++ b/demos/api/t3.cpp
@@ -0,0 +1,49 @@
+#include <cmath>
+#include <gmsh.h>
+
+// this reimplements gmsh/tutorial/t3.geo
+
+int main(int argc, char **argv)
+{
+  gmshInitialize(argc, argv);
+  gmshOptionSetNumber("General.Terminal", 1);
+
+  gmshModelCreate("t2");
+
+  // copy/paste from t1.cpp
+  double lc = 1e-2;
+  int o;
+  gmshModelGeoAddPoint(1, 0, 0, 0, o, lc);
+  gmshModelGeoAddPoint(2, .1, 0,  0, o, lc);
+  gmshModelGeoAddPoint(3, .1, .3, 0, o, lc);
+  gmshModelGeoAddPoint(4, 0,  .3, 0, o, lc);
+
+  gmshModelGeoAddLine(1, 1, 2, o);
+  gmshModelGeoAddLine(2, 3, 2, o);
+  gmshModelGeoAddLine(3, 3, 4, o);
+  gmshModelGeoAddLine(4, 4, 1, o);
+
+  gmshModelGeoAddLineLoop(1, {4, 1, -2, 3}, o);
+  gmshModelGeoAddPlaneSurface(1, {1}, o);
+  gmshModelAddPhysicalGroup(0, 1, {1, 2});
+  gmshModelAddPhysicalGroup(1, 2, {1, 2});
+  gmshModelAddPhysicalGroup(2, 6, {1});
+  gmshModelSetPhysicalName(2, 6, "My surface");
+  // end copy/paste
+
+  double h = 0.1, angle = 90.;
+
+  std::vector<std::pair<int, int> > ov;
+  gmshModelGeoExtrude({{2,1}}, 0, 0, h, ov, {8,2}, {0.5,1});
+  gmshModelGeoRevolve({{2,28}}, -0.1,0,0.1, 0,1,0, -M_PI/2, ov, {7});
+  gmshModelGeoTwist({{2,50}}, 0,0.15,0.25, -2*h,0,0, 1,0,0, angle*M_PI/180.,
+                    ov, {10}, {}, true);
+  gmshModelAddPhysicalGroup(3, 101, {1, 2, ov[1].second});
+
+  gmshModelGeoSynchronize();
+  gmshModelMesh(3);
+  gmshExport("t3.msh");
+  gmshFinalize();
+
+  return 0;
+}