 
         // #0
         uint w0 = v2;
-        uint w1 = vNew1;
-        uint w2 = vNew2;
+        uint w1 = vNew2;
+        uint w2 = vNew1;
 
 
         // This neighbor has to be determined by comparing vertex indices
-         uint subDivCntN1 = subdivCnt_D[oldN1];
-         if (subDivCntN1 > 0) {
-             for (int i = 0; i < subDivCntN1; ++i) {
+         uint subDivCntN2 = subdivCnt_D[oldN2];
+         if (subDivCntN2 > 0) {
+             for (int i = 0; i < subDivCntN2; ++i) {
                  uint u0, u1, u2;
-                 u0 = newTriangles_D[3*(newTriangleIdxOffsets[oldN1]+i)+0];
-                 u1 = newTriangles_D[3*(newTriangleIdxOffsets[oldN1]+i)+1];
-                 u2 = newTriangles_D[3*(newTriangleIdxOffsets[oldN1]+i)+2];
+                 u0 = newTriangles_D[3*(newTriangleIdxOffsets[oldN2]+i)+0];
+                 u1 = newTriangles_D[3*(newTriangleIdxOffsets[oldN2]+i)+1];
+                 u2 = newTriangles_D[3*(newTriangleIdxOffsets[oldN2]+i)+2];
                  if (hasAdjEdge_D (w0, w1, w2, u0, u1, u2)) {
                      newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+0]=
-                             numberOfKeptTriangles + newTriangleIdxOffsets[oldN1]+i;
+                             numberOfKeptTriangles + newTriangleIdxOffsets[oldN2]+i;
                  }
              }
          } else {
              newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+0] =
-                     oldTriangleIdxOffset[oldN1];
+                     oldTriangleIdxOffset[oldN2];
          }
 
          // This neighbor is the other subdivision


        // #1
        w0 = v2;
        w1 = vNew0;
        w2 = vNew2;

        // This neighbor is the other subdivision
        newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs) + 3] =
                numberOfKeptTriangles+triIdxOffs + 2;

        newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs) + 4] =
                 numberOfKeptTriangles+triIdxOffs;


        // This neighbor has to be determined by comparing vertex indices
         subDivCntN2 = subdivCnt_D[oldN2];

                 u1 = newTriangles_D[3*(newTriangleIdxOffsets[oldN0]+i)+1];
                 u2 = newTriangles_D[3*(newTriangleIdxOffsets[oldN0]+i)+2];
                 if (hasAdjEdge_D (w0, w1, w2, u0, u1, u2)) {
                     newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+5]=
                             numberOfKeptTriangles + newTriangleIdxOffsets[oldN0]+i;
                 }
             }
         } else {
             newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+5]=
                     oldTriangleIdxOffset[oldN0];
         }



        // #2
        w0 = v2;
        w1 = vNew2;
        w2 = vNew1;


        // This neighbor has to be determined by comparing vertex indices
        subDivCntN2 = subdivCnt_D[oldN2];
         if (subDivCntN2 > 0) {
             for (int i = 0; i < subDivCntN2; ++i) {
                 uint u0, u1, u2;
                 u0 = newTriangles_D[3*(newTriangleIdxOffsets[oldN2]+i)+0];
                 u1 = newTriangles_D[3*(newTriangleIdxOffsets[oldN2]+i)+1];
                 u2 = newTriangles_D[3*(newTriangleIdxOffsets[oldN2]+i)+2];
                 if (hasAdjEdge_D (w0, w1, w2, u0, u1, u2)) {
                     newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+6]=
                             numberOfKeptTriangles + newTriangleIdxOffsets[oldN2]+i;
                 }
             }
         } else {
             newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+6]=
                     oldTriangleIdxOffset[oldN2];
         }

         // This neighbor is the middle subdivision
         newTriangleNeighbors_D[3*(numberOfKeptTriangles+triIdxOffs)+7] =
                 numberOfKeptTriangles+triIdxOffs + 3;

         // This neighbor has to be determined by comparing vertex indices
         subDivCntN1 = subdivCnt_D[oldN1];
         if (subDivCntN1 > 0) {
             for (int i = 0; i < subDivCntN1; ++i) {
                 uint u0, u1, u2;
