diff --git a/src/Makefile.am b/src/Makefile.am
index 0f184e850fc1e2eeaa7a86e73db317216da8b436..6467a5d93411ff053263febc1611bce1eab6f9f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,7 @@ common_sources = \
 	enumparser.cc \
 	fixedpointiterator.cc \
 	friction_writer.cc \
+	sand-wedge-data/mygrid.cc \
 	solverfactory.cc \
 	state.cc \
 	timestepping.cc \
diff --git a/src/sand-wedge-data/mygrid.cc b/src/sand-wedge-data/mygrid.cc
index 61ecdada7b9b5b61b1721aec179ce4ee101a1d56..8755a29c5cbfa370049563a87a9d2bc1a95386d8 100644
--- a/src/sand-wedge-data/mygrid.cc
+++ b/src/sand-wedge-data/mygrid.cc
@@ -5,24 +5,21 @@
 #include "mygrid.hh"
 #include "midpoint.hh"
 
-class SimplexManager {
-public:
-  using SimplexList = std::vector<std::vector<unsigned int>>;
-
 #if DIM == 3
-  SimplexManager(unsigned int shift) : shift_(shift) {}
+SimplexManager::SimplexManager(unsigned int shift) : shift_(shift) {}
 #endif
 
-  void addFromVertices(unsigned int U, unsigned int V, unsigned int W) {
+void SimplexManager::addFromVertices(unsigned int U, unsigned int V,
+                                     unsigned int W) {
 #if DIM == 3
-    unsigned int const U2 = U + shift_;
-    unsigned int const V2 = V + shift_;
-    unsigned int const W2 = W + shift_;
+  unsigned int const U2 = U + shift_;
+  unsigned int const V2 = V + shift_;
+  unsigned int const W2 = W + shift_;
 
-    // back-to-front, back-to-front, back-to-front
-    simplices_.push_back({ U, V, W, U2 });
-    simplices_.push_back({ V, V2, W2, U2 });
-    simplices_.push_back({ W, W2, U2, V });
+  // back-to-front, back-to-front, back-to-front
+  simplices_.push_back({ U, V, W, U2 });
+  simplices_.push_back({ V, V2, W2, U2 });
+  simplices_.push_back({ W, W2, U2, V });
 
 // back-to-front, front-to-back, back-to-front would be
 /*
@@ -31,130 +28,118 @@ class SimplexManager {
   simplices_.push_back({ V2, W2, U2, W });
 */
 #else
-    simplices_.push_back({ U, V, W });
+  simplices_.push_back({ U, V, W });
 #endif
-  }
-
-  SimplexList const &getSimplices() { return simplices_; }
-
-private:
-  SimplexList simplices_;
+}
 
-#if DIM == 3
-  unsigned int const shift_;
-#endif
-};
+auto SimplexManager::getSimplices() -> SimplexList const &{ return simplices_; }
 
-template <class Grid> class GridConstructor {
-public:
-  GridConstructor() {
-    auto const &A = MyGeometry::A;
-    auto const &B = MyGeometry::B;
-    auto const &C = MyGeometry::C;
+template <class Grid> GridConstructor<Grid>::GridConstructor() {
+  auto const &A = MyGeometry::A;
+  auto const &B = MyGeometry::B;
+  auto const &C = MyGeometry::C;
 
-    auto const AB = midPoint(A, B);
-    auto const AC = midPoint(A, C);
-    auto const BC = midPoint(B, C);
+  auto const AB = midPoint(A, B);
+  auto const AC = midPoint(A, C);
+  auto const BC = midPoint(B, C);
 
-    auto const AAB = midPoint(A, AB);
-    auto const AAC = midPoint(A, AC);
-    auto const ABB = midPoint(AB, B);
-    auto const ABC = midPoint(AB, C); // the interiour point
-    auto const ACC = midPoint(AC, C);
+  auto const AAB = midPoint(A, AB);
+  auto const AAC = midPoint(A, AC);
+  auto const ABB = midPoint(AB, B);
+  auto const ABC = midPoint(AB, C); // the interiour point
+  auto const ACC = midPoint(AC, C);
 
-    unsigned int const vc = 11;
+  unsigned int const vc = 11;
 
 #if DIM == 3
-    Dune::FieldMatrix<double, 2 * vc, DIM> vertices;
+  Dune::FieldMatrix<double, 2 * vc, DIM> vertices;
 #else
-    Dune::FieldMatrix<double, vc, DIM> vertices;
+  Dune::FieldMatrix<double, vc, DIM> vertices;
 #endif
-    for (size_t i = 0; i < 2; ++i) {
-      size_t k = 0;
-      vertices[k++][i] = A[i];
-      vertices[k++][i] = AAB[i];
-      vertices[k++][i] = AB[i];
-      vertices[k++][i] = ABB[i];
-      vertices[k++][i] = B[i];
-      vertices[k++][i] = AAC[i];
-      vertices[k++][i] = AC[i];
-      vertices[k++][i] = ABC[i];
-      vertices[k++][i] = BC[i];
-      vertices[k++][i] = ACC[i];
-      vertices[k++][i] = C[i];
-      assert(k == vc);
+  for (size_t i = 0; i < 2; ++i) {
+    size_t k = 0;
+    vertices[k++][i] = A[i];
+    vertices[k++][i] = AAB[i];
+    vertices[k++][i] = AB[i];
+    vertices[k++][i] = ABB[i];
+    vertices[k++][i] = B[i];
+    vertices[k++][i] = AAC[i];
+    vertices[k++][i] = AC[i];
+    vertices[k++][i] = ABC[i];
+    vertices[k++][i] = BC[i];
+    vertices[k++][i] = ACC[i];
+    vertices[k++][i] = C[i];
+    assert(k == vc);
 #if DIM == 3
-      vertices[k++][i] = A[i];
-      vertices[k++][i] = AAB[i];
-      vertices[k++][i] = AB[i];
-      vertices[k++][i] = ABB[i];
-      vertices[k++][i] = B[i];
-      vertices[k++][i] = AAC[i];
-      vertices[k++][i] = AC[i];
-      vertices[k++][i] = ABC[i];
-      vertices[k++][i] = BC[i];
-      vertices[k++][i] = ACC[i];
-      vertices[k++][i] = C[i];
-      assert(k == 2 * vc);
+    vertices[k++][i] = A[i];
+    vertices[k++][i] = AAB[i];
+    vertices[k++][i] = AB[i];
+    vertices[k++][i] = ABB[i];
+    vertices[k++][i] = B[i];
+    vertices[k++][i] = AAC[i];
+    vertices[k++][i] = AC[i];
+    vertices[k++][i] = ABC[i];
+    vertices[k++][i] = BC[i];
+    vertices[k++][i] = ACC[i];
+    vertices[k++][i] = C[i];
+    assert(k == 2 * vc);
 #endif
-    }
+  }
 
 #if DIM == 3
-    for (size_t k = 0; k < vc; ++k) {
-      vertices[k][2] = -MyGeometry::depth / 2.0;
-      vertices[k + vc][2] = MyGeometry::depth / 2.0;
-    }
+  for (size_t k = 0; k < vc; ++k) {
+    vertices[k][2] = -MyGeometry::depth / 2.0;
+    vertices[k + vc][2] = MyGeometry::depth / 2.0;
+  }
 #endif
 
-    for (size_t i = 0; i < vertices.N(); ++i)
-      gridFactory.insertVertex(vertices[i]);
+  for (size_t i = 0; i < vertices.N(); ++i)
+    gridFactory.insertVertex(vertices[i]);
 
-    Dune::GeometryType cell;
+  Dune::GeometryType cell;
 #if DIM == 3
-    cell.makeTetrahedron();
+  cell.makeTetrahedron();
 #else
-    cell.makeTriangle();
+  cell.makeTriangle();
 #endif
 
 #if DIM == 3
-    SimplexManager sm(vc);
+  SimplexManager sm(vc);
 #else
-    SimplexManager sm;
+  SimplexManager sm;
 #endif
-    sm.addFromVertices(1, 5, 0);
-    sm.addFromVertices(1, 6, 5);
-    sm.addFromVertices(2, 6, 1);
-    sm.addFromVertices(7, 6, 2);
-    sm.addFromVertices(7, 2, 3);
-    sm.addFromVertices(7, 3, 8);
-    sm.addFromVertices(7, 8, 10);
-    sm.addFromVertices(7, 10, 9);
-    sm.addFromVertices(7, 9, 6);
-    sm.addFromVertices(8, 3, 4);
-    auto const &simplices = sm.getSimplices();
-
-    // sanity-check choices of simplices
-    for (size_t i = 0; i < simplices.size(); ++i) {
-      Dune::FieldMatrix<double, DIM, DIM> check;
-      for (size_t j = 0; j < DIM; ++j)
-        check[j] = vertices[simplices[i][j + 1]] - vertices[simplices[i][j]];
-      assert(check.determinant() > 0);
-      gridFactory.insertElement(cell, simplices[i]);
-    }
-  }
-
-  std::shared_ptr<Grid> getGrid() {
-    return std::shared_ptr<Grid>(gridFactory.createGrid());
+  sm.addFromVertices(1, 5, 0);
+  sm.addFromVertices(1, 6, 5);
+  sm.addFromVertices(2, 6, 1);
+  sm.addFromVertices(7, 6, 2);
+  sm.addFromVertices(7, 2, 3);
+  sm.addFromVertices(7, 3, 8);
+  sm.addFromVertices(7, 8, 10);
+  sm.addFromVertices(7, 10, 9);
+  sm.addFromVertices(7, 9, 6);
+  sm.addFromVertices(8, 3, 4);
+  auto const &simplices = sm.getSimplices();
+
+  // sanity-check choices of simplices
+  for (size_t i = 0; i < simplices.size(); ++i) {
+    Dune::FieldMatrix<double, DIM, DIM> check;
+    for (size_t j = 0; j < DIM; ++j)
+      check[j] = vertices[simplices[i][j + 1]] - vertices[simplices[i][j]];
+    assert(check.determinant() > 0);
+    gridFactory.insertElement(cell, simplices[i]);
   }
+}
 
-  template <class GridView>
-  MyFaces<GridView> constructFaces(GridView const &gridView) {
-    return MyFaces<GridView>(gridView);
-  }
+template <class Grid> std::shared_ptr<Grid> GridConstructor<Grid>::getGrid() {
+  return std::shared_ptr<Grid>(gridFactory.createGrid());
+}
 
-private:
-  Dune::GridFactory<Grid> gridFactory;
-};
+template <class Grid>
+template <class GridView>
+MyFaces<GridView> GridConstructor<Grid>::constructFaces(
+    GridView const &gridView) {
+  return MyFaces<GridView>(gridView);
+}
 
 template <class GridView>
 template <class Vector>
diff --git a/src/sand-wedge-data/mygrid.hh b/src/sand-wedge-data/mygrid.hh
index cd17d0858f0475ac736f578eabc663a3bd79f20f..9759252b91173b5178f01d0649ec6bae82f1bbb5 100644
--- a/src/sand-wedge-data/mygrid.hh
+++ b/src/sand-wedge-data/mygrid.hh
@@ -40,4 +40,37 @@ template <class GridView> struct MyFaces {
   template <class Vector>
   bool xyBetween(Vector const &v1, Vector const &v2, Vector const &x);
 };
+
+class SimplexManager {
+public:
+  using SimplexList = std::vector<std::vector<unsigned int>>;
+
+#if DIM == 3
+  SimplexManager(unsigned int shift);
+#endif
+
+  void addFromVertices(unsigned int U, unsigned int V, unsigned int W);
+
+  SimplexList const &getSimplices();
+
+private:
+  SimplexList simplices_;
+
+#if DIM == 3
+  unsigned int const shift_;
+#endif
+};
+
+template <class Grid> class GridConstructor {
+public:
+  GridConstructor();
+
+  std::shared_ptr<Grid> getGrid();
+
+  template <class GridView>
+  MyFaces<GridView> constructFaces(GridView const &gridView);
+
+private:
+  Dune::GridFactory<Grid> gridFactory;
+};
 #endif
diff --git a/src/sand-wedge-data/mygrid_tmpl.cc b/src/sand-wedge-data/mygrid_tmpl.cc
index 2668596c42fe202deeb150408066bc48508f7e66..ea5190a1ee9924420716affa09314bba259cfa70 100644
--- a/src/sand-wedge-data/mygrid_tmpl.cc
+++ b/src/sand-wedge-data/mygrid_tmpl.cc
@@ -7,3 +7,6 @@
 template class GridConstructor<Grid>;
 
 template struct MyFaces<GridView>;
+
+template MyFaces<GridView> GridConstructor<Grid>::constructFaces(
+    GridView const &gridView);
diff --git a/src/sand-wedge.cc b/src/sand-wedge.cc
index 520cfc4c3d19e7012fba34f095759ce3b07fc2b3..2b39dbdffff833193609411c321a9696620a1967 100644
--- a/src/sand-wedge.cc
+++ b/src/sand-wedge.cc
@@ -77,7 +77,6 @@
 #include "sand-wedge-data/mygeometry.hh"
 #include "sand-wedge-data/mygeometry.cc" // FIXME
 #include "sand-wedge-data/myglobalfrictiondata.hh"
-#include "sand-wedge-data/mygrid.cc" // FIXME
 #include "sand-wedge-data/mygrid.hh"
 #include "sand-wedge-data/special_writer.hh"
 #include "solverfactory.hh"