diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
index 2b8216956161bb4aad0998c80d3b16c4c21cb634..aaf2de52eb5c984aa6b4f3273b31f0240c0d0254 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
@@ -146,7 +146,8 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
         this->time().timeName(),
         this->db(),
         IOobject::READ_IF_PRESENT,
-        IOobject::AUTO_WRITE
+        IOobject::AUTO_WRITE,
+        this->registerObject()
     );
 
     if (field0.headerOk())
@@ -761,7 +762,10 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const
             (
                 this->name() + "_0",
                 this->time().timeName(),
-                this->db()
+                this->db(),
+                IOobject::NO_READ,
+                IOobject::NO_WRITE,
+                this->registerObject()
             ),
             *this
         );
diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C
index ae4954b8cb4e70e0fa38f1a65a25f4b3b5db81f3..54306d7230b5c758bda3adca5822089fc6e784b0 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortEdges.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -66,16 +66,31 @@ Foam::PatchTools::sortedEdgeFaces
             vector e2 = e.vec(localPoints);
             e2 /= mag(e2) + VSMALL;
 
-            // Get opposite vertex for 0th face
-            const Face& f = localFaces[faceNbs[0]];
+            // Get the vertex on 0th face that forms a vector with the first
+            // edge point that has the largest angle with the edge
+            const Face& f0 = localFaces[faceNbs[0]];
 
-            label fp0 = findIndex(f, e[0]);
-            label fp1 = f.fcIndex(fp0);
-            label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
+            scalar maxAngle = GREAT;
+            vector maxAngleEdgeDir(vector::max);
+
+            forAll(f0, fpI)
+            {
+                if (f0[fpI] != e.start())
+                {
+                    const vector faceEdgeDir = localPoints[f0[fpI]] - edgePt;
+                    const scalar angle = faceEdgeDir & e2;
+
+                    if (angle < maxAngle)
+                    {
+                        maxAngle = angle;
+                        maxAngleEdgeDir = faceEdgeDir;
+                    }
+                }
+            }
 
             // Get vector normal both to e2 and to edge from opposite vertex
             // to edge (will be x-axis of our coordinate system)
-            vector e0 = e2 ^ (localPoints[vertI] - edgePt);
+            vector e0 = e2 ^ maxAngleEdgeDir;
             e0 /= mag(e0) + VSMALL;
 
             // Get y-axis of coordinate system
@@ -88,13 +103,29 @@ Foam::PatchTools::sortedEdgeFaces
 
             for (label nbI = 1; nbI < faceNbs.size(); nbI++)
             {
-                // Get opposite vertex
+                // Get the vertex on face that forms a vector with the first
+                // edge point that has the largest angle with the edge
                 const Face& f = localFaces[faceNbs[nbI]];
-                label fp0 = findIndex(f, e[0]);
-                label fp1 = f.fcIndex(fp0);
-                label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
 
-                vector vec = e2 ^ (localPoints[vertI] - edgePt);
+                maxAngle = GREAT;
+                maxAngleEdgeDir = vector::max;
+
+                forAll(f, fpI)
+                {
+                    if (f[fpI] != e.start())
+                    {
+                        const vector faceEdgeDir = localPoints[f[fpI]] - edgePt;
+                        const scalar angle = faceEdgeDir & e2;
+
+                        if (angle < maxAngle)
+                        {
+                            maxAngle = angle;
+                            maxAngleEdgeDir = faceEdgeDir;
+                        }
+                    }
+                }
+
+                vector vec = e2 ^ maxAngleEdgeDir;
                 vec /= mag(vec) + VSMALL;
 
                 faceAngles[nbI] = pseudoAngle
diff --git a/src/dynamicMesh/attachDetach/attachInterface.C b/src/dynamicMesh/attachDetach/attachInterface.C
index 11332a6257631a98b9773147f49b207adfcb7bd9..40c68cb8453c246bfa9bded9b2db6883bddf2caa 100644
--- a/src/dynamicMesh/attachDetach/attachInterface.C
+++ b/src/dynamicMesh/attachDetach/attachInterface.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -83,6 +83,10 @@ void Foam::attachDetach::attachInterface
 
     forAll(removedPoints, pointI)
     {
+        //Pout<< "Removing point:" << removedPoints[pointI]
+        //    << " currently at:" << ref.points()[removedPoints[pointI]]
+        //    << endl;
+
         ref.setAction(polyRemovePoint(removedPoints[pointI]));
     }
 
@@ -90,8 +94,16 @@ void Foam::attachDetach::attachInterface
     // Remove all faces from the slave patch
     forAll(slavePatch, i)
     {
+        //Pout<< "Removing face " << i + slavePatchStart
+        //    << " with verts:" << ref.faces()[i + slavePatchStart]
+        //    << " at:"
+        //    <<  UIndirectList<point>
+        //        (
+        //            ref.points(),
+        //            ref.faces()[i + slavePatchStart]
+        //        )
+        //    << endl;
         ref.setAction(polyRemoveFace(i + slavePatchStart));
-// Pout<< "Removing face " << i + slavePatchStart << endl;
     }
 
     // Modify the faces from the master patch
diff --git a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C
index fdcc41b6cb445690e4dd56a6c624334e19720809..2fe428d45c0c071b1de0c1aed58607d68d712b92 100644
--- a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C
+++ b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -203,8 +203,8 @@ void Foam::layerAdditionRemoval::addCellLayer
         // Flip the face as necessary
         if
         (
-            mc[faceI] == nei[mf[faceI]]
-         || !mesh.isInternalFace(mf[faceI])
+           !mesh.isInternalFace(mf[faceI])
+         || mc[faceI] == nei[mf[faceI]]
         )
         {
             flipFaceFlux = true;
diff --git a/src/dynamicMesh/layerAdditionRemoval/removeCellLayer.C b/src/dynamicMesh/layerAdditionRemoval/removeCellLayer.C
index c6348af363460a07fac9a3e88470b761e605525a..1edaf10735c298436ac4d2bffba2ea53a0237b27 100644
--- a/src/dynamicMesh/layerAdditionRemoval/removeCellLayer.C
+++ b/src/dynamicMesh/layerAdditionRemoval/removeCellLayer.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -275,7 +275,7 @@ void Foam::layerAdditionRemoval::removeCellLayer
         // of the cell to be removed
         label masterSideCell = own[mf[faceI]];
 
-        if (masterSideCell == mc[faceI])
+        if (mesh.isInternalFace(mf[faceI]) && masterSideCell == mc[faceI])
         {
             // Owner cell of the face is being removed.
             // Grab the neighbour instead
@@ -284,7 +284,7 @@ void Foam::layerAdditionRemoval::removeCellLayer
 
         label slaveSideCell = own[ftc[faceI]];
 
-        if (slaveSideCell == mc[faceI])
+        if (mesh.isInternalFace(ftc[faceI]) && slaveSideCell == mc[faceI])
         {
             // Owner cell of the face is being removed.
             // Grab the neighbour instead
diff --git a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C
index 736e1e44568e851298cb0eb58858fbfcf21c6c33..6a3e337357cb053f7367aee8085e1951c47f0c03 100644
--- a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C
+++ b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -82,7 +82,8 @@ void Foam::fvPatchMapper::calcAddressing() const
             }
             else
             {
-                addr[faceI] = 0;
+                //addr[faceI] = 0;
+                addr[faceI] = -1;
             }
         }
 
@@ -90,12 +91,14 @@ void Foam::fvPatchMapper::calcAddressing() const
         {
             if (min(addr) < 0)
             {
-                FatalErrorIn
+                //FatalErrorIn
+                WarningIn
                 (
                     "void fvPatchMapper::calcAddressing() const"
-                )   << "Error in patch mapping for patch "
+                )   << "Unmapped entry in patch mapping for patch "
                     << patch_.index() << " named " << patch_.name()
-                    << abort(FatalError);
+                    //<< abort(FatalError);
+                    << endl;
             }
         }
     }
@@ -156,19 +159,22 @@ void Foam::fvPatchMapper::calcAddressing() const
                     }
                 }
 
-                // Cater for bad mapping
-                if (nActive == 0)
-                {
-                    newAddr[nActive] = 0;
-                    newWeights[nActive] = 1;
-                    nActive++;
-                }
+                //// Cater for bad mapping
+                //if (nActive == 0)
+                //{
+                //    newAddr[nActive] = 0;
+                //    newWeights[nActive] = 1;
+                //    nActive++;
+                //}
 
                 newAddr.setSize(nActive);
                 newWeights.setSize(nActive);
 
                 // Re-scale the weights
-                newWeights /= sum(newWeights);
+                if (nActive > 0)
+                {
+                    newWeights /= sum(newWeights);
+                }
 
                 // Reset addressing and weights
                 curAddr = newAddr;
diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C
index d6556a95083f401061c99db53c78fdc4f74b9f3e..1f36aa1ab8c4fa7968d0a7a3f81656badbc98b0a 100644
--- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C
+++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C
@@ -1287,7 +1287,7 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
               + ".obj"
             )
         );
-        Info<< "Writing points with too large a extrusion distance to "
+        Info<< "Writing points with too large an extrusion distance to "
             << str().name() << endl;
     }
 
@@ -1304,7 +1304,7 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
               + ".obj"
             )
         );
-        Info<< "Writing points with too large a extrusion distance to "
+        Info<< "Writing points with too large an extrusion distance to "
             << medialVecStr().name() << endl;
     }
 
diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C
index b7b79d715e3e71cd3ca2656d511ff86b46ac3282..f7b2e7fafd718d9e1127d1fee8219f1e0000c154 100644
--- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C
+++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -1360,6 +1360,19 @@ void Foam::autoSnapDriver::doSnap
                 regionSide
             );
             meshRefinement::updateList(mapPtr().faceMap(), -1, filterFace);
+
+            if (debug&meshRefinement::MESH)
+            {
+                const_cast<Time&>(mesh.time())++;
+                Pout<< "Writing duplicatedPoints mesh to time "
+                    << meshRefiner_.timeName()
+                    << endl;
+                meshRefiner_.write
+                (
+                    debug, mesh.time().path()
+                   /"duplicatedPoints"
+                );
+            }
         }
 
 
diff --git a/src/triSurface/triSurface/triSurfaceAddressing.C b/src/triSurface/triSurface/triSurfaceAddressing.C
index b1602c4f20436f75d263be292a081820bde0f97f..f1a8b8a2fd9cd5547ac172c0b4e726384f91850c 100644
--- a/src/triSurface/triSurface/triSurfaceAddressing.C
+++ b/src/triSurface/triSurface/triSurfaceAddressing.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -31,7 +31,7 @@ Description
 #include "HashTable.H"
 #include "SortableList.H"
 #include "transform.H"
-
+#include "PatchTools.H"
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
@@ -46,79 +46,10 @@ void Foam::triSurface::calcSortedEdgeFaces() const
 
     const labelListList& eFaces = edgeFaces();
 
-    // create the lists for the various results. (resized on completion)
     sortedEdgeFacesPtr_ = new labelListList(eFaces.size());
     labelListList& sortedEdgeFaces = *sortedEdgeFacesPtr_;
 
-    forAll(eFaces, edgeI)
-    {
-        const labelList& myFaceNbs = eFaces[edgeI];
-
-        if (myFaceNbs.size() > 2)
-        {
-            // Get point on edge and normalized direction of edge (= e2 base
-            // of our coordinate system)
-            const edge& e = edges()[edgeI];
-
-            const point& edgePt = localPoints()[e.start()];
-
-            vector e2 = e.vec(localPoints());
-            e2 /= mag(e2) + VSMALL;
-
-
-            // Get opposite vertex for 0th face
-            const labelledTri& f = localFaces()[myFaceNbs[0]];
-            label fp0 = findIndex(f, e[0]);
-            label fp1 = f.fcIndex(fp0);
-            label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
-
-            // Get vector normal both to e2 and to edge from opposite vertex
-            // to edge (will be x-axis of our coordinate system)
-            vector e0 = e2 ^ (localPoints()[vertI] - edgePt);
-            e0 /= mag(e0) + VSMALL;
-
-            // Get y-axis of coordinate system
-            vector e1 = e2 ^ e0;
-
-
-            SortableList<scalar> faceAngles(myFaceNbs.size());
-
-            // e0 is reference so angle is 0
-            faceAngles[0] = 0;
-
-            for (label nbI = 1; nbI < myFaceNbs.size(); nbI++)
-            {
-                // Get opposite vertex
-                const labelledTri& f = localFaces()[myFaceNbs[nbI]];
-                label fp0 = findIndex(f, e[0]);
-                label fp1 = f.fcIndex(fp0);
-                label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
-
-                vector vec = e2 ^ (localPoints()[vertI] - edgePt);
-                vec /= mag(vec) + VSMALL;
-
-                faceAngles[nbI] = pseudoAngle
-                (
-                    e0,
-                    e1,
-                    vec
-                );
-            }
-
-            faceAngles.sort();
-
-            sortedEdgeFaces[edgeI] = UIndirectList<label>
-            (
-                myFaceNbs,
-                faceAngles.indices()
-            );
-        }
-        else
-        {
-            // No need to sort. Just copy.
-            sortedEdgeFaces[edgeI] = myFaceNbs;
-        }
-    }
+    sortedEdgeFaces = PatchTools::sortedEdgeFaces(*this);
 }