diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C
index d9a4a4e7df1b705adc5ee70e9010ebd903346b4e..0590e8d09801cefdd24746db7bb24b3fc447110d 100644
--- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C
+++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C
@@ -209,16 +209,14 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
 
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
-    writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
+    os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_);
 
-    os.writeKeyword("accommodationCoeff")
-        << accommodationCoeff_ << token::END_STATEMENT << nl;
+    os.writeEntry("accommodationCoeff", accommodationCoeff_);
     Twall_.writeEntry("Twall", os);
-    os.writeKeyword("gamma")
-        << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntry("gamma", gamma_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H
index 03625d89682013229f1e17bfa9dce325504fba7d..a854e75458d0eff80a236cbe7b85ed7a18118a8b 100644
--- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H
+++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef smoluchowskiJumpTFvPatchScalarFields_H
-#define smoluchowskiJumpTFvPatchScalarFields_H
+#ifndef smoluchowskiJumpTFvPatchScalarField_H
+#define smoluchowskiJumpTFvPatchScalarField_H
 
 #include "mixedFvPatchFields.H"
 
@@ -43,7 +43,7 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-                 Class smoluchowskiJumpTFvPatch Declaration
+            Class smoluchowskiJumpTFvPatchScalarField Declaration
 \*---------------------------------------------------------------------------*/
 
 class smoluchowskiJumpTFvPatchScalarField
@@ -74,6 +74,7 @@ class smoluchowskiJumpTFvPatchScalarField
         //- Heat capacity ratio (default 1.4)
         scalar gamma_;
 
+
 public:
 
     //- Runtime type information
diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C
index 7f19817660b49d8f1c1b4bf68e7f82a12419ef28..c79f8d5062d39b495c0f7a3213df7a772e03d40d 100644
--- a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C
+++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C
@@ -200,18 +200,16 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
 void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "T", "T", TName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
-    writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_);
-    writeEntryIfDifferent<word>(os, "tauMC", "tauMC", tauMCName_);
-
-    os.writeKeyword("accommodationCoeff")
-        << accommodationCoeff_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("T", "T", TName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
+    os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_);
+    os.writeEntryIfDifferent<word>("tauMC", "tauMC", tauMCName_);
+
+    os.writeEntry("accommodationCoeff", accommodationCoeff_);
     Uwall_.writeEntry("Uwall", os);
-    os.writeKeyword("thermalCreep")
-        << thermalCreep_ << token::END_STATEMENT << nl;
-    os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
+    os.writeEntry("thermalCreep", thermalCreep_);
+    os.writeEntry("curvature", curvature_);
 
     refValue().writeEntry("refValue", os);
     valueFraction().writeEntry("valueFraction", os);
diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C
index 5eefe82ff5dedae1001c4f026b208a56e0b0293a..d71824052f514a7bdacb57af1ef5333f583f8b4b 100644
--- a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C
+++ b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C
@@ -117,8 +117,8 @@ void Foam::fixedRhoFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
 
-    writeEntryIfDifferent<word>(os, "p", "p", this->pName_);
-    writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
+    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C
index b24f21fe8dfc6d88bac7f046f52353fbcef55fc7..5d76f3deabf4739c352db1f26dc67deb3f2e608b 100644
--- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C
+++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C
@@ -113,6 +113,9 @@ int main(int argc, char *argv[])
             phiv_pos -= mesh.phi();
             phiv_neg -= mesh.phi();
         }
+        // Note: extracted out the orientation so becomes unoriented
+        phiv_pos.setOriented(false);
+        phiv_neg.setOriented(false);
 
         volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi));
         surfaceScalarField cSf_pos
@@ -120,14 +123,11 @@ int main(int argc, char *argv[])
             "cSf_pos",
             interpolate(c, pos, T.name())*mesh.magSf()
         );
-        cSf_pos.setOriented();
-
         surfaceScalarField cSf_neg
         (
             "cSf_neg",
             interpolate(c, neg, T.name())*mesh.magSf()
         );
-        cSf_neg.setOriented();
 
         surfaceScalarField ap
         (
@@ -168,11 +168,12 @@ int main(int argc, char *argv[])
 
         phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg;
 
-        surfaceVectorField phiUp
-        (
-            (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg)
-          + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf()
-        );
+        surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg);
+        // Note: reassembled orientation from the pos and neg parts so becomes
+        // oriented
+        phiU.setOriented(true);
+
+        surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf());
 
         surfaceScalarField phiEp
         (
@@ -185,7 +186,10 @@ int main(int argc, char *argv[])
         // Make flux for pressure-work absolute
         if (mesh.moving())
         {
-            phiEp += mesh.phi()*(a_pos*p_pos + a_neg*p_neg);
+            surfaceScalarField phia(a_pos*p_pos + a_neg*p_neg);
+            phia.setOriented(true);
+
+            phiEp += mesh.phi()*phia;
         }
 
         volScalarField muEff("muEff", turbulence->muEff());
@@ -222,7 +226,7 @@ int main(int argc, char *argv[])
                 fvc::interpolate(muEff)*mesh.magSf()*fvc::snGrad(U)
               + fvc::dotInterpolate(mesh.Sf(), tauMC)
             )
-            & (a_pos*U_pos + a_neg*U_neg)
+          & (a_pos*U_pos + a_neg*U_neg)
         );
 
         solve
diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C
index 6550d62b28cb858759307c5bcde1c442fcdc6108..a975275925843dc8e8d6b3d1002e7d00f28be488 100644
--- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C
+++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C
@@ -93,7 +93,10 @@ int main(int argc, char *argv[])
         surfaceScalarField p_neg("p_neg", rho_neg*rPsi_neg);
 
         surfaceScalarField phiv_pos("phiv_pos", U_pos & mesh.Sf());
+        // Note: extracted out the orientation so becomes unoriented
+        phiv_pos.setOriented(false);
         surfaceScalarField phiv_neg("phiv_neg", U_neg & mesh.Sf());
+        phiv_neg.setOriented(false);
 
         volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi));
         surfaceScalarField cSf_pos
@@ -101,20 +104,19 @@ int main(int argc, char *argv[])
             "cSf_pos",
             interpolate(c, pos, T.name())*mesh.magSf()
         );
-        cSf_pos.setOriented();
 
         surfaceScalarField cSf_neg
         (
             "cSf_neg",
             interpolate(c, neg, T.name())*mesh.magSf()
         );
-        cSf_neg.setOriented();
 
         surfaceScalarField ap
         (
             "ap",
             max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero)
         );
+
         surfaceScalarField am
         (
             "am",
@@ -163,11 +165,12 @@ int main(int argc, char *argv[])
 
         phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg;
 
-        surfaceVectorField phiUp
-        (
-            (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg)
-          + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf()
-        );
+        surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg);
+        // Note: reassembled orientation from the pos and neg parts so becomes
+        // oriented
+        phiU.setOriented(true);
+
+        surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf());
 
         surfaceScalarField phiEp
         (
diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H
index 797bb765a0c81f7200b88d6c9099fdcdf4b4451b..3dd4e261ad45ee46b4261f2bf27a14a1d96230e8 100644
--- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H
+++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H
@@ -27,8 +27,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef solidRegionDiff_H
-#define solidRegionDiff_H
+#ifndef solidRegionDiffNo_H
+#define solidRegionDiffNo_H
 
 #include "fvMesh.H"
 
diff --git a/applications/solvers/heatTransfer/thermoFoam/EEqn.H b/applications/solvers/heatTransfer/thermoFoam/EEqn.H
index 98a248ac35ae47bada3bbca30859ae9dfbeb616f..55088296638aa3b3f7901de2f977452df00b4e90 100644
--- a/applications/solvers/heatTransfer/thermoFoam/EEqn.H
+++ b/applications/solvers/heatTransfer/thermoFoam/EEqn.H
@@ -15,12 +15,16 @@
             )
           : -dpdt
         )
-      - fvm::laplacian(alphaEff, he)
      ==
         radiation->Sh(thermo, he)
       + fvOptions(rho, he)
     );
 
+    if (turbulence.valid())
+    {
+        EEqn -= fvm::laplacian(turbulence->alphaEff(), he);
+    }
+
     EEqn.relax();
 
     fvOptions.constrain(EEqn);
diff --git a/applications/solvers/heatTransfer/thermoFoam/createFields.H b/applications/solvers/heatTransfer/thermoFoam/createFields.H
index 90f25a89a3a930a0e416c19e586d7fcb48511ea9..2e09b43e59592c7db3fce6343e576173bbcbde9c 100644
--- a/applications/solvers/heatTransfer/thermoFoam/createFields.H
+++ b/applications/solvers/heatTransfer/thermoFoam/createFields.H
@@ -35,7 +35,31 @@ volVectorField U
 
 #include "compressibleCreatePhi.H"
 
-#include "setAlphaEff.H"
+autoPtr<compressible::turbulenceModel> turbulence;
+
+IOobject turbulencePropertiesHeader
+(
+    "turbulenceProperties",
+    runTime.constant(),
+    mesh,
+    IOobject::MUST_READ_IF_MODIFIED,
+    IOobject::NO_WRITE,
+    false
+);
+
+if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(false))
+{
+    Info<< "Creating turbulence model\n" << endl;
+
+    turbulence =
+        compressible::turbulenceModel::New
+        (
+            rho,
+            U,
+            phi,
+            thermo
+        );
+}
 
 #include "createDpdt.H"
 
diff --git a/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H b/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
deleted file mode 100644
index e7da9c6af68050ba26abf6891cc6075340e860c1..0000000000000000000000000000000000000000
--- a/applications/solvers/heatTransfer/thermoFoam/setAlphaEff.H
+++ /dev/null
@@ -1,47 +0,0 @@
-Info<< "Creating turbulence model\n" << endl;
-tmp<volScalarField> talphaEff;
-
-IOobject turbulencePropertiesHeader
-(
-    "turbulenceProperties",
-    runTime.constant(),
-    mesh,
-    IOobject::MUST_READ_IF_MODIFIED,
-    IOobject::NO_WRITE,
-    false
-);
-
-if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(true))
-{
-    autoPtr<compressible::turbulenceModel> turbulence
-    (
-        compressible::turbulenceModel::New
-        (
-            rho,
-            U,
-            phi,
-            thermo
-        )
-    );
-
-    talphaEff = turbulence->alphaEff();
-}
-else
-{
-    talphaEff = tmp<volScalarField>
-    (
-        new volScalarField
-        (
-            IOobject
-            (
-                "alphaEff",
-                runTime.timeName(),
-                mesh,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE
-            ),
-            mesh,
-            dimensionedScalar("0", dimMass/dimLength/dimTime, 0.0)
-        )
-    );
-}
diff --git a/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C b/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
index a8cbdf9f7e6188ae65d58031c3648aeaca54c42b..ea5012e72eaba0a28bb8aa7d81f713842da475ac 100644
--- a/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
+++ b/applications/solvers/heatTransfer/thermoFoam/thermoFoam.C
@@ -54,8 +54,6 @@ int main(int argc, char *argv[])
     #include "createFields.H"
     #include "createFvOptions.H"
 
-    const volScalarField& alphaEff = talphaEff();
-
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
     Info<< "\nEvolving thermodynamics\n" << endl;
diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
index 6872ae0321e74659359ee24d45561f5f01e04fca..9baa712b95831c26a8ad77b05619354cab69bac9 100644
--- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
+++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
@@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
 void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("thetaProperties")
-        << thetaProps_ << token::END_STATEMENT << nl;
+    os.writeEntry("thetaProperties", thetaProps_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H
index cc61acf6749e4d6ae838ae21e7bb9b19e2cd2355..cdeb8aaf2a9b8a00d972dceaa76f7520c7994107 100644
--- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H
+++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef flashThermo_H
-#define flashThermo_H
+#ifndef twoPhaseMixtureEThermo_H
+#define twoPhaseMixtureEThermo_H
 
 #include "volFields.H"
 
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
index a0d433f4e8b12a7bdbac428741e93de45973b4f4..d9c325a3ba3c124fa89d3fe0a298eb08de6e8468 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
@@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
 void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("thetaProperties")
-        << thetaProps_ << token::END_STATEMENT << nl;
+    os.writeEntry("thetaProperties", thetaProps_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H
index 738b7ae57048422a57443f41a5da06d23a50029a..ab24c73736918c7adf7a3c8a28bcb003104f7c3b 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/constantDiameter/constantDiameter.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef constant_H
-#define constant_H
+#ifndef diameterModels_constant_H
+#define diameterModels_constant_H
 
 #include "diameterModel.H"
 
diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H
index 0d155ad16e0bb4a6aca3ab251e6c89c68c89cfbd..8bdb54eff647c23d21b75543c20ff47a761d5ad7 100644
--- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H
+++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H
@@ -22,7 +22,7 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Class
-    Foam::isothermal
+    Foam::diameterModels::isothermal
 
 Description
     Isothermal dispersed-phase particle diameter model.
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef isothermal_H
-#define isothermal_H
+#ifndef diameterModels_isothermal_H
+#define diameterModels_isothermal_H
 
 #include "diameterModel.H"
 
diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
index a0d433f4e8b12a7bdbac428741e93de45973b4f4..d9c325a3ba3c124fa89d3fe0a298eb08de6e8468 100644
--- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
+++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
@@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
 void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("thetaProperties")
-        << thetaProps_ << token::END_STATEMENT << nl;
+    os.writeEntry("thetaProperties", thetaProps_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H
index bbac62d50b357130b46a6e9e48437d9cdff5fef9..23710027e3f2485f711a905ed78dbe157e81158a 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H
+++ b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H
@@ -72,8 +72,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef function1_saturationModel_H
-#define function1_saturationModel_H
+#ifndef saturationModels_function1_H
+#define saturationModels_function1_H
 
 #include "saturationModel.H"
 #include "Function1.H"
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
index b26ec2faa0829dbd7bca3f811d4572b489e6cee9..284992c64c9f0b0776efdac15b898f4bb2e1a5b2 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/alphaContactAngle/alphaContactAngleFvPatchScalarField.C
@@ -125,8 +125,7 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
 void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("thetaProperties")
-        << thetaProps_ << token::END_STATEMENT << nl;
+    os.writeEntry("thetaProperties", thetaProps_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C
index 2a4732fd97161a870d22226538f295232326a93a..464bbd01e4201e3519ed159398f3f24424012367 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C
@@ -138,9 +138,9 @@ void alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::write
 ) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl;
-    os.writeKeyword("fixedDmdt") << fixedDmdt_ << token::END_STATEMENT << nl;
-    os.writeKeyword("L") << L_ << token::END_STATEMENT << nl;
+    os.writeEntry("relax", relax_);
+    os.writeEntry("fixedDmdt", fixedDmdt_);
+    os.writeEntry("L", L_);
     dmdt_.writeEntry("dmdt", os);
     writeEntry("value", os);
 }
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C
index 7b854df507f1549609a186eabb4369f8e43949d4..f6c4ca196e7a2cd981d41c1a16fb16836b522802 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatPhaseChangeJayatillekeWallFunction/alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField.C
@@ -334,10 +334,10 @@ void alphatPhaseChangeJayatillekeWallFunctionFvPatchScalarField::write
 ) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Prt", Prt_);
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
     dmdt_.writeEntry("dmdt", os);
     writeEntry("value", os);
 }
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
index a1ac6c46f6590e1b5fd456272aad268b13a6b793..e10422c800f5618a73118578813ea19b115068fc 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C
@@ -596,42 +596,36 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
 
-    os.writeKeyword("phaseType") << phaseTypeNames_[phaseType_]
-        << token::END_STATEMENT << nl;
+    os.writeEntry("phaseType", phaseTypeNames_[phaseType_]);
 
-    os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl;
+    os.writeEntry("relax", relax_);
 
     switch (phaseType_)
     {
         case vaporPhase:
         {
-            os.writeKeyword("partitioningModel") << nl;
-            os  << indent << token::BEGIN_BLOCK << incrIndent << nl;
+            os.beginBlock("partitioningModel");
             partitioningModel_->write(os);
-            os << decrIndent << indent << token::END_BLOCK << nl;
+            os.endBlock();
             break;
         }
         case liquidPhase:
         {
-            os.writeKeyword("partitioningModel") << nl;
-            os << indent << token::BEGIN_BLOCK << incrIndent << nl;
+            os.beginBlock("partitioningModel");
             partitioningModel_->write(os);
-            os << decrIndent << indent << token::END_BLOCK << nl;
+            os.endBlock();
 
-            os.writeKeyword("nucleationSiteModel") << nl;
-            os << indent << token::BEGIN_BLOCK << incrIndent << nl;
+            os.beginBlock("nucleationSiteModel");
             nucleationSiteModel_->write(os);
-            os << decrIndent << indent << token::END_BLOCK << nl;
+            os.endBlock();
 
-            os.writeKeyword("departureDiamModel") << nl;
-            os << indent << token::BEGIN_BLOCK << incrIndent << nl;
+            os.beginBlock("departureDiamModel");
             departureDiamModel_->write(os);
-            os << decrIndent << indent << token::END_BLOCK << nl;
+            os.endBlock();
 
-            os.writeKeyword("departureFreqModel") << nl;
-            os << indent << token::BEGIN_BLOCK << incrIndent << nl;
+            os.beginBlock("departureFreqModel");
             departureFreqModel_->write(os);
-            os << decrIndent << indent << token::END_BLOCK << nl;
+            os.endBlock();
 
             break;
         }
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C
index 63c85938cfdd90dafbc7e0eb13c01229d9e6542f..f9142de5cf0d2eae64a9dcee8179197ce3d59940 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C
@@ -109,8 +109,7 @@ void Foam::copiedFixedValueFvPatchScalarField::updateCoeffs()
 void Foam::copiedFixedValueFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("sourceField")
-        << sourceFieldName_ << token::END_STATEMENT << nl;
+    os.writeEntry("sourceField", sourceFieldName_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
index c991a1a3336f7f2b030ef0150c3fa759c374a1a2..c84f323e741bb52745524efc5a907882977c9a09 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
@@ -183,7 +183,7 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
 void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl;
+    os.writeEntry("relax", relax_);
     q_.writeEntry("q", os);
     writeEntry("value", os);
 }
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C
index 53fe0e2f15bfd5295b91ef4260d28c78fee2e9e7..c18a01cf0b038f31a35282f33c8d3929f6dab6cd 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/KocamustafaogullariIshii/KocamustafaogullariIshii.C
@@ -114,7 +114,7 @@ void Foam::wallBoilingModels::departureDiameterModels::
 KocamustafaogullariIshii::write(Ostream& os) const
 {
     departureDiameterModel::write(os);
-    os.writeKeyword("phi") << phi_ << token::END_STATEMENT << nl;
+    os.writeEntry("phi", phi_);
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C
index 71ef4f03c735815d34c261da4e2af756eea66c8a..e2ec8ef829e418c3d013c38b463faeacdb290328 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/TolubinskiKostanchuk/TolubinskiKostanchuk.C
@@ -90,9 +90,9 @@ void Foam::wallBoilingModels::departureDiameterModels::
 TolubinskiKostanchuk::write(Ostream& os) const
 {
     departureDiameterModel::write(os);
-    os.writeKeyword("dRef") << dRef_ << token::END_STATEMENT << nl;
-    os.writeKeyword("dMax") << dMax_ << token::END_STATEMENT << nl;
-    os.writeKeyword("dMin") << dMin_ << token::END_STATEMENT << nl;
+    os.writeEntry("dRef", dRef_);
+    os.writeEntry("dMax", dMax_);
+    os.writeEntry("dMin", dMin_);
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C
index 4c3564a006b85061cdc452b21879268cc3ce6faa..1c8c3dba40711a74811e21af15b252dcab077b60 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureDiameterModels/departureDiameterModel/departureDiameterModel.C
@@ -53,7 +53,7 @@ Foam::wallBoilingModels::departureDiameterModel::~departureDiameterModel()
 
 void Foam::wallBoilingModels::departureDiameterModel::write(Ostream& os) const
 {
-    os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", this->type());
 }
 
 // ************************************************************************* //
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C
index e87e520096b49ac3cc18a225e266cb8a258f543b..e76f789cc60502d09c9a69be8dc6a1033840b3d5 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/departureFrequencyModels/departureFrequencyModel/departureFrequencyModel.C
@@ -53,7 +53,7 @@ Foam::wallBoilingModels::departureFrequencyModel::~departureFrequencyModel()
 
 void Foam::wallBoilingModels::departureFrequencyModel::write(Ostream& os) const
 {
-    os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", this->type());
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C
index fbf495a5e2f08020abbf32feefad6299737297ec..16c2112664c1cd151e9dd91c38d796f7271d19a1 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/nucleationSiteModels/nucleationSiteModel/nucleationSiteModel.C
@@ -53,7 +53,7 @@ Foam::wallBoilingModels::nucleationSiteModel::~nucleationSiteModel()
 
 void Foam::wallBoilingModels::nucleationSiteModel::write(Ostream& os) const
 {
-    os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", this->type());
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C
index 04b8c2917e2a050a9547afeedc6a8ef83627e99b..581a83a6d1b0dbcd9ea3054602c4e3deff2900e0 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/Lavieville/Lavieville.C
@@ -88,7 +88,7 @@ void Foam::wallBoilingModels::partitioningModels::
 Lavieville::write(Ostream& os) const
 {
     partitioningModel::write(os);
-    os.writeKeyword("alphaCrit") << alphaCrit_ << token::END_STATEMENT << nl;
+    os.writeEntry("alphaCrit", alphaCrit_);
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C
index 1d157b67ab13eaba8b495ef04944d3887f264556..f9528677d4f41ec886e0ce6f88b596dc55195e84 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/cosine/cosine.C
@@ -97,10 +97,8 @@ void Foam::wallBoilingModels::partitioningModels::
 cosine::write(Ostream& os) const
 {
     partitioningModel::write(os);
-    os.writeKeyword("alphaLiquid1") << alphaLiquid1_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("alphaLiquid0") << alphaLiquid0_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("alphaLiquid1", alphaLiquid1_);
+    os.writeEntry("alphaLiquid0", alphaLiquid0_);
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C
index dd1142b1372458d6ad934078bc752a71f7bf1d39..cc6d648f8492f4702421aa006ee634172d9a2240 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/linear/linear.C
@@ -90,10 +90,8 @@ void Foam::wallBoilingModels::partitioningModels::
 linear::write(Ostream& os) const
 {
     partitioningModel::write(os);
-    os.writeKeyword("alphaLiquid1") << alphaLiquid1_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("alphaLiquid0") << alphaLiquid0_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("alphaLiquid1", alphaLiquid1_);
+    os.writeEntry("alphaLiquid0", alphaLiquid0_);
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C
index 7b68289d948b5f1221cf1b68e8f6bfcc6a3557af..cb12aca19087f130c3a6d99de5d509d152a970b3 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/wallBoilingSubModels/partitioningModels/partitioningModel/partitioningModel.C
@@ -53,7 +53,7 @@ Foam::wallBoilingModels::partitioningModel::~partitioningModel()
 
 void Foam::wallBoilingModels::partitioningModel::write(Ostream& os) const
 {
-    os.writeKeyword("type") << this->type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", this->type());
 }
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C
index 651de2ea03fea1b267335c0b389aa548a4e61c3a..a64155e4a0c512e131de1f031da364a25f2d31c4 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C
@@ -245,8 +245,7 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("specularityCoefficient")
-        << specularityCoefficient_ << token::END_STATEMENT << nl;
+    os.writeEntry("specularityCoefficient", specularityCoefficient_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C
index 0fa9d5faf628a5fcdf9eefc3e2a98fa8248a3709..53431117d5584da10a78fca929c044d726a6bd60 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C
@@ -289,10 +289,8 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("restitutionCoefficient")
-        << restitutionCoefficient_ << token::END_STATEMENT << nl;
-    os.writeKeyword("specularityCoefficient")
-        << specularityCoefficient_ << token::END_STATEMENT << nl;
+    os.writeEntry("restitutionCoefficient", restitutionCoefficient_);
+    os.writeEntry("specularityCoefficient", specularityCoefficient_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C
index 651de2ea03fea1b267335c0b389aa548a4e61c3a..a64155e4a0c512e131de1f031da364a25f2d31c4 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C
@@ -245,8 +245,7 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("specularityCoefficient")
-        << specularityCoefficient_ << token::END_STATEMENT << nl;
+    os.writeEntry("specularityCoefficient", specularityCoefficient_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C
index 0fa9d5faf628a5fcdf9eefc3e2a98fa8248a3709..53431117d5584da10a78fca929c044d726a6bd60 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C
@@ -289,10 +289,8 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("restitutionCoefficient")
-        << restitutionCoefficient_ << token::END_STATEMENT << nl;
-    os.writeKeyword("specularityCoefficient")
-        << specularityCoefficient_ << token::END_STATEMENT << nl;
+    os.writeEntry("restitutionCoefficient", restitutionCoefficient_);
+    os.writeEntry("specularityCoefficient", specularityCoefficient_);
     writeEntry("value", os);
 }
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H
index 6f616c6f73df37fec0c840c918aa07f7ee1a2dd7..fbf20426e8f8a74ee49b690004251e35f86d9e5b 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/constantDiameter/constantDiameter.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef constant_H
-#define constant_H
+#ifndef diameterModels_constant_H
+#define diameterModels_constant_H
 
 #include "diameterModel.H"
 
diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H
index 6e997a210aec2ffbc98797a8c0a94b43b1b8bfb6..1d83bc575a849a5147875395dc0f4fcf2e0c8f41 100644
--- a/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H
+++ b/applications/solvers/multiphase/twoPhaseEulerFoam/twoPhaseSystem/diameterModels/isothermalDiameter/isothermalDiameter.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef isothermal_H
-#define isothermal_H
+#ifndef diameterModels_isothermal_H
+#define diameterModels_isothermal_H
 
 #include "diameterModel.H"
 
diff --git a/applications/test/DynamicList/Test-DynamicList.C b/applications/test/DynamicList/Test-DynamicList.C
index c8e2ed4a93be0d6b8b2a0b713463e2189da48ea9..11111aad0044d37eeedd6ed6e53fe04042f375f9 100644
--- a/applications/test/DynamicList/Test-DynamicList.C
+++ b/applications/test/DynamicList/Test-DynamicList.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,7 +27,10 @@ Description
 
 #include "DynamicList.H"
 #include "IOstreams.H"
+#include "FlatOutput.H"
 #include "ListOps.H"
+#include "labelRange.H"
+#include "labelIndList.H"
 
 using namespace Foam;
 
@@ -43,16 +46,24 @@ void printInfo
     if (showSize)
     {
         Info<< " size=\"" << lst.size() << "\"";
+        if (lst.cdata())
+        {
+            Info<< " ptr=\"" << long(lst.cdata()) << "\"";
+        }
+        else
+        {
+            Info<< " ptr=\"nullptr\"";
+        }
     }
-    Info<< ">" << lst << "</" << tag << ">" << endl;
+    Info<< ">" << nl << flatOutput(lst) << nl << "</" << tag << ">" << endl;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 void printInfo
 (
     const word& tag,
-    const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst,
+    const DynamicList<T, SizeMin>& lst,
     const bool showSize = false
 )
 {
@@ -61,8 +72,16 @@ void printInfo
     {
         Info<< " size=\"" << lst.size()
             << "\" capacity=\"" << lst.capacity() << "\"";
+        if (lst.cdata())
+        {
+            Info<< " ptr=\"" << long(lst.cdata()) << "\"";
+        }
+        else
+        {
+            Info<< " ptr=\"nullptr\"";
+        }
     }
-    Info<< ">" << lst << "</" << tag << ">" << endl;
+    Info<< ">" << nl << flatOutput(lst) << nl << "</" << tag << ">" << endl;
 }
 
 
@@ -71,7 +90,7 @@ void printInfo
 
 int main(int argc, char *argv[])
 {
-    List<DynamicList<label, 1, 0>> ldl(2);
+    List<DynamicList<label>> ldl(2);
 
     ldl[0](0) = 0;
     ldl[0](2) = 2;
@@ -89,7 +108,7 @@ int main(int argc, char *argv[])
 
     ldl[1] = 3;
 
-    Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
+    Info<< "<ldl>" << flatOutput(ldl) << "</ldl>" << nl << "sizes: ";
     forAll(ldl, i)
     {
         Info<< " " << ldl[i].size() << "/" << ldl[i].capacity();
@@ -100,7 +119,7 @@ int main(int argc, char *argv[])
     ll[0].transfer(ldl[0]);
     ll[1].transfer(ldl[1].shrink());
 
-    Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
+    Info<< "<ldl>" << flatOutput(ldl) << "</ldl>" << nl << "sizes: ";
     forAll(ldl, i)
     {
         Info<< " " << ldl[i].size() << "/" << ldl[i].capacity();
@@ -111,18 +130,18 @@ int main(int argc, char *argv[])
 
 
     // test the transfer between DynamicLists
-    DynamicList<label, 1, 0> dlA
+    DynamicList<label> dlA
     {
         0, 1, 2, 3, 4
     };
     dlA.append({ 5, 6 });
     dlA = { 1, 2, 4 };
 
-    DynamicList<label, 1, 0> dlB;
+    DynamicList<label> dlB;
 
     dlA.setCapacity(10);
 
-    Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
+    Info<< "<dlA>" << flatOutput(dlA) << "</dlA>" << nl << "sizes: "
         << " " << dlA.size() << "/" << dlA.capacity() << endl;
 
     dlB.transfer(dlA);
@@ -132,9 +151,9 @@ int main(int argc, char *argv[])
     dlB[6] = 6;
 
     Info<< "Transferred to dlB" << endl;
-    Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
+    Info<< "<dlA>" << flatOutput(dlA) << "</dlA>" << nl << "sizes: "
         << " " << dlA.size() << "/" << dlA.capacity() << endl;
-    Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
+    Info<< "<dlB>" << flatOutput(dlB) << "</dlB>" << nl << "sizes: "
         << " " << dlB.size() << "/" << dlB.capacity() << endl;
 
     // try with a normal list:
@@ -166,7 +185,7 @@ int main(int argc, char *argv[])
 
 
     // check allocation granularity
-    DynamicList<label, 6, 0> dlC;
+    DynamicList<label> dlC;
 
     printInfo("dlC", dlC, true);
 
@@ -227,15 +246,102 @@ int main(int argc, char *argv[])
             dlE2[i] *= 10;
         }
 
-        UIndirectList<label> uil
+        labelUIndList uil
         (
             dlE2, addr
         );
         Info<< "use UIndirectList " << uil << " remapped from " << dlE2 << endl;
         dlE4 = uil;
         printInfo("dlE4", dlE4, true);
-     }
+    }
+
+    {
+        Info<< nl << "Test moving:" << nl;
+
+        labelList input1 = identity(15);
+        labelList input2 = identity(15);
+        inplaceReverseList(input2);
+
+        DynamicList<label> list1(std::move(input1));
+        DynamicList<label> list2;
+
+        Info<< "move construct:" << nl
+            << "input: " << flatOutput(input1) << nl
+            << "list:  " << flatOutput(list1) << endl;
+
+        list1 = std::move(input2);
+
+        Info<< "move assignment:" << nl
+            << "input: " << flatOutput(input2) << nl
+            << "list:  " << flatOutput(list1) << endl;
+
+        list2 = std::move(list1);
+        Info<< "list in:  " << flatOutput(list1) << nl
+            << "list out: " << flatOutput(list2) << endl;
 
+        input2 = std::move(identity(15));
+        list2 = std::move(input2);
+        Info<< "list in:  " << flatOutput(input2) << nl
+            << "list out: " << flatOutput(list2) << endl;
+
+        input1 = identity(15);
+        input2 = identity(15);
+        inplaceReverseList(input2);
+
+        Info<< "test move-append with "
+            << flatOutput(input1) << " and " << flatOutput(input2) << endl;
+
+        list2.append(std::move(list1));
+        list2.append(std::move(input1));
+        list2.append(std::move(input2));
+
+        Info<< "result: " << flatOutput(list2) << nl
+            << "inputs: " << flatOutput(list1) << " / "
+            << flatOutput(input1) << " / "
+            << flatOutput(input2) << nl;
+
+        Info<< "test move dissimilar sizing:" << nl;
+        list1 = list2;
+        list1.reserve(100);
+
+        // DynamicList<label,1000> list3; // (std::move(list1));
+        DynamicList<label,1000> list3(std::move(list1));
+        Info<< "orig: " << flatOutput(list1) << nl;
+
+        // list3.swap(list1);
+        // list3 = std::move(list1);
+
+        printInfo("input",  list1, true);
+        printInfo("output", list3, true);
+
+        input1 = list2;
+
+        Info<< nl << "test subset/remove with "
+            << flatOutput(input1) << endl;
+
+        for
+        (
+            const labelRange range :
+            {
+                labelRange(-10, 8),  // invalid range
+                labelRange(40, 18),  // trailing portion
+                labelRange(-5, 10),  // leading portion
+                labelRange(10, 8),   // mid-portion
+                labelRange(0, input1.size()), // everything
+            }
+        )
+        {
+            list1 = input1;
+            list2 = input1;
+
+            list1.remove(range);
+            list2.subset(range);
+
+            Info<< "input = " << flatOutput(input1) << nl
+                << "remove " << range << " = " << flatOutput(list1) << nl
+                << "subset " << range << " = " << flatOutput(list2) << nl;
+        }
+    }
 
     Info<< "\nEnd\n";
 
diff --git a/applications/test/Field/Make/files b/applications/test/Field/Make/files
deleted file mode 100644
index f8f0bb64df86a9a9b3046fe13eb7359d827096cc..0000000000000000000000000000000000000000
--- a/applications/test/Field/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-Test-Field.C
-
-EXE = $(FOAM_USER_APPBIN)/Test-Field
diff --git a/applications/test/Field/Test-Field.C b/applications/test/Field/Test-Field.C
deleted file mode 100644
index 2e037f6a34b607546c8f525e89664d1fac084178..0000000000000000000000000000000000000000
--- a/applications/test/Field/Test-Field.C
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "Test-Field.H"
-
-int main()
-{
-    Vector<double> v1(1, 2);
-    Vector<double> v2(2, 3);
-
-    std::cout << v1 + v2;
-
-    return 0;
-}
diff --git a/applications/test/Field/Test-Field.H b/applications/test/Field/Test-Field.H
deleted file mode 100644
index bd6929f838ea4bea957f3fdff28abf6463b4c3fa..0000000000000000000000000000000000000000
--- a/applications/test/Field/Test-Field.H
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <iostream>
-
-template<class C>
-class Vector;
-
-template<class C>
-Vector<C> operator+(const Vector<C>& v1, const Vector<C>& v2);
-
-template<class C>
-std::ostream& operator<<(std::ostream& os, const Vector<C>& v);
-
-
-/*---------------------------------------------------------------------------*\
-                           Class Vector Declaration
-\*---------------------------------------------------------------------------*/
-
-template<class C>
-class Vector
-{
-
-    double X, Y;
-
-public:
-
-    inline Vector(const double x, const double y);
-
-    C x() const
-    {
-        return X;
-    }
-
-    C y() const
-    {
-        return Y;
-    }
-
-    friend Vector<C> operator+ <C>(const Vector<C>& v1, const Vector<C>& v2);
-
-    friend std::ostream& operator<<(std::ostream& os, const Vector<C>& v)
-    {
-        os  << v.X << '\t' << v.Y << '\n';
-        return os;
-    }
-};
-
-template<class C>
-inline Vector<C>::Vector(const double x, const double y)
-{
-    X = x;
-    Y = y;
-}
-
-
-template<class C>
-inline Vector<C> operator+(const Vector<C>& v1, const Vector<C>& v2)
-{
-    return Vector<C>(v1.X+v2.X, v1.Y+v2.Y);
-}
diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C
index b057b43f2765880829328a6e1a2d54b19a3d6e8c..c501b77bc4cf70cd10b8eec4a14f1907653d7a25 100644
--- a/applications/test/FixedList/Test-FixedList.C
+++ b/applications/test/FixedList/Test-FixedList.C
@@ -35,8 +35,10 @@ See also
 #include "argList.H"
 #include "FixedList.H"
 #include "Fstream.H"
+#include "List.H"
 #include "IPstream.H"
 #include "OPstream.H"
+#include <numeric>
 
 using namespace Foam;
 
@@ -47,36 +49,101 @@ int main(int argc, char *argv[])
 {
     argList args(argc, argv);
 
-    FixedList<label, 4> list;
-    list[0] = 1;
-    list[1] = 2;
-    list[2] = 3;
-    list[3] = 4;
+    if (false)
+    {
+        FixedList<string, 1> ident;
+
+        auto iter = ident.begin();
+
+        Info << iter->size() << endl;
 
-    Info<< "list:" << list
-        << " hash:" << FixedList<label, 4>::Hash<>()(list) << endl;
+        auto riter = ident.rbegin();
+        Info << riter->size() << endl;
 
-    label a[4] = {0, 1, 2, 3};
-    FixedList<label, 4> list2(a);
+        auto iter2 = ident.rbegin();
 
-    Info<< "list2:" << list2
-        << " hash:" << FixedList<label, 4>::Hash<>()(list2) << endl;
+        iter2 = iter;
+    }
 
-    // Using FixedList for content too
     {
-        List<FixedList<label, 4>> twolists{list, list2};
-        Info<<"List of FixedList: " << flatOutput(twolists) << endl;
-        sort(twolists);
-        // outer-sort only
-        Info<<"sorted FixedList : " << flatOutput(twolists) << endl;
+        FixedList<label, 15> ident;
+        std::iota(ident.begin(), ident.end(), 0);
+
+        // auto iter = ident.begin();
+        //
+        // iter += 5;
+        // Info << *iter << "< " << endl;
+        // iter -= 2;
+        // Info << *iter << "< " << endl;
+
+        // Don't yet bother with making reverse iterators random access
+        // auto riter = ident.crbegin();
+
+        // riter += 5;
+        // Info << *riter << "< " << endl;
+        // riter += 2;
+        // Info << *riter << "< " << endl;
+
+        Info<<"Ident:";
+        forAllConstIters(ident, iter)
+        {
+            Info<<" " << *iter;
+        }
+        Info<< nl;
+
+        Info<<"reverse:";
+        forAllReverseIters(ident, iter)
+        {
+            Info<<" " << *iter;
+        }
+        Info<< nl;
+
+        Info<<"const reverse:";
+        forAllConstReverseIters(ident, iter)
+        {
+            Info<<" " << *iter;
+        }
+        Info<< nl;
     }
 
-    Info<< "list: " << list << nl
-        << "list2: " << list2 << endl;
-    list.swap(list2);
-    Info<< "Swapped via the swap() method" << endl;
-    Info<< "list: " << list << nl
-        << "list2: " << list2 << endl;
+    {
+        FixedList<label, 4> list1{1, 2, 3, 4};
+
+        Info<< "list1:" << list1
+            << " hash:" << FixedList<label, 4>::Hash<>()(list1) << endl;
+
+        label a[4] = {0, 1, 2, 3};
+        FixedList<label, 4> list2(a);
+
+        Info<< "list2:" << list2
+            << " hash:" << FixedList<label, 4>::Hash<>()(list2) << endl;
+
+        // Using FixedList for content too
+        {
+            List<FixedList<label, 4>> twolists{list1, list2};
+            Info<<"List of FixedList: " << flatOutput(twolists) << endl;
+            sort(twolists);
+            // outer-sort only
+            Info<<"sorted FixedList : " << flatOutput(twolists) << endl;
+        }
+
+        Info<< "====" << nl
+            << "Test swap" << nl;
+
+        Info<< "list1: " << list1 << nl
+            << "list2: " << list2 << endl;
+        list1.swap(list2);
+        Info<< "The swap() method" << endl;
+        Info<< "list1: " << list1 << nl
+            << "list2: " << list2 << endl;
+
+        Swap(list1, list2);
+        Info<< "The Swap() function" << endl;
+        Info<< "list1: " << list1 << nl
+            << "list2: " << list2 << endl;
+
+        Info<< "====" << nl;
+    }
 
     List<label> list3{0, 1, 2, 3};
     FixedList<label, 4> list4(list3.begin(), list3.end());
diff --git a/applications/test/FixedList/fixedListFile b/applications/test/FixedList/fixedListFile
deleted file mode 100644
index 4faae2f6aab9b12b7503643eb87c1756e9139d44..0000000000000000000000000000000000000000
Binary files a/applications/test/FixedList/fixedListFile and /dev/null differ
diff --git a/applications/test/FixedList2/Make/files b/applications/test/FixedList2/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..548fa36bc5ee5fb3f587cdd58a4efe01dcdfc6f6
--- /dev/null
+++ b/applications/test/FixedList2/Make/files
@@ -0,0 +1,3 @@
+Test-FixedList2.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-FixedList2
diff --git a/applications/test/HashTable/Make/options b/applications/test/FixedList2/Make/options
similarity index 100%
rename from applications/test/HashTable/Make/options
rename to applications/test/FixedList2/Make/options
diff --git a/applications/test/FixedList2/Test-FixedList2.C b/applications/test/FixedList2/Test-FixedList2.C
new file mode 100644
index 0000000000000000000000000000000000000000..efd3cfabdcb620153f2135317a4272553eaea008
--- /dev/null
+++ b/applications/test/FixedList2/Test-FixedList2.C
@@ -0,0 +1,190 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    Test-FixedList2
+
+Description
+    Test speeds, usability of some List/FixedList operations
+
+See also
+    Foam::FixedList
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "FixedList.H"
+#include "labelList.H"
+#include "vectorList.H"
+#include "ListOps.H"
+#include "IFstream.H"
+#include "OFstream.H"
+#include "cpuTime.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+using namespace Foam;
+
+template<class ListType>
+void runSwapTest
+(
+    const label nLoops,
+    ListType& list1,
+    ListType& list2
+)
+{
+    cpuTime timer;
+
+    Info<<"Swapping fixed lists with " << list1.size() << " elements\n";
+
+    Info<< "input 1: " << list1.first() << nl;
+    Info<< "input 2: " << list2.first() << nl;
+
+    // Should be zero, since this is a compile-time value
+
+    Info<< "Perform " << nLoops << " swaps..." << nl;
+
+    for (label iLoop = 0; iLoop < nLoops; ++iLoop)
+    {
+        Swap(list1, list2);
+    }
+
+    Info<< "output 1: " << list1.first() << nl;
+    Info<< "output 2: " << list2.first() << nl;
+
+    Info<< "Operation took"
+        << "  " << timer.cpuTimeIncrement() << " s\n\n";
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+    argList::addBoolOption("label");
+    argList::addBoolOption("float");
+    argList::addBoolOption("vector");
+    argList::addBoolOption("labelList");
+    argList::addBoolOption("vectorList");
+    argList::addBoolOption("fixedLabel");
+    argList::addBoolOption("fixedLabelList");
+
+    argList args(argc, argv);
+
+    if (args.options().empty())
+    {
+        Info<< nl << "Specify an option! " << nl << endl;
+    }
+
+    if (args.optionFound("label"))
+    {
+        FixedList<label, 100000> list1(1);
+        FixedList<label, 100000> list2(0);
+
+        runSwapTest(1000001, list1, list2);
+    }
+
+    if (args.optionFound("float"))
+    {
+        FixedList<double, 100000> list1(1.0);
+        FixedList<double, 100000> list2(0.0);
+
+        runSwapTest(1000001, list1, list2);
+    }
+
+    if (args.optionFound("vector"))
+    {
+        FixedList<vector, 100000> list1(vector::one);
+        FixedList<vector, 100000> list2(vector::zero);
+
+        runSwapTest(100001, list1, list2);
+    }
+
+    if (args.optionFound("labelList"))
+    {
+        typedef labelList testType;
+        testType initVal(500);
+
+        initVal = 0;
+        FixedList<testType, 1000> list1(initVal);
+
+        initVal = 1;
+        FixedList<testType, 1000> list2(initVal);
+
+        runSwapTest(100001, list1, list2);
+    }
+
+    if (args.optionFound("vectorList"))
+    {
+        typedef vectorList testType;
+        testType initVal(500);
+
+        initVal = vector::zero;
+        FixedList<testType, 1000> list1(initVal);
+
+        initVal = vector::one;
+        FixedList<testType, 1000> list2(initVal);
+
+        runSwapTest(100001, list1, list2);
+    }
+
+    if (args.optionFound("fixedLabel"))
+    {
+        typedef FixedList<label,1000> testType;
+
+        testType initVal;
+
+        initVal = 0;
+        FixedList<testType, 1000> list1(initVal);
+
+        initVal = 1;
+        FixedList<testType, 1000> list2(initVal);
+
+        runSwapTest(100001, list1, list2);
+    }
+
+    if (args.optionFound("fixedLabelList"))
+    {
+        typedef labelList testType;
+        typedef FixedList<testType,10> containerType;
+
+        testType tinitVal(500);
+        containerType initVal;
+
+        tinitVal = 0;
+        initVal = tinitVal;
+        FixedList<containerType, 1000> list1(initVal);
+
+        tinitVal = 1;
+        initVal = tinitVal;
+        FixedList<containerType, 1000> list2(initVal);
+
+        runSwapTest(10001, list1, list2);
+    }
+
+    Info<< nl << "Done" << nl << endl;
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/Function1/Test-Function1.C b/applications/test/Function1/Test-Function1.C
index ab4baee1509f8dd10ac285939a2fb97e029f89f6..d1d3b1f073c4ddff57d2ba432ecf58ce21da1ef5 100644
--- a/applications/test/Function1/Test-Function1.C
+++ b/applications/test/Function1/Test-Function1.C
@@ -31,6 +31,7 @@ Description
 
 #include "fvCFD.H"
 #include "Function1.H"
+#include "scalarIndList.H"
 #include "IOdictionary.H"
 #include "linearInterpolationWeights.H"
 #include "splineInterpolationWeights.H"
@@ -69,7 +70,7 @@ int main(int argc, char *argv[])
     scalar baseSum = interpolator.weightedSum
     (
         weights,
-        UIndirectList<scalar>(values, indices)
+        scalarUIndList(values, indices)
     );
     Pout<< "baseSum=" << baseSum << nl << nl << endl;
 
@@ -78,7 +79,7 @@ int main(int argc, char *argv[])
 //    scalar partialSum = interpolator.weightedSum
 //    (
 //        weights,
-//        UIndirectList<scalar>(values, indices)
+//        scalarUIndList(values, indices)
 //    );
 //    Pout<< "partialSum=" << partialSum << nl << nl << endl;
 //
@@ -90,7 +91,7 @@ int main(int argc, char *argv[])
 //    scalar sum = interpolator.weightedSum
 //    (
 //        weights,
-//        UIndirectList<scalar>(values, indices)
+//        scalarUIndList(values, indices)
 //    );
 //    Pout<< "integrand=" << sum << nl << nl << endl;
 
diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C
index 55640829fb2ea0c2aa01630194e5260144253310..7ead0c42852f3cf7fa71632c6c92bcefd0960030 100644
--- a/applications/test/HashSet/Test-hashSet.C
+++ b/applications/test/HashSet/Test-hashSet.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,6 +26,7 @@ Description
 \*---------------------------------------------------------------------------*/
 
 #include "hashedWordList.H"
+#include "nil.H"
 #include "HashSet.H"
 #include "Map.H"
 #include "labelPairHashes.H"
@@ -69,6 +70,8 @@ int main(int argc, char *argv[])
 
     Info<< "tableA keys: "; tableA.writeKeys(Info) << endl;
 
+    Info<< "tableB content: " << tableB << endl;
+
     auto keyIterPair = tableA.keys();
     for (const auto& i : keyIterPair)
     {
@@ -223,6 +226,31 @@ int main(int argc, char *argv[])
         Info << i << endl;
     }
 
+    Info<< nl << "Test swapping, moving etc." << nl;
+    setA.insert({ "some", "more", "entries" });
+
+    Info<< "input" << nl;
+    Info<< "setA: " << setA << nl;
+
+    wordHashSet setA1(std::move(setA));
+
+    Info<< "move construct" << nl;
+    Info<< "setA: " << setA << nl
+        << "setA1: " << setA1 << nl;
+
+
+    wordHashSet setB1;
+    Info<< "move assign" << nl;
+    setB1 = std::move(setA1);
+
+    Info<< "setA1: " << setA1 << nl
+        << "setB1: " << setB1 << nl;
+
+    setB1.swap(setA1);
+
+    Info<< "setA1: " << setA1 << nl
+        << "setB1: " << setB1 << nl;
+
     return 0;
 }
 
diff --git a/applications/test/HashTable/Make/files b/applications/test/HashTable/Make/files
deleted file mode 100644
index 53d1e076991e7cfe348e80242dea3d87a9a30c98..0000000000000000000000000000000000000000
--- a/applications/test/HashTable/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-Test-hashTable.C
-
-EXE = $(FOAM_USER_APPBIN)/Test-hashTable
diff --git a/applications/test/HashTable1/Make/files b/applications/test/HashTable1/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..05c776d65ceb1fa3edcc57fea9e01ff0d28646f0
--- /dev/null
+++ b/applications/test/HashTable1/Make/files
@@ -0,0 +1,3 @@
+Test-HashTable1.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-HashTable1
diff --git a/applications/test/StaticHashTable/Make/options b/applications/test/HashTable1/Make/options
similarity index 100%
rename from applications/test/StaticHashTable/Make/options
rename to applications/test/HashTable1/Make/options
diff --git a/applications/test/HashTable/Test-hashTable.C b/applications/test/HashTable1/Test-HashTable1.C
similarity index 90%
rename from applications/test/HashTable/Test-hashTable.C
rename to applications/test/HashTable1/Test-HashTable1.C
index 1071b0a473af0b2040d711f79f13abb92f1e731c..f0017d4e5af3738a2ffbbe4e845c89985b142bb3 100644
--- a/applications/test/HashTable/Test-hashTable.C
+++ b/applications/test/HashTable1/Test-HashTable1.C
@@ -324,6 +324,34 @@ int main()
         << nl;
 
 
+    // Start again with new value
+    table2.set("ada", 14.0);
+    table2.set("aeq", 15.0);
+    table2.set("aaw", 16.0);
+
+    Info<< nl << "input values" << nl;
+    Info<<"table1 =  " << table1 << nl <<"table2 =  " << table2 << nl;
+
+    Info<<"global Swap function" << nl;
+    Swap(table1, table2);
+    Info<<"table1 =  " << table1 << nl <<"table2 =  " << table2 << nl;
+
+    Info<<"swap method" << nl;
+    table1.swap(table2);
+    Info<<"table1 =  " << table1 << nl <<"table2 =  " << table2 << nl;
+
+    Info<<"transfer" << nl;
+    table1.transfer(table2);
+    Info<<"table1 =  " << table1 << nl <<"table2 =  " << table2 << nl;
+
+    Info<<"move assign" << nl;
+    table2 = std::move(table1);
+    Info<<"table1 =  " << table1 << nl <<"table2 =  " << table2 << nl;
+
+    Info<<"move construct" << nl;
+    HashTable<scalar> table1b(std::move(table2));
+    Info<<"table1 =  " << table1b << nl <<"table2 =  " << table2 << nl;
+
     Info<< "\nDone\n";
 
     return 0;
diff --git a/applications/test/HashTable3/Test-HashTable3.C b/applications/test/HashTable3/Test-HashTable3.C
index 7184d305743303f66ef177cf40de1534b0676c1d..99e0749d1666caa101f7c8b1eedb06115a9d1202 100644
--- a/applications/test/HashTable3/Test-HashTable3.C
+++ b/applications/test/HashTable3/Test-HashTable3.C
@@ -30,17 +30,24 @@ Description
 #include "HashTable.H"
 #include "HashPtrTable.H"
 #include "Map.H"
-#include "StaticHashTable.H"
 #include "cpuTime.H"
 
 using namespace Foam;
 
+template<class T>
+Ostream& printInfo(Ostream& os, const HashTable<T, T, Hash<T>>& ht)
+{
+    os << " (size " << ht.size() << " capacity " << ht.capacity() << ") ";
+    return os;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // Main program:
 
 int main(int argc, char *argv[])
 {
-    const label nLoops = 30;
+    const label nLoops = 300;
     const label nBase  = 100000;
     const label nSize  = nLoops * nBase;
 
@@ -49,20 +56,20 @@ int main(int argc, char *argv[])
     // ie, a
     // Map<label> map(2 * nSize);
     // HashTable<label, label, Hash<label>> map(2 * nSize);
-    // StaticHashTable<label, label, Hash<label>> map(2 * nSize);
     HashTable<label, label, Hash<label>> map(2 * nSize);
 
-    Info<< "Constructed map of size: " << nSize
-        << " (size " << map.size() << " capacity " << map.capacity() << ") "
-        << "  " << timer.cpuTimeIncrement() << " s\n\n";
+    Info<< "Constructed map of size: " << nSize;
+    printInfo(Info, map);
+    Info<< timer.cpuTimeIncrement() << " s\n\n";
 
     for (label i = 0; i < nSize; i++)
     {
         map.insert(i, i);
     }
-    Info<< "Inserted " << nSize << " elements"
-        << " (size " << map.size() << " capacity " << map.capacity() << ") "
-        << timer.cpuTimeIncrement() << " s\n";
+
+    Info<< "Inserted " << nSize << " elements";
+    printInfo(Info, map);
+    Info<< timer.cpuTimeIncrement() << " s\n\n";
 
     label elemI = 0;
     for (label iLoop = 0; iLoop < nLoops; iLoop++)
@@ -72,12 +79,14 @@ int main(int argc, char *argv[])
             map.erase(elemI++);
         }
 
-        map.shrink();
-        Info<< "loop " << iLoop << " - Erased " << nBase << " elements"
-            << " (size " << map.size() << " capacity " << map.capacity() << ") "
-            << timer.cpuTimeIncrement() << " s\n";
+        // map.shrink();
+        Info<< "loop " << iLoop << " - Erased " << nBase << " elements";
+        printInfo(Info, map);
+        Info << nl;
     }
 
+    Info<< timer.cpuTimeIncrement() << " s\n";
+
     return 0;
 }
 
diff --git a/applications/test/HashTable4/Make/files b/applications/test/HashTable4/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..fcc01c49bda23e268948703702f084071fe6ade4
--- /dev/null
+++ b/applications/test/HashTable4/Make/files
@@ -0,0 +1,3 @@
+Test-HashTable4.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-HashTable4
diff --git a/applications/test/Field/Make/options b/applications/test/HashTable4/Make/options
similarity index 100%
rename from applications/test/Field/Make/options
rename to applications/test/HashTable4/Make/options
diff --git a/applications/test/HashTable4/Test-HashTable4.C b/applications/test/HashTable4/Test-HashTable4.C
new file mode 100644
index 0000000000000000000000000000000000000000..b9333f320db1a7a5f492eba2822ce07a3bd6543b
--- /dev/null
+++ b/applications/test/HashTable4/Test-HashTable4.C
@@ -0,0 +1,312 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+    Test HashTable resizing
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "HashSet.H"
+#include "HashTable.H"
+#include "Map.H"
+#include "cpuTime.H"
+#include "memInfo.H"
+
+#include <map>
+#include <set>
+#include <unordered_map>
+#include <unordered_set>
+
+// #undef ORDERED
+// #define ORDERED
+
+using namespace Foam;
+
+template<class T>
+Ostream& printInfo(Ostream& os, const HashTable<T, T, Hash<T>>& ht)
+{
+    os << " (size " << ht.size() << " capacity " << ht.capacity() << ") ";
+    return os;
+}
+
+
+template<class K, class V>
+inline void insertElem
+(
+    #ifdef ORDERED
+    std::set<K>& container,
+    #else
+    std::unordered_set<K, Hash<K>>& container,
+    #endif
+    K k,
+    V v
+)
+{
+    container.insert(k);
+}
+
+
+template<class K, class V>
+inline void insertElem
+(
+    #ifdef ORDERED
+    std::map<K, V>& container,
+    #else
+    std::unordered_map<K, V, Hash<K>>& container,
+    #endif
+    K k,
+    V v
+)
+{
+    container.insert(std::make_pair(k, v));
+}
+
+
+template<class K, class V>
+inline void insertElem
+(
+    HashSet<K, Hash<K>>& container,
+    K k,
+    V v
+)
+{
+    container.insert(k);
+}
+
+
+template<class K, class V>
+inline void insertElem
+(
+    HashTable<K, V, Hash<K>>& container,
+    K k,
+    V v
+)
+{
+    container.insert(k, v);
+}
+
+
+template<class Container>
+inline void loopInsert(Container& container, const label n)
+{
+    for (label i = 0; i < n; i++)
+    {
+        insertElem(container, i, i);
+    }
+}
+
+
+template<class Container>
+inline unsigned long loopFind(const Container& container, const label n)
+{
+    const auto endIter = container.end();
+    unsigned long sum = 0;
+
+    for (label i = 0; i < n; i++)
+    {
+        if (container.find(i) != endIter)
+        {
+            ++sum;
+        }
+    }
+
+    return sum;
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    const label nLoops = 200;
+    const label nFind  = 10;
+    const label nElem  = 1000000;
+
+    argList::noBanner();
+    argList::addBoolOption("std", "use std::unordered_map or std::set");
+    argList::addBoolOption("set", "test HashSet");
+    argList::addBoolOption("find", "test find");
+
+    argList args(argc, argv);
+
+    const bool optStd = args.optionFound("std");
+    const bool optSet = args.optionFound("set");
+    const bool optFnd = args.optionFound("find");
+
+
+    cpuTime timer;
+    memInfo mem;
+
+    Info<< "insert " << nElem << " (int) elements";
+    if (optFnd)
+    {
+        Info<< ", then find " << (nFind*nLoops) << " times\n";
+    }
+    else
+    {
+        Info<< " repeated " << nLoops << " times " << endl;
+    }
+
+    if (false)
+    {
+        // verify that resizing around (0) doesn't fail
+        HashTable<label, label, Hash<label>> map(32);
+        printInfo(Info, map) << endl;
+
+        map.insert(10, 1000);
+
+        map.resize(0);
+        printInfo(Info, map) << endl;
+
+        map.resize(10);
+        printInfo(Info, map) << endl;
+
+        map.clear();
+        printInfo(Info, map) << endl;
+
+        map.resize(0);
+        printInfo(Info, map) << endl;
+        return 0;
+    }
+
+
+    if (optStd)
+    {
+        if (optFnd)
+        {
+            #ifdef ORDERED
+            Info<< "using stl::set" << endl;
+            std::set<label> map;
+            #else
+            Info<< "using stl::unordered_set" << endl;
+            std::unordered_set<label, Hash<label>> map(32);
+            #endif
+
+            loopInsert(map, nElem);
+            (void)timer.cpuTimeIncrement();
+
+            unsigned long sum = 0;
+            for (label loopi = 0; loopi < nFind*nLoops; ++loopi)
+            {
+                sum += loopFind(map, nElem);
+            }
+
+            // check result (suppress compiler optimizations?)
+            if (sum == 0)
+            {
+                Info<<"sum=0\n";
+            }
+        }
+        else if (optSet)
+        {
+            #ifdef ORDERED
+            Info<< "using stl::set" << endl;
+            #else
+            Info<< "using stl::unordered_set" << endl;
+            #endif
+
+            for (label loopi = 0; loopi < nLoops; ++loopi)
+            {
+                #ifdef ORDERED
+                std::set<label> map;
+                #else
+                std::unordered_set<label, Hash<label>> map(32);
+                #endif
+
+                loopInsert(map, nElem);
+            }
+        }
+        else
+        {
+            #ifdef ORDERED
+            Info<< "using stl::map" << endl;
+            #else
+            Info<< "using stl::unordered_set" << endl;
+            #endif
+
+            for (label loopi = 0; loopi < nLoops; ++loopi)
+            {
+                #ifdef ORDERED
+                std::map<label, label> map;
+                #else
+                std::unordered_map<label, label, Hash<label>> map(32);
+                #endif
+
+                loopInsert(map, nElem);
+            }
+        }
+    }
+    else
+    {
+        if (optFnd)
+        {
+            Info<< "using HashSet" << endl;
+
+            HashSet<label, Hash<label>> map(32);
+
+            loopInsert(map, nElem);
+            (void)timer.cpuTimeIncrement();
+
+            unsigned long sum = 0;
+            for (label loopi = 0; loopi < nFind*nLoops; ++loopi)
+            {
+                sum += loopFind(map, nElem);
+            }
+
+            // check result (suppress compiler optimizations?)
+            if (sum == 0)
+            {
+                Info<<"sum=0\n";
+            }
+        }
+        else if (optSet)
+        {
+            Info<< "using HashSet" << endl;
+            for (label loopi = 0; loopi < nLoops; ++loopi)
+            {
+                HashSet<label, Hash<label>> map(32);
+
+                loopInsert(map, nElem);
+            }
+        }
+        else
+        {
+            Info<< "using HashTable" << endl;
+            for (label loopi = 0; loopi < nLoops; ++loopi)
+            {
+                HashTable<label, label, Hash<label>> map(32);
+
+                loopInsert(map, nElem);
+            }
+        }
+    }
+
+    Info<< timer.cpuTimeIncrement() << " s\n";
+    Info<< "mem info: " << mem.update() << endl;
+
+    return 0;
+}
+
+// ************************************************************************* //
diff --git a/applications/test/Hashing/Make/options b/applications/test/Hashing/Make/options
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7dba39797af85b1eab2a90d719c7d43abc2309f1 100644
--- a/applications/test/Hashing/Make/options
+++ b/applications/test/Hashing/Make/options
@@ -0,0 +1,3 @@
+EXE_INC = ${c++LESSWARN}
+
+/* EXE_LIBS = */
diff --git a/applications/test/HashingSpeed/Make/options b/applications/test/HashingSpeed/Make/options
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7dba39797af85b1eab2a90d719c7d43abc2309f1 100644
--- a/applications/test/HashingSpeed/Make/options
+++ b/applications/test/HashingSpeed/Make/options
@@ -0,0 +1,3 @@
+EXE_INC = ${c++LESSWARN}
+
+/* EXE_LIBS = */
diff --git a/applications/test/IListStream/Make/files b/applications/test/IListStream/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..7f0914970b11df86bb8ec61ae08b465c6a0566ad
--- /dev/null
+++ b/applications/test/IListStream/Make/files
@@ -0,0 +1,3 @@
+Test-IListStream.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-IListStream
diff --git a/applications/test/IListStream/Make/options b/applications/test/IListStream/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..18e6fe47afacb902cddccf82632772447704fd88
--- /dev/null
+++ b/applications/test/IListStream/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/IListStream/Test-IListStream.C b/applications/test/IListStream/Test-IListStream.C
new file mode 100644
index 0000000000000000000000000000000000000000..588550a7a95cecd65927b36d9114db8124c4e933
--- /dev/null
+++ b/applications/test/IListStream/Test-IListStream.C
@@ -0,0 +1,151 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include "ListStream.H"
+#include "UListStream.H"
+#include "wordList.H"
+#include "IOstreams.H"
+#include "argList.H"
+
+using namespace Foam;
+
+Ostream& toString(Ostream& os, const UList<char>& list)
+{
+    os << '"';
+    for (const char c : list)
+    {
+        os << c;
+    }
+    os << '"';
+
+    return os;
+}
+
+
+template<class BufType>
+void printInfo(const BufType& buf)
+{
+    Info<< nl << "=========================" << endl;
+    buf.print(Info);
+    toString(Info, buf.list());
+    Info<< nl << "=========================" << endl;
+}
+
+
+void printTokens(Istream& is)
+{
+    label count = 0;
+    token t;
+    while (is.good())
+    {
+        is >> t;
+        if (t.good())
+        {
+            ++count;
+            Info<<"token: " << t << endl;
+        }
+    }
+
+    Info<< count << " tokens" << endl;
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    // Buffer storage
+    DynamicList<char> storage(16);
+
+    OListStream obuf(std::move(storage));
+    obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n";
+
+    // Move contents to output buffer
+    printInfo(obuf);
+
+    Info<<nl << "as string: ";
+    toString(Info, obuf.list()) << endl;
+
+    Info<< "transfer contents to a List" << endl;
+
+    IListStream ibuf(obuf.xfer());
+
+    Info<< nl;
+    Info<< nl << "input string:";
+    printInfo(ibuf);
+
+    Info<< nl << "orig output:";
+    printInfo(obuf);
+
+    printTokens(ibuf);
+
+    Info<<nl << "after:";
+    printInfo(ibuf);
+
+    // This should also work
+    ibuf.list() = 'X';
+
+    Info<<nl << "overwritten with const value:";
+    printInfo(ibuf);
+
+    // Can also change content like this:
+    {
+        const int n = min(26, ibuf.size());
+
+        for (int i=0; i<n; ++i)
+        {
+            ibuf.list()[i] = 'A' + i;
+        }
+    }
+
+    Info<<nl << "directly written:";
+    printInfo(ibuf);
+
+    // But cannot easily swap in/out an entirely new list storage:
+    //
+    // List<char> newvalues(52);
+    // {
+    //     for (int i=0; i<26; ++i)
+    //     {
+    //         newvalues[2*i+0] = char('a' + i);
+    //         newvalues[2*i+1] = char('A' + i);
+    //     }
+    // }
+    // ibuf.swap(newvalues);
+    //
+    // Info<<nl << "after swap:";
+    // printInfo(ibuf);
+
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/IStringStream/Test-IStringStream.C b/applications/test/IStringStream/Test-IStringStream.C
index cd8ba0e2a6165cba7df6db65c52fb59aa27e2874..b265b15a61f747492bd13552a1bd941cabb0e8df 100644
--- a/applications/test/IStringStream/Test-IStringStream.C
+++ b/applications/test/IStringStream/Test-IStringStream.C
@@ -36,20 +36,22 @@ using namespace Foam;
 
 int main(int argc, char *argv[])
 {
-    IStringStream testStream(Foam::string("1002 sfsd sdfsd"));
+    IStringStream testStream(Foam::string("  1002  abcd  defg;"));
 
     label i(readLabel(testStream));
 
-    Info<< i << endl;
+    Info<< "label=" << i << nl;
 
-    word bla(testStream);
-    word bla2(testStream);
+    word w1(testStream);
+    word w2(testStream);
 
-    Info<< bla << tab << bla2 << endl;
+    Info<< "word=" << w1 << nl;
+    Info<< "word=" << w2 << nl;
 
-    wordList wl(IStringStream("(hello1")());
+    testStream.reset("(hello1)");
 
-    Info<< wl << endl;
+    wordList wl(testStream);
+    Info<< wl << nl;
 
     Info<< "\nEnd\n" << endl;
 
diff --git a/applications/test/ITstream/Make/files b/applications/test/ITstream/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..6b70c4ea8376dd91b9a313d0702112996d8adb39
--- /dev/null
+++ b/applications/test/ITstream/Make/files
@@ -0,0 +1,3 @@
+Test-ITstream.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-ITstream
diff --git a/applications/test/ITstream/Make/options b/applications/test/ITstream/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..18e6fe47afacb902cddccf82632772447704fd88
--- /dev/null
+++ b/applications/test/ITstream/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/ITstream/Test-ITstream.C b/applications/test/ITstream/Test-ITstream.C
new file mode 100644
index 0000000000000000000000000000000000000000..a81e8585eedbfa5d3641bbc5473cb37f6fe056f8
--- /dev/null
+++ b/applications/test/ITstream/Test-ITstream.C
@@ -0,0 +1,137 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include "ListStream.H"
+#include "UListStream.H"
+#include "wordList.H"
+#include "IOstreams.H"
+#include "argList.H"
+#include "ITstream.H"
+
+using namespace Foam;
+
+template<class T>
+Ostream& toString(Ostream& os, const T& str)
+{
+    os << str;
+    return os;
+}
+
+
+template<>
+Ostream& toString(Ostream& os, const UList<char>& list)
+{
+    for (const char c : list)
+    {
+        os << c;
+    }
+
+    return os;
+}
+
+
+template<>
+Ostream& toString(Ostream& os, const List<char>& list)
+{
+    for (const char c : list)
+    {
+        os << c;
+    }
+
+    return os;
+}
+
+
+void printTokens(Istream& is)
+{
+    label count = 0;
+    token t;
+    while (is.good())
+    {
+        is >> t;
+        if (t.good())
+        {
+            ++count;
+            Info<<"token: " << t << endl;
+        }
+    }
+
+    Info<< count << " tokens" << endl;
+}
+
+
+template<class BUF>
+void doTest(const string& name, const BUF& input, bool verbose=false)
+{
+    Info<<"test " << name.c_str() << ":" << nl
+        <<"====" << nl;
+    toString(Info, input)
+        << nl
+        <<"====" << nl << endl;
+
+    ITstream its(name, input);
+    Info<< "got " << its.size() << " tokens - index at "
+        << its.tokenIndex() << endl;
+
+    if (verbose)
+    {
+        for (const token& tok : its)
+        {
+            Info<< "    " << tok.info() << nl;
+        }
+        Info<< nl;
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    const char* charInput =
+        "( const char input \"string\" to tokenize )"
+        "List<label> 5(0 1 2 3 4);";
+
+    string stringInput("( string     ;    input \"string\" to tokenize )");
+
+    List<char> listInput(stringInput.cbegin(), stringInput.cend());
+
+    doTest("char*", charInput, true);
+    doTest("string", stringInput, true);
+    doTest("List<char>", listInput, true);
+
+    reverse(listInput);
+    doTest("List<char>", listInput, true);
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/IndirectList/Test-IndirectList.C b/applications/test/IndirectList/Test-IndirectList.C
index 1af5a1682cff577a64c60175dbdd0c596dcc5f8d..449af8ca7d412c6becc83f27026df6cdabdbd296 100644
--- a/applications/test/IndirectList/Test-IndirectList.C
+++ b/applications/test/IndirectList/Test-IndirectList.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,58 +27,82 @@ Description
 
 #include "IndirectList.H"
 #include "IOstreams.H"
+#include "Fstream.H"
+#include "ListOps.H"
+#include "labelIndList.H"
+#include "argList.H"
 
 using namespace Foam;
 
 template<class ListType>
 void printInfo(const ListType& lst)
 {
-    Info<< "addr: " << lst.addressing() << nl
-        << "list: " << lst << nl
+    Info<< "full: " << flatOutput(lst.completeList()) << nl
+        << "addr: " << flatOutput(lst.addressing()) << nl
+        << "list: " << flatOutput(lst) << nl
         << endl;
 }
 
 
+template<class T, class ListType>
+void testFind(const T& val, const ListType& lst)
+{
+    Info<< nl
+        << "Search for "<< val << " in " << flatOutput(lst) << nl
+        <<" found() = " << lst.found(val)
+        <<" find() = " << lst.find(val)
+        <<" rfind() = " << lst.rfind(val)
+        <<" find(2) = " << lst.find(val, 2)
+        <<" rfind(2) = " << lst.rfind(val, 2)
+        <<" findIndex = " << findIndex(lst, val) << nl
+        << nl;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // Main program:
 
 int main(int argc, char *argv[])
 {
-    List<double> completeList(10);
+    argList::addOption
+    (
+        "binary",
+        "file",
+        "write lists in binary to specified file"
+    );
+
+    argList args(argc, argv);
+
+    List<label> completeList(20);
 
     forAll(completeList, i)
     {
-        completeList[i] = 0.1*i;
+        completeList[i] = 10*i;
     }
 
-    Info<< "raw : " << completeList << nl << endl;
-
+    Info<< "raw : " << flatOutput(completeList) << nl << endl;
 
-    List<label> addresses(5);
-    addresses[0] = 1;
-    addresses[1] = 0;
-    addresses[2] = 7;
-    addresses[3] = 8;
-    addresses[4] = 5;
+    List<label> addresses{1, 0, 3, 7, 4, 8, 5, 1, 0, 3, 7, 4, 8, 5, };
 
-    IndirectList<double> idl1(completeList, addresses);
+    labelIndList idl1(completeList, addresses);
 
     printInfo(idl1);
 
-    addresses[4] = 1;
-    addresses[3] = 0;
-    addresses[2] = 7;
-    addresses[1] = 8;
-    addresses[0] = 5;
+    for (const label val : { 10, 30, 40, 50, 90, 80, 120 } )
+    {
+        testFind(val, idl1);
+    }
+
+    inplaceReverseList(addresses);
 
     idl1.resetAddressing(addresses.xfer());
 
     printInfo(idl1);
 
-    // test copying
-    UIndirectList<double> uidl1(idl1);
-    IndirectList<double> idl2(uidl1);
-    IndirectList<double> idl3(idl2);
+    // Test copying
+    labelUIndList uidl1(idl1);
+    labelIndList idl2(uidl1);
+    labelIndList idl3(idl2);
 
     printInfo(uidl1);
 
@@ -92,6 +116,55 @@ int main(int argc, char *argv[])
     printInfo(idl2);
     printInfo(idl3);
 
+    fileName binaryOutput;
+    if (args.optionReadIfPresent("binary", binaryOutput))
+    {
+        Info<<"Writing output to " << binaryOutput << endl;
+
+        OFstream os(binaryOutput, IOstream::BINARY);
+
+        os.writeEntry("idl1", idl1);
+        os.writeEntry("idl2", idl2);
+        os.writeEntry("idl3", idl3);
+    }
+
+    if (Pstream::parRun())
+    {
+        if (Pstream::master())
+        {
+            Pout<< "full: " << flatOutput(idl3.completeList()) << nl
+                << "send: " << flatOutput(idl3) << endl;
+
+            for
+            (
+                int slave = Pstream::firstSlave();
+                slave <= Pstream::lastSlave();
+                ++slave
+            )
+            {
+                OPstream toSlave(Pstream::commsTypes::scheduled, slave);
+                toSlave << idl3;
+            }
+        }
+        else
+        {
+            // From master
+            IPstream fromMaster
+            (
+                Pstream::commsTypes::scheduled,
+                Pstream::masterNo()
+            );
+
+            List<label> recv(fromMaster);
+
+            Pout<<"recv: " << flatOutput(recv) << endl;
+        }
+
+        // MPI barrier
+        bool barrier = true;
+        Pstream::scatter(barrier);
+    }
+
     Info<< "End\n" << endl;
 
     return 0;
diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C
index 5d3f3ba4b49c840ecf6b835b9b3b398a325a6767..cfb709bf3bbecab541d7ab7f313dbd54a0b2efe1 100644
--- a/applications/test/List/Test-List.C
+++ b/applications/test/List/Test-List.C
@@ -47,9 +47,24 @@ See also
 #include "SubList.H"
 
 #include <list>
+#include <numeric>
 
 using namespace Foam;
 
+template<class T, class ListType>
+void testFind(const T& val, const ListType& lst)
+{
+    Info<< nl
+        << "Search for "<< val << " in " << flatOutput(lst) << nl
+        <<" found() = " << lst.found(val)
+        <<" find() = " << lst.find(val)
+        <<" rfind() = " << lst.rfind(val)
+        <<" find(2) = " << lst.find(val, 2)
+        <<" rfind(2) = " << lst.rfind(val, 2)
+        <<" findIndex = " << findIndex(lst, val) << nl
+        << nl;
+}
+
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 //  Main program:
@@ -65,6 +80,33 @@ int main(int argc, char *argv[])
 
     #include "setRootCase.H"
 
+    {
+        List<label> ident(15);
+        std::iota(ident.begin(), ident.end(), 0);
+
+        Info<<"Ident:";
+        forAllConstIters(ident, iter)
+        {
+            Info<<" " << *iter;
+        }
+        Info<< nl;
+
+        Info<<"reverse:";
+        forAllReverseIters(ident, iter)
+        {
+            Info<<" " << *iter;
+        }
+        Info<< nl;
+
+        Info<<"const reverse:";
+        forAllConstReverseIters(ident, iter)
+        {
+            Info<<" " << *iter;
+        }
+        Info<< nl;
+    }
+
+
     if (false)
     {
         labelList intlist(IStringStream("(0 1 2)")());
@@ -84,14 +126,36 @@ int main(int argc, char *argv[])
     {
         vector(0, 1, 2),
         vector(3, 4, 5),
-        vector(6, 7, 8)
+        vector(6, 7, 8),
+        vector(0, 1, 2),
+        vector(3, 4, 5),
+        vector(6, 7, 8),
     };
     Info<< "list2: " << list2 << endl;
 
+    Info<< "forAllConstIters(list2): ";
+    forAllConstIters(list2, iter) { Info<< " " << *iter; }
+    Info<< endl;
+
+    Info<< "forAllConstReverseIters(list2): ";
+    forAllConstReverseIters(list2, iter) { Info<< " " << *iter; }
+    Info<< endl;
+
+    Info<< "forAllConstIters(list2): ";
+    forAllIters(list2, iter) { *iter *= 2; Info<< " " << *iter; }
+    Info<< endl;
+
+    Info<< "forAllReverseIters(list2): ";
+    forAllReverseIters(list2, iter) { *iter *= 0.5; Info<< " " << *iter; }
+    Info<< endl;
+
     list1.append(list2);
     Info<< "list1.append(list2): " << list1 << endl;
 
-    Info<< findIndex(list2, vector(3, 4, 5)) << endl;
+    for (const vector& val : { vector(3, 4, 5), vector(10,11, 12)} )
+    {
+        testFind(val, list2);
+    }
 
     list2.setSize(10, vector(1, 2, 3));
     Info<< "list2: " << list2 << endl;
diff --git a/applications/test/List2/Make/files b/applications/test/List2/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..49c6d304c831ccb19da834a0a0fa59a672f76c15
--- /dev/null
+++ b/applications/test/List2/Make/files
@@ -0,0 +1,3 @@
+Test-List2.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-List2
diff --git a/applications/test/List2/Make/options b/applications/test/List2/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/applications/test/List2/Test-List2.C b/applications/test/List2/Test-List2.C
new file mode 100644
index 0000000000000000000000000000000000000000..0be3acda63e53e3d3a996c8dbfd46837bd2527e7
--- /dev/null
+++ b/applications/test/List2/Test-List2.C
@@ -0,0 +1,269 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    Test-List2
+
+Description
+    Test speeds, usability of some List/FixedList operations
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "FixedList.H"
+#include "labelList.H"
+#include "vectorList.H"
+#include "ListOps.H"
+#include "IFstream.H"
+#include "OFstream.H"
+#include "cpuTime.H"
+
+#include <initializer_list>
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+using namespace Foam;
+
+template<class ListType>
+void runResizeTest
+(
+    const label nLoops,
+    ListType& list,
+    std::initializer_list<label> sizes
+)
+{
+    cpuTime timer;
+
+    const label size0 = list.size();
+    const auto val = list.first();
+
+    Info<<"Resize list(" << list.size() << ") to";
+
+    for (auto len : sizes)
+    {
+        Info<< " " << len;
+    }
+    Info<< nl;
+
+    Info<< "Perform " << nLoops << " times..." << nl;
+    for (label iLoop = 0; iLoop < nLoops; ++iLoop)
+    {
+        list.setSize(size0, val);
+
+        for (auto len : sizes)
+        {
+            list.setSize(len, val);
+        }
+    }
+
+    Info<< "Operation took"
+        << "  " << timer.cpuTimeIncrement() << " s\n\n";
+}
+
+
+template<class ListType>
+void runOrderingTest(const label nLoops, const ListType& list)
+{
+    if (true)
+    {
+        cpuTime timer;
+
+        float total = 0;
+
+        Info<<"forAll - perform " << nLoops << " times..." << nl;
+        for (label iLoop = 0; iLoop < nLoops; ++iLoop)
+        {
+            float sum = 0;
+            forAll(list, i)
+            {
+                sum += list[i];
+            }
+
+            total += sum;
+        }
+
+        Info<< "Operation (sum " << total << ") took"
+            << "  " << timer.cpuTimeIncrement() << " s\n\n";
+    }
+
+    if (true)
+    {
+        cpuTime timer;
+
+        float total = 0;
+
+        Info<<"reverse pointer loop - perform " << nLoops << " times..." << nl;
+        for (label iLoop = 0; iLoop < nLoops; ++iLoop)
+        {
+            float sum = 0;
+
+            const typename ListType::value_type* __restrict__ fp
+                = (list).end();
+
+            label i = (list).size();
+            while (i--)
+            {
+                sum += (*--fp);
+            }
+
+            total += sum;
+        }
+
+        Info<< "Operation (sum " << total << ") took"
+            << "  " << timer.cpuTimeIncrement() << " s\n\n";
+    }
+
+    if (true)
+    {
+        cpuTime timer;
+
+        float total = 0;
+
+        Info<<"forward pointer loop - perform " << nLoops << " times..." << nl;
+        for (label iLoop = 0; iLoop < nLoops; ++iLoop)
+        {
+            float sum = 0;
+
+            const typename ListType::value_type* __restrict__ fp
+                = (list).begin();
+
+            label i = (list).size();
+            while (i--)
+            {
+                sum += (*fp++);
+            }
+
+            total += sum;
+        }
+
+        Info<< "Operation (sum " << total << ") took"
+            << "  " << timer.cpuTimeIncrement() << " s\n\n";
+    }
+
+
+    if (true)
+    {
+        cpuTime timer;
+
+        float total = 0;
+
+        Info<<"for loop - perform " << nLoops << " times..." << nl;
+        for (label iLoop = 0; iLoop < nLoops; ++iLoop)
+        {
+            float sum = 0;
+
+            const typename ListType::value_type* __restrict__ fp
+                = (list).begin();
+
+            const label sz = (list).size();
+            for (label i=0; i<sz; ++i)
+            {
+                sum += fp[i];
+            }
+
+            total += sum;
+        }
+
+        Info<< "Operation (sum " << total << ") took"
+            << "  " << timer.cpuTimeIncrement() << " s\n\n";
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+    argList::addBoolOption("label");
+    argList::addBoolOption("float");
+    argList::addBoolOption("vector");
+    argList::addBoolOption("order");
+    argList::addBoolOption("labelList");
+    argList::addBoolOption("vectorList");
+
+    argList args(argc, argv);
+
+    if (args.options().empty())
+    {
+        Info<< nl << "Specify an option! " << nl << endl;
+    }
+
+
+    std::initializer_list<label> increments
+        = {10000, 20000, 40000, 80000, 160000};
+
+    if (args.optionFound("label"))
+    {
+        List<label> list(10, 1);
+
+        runResizeTest(100000, list, increments);
+    }
+
+    if (args.optionFound("float"))
+    {
+        List<double> list(10, 1.0);
+
+        runResizeTest(10000, list, increments);
+    }
+
+    if (args.optionFound("vector"))
+    {
+        List<vector> list(10, vector::one);
+
+        runResizeTest(10000, list, increments);
+    }
+
+    if (args.optionFound("labelList"))
+    {
+        typedef labelList testType;
+        testType initVal(500, label(1));
+
+        List<testType> list(10, initVal);
+
+        runResizeTest(200, list, increments);
+    }
+
+    if (args.optionFound("vectorList"))
+    {
+        typedef vectorList testType;
+        testType initVal(500, vector::one);
+
+        List<testType> list(10, initVal);
+
+        runResizeTest(100, list, increments);
+    }
+
+    if (args.optionFound("order"))
+    {
+        List<label> list(100000000, 1);
+
+        runOrderingTest(100, list);
+    }
+
+
+    Info<< nl << "Done" << nl << endl;
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/ListOps2/Make/files b/applications/test/ListOps2/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..4149f5146d32a8a4441868a903ad5a40adc991a6
--- /dev/null
+++ b/applications/test/ListOps2/Make/files
@@ -0,0 +1,2 @@
+Test-ListOps2.C
+EXE = $(FOAM_USER_APPBIN)/Test-ListOps2
diff --git a/applications/test/ListOps2/Make/options b/applications/test/ListOps2/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..51903c0ce4fdd9fb77e67d8ae80beba4ea282cd3
--- /dev/null
+++ b/applications/test/ListOps2/Make/options
@@ -0,0 +1,3 @@
+EXE_INC = /*-DFULLDEBUG -O0 -g*/ \
+
+EXE_LIBS =
diff --git a/applications/test/ListOps2/Test-ListOps2.C b/applications/test/ListOps2/Test-ListOps2.C
new file mode 100644
index 0000000000000000000000000000000000000000..e41ae9f893b42b5dcf48ecfc8b313cc0b4e782af
--- /dev/null
+++ b/applications/test/ListOps2/Test-ListOps2.C
@@ -0,0 +1,144 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    Test-ListOps2
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "List.H"
+#include "FixedList.H"
+#include "DynamicList.H"
+#include "SubList.H"
+#include "ListOps.H"
+#include "FlatOutput.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template<class ListType>
+void testFind(const ListType& list)
+{
+    Info<< nl << "list: " << flatOutput(list) << nl << endl;
+
+    for (auto val : { 20, 35, 6, 13, 12, -12})
+    {
+        Info<< "lookup " << val
+            << " found " << list.found(val)
+            << " index " << list.find(val) << nl;
+    }
+}
+
+
+template<class ListType>
+void testMoving(ListType& list)
+{
+    Info<< nl << "list: " << flatOutput(list) << nl << endl;
+
+    {
+        const label i = 3;
+        list.swapFirst(i);
+        Info<<"swapFirst: " << i << " = " << flatOutput(list) << nl;
+    }
+
+    {
+        const label i = 6;
+        list.moveFirst(i);
+        Info<<"moveFirst: " << i << " = " << flatOutput(list) << nl;
+    }
+
+    {
+        const label i = 6;
+        list.moveLast(i);
+        Info<<"moveLast: " << i  << " = " << flatOutput(list) << nl;
+    }
+
+    {
+        const label i = 8;
+        list.swapLast(i);
+        Info<<"swapLast: " << i << " = " << flatOutput(list) << nl;
+    }
+}
+
+
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    List<label> list1(identity(15));
+    shuffle(list1);
+
+    FixedList<label, 15> list2(list1);
+    inplaceReverseList(list2);
+
+    DynamicList<label> list3(list1);
+    inplaceReverseList(list3);
+
+    testFind(list1);
+    testFind(list2);
+    testFind(list3);
+
+    testMoving(list1);
+    testMoving(list2);
+    testMoving(list3);
+
+    // Test remove
+    {
+        auto& list = list3;
+
+        Info<< nl << "list: " << flatOutput(list) << nl << endl;
+
+        list.remove();
+        Info<<"remove = " << flatOutput(list) << nl;
+
+        {
+            const label i = 6;
+            list.remove(i);
+            Info<<"rmSwap: " << i << " = " << flatOutput(list) << nl;
+        }
+
+        {
+            const label i = 3;
+            list.remove(i);
+            Info<<"rmSwap: " << i << " = " << flatOutput(list) << nl;
+        }
+
+        {
+            const label i = 8;
+            list.remove(i);
+            Info<<"rmMove: " << i << " = " << flatOutput(list) << nl;
+        }
+    }
+
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/Map/Test-Map.C b/applications/test/Map/Test-Map.C
index 5ced3b569d0953d70be8214269fd81912ba88b50..5ba38e9f60bed6decb46023385e2c19ba9a2fde9 100644
--- a/applications/test/Map/Test-Map.C
+++ b/applications/test/Map/Test-Map.C
@@ -38,41 +38,75 @@ using namespace Foam;
 
 int main(int argc, char *argv[])
 {
-    Map<bool> banana{{5, true}};
+    Map<bool> map1
+    {
+        {1, true}, {2, false}, {3, true}, {4, false}, {5, true}
+    };
 
     // Taking a const iterator from find does not work!
     // Also, fails later on op==
-    Map<bool>::const_iterator bananaIter = banana.find(5);
+    Map<bool>::const_iterator map1Iter = map1.cfind(5);
 
-    // This works but now I can change the value.
-    //Map<bool>::iterator bananaIter = banana.find(5);
+    // Same, but with non-const access
+    // Map<bool>::iterator map1Iter = map1.find(5);
 
-    if (!bananaIter.found()) // same as  (bananaIter == banana.end())
+    if (!map1Iter.found()) // same as  (map1Iter == map1.end())
     {
         Info<< "not found" << endl;
     }
     else
     {
-        Info<< "5 is " << bananaIter() << endl;
+        Info<< "5 is " << *map1Iter << endl;
     }
 
-    // Same with STL
+    // Repeat with std::map
     Info<< "Same with STL" << endl;
 
-    std::map<label, bool> STLbanana{{5, true}};
-    std::map<label, bool>::const_iterator STLbananaIter = STLbanana.find(5);
+    std::map<label, bool> stdmap1
+    {
+        {1, true}, {2, false}, {3, true}, {4, false}, {5, true}
+    };
+
+    std::map<label, bool>::const_iterator stdmap1Iter = stdmap1.find(5);
 
-    if (STLbananaIter == STLbanana.end())
+    if (stdmap1Iter == stdmap1.cend())
     {
         Info<< "not found" << endl;
     }
     else
     {
-        Info<< "5 is " << STLbananaIter->second << endl;
+        Info<< "5 is " << stdmap1Iter->second << endl;
     }
 
 
-    Info<< "End\n" << endl;
+    Info<<"test move construct" << nl;
+    Map<bool> map2(std::move(map1));
+    Map<bool> map3;
+
+    std::map<label, bool> stdmap2(std::move(stdmap1));
+    std::map<label, bool> stdmap3;
+
+    Info<<"map1: " << map1 << nl
+        <<"map2: " << map2 << nl;
+
+    Info
+        <<"stdmap1: " << stdmap1.size() << nl
+        <<"stdmap2: " << stdmap2.size() << nl;
+
+
+    Info<<"test move assign" << nl;
+    map3 = std::move(map2);
+    stdmap3 = std::move(stdmap2);
+
+    Info<<"map2: " << map2 << nl
+        <<"map3: " << map3 << nl;
+
+    Info
+        <<"stdmap2: " << stdmap2.size() << nl
+        <<"stdmap3: " << stdmap3.size() << nl;
+
+
+    Info<< nl << "End\n" << endl;
 
     return 0;
 }
diff --git a/applications/test/OCountStream/Make/files b/applications/test/OCountStream/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..87df932eeaf1e356c69af35ba059feb2e9289144
--- /dev/null
+++ b/applications/test/OCountStream/Make/files
@@ -0,0 +1,3 @@
+Test-OCountStream.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-OCountStream
diff --git a/applications/test/OCountStream/Make/options b/applications/test/OCountStream/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..18e6fe47afacb902cddccf82632772447704fd88
--- /dev/null
+++ b/applications/test/OCountStream/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/OCountStream/Test-OCountStream.C b/applications/test/OCountStream/Test-OCountStream.C
new file mode 100644
index 0000000000000000000000000000000000000000..0cbaac4a7ef10552e4af730d1a0f173310bc7f46
--- /dev/null
+++ b/applications/test/OCountStream/Test-OCountStream.C
@@ -0,0 +1,61 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include "OCountStream.H"
+#include "StringStream.H"
+#include "IOstreams.H"
+#include "argList.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    OCountStream cnt;
+    OStringStream str;
+
+    for (label i = 0; i < 50; ++i)
+    {
+        str << 1002 << " " << "abcd" << " "
+            << "def" << " " << 3.14159 << ";\n";
+
+        cnt << 1002 << " " << "abcd" << " "
+            << "def" << " " << 3.14159 << ";\n";
+    }
+
+    cnt.print(Info);
+    Info<< "via string-stream: " << str.str().size() << " chars" << endl;
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/OListStream/Make/files b/applications/test/OListStream/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..583b8e7f0699df33e7deb8b5a2487d7e39c37f43
--- /dev/null
+++ b/applications/test/OListStream/Make/files
@@ -0,0 +1,3 @@
+Test-OListStream.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-OListStream
diff --git a/applications/test/OListStream/Make/options b/applications/test/OListStream/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..18e6fe47afacb902cddccf82632772447704fd88
--- /dev/null
+++ b/applications/test/OListStream/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/OListStream/Test-OListStream.C b/applications/test/OListStream/Test-OListStream.C
new file mode 100644
index 0000000000000000000000000000000000000000..4c3a758f0fc4f9b1e0fb884c62fe2ba057cd59ba
--- /dev/null
+++ b/applications/test/OListStream/Test-OListStream.C
@@ -0,0 +1,208 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include "ListStream.H"
+#include "wordList.H"
+#include "IOstreams.H"
+#include "argList.H"
+
+using namespace Foam;
+
+Ostream& toString(Ostream& os, const UList<char>& list)
+{
+    os << '"';
+    for (const char c : list)
+    {
+        os << c;
+    }
+    os << '"';
+
+    return os;
+}
+
+
+template<class BufType>
+void printInfo(const BufType& buf)
+{
+    Info<< nl << "=========================" << endl;
+    buf.print(Info);
+    toString(Info, buf.list());
+    Info<< nl << "=========================" << endl;
+}
+
+
+void printTokens(Istream& is)
+{
+    label count = 0;
+    token t;
+    while (is.good())
+    {
+        is >> t;
+        if (t.good())
+        {
+            ++count;
+            Info<<"token: " << t << endl;
+        }
+    }
+
+    Info<< count << " tokens" << endl;
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    // Buffer storage
+    DynamicList<char> storage(16);
+
+    OListStream obuf(std::move(storage));
+
+    obuf.setBlockSize(100);
+
+    printInfo(obuf);
+
+    // Fill with some content
+    for (label i = 0; i < 50; ++i)
+    {
+        obuf<< 1002 << " " << "abcd" << " "
+            << "def" << " " << 3.14159 << ";\n";
+    }
+
+    printInfo(obuf);
+
+    obuf.rewind();
+    printInfo(obuf);
+
+    for (label i=0; i < 10; ++i)
+    {
+        obuf << "item" << i << "\n";
+    }
+
+    printInfo(obuf);
+
+    obuf.shrink();
+
+    Info<< "after shrink" << nl;
+    printInfo(obuf);
+
+    // Add some more
+    for (label i=10; i < 15; ++i)
+    {
+        obuf << "more" << i << nl;
+    }
+
+    Info<< "appended more" << nl;
+    printInfo(obuf);
+
+    // Overwrite at some position
+    obuf.stdStream().rdbuf()->pubseekpos(0.60 * obuf.size());
+    obuf << "<" << nl << "OVERWRITE" << nl;
+
+    Info<<"after overwrite" << nl;
+    printInfo(obuf);
+
+    Info<< "transfer contents to a List or IListStream" << nl;
+
+    IListStream ibuf(obuf.xfer());
+
+    Info<<"original:";
+    printInfo(obuf);
+
+    Info<<"new input:" << nl;
+    printInfo(ibuf);
+
+    printTokens(ibuf);
+
+    // Create from other storage types
+
+    Info<< nl;
+    {
+        Info<<"create std::move(List)" << endl;
+        List<char> list(16, 'A');
+
+        Info<<"input:";
+        toString(Info, list) << endl;
+
+        OListStream buf1(std::move(list));
+        for (label i = 0; i < 26; ++i)
+        {
+            buf1 << char('A' +i);
+        }
+        for (label i = 0; i < 26; ++i)
+        {
+            buf1 << char('a' +i);
+        }
+
+        Info<<"orig:";
+        toString(Info, list) << endl;
+
+        printInfo(buf1);
+    }
+
+    Info<< nl;
+
+    List<char> written;
+    {
+        Info<<"create List.xfer()" << endl;
+        List<char> list(16, 'B');
+
+        Info<<"input:";
+        toString(Info, list) << endl;
+
+        OListStream buf1(list.xfer());
+        for (label i = 0; i < 26; ++i)
+        {
+            buf1 << char('A' + i);
+        }
+        for (label i = 0; i < 26; ++i)
+        {
+            buf1 << char('a' +i);
+        }
+
+        Info<<"orig:";
+        toString(Info, list) << endl;
+
+        printInfo(buf1);
+
+        // Move back to written
+        written = buf1.xfer();
+
+        printInfo(buf1);
+    }
+    Info<<"'captured' content ";
+    toString(Info, written);
+
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/PackedList/Test-PackedList.C b/applications/test/PackedList/Test-PackedList.C
index 90ed8ac740810c7669a892d355c13ed1580016c6..45d5ab00b6e8333a30cc181b2cfc4b508096696b 100644
--- a/applications/test/PackedList/Test-PackedList.C
+++ b/applications/test/PackedList/Test-PackedList.C
@@ -41,7 +41,7 @@ using namespace Foam;
 template<unsigned nBits>
 inline void reportInfo()
 {
-    unsigned offset = PackedList<nBits>::packing();
+    const unsigned offset = PackedList<nBits>::packing();
 
     unsigned useSHL = ((1u << (nBits * offset)) - 1);
     unsigned useSHR = (~0u >> (sizeof(unsigned)*CHAR_BIT - nBits * offset));
diff --git a/applications/test/PackedList2/Test-PackedList2.C b/applications/test/PackedList2/Test-PackedList2.C
index ce9b15ed51faa10a126f591c98c4085f3152a58e..51ddcdaec7b8c0bbd9affbd229453338278ffcda 100644
--- a/applications/test/PackedList2/Test-PackedList2.C
+++ b/applications/test/PackedList2/Test-PackedList2.C
@@ -31,12 +31,26 @@ Description
 #include "boolList.H"
 #include "PackedBoolList.H"
 #include "HashSet.H"
-#include "StaticHashTable.H"
 #include "cpuTime.H"
 #include <vector>
+#include <unordered_set>
 
 using namespace Foam;
 
+#undef TEST_STD_BOOLLIST
+#undef TEST_STD_UNORDERED_SET
+
+template<class T>
+void printInfo(const std::unordered_set<T, Foam::Hash<T>>& ht)
+{
+    Info<<"std::unordered_set elements:"
+        << ht.size()
+        << " buckets:" << ht.bucket_count()
+        << " load_factor: " << ht.load_factor()
+        << nl;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 
@@ -47,11 +61,16 @@ int main(int argc, char *argv[])
     const label n = 1000000;
     const label nIters = 1000;
 
-    unsigned int sum = 0;
+    unsigned long sum = 0;
 
     PackedBoolList packed(n, 1);
     boolList unpacked(n, true);
-    std::vector<bool> stlVector(n, true);
+
+    #ifdef TEST_STD_BOOLLIST
+    std::vector<bool> stdBoolList(n, true);
+    #endif
+
+    cpuTime timer;
 
     labelHashSet emptyHash;
     labelHashSet fullHash(1024);
@@ -60,22 +79,27 @@ int main(int argc, char *argv[])
         fullHash.insert(i);
     }
 
-    // fullStaticHash is really slow
-    // give it lots of slots to help
-    StaticHashTable<nil, label, Hash<label>> emptyStaticHash;
-    StaticHashTable<nil, label, Hash<label>> fullStaticHash(100000);
+    Info<< "populated labelHashSet in "
+        << timer.cpuTimeIncrement() << " s\n\n";
+
+    #ifdef TEST_STD_UNORDERED_SET
+    std::unordered_set<label, Foam::Hash<label>> emptyStdHash;
+    std::unordered_set<label, Foam::Hash<label>> fullStdHash;
+    fullStdHash.reserve(1024);
     for (label i = 0; i < n; i++)
     {
-        fullStaticHash.insert(i, nil());
+        fullStdHash.insert(i);
     }
+    Info<< "populated unordered_set in "
+        << timer.cpuTimeIncrement() << " s\n\n";
+    #endif
 
     emptyHash.printInfo(Info);
     fullHash.printInfo(Info);
-    emptyStaticHash.printInfo(Info);
-    fullStaticHash.printInfo(Info);
-
-
-    cpuTime timer;
+    #ifdef TEST_STD_UNORDERED_SET
+    printInfo(emptyStdHash);
+    printInfo(fullStdHash);
+    #endif
 
     for (label iter = 0; iter < nIters; ++iter)
     {
@@ -104,9 +128,11 @@ int main(int argc, char *argv[])
             sum += packed[i];
         }
     }
-    Info<< "Counting brute-force:" << timer.cpuTimeIncrement()
+
+    std::cout
+        << "Counting brute-force:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Count packed
@@ -115,9 +141,11 @@ int main(int argc, char *argv[])
     {
         sum += packed.count();
     }
-    Info<< "Counting via count():" << timer.cpuTimeIncrement()
+
+    std::cout
+        << "Counting via count():" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Dummy addition
@@ -129,25 +157,29 @@ int main(int argc, char *argv[])
             sum += i + 1;
         }
     }
-    Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl
-        << "  sum " << sum << " (sum is meaningless)" << endl;
+
+    std::cout
+        << "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl
+        << "  sum " << sum << " (sum is meaningless)" << nl;
 
     //
     // Read
     //
 
+    #ifdef TEST_STD_BOOLLIST
     // Read stl
     sum = 0;
     for (label iter = 0; iter < nIters; ++iter)
     {
-        for (unsigned int i = 0; i < stlVector.size(); i++)
+        for (unsigned int i = 0; i < stdBoolList.size(); i++)
         {
-            sum += stlVector[i];
+            sum += stdBoolList[i];
         }
     }
-    Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << nl
-        << "  sum " << sum << endl;
-
+    std::cout
+        << "Reading stdBoolList:" << timer.cpuTimeIncrement() << " s" << nl
+        << "  sum " << sum << nl;
+    #endif
 
     // Read unpacked
     sum = 0;
@@ -158,8 +190,9 @@ int main(int argc, char *argv[])
             sum += unpacked[i];
         }
     }
-    Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl
-        << "  sum " << sum << endl;
+    std::cout
+        << "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl
+        << "  sum " << sum << nl;
 
 
     // Read packed
@@ -171,9 +204,10 @@ int main(int argc, char *argv[])
             sum += packed.get(i);
         }
     }
-    Info<< "Reading packed using get:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading packed using get:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Read packed
@@ -185,9 +219,10 @@ int main(int argc, char *argv[])
             sum += packed[i];
         }
     }
-    Info<< "Reading packed using reference:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading packed using reference:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Read via iterator
@@ -199,9 +234,10 @@ int main(int argc, char *argv[])
             sum += it;
         }
     }
-    Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading packed using iterator:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Read via iterator
@@ -213,9 +249,10 @@ int main(int argc, char *argv[])
             sum += cit();
         }
     }
-    Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Read empty hash
@@ -227,9 +264,10 @@ int main(int argc, char *argv[])
             sum += emptyHash.found(i);
         }
     }
-    Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
     // Read full hash
@@ -241,55 +279,59 @@ int main(int argc, char *argv[])
             sum += fullHash.found(i);
         }
     }
-    Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading full labelHashSet:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
 
-    // Read empty static hash
+    #ifdef TEST_STD_UNORDERED_SET
+    // Read empty stl set
     sum = 0;
     for (label iter = 0; iter < nIters; ++iter)
     {
         forAll(unpacked, i)
         {
-            sum += emptyStaticHash.found(i);
+            sum += (emptyStdHash.find(i) != emptyStdHash.cend());
         }
     }
-    Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading empty std::unordered_set:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
+        << "  sum " << sum << nl;
 
-#if 0
-    // we can skip this test - it is usually quite slow
-    // Read full static hash
+    // Read full stl set
     sum = 0;
     for (label iter = 0; iter < nIters; ++iter)
     {
         forAll(unpacked, i)
         {
-            sum += fullStaticHash.found(i);
+            sum += (fullStdHash.find(i) != fullStdHash.cend());
         }
     }
-    Info<< "Reading full StaticHash:" << timer.cpuTimeIncrement()
+    std::cout
+        << "Reading full std::unordered_set:" << timer.cpuTimeIncrement()
         << " s" << nl
-        << "  sum " << sum << endl;
-#endif
+        << "  sum " << sum << nl;
+    #endif
 
-    Info<< "Starting write tests" << endl;
+    Info<< "Starting write tests" << nl;
 
     //
     // Write
     //
 
-    // Write stl
+    #ifdef TEST_STD_BOOLLIST
+    // Read stl
     for (label iter = 0; iter < nIters; ++iter)
     {
-        for (unsigned int i = 0; i < stlVector.size(); i++)
+        for (unsigned int i = 0; i < stdBoolList.size(); i++)
         {
-            stlVector[i] = true;
+            stdBoolList[i] = true;
         }
     }
-    Info<< "Writing stl:" << timer.cpuTimeIncrement() << " s" << endl;
+    Info<< "Writing stdBoolList:" << timer.cpuTimeIncrement() << " s" << nl;
+    #endif
 
     // Write unpacked
     for (label iter = 0; iter < nIters; ++iter)
@@ -299,7 +341,7 @@ int main(int argc, char *argv[])
             unpacked[i] = true;
         }
     }
-    Info<< "Writing unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
+    Info<< "Writing unpacked:" << timer.cpuTimeIncrement() << " s" << nl;
 
 
     // Write packed
@@ -311,7 +353,7 @@ int main(int argc, char *argv[])
         }
     }
     Info<< "Writing packed using reference:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
 
     // Write packed
@@ -323,7 +365,7 @@ int main(int argc, char *argv[])
         }
     }
     Info<< "Writing packed using set:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
     // Write packed
     for (label iter = 0; iter < nIters; ++iter)
@@ -334,7 +376,7 @@ int main(int argc, char *argv[])
         }
     }
     Info<< "Writing packed using iterator:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
 
     // Write packed
@@ -343,7 +385,7 @@ int main(int argc, char *argv[])
         packed = 0;
     }
     Info<< "Writing packed uniform 0:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
 
     // Write packed
@@ -352,7 +394,7 @@ int main(int argc, char *argv[])
         packed = 1;
     }
     Info<< "Writing packed uniform 1:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
 
     PackedList<3> oddPacked(n, 3);
@@ -363,7 +405,7 @@ int main(int argc, char *argv[])
         packed = 0;
     }
     Info<< "Writing packed<3> uniform 0:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
 
     // Write packed
@@ -372,7 +414,7 @@ int main(int argc, char *argv[])
         packed = 1;
     }
     Info<< "Writing packed<3> uniform 1:" << timer.cpuTimeIncrement()
-        << " s" << endl;
+        << " s" << nl;
 
 
     Info<< "End\n" << endl;
diff --git a/applications/test/PackedList3/Test-PackedList3.C b/applications/test/PackedList3/Test-PackedList3.C
index 0665363ebe8112f57cf717e94bcf77066b54cb09..5add8789250e4ab05432e83a3621fa1850114514 100644
--- a/applications/test/PackedList3/Test-PackedList3.C
+++ b/applications/test/PackedList3/Test-PackedList3.C
@@ -28,11 +28,7 @@ Description
 \*---------------------------------------------------------------------------*/
 
 #include "argList.H"
-#include "boolList.H"
-#include "HashSet.H"
-#include "StaticHashTable.H"
 #include "cpuTime.H"
-#include <vector>
 #include "PackedBoolList.H"
 
 using namespace Foam;
@@ -44,24 +40,29 @@ using namespace Foam;
 
 int main(int argc, char *argv[])
 {
+    const label nLoop = 5;
     const label n = 100000000;
-    const label nReport = 1000000;
+    // const label nReport = 1000000;
 
     cpuTime timer;
 
     // test inserts
-    // PackedBoolList
     PackedBoolList packed;
-    for (label i = 0; i < n; i++)
+    for (label iloop = 0; iloop < nLoop; ++iloop)
     {
-        if ((i % nReport) == 0 && i)
+        for (label i = 0; i < n; ++i)
         {
-            Info<< "i:" << i << " in " << timer.cpuTimeIncrement() << " s"
-                <<endl;
+            // if ((i % nReport) == 0 && i)
+            // {
+            //     Info<< "." << flush;
+            // }
+            packed[i] = 1;
+            // Make compiler do something else too
+            packed[i/2] = 0;
         }
-        packed[i] = 1;
     }
-    Info<< "insert test: " << n << " elements in "
+    Info<< nl
+        << "insert test: " << nLoop << "*" << n << " elements in "
         << timer.cpuTimeIncrement() << " s\n\n";
 
     Info << "\nEnd\n" << endl;
diff --git a/applications/test/PackedList4/Test-PackedList4.C b/applications/test/PackedList4/Test-PackedList4.C
index ee85d62985426c2f5db9aeb8eceb47c28d77325e..e50eee04f4d6dae8bcf77141a36cdc7280f4be71 100644
--- a/applications/test/PackedList4/Test-PackedList4.C
+++ b/applications/test/PackedList4/Test-PackedList4.C
@@ -28,6 +28,7 @@ Description
 \*---------------------------------------------------------------------------*/
 
 #include "uLabel.H"
+#include "boolList.H"
 #include "IOstreams.H"
 #include "PackedBoolList.H"
 #include "StringStream.H"
@@ -146,17 +147,16 @@ int main(int argc, char *argv[])
     Info<< list4 << " indices: " << list4.used()() << nl;
 
     Info<< "\nassign from labelList\n";
-    list4 = labelList
-    (
-        IStringStream
-        (
-            "(0 1 2 3 12 13 14 19 20 21)"
-        )()
-    );
+    list4 = labelList{0, 1, 2, 3, 12, 13, 14, 19, 20, 21};
 
     list4.printInfo(Info, true);
     Info<< list4 << " indices: " << list4.used()() << nl;
 
+    // Not yet:
+    // PackedBoolList list5{0, 1, 2, 3, 12, 13, 14, 19, 20, 21};
+    // list5.printInfo(Info, true);
+    // Info<< list5 << " indices: " << list5.used()() << nl;
+
     Info<< "\nassign from indices\n";
     list4.read
     (
@@ -170,13 +170,13 @@ int main(int argc, char *argv[])
     list4.printInfo(Info, true);
     Info<< list4 << " indices: " << list4.used()() << nl;
 
-    List<bool> boolLst(list4.size());
+    boolList bools(list4.size());
     forAll(list4, i)
     {
-        boolLst[i] = list4[i];
+        bools[i] = list4[i];
     }
 
-    Info<< "List<bool>: " << boolLst << nl;
+    Info<< "boolList: " << bools << nl;
 
     // check roundabout assignments
     PackedList<2> pl2
diff --git a/applications/test/StaticHashTable/Make/files b/applications/test/StaticHashTable/Make/files
deleted file mode 100644
index e8d76bddc0c9d5bd67784f8e48813eb60364e3a0..0000000000000000000000000000000000000000
--- a/applications/test/StaticHashTable/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-Test-staticHashTable.C
-
-EXE = $(FOAM_USER_APPBIN)/Test-staticHashTable
diff --git a/applications/test/StaticHashTable/Test-staticHashTable.C b/applications/test/StaticHashTable/Test-staticHashTable.C
deleted file mode 100644
index c21e6597debda0bc95cf1e5be8501da9fcf42eb9..0000000000000000000000000000000000000000
--- a/applications/test/StaticHashTable/Test-staticHashTable.C
+++ /dev/null
@@ -1,170 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-\*---------------------------------------------------------------------------*/
-
-#include "StaticHashTable.H"
-#include "IOstreams.H"
-#include "StringStream.H"
-
-using namespace Foam;
-
-// use define so we can easily test other implementations
-#define HASHTABLE_CLASS StaticHashTable
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-//  Main program:
-
-int main()
-{
-    HASHTABLE_CLASS<double> table1(13);
-
-    table1.insert("aaa", 1.0);
-    table1.insert("aba", 2.0);
-    table1.insert("aca", 3.0);
-    table1.insert("ada", 4.0);
-    table1.insert("aeq", 5.0);
-    table1.insert("aaw", 6.0);
-    table1.insert("abs", 7.0);
-    table1.insert("acr", 8.0);
-    table1.insert("adx", 9.0);
-    table1.insert("aec", 10.0);
-
-    table1.erase("aaw");
-    table1.erase("abs");
-
-    Info<< "\ntable1 toc: " << table1.toc() << endl;
-    table1.printInfo(Info)
-        << "table1 [" << table1.size() << "] " << endl;
-    forAllIter(HASHTABLE_CLASS<double>, table1, iter)
-    {
-        Info<< iter.key() << " => " << iter() << nl;
-    }
-
-    table1.set("acr", 108);
-    table1.set("adx", 109);
-    table1.set("aec", 100);
-    table1("aaw") -= 1000;
-    table1("aeq") += 1000;
-
-    Info<< "\noverwrote some values table1: " << table1 << endl;
-
-    Info<< "\ntest find:" << endl;
-    Info<< table1.find("aaa")() << nl
-        << table1.find("aba")() << nl
-        << table1.find("aca")() << nl
-        << table1.find("ada")() << nl
-        << table1.find("aeq")() << nl
-        << table1.find("acr")() << nl
-        << table1.find("adx")() << nl
-        << table1.find("aec")() << nl
-        << table1["aaa"] << nl;
-
-    {
-        OStringStream os;
-        os  << table1;
-        HASHTABLE_CLASS<double> readTable(IStringStream(os.str())(), 100);
-
-        Info<< "Istream constructor:" << readTable << endl;
-    }
-
-
-    HASHTABLE_CLASS<double> table2(table1);
-    HASHTABLE_CLASS<double> table3(table1.xfer());
-
-    Info<< "\ncopy table1 -> table2" << nl
-        << "transfer table1 -> table3 via the xfer() method" << nl;
-
-    Info<< "\ntable1" << table1 << nl
-        << "\ntable2" << table2 << nl
-        << "\ntable3" << table3 << nl;
-
-    Info<< "\nerase table2 by iterator" << nl;
-    forAllIter(HASHTABLE_CLASS<double>, table2, iter)
-    {
-        Info<< "erasing " << iter.key() << " => " << iter() << " ... ";
-        table2.erase(iter);
-        Info<< "erased" << endl;
-    }
-
-    Info<< "\ntable1" << table1 << nl
-        << "\ntable2" << table2 << nl
-        << "\ntable3" << table3 << nl;
-
-    table3.resize(1);
-    Info<< "\nresize(1) table3" << nl;
-    table3.printInfo(Info)
-        << table3 << nl;
-
-    table3.resize(10000);
-    Info<< "\nresize(10000) table3" << nl;
-    table3.printInfo(Info)
-        << table3 << nl;
-
-    HASHTABLE_CLASS<double> table4;
-
-    table4 = table3;
-    Info<< "\ncopy table3 -> table4 " << table4 << nl;
-
-    Info<< "\nclear table4 ... ";
-    table4.clear();
-    Info<< "[" << table4.size() << "] " << table4 << nl;
-
-    table1 = table3;
-    Info<< "\ncopy table3 -> table1 (previously transferred)" << table1 << nl;
-
-    Info<< "test table1 == table3 : " << (table1 == table3) << nl;
-    table1.erase(table1.begin());
-    Info<< "removed an element - test table1 != table3 : "
-        << (table1 != table3) << nl;
-
-    // insert a few things into table2
-    table2.set("ada", 14.0);
-    table2.set("aeq", 15.0);
-    table2.set("aaw", 16.0);
-    table2.set("abs", 17.0);
-    table2.set("adx", 20.0);
-
-    Info<< "\ntable1" << table1 << nl
-        << "\ntable2" << table2 << nl;
-
-    label nErased = table1.erase(table2);
-
-    Info<< "\nerase table2 keys from table1 (removed "
-        << nErased << " elements)" << nl
-        << "\ntable1" << table1 << nl
-        << "\ntable2" << table2 << nl;
-
-
-    Info<< "\ntable3" << table3
-        << "\nclearStorage table3 ... ";
-    table3.clearStorage();
-    Info<< table3 << nl;
-
-    Info<< "\nDone\n";
-
-    return 0;
-}
-
-
-// ************************************************************************* //
diff --git a/applications/test/UIListStream/Make/files b/applications/test/UIListStream/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..f60abd8967b8d24936d8d241c3fcc3cac46b4ce1
--- /dev/null
+++ b/applications/test/UIListStream/Make/files
@@ -0,0 +1,3 @@
+Test-UIListStream.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-UIListStream
diff --git a/applications/test/UIListStream/Make/options b/applications/test/UIListStream/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..18e6fe47afacb902cddccf82632772447704fd88
--- /dev/null
+++ b/applications/test/UIListStream/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/test/UIListStream/Test-UIListStream.C b/applications/test/UIListStream/Test-UIListStream.C
new file mode 100644
index 0000000000000000000000000000000000000000..fb0a1f378ce889049f5ecc820e748ac68140f088
--- /dev/null
+++ b/applications/test/UIListStream/Test-UIListStream.C
@@ -0,0 +1,111 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#include "UListStream.H"
+#include "wordList.H"
+#include "IOstreams.H"
+#include "argList.H"
+
+using namespace Foam;
+
+Ostream& toString(Ostream& os, const UList<char>& list)
+{
+    os << '"';
+    for (const char c : list)
+    {
+        os << c;
+    }
+    os << '"';
+
+    return os;
+}
+
+
+template<class BufType>
+void printInfo(const BufType& buf)
+{
+    Info<< nl << "=========================" << endl;
+    buf.print(Info);
+    toString(Info, buf.list());
+    Info<< nl << "=========================" << endl;
+}
+
+
+void printTokens(Istream& is)
+{
+    label count = 0;
+    token t;
+    while (is.good())
+    {
+        is >> t;
+        if (t.good())
+        {
+            ++count;
+            Info<<"token: " << t << endl;
+        }
+    }
+
+    Info<< count << " tokens" << endl;
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    // Buffer storage
+    DynamicList<char> storage(1000);
+
+    UOListStream obuf(storage);
+    obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n";
+
+    obuf.print(Info);
+
+    // Match size
+    storage.resize(obuf.size());
+
+    Info<<"as string: " << string(storage.cdata(), storage.size()) << endl;
+
+    // Attach input buffer - could also do without previous resize
+
+    UIListStream ibuf(storage);
+
+    printTokens(ibuf);
+
+    Info<< nl << "Repeat..." << endl;
+    ibuf.rewind();
+
+    printTokens(ibuf);
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/UIndirectList/Test-UIndirectList.C b/applications/test/UIndirectList/Test-UIndirectList.C
index be78bbd16b3fb643a7c9730b31e705ed68b606c3..7749a2b18fcb44cf68fa218fe90108ce6ebbaa11 100644
--- a/applications/test/UIndirectList/Test-UIndirectList.C
+++ b/applications/test/UIndirectList/Test-UIndirectList.C
@@ -29,75 +29,102 @@ Description
 #include "DynamicList.H"
 #include "IOstreams.H"
 #include "ListOps.H"
-#include "OFstream.H"
+#include "labelIndList.H"
 
 using namespace Foam;
 
+template<class ListType>
+void printInfo(const ListType& lst)
+{
+    Info<< "addr: " << flatOutput(lst.addressing()) << nl
+        << "list: " << flatOutput(lst) << nl
+        << endl;
+}
+
+template<class T, class ListType>
+void testFind(const T& val, const ListType& lst)
+{
+    Info<< nl
+        << "Search for "<< val << " in " << flatOutput(lst) << nl
+        <<" found() = " << lst.found(val)
+        <<" find() = " << lst.find(val)
+        <<" rfind() = " << lst.rfind(val)
+        <<" find(2) = " << lst.find(val, 2)
+        <<" rfind(2) = " << lst.rfind(val, 2)
+        <<" findIndex = " << findIndex(lst, val) << nl
+        << nl;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // Main program:
 
 int main(int argc, char *argv[])
 {
-    List<double> completeList(10);
+    List<label> completeList(20);
 
     forAll(completeList, i)
     {
-        completeList[i] = 0.1*i;
+        completeList[i] = 10*i;
     }
 
-    List<label> addresses(5);
-    addresses[0] = 1;
-    addresses[1] = 0;
-    addresses[2] = 7;
-    addresses[3] = 8;
-    addresses[4] = 5;
+    Info<< "raw : " << flatOutput(completeList) << nl << endl;
+
+    List<label> addresses{1, 0, 3, 7, 4, 8, 5, 1, 0, 3, 7, 4, 8, 5, };
+
+    labelUIndList idl1(completeList, addresses);
 
-    UIndirectList<double> idl(completeList, addresses);
+    printInfo(idl1);
 
-    Info<< idl << "\n";
+    for (const label val : { 10, 30, 40, 50, 90, 80, 120 } )
+    {
+        testFind(val, idl1);
+    }
 
-    idl[1] = -666;
+    Info<< flatOutput(idl1) << nl;
 
-    Info<< "idl[1] changed: " << idl << endl;
+    idl1[1] = -666;
 
-    idl = -999;
+    Info<< "idl1[1] changed: " << flatOutput(idl1) << endl;
 
-    Info<< "idl changed: " << idl << endl;
+    idl1 = -999;
 
-    UIndirectList<double> idl2(idl);
+    Info<< "idl1 changed: " << flatOutput(idl1) << endl;
 
-    Info<< "idl2: " << idl2 << endl;
+    labelUIndList idl2(idl1);
 
+    Info<< "idl2: " << flatOutput(idl2) << endl;
 
     {
-        List<double> ident(idl.size());
+        List<label> ident(idl1.size());
 
         forAll(ident, i)
         {
             ident[i] = ident.size() - i;
         }
-        idl = ident;
+        idl1 = ident;
     }
 
-    Info<< "idl assigned from UList: " << idl << endl;
+    Info<< "idl1 assigned from UList: " << flatOutput(idl1) << endl;
 
     // test List operations
 
-    List<double> flatList(UIndirectList<double>(completeList, addresses));
-    Info<< "List constructed from UIndirectList: " << flatList << endl;
+    List<label> flatList(labelUIndList(completeList, addresses));
+    Info<< "List construct from UIndirectList: " << flatOutput(flatList) << nl;
 
-    flatList = UIndirectList<double>(completeList, addresses);
-    Info<< "List assigned from UIndirectList: " << flatList << endl;
+    flatList = labelUIndList(completeList, addresses);
+    Info<< "List assign from UIndirectList: " << flatOutput(flatList) << nl;
 
-    flatList.append(UIndirectList<double>(completeList, addresses));
-    Info<< "List::append(UIndirectList): " << flatList << endl;
+    flatList.append(labelUIndList(completeList, addresses));
+    Info<< "List::append(UIndirectList): " << flatOutput(flatList) << nl;
 
 
-    DynamicList<double> dynList(UIndirectList<double>(completeList, addresses));
-    Info<< "DynamicList constructed from UIndirectList: " << dynList << endl;
+    DynamicList<label> dynList(labelUIndList(completeList, addresses));
+    Info<< "DynamicList construct from UIndirectList: " << flatOutput(dynList)
+        << nl;
 
-    dynList.append(UIndirectList<double>(completeList, addresses));
-    Info<< "DynamicList::append(UIndirectList): " << dynList << endl;
+    dynList.append(labelUIndList(completeList, addresses));
+    Info<< "DynamicList::append(UIndirectList): " << flatOutput(dynList) << nl;
 
     Info<< "\nEnd\n" << endl;
 
diff --git a/applications/test/checkDecomposePar/Make/files b/applications/test/checkDecomposePar/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..512f2b1736000a070b0ba83547e9a8df4e62f69b
--- /dev/null
+++ b/applications/test/checkDecomposePar/Make/files
@@ -0,0 +1,3 @@
+Test-checkDecomposePar.C
+
+EXE = $(FOAM_APPBIN)/Test-checkDecomposePar
diff --git a/applications/test/checkDecomposePar/Make/options b/applications/test/checkDecomposePar/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..70323818234c0ba6e39935c3377245da57ec0a05
--- /dev/null
+++ b/applications/test/checkDecomposePar/Make/options
@@ -0,0 +1,11 @@
+EXE_INC = \
+    -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
+    -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/regionModels/regionModel/lnInclude
+
+EXE_LIBS = \
+    -ldecompose \
+    -ldecompositionMethods \
+    -lregionModels
diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C
new file mode 100644
index 0000000000000000000000000000000000000000..b88e92d25ec53dfd7912d15539cf73f2a1a04af8
--- /dev/null
+++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C
@@ -0,0 +1,193 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    checkDecomposePar
+
+Group
+    grpParallelUtilities
+
+Description
+    Check decomposition from kaffpa (KaHIP) output.
+    foamToMetisGraph was likely used for producing the kaffpa input.
+
+\*---------------------------------------------------------------------------*/
+
+#include "OSspecific.H"
+#include "fvCFD.H"
+#include "cpuTime.H"
+#include "IFstream.H"
+#include "regionProperties.H"
+#include "decompositionInformation.H"
+#include "decompositionModel.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+    argList::addNote
+    (
+        "Check decomposition from kaffpa (KaHIP) output"
+    );
+
+    argList::noParallel();
+    argList::noBanner();
+
+    #include "addRegionOption.H"
+    argList::addBoolOption
+    (
+        "allRegions",
+        "operate on all regions in regionProperties"
+    );
+    argList::addBoolOption
+    (
+        "verbose",
+        "more information about decomposition"
+    );
+
+    argList::validArgs.append("kaffpa-output-file");
+
+    // Include explicit constant options, have zero from time range
+    timeSelector::addOptions(true, false);
+
+    #include "setRootCase.H"
+
+    const fileName decompFile = args[1];
+
+    const bool region     = args.optionFound("region");
+    const bool allRegions = args.optionFound("allRegions");
+    const bool verbose    = args.optionFound("verbose");
+
+    // Set time from database
+    #include "createTime.H"
+    // Allow override of time
+    instantList times = timeSelector::selectIfPresent(runTime, args);
+
+    // Allow override of decomposeParDict location
+    fileName decompDictFile;
+    args.optionReadIfPresent("decomposeParDict", decompDictFile);
+
+    wordList regionNames;
+    wordList regionDirs;
+    if (allRegions)
+    {
+        Info<< "Decomposing all regions in regionProperties" << nl << endl;
+        regionProperties rp(runTime);
+        forAllConstIters(rp, iter)
+        {
+            const wordList& regions = iter();
+            forAll(regions, i)
+            {
+                if (!regionNames.found(regions[i]))
+                {
+                    regionNames.append(regions[i]);
+                }
+            }
+        }
+        regionDirs = regionNames;
+    }
+    else
+    {
+        word regionName;
+        if (args.optionReadIfPresent("region", regionName))
+        {
+            regionNames = wordList(1, regionName);
+            regionDirs = regionNames;
+        }
+        else
+        {
+            regionNames = wordList(1, fvMesh::defaultRegion);
+            regionDirs = wordList(1, word::null);
+        }
+    }
+
+    labelList cellToProc;
+
+    forAll(regionNames, regioni)
+    {
+        const word& regionName = regionNames[regioni];
+        const word& regionDir = regionDirs[regioni];
+
+        Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
+        Info<< "Create mesh..." << flush;
+
+        fvMesh mesh
+        (
+            IOobject
+            (
+                regionName,
+                runTime.timeName(),
+                runTime,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE,
+                false
+            )
+        );
+
+        Info<< " nCells = " << mesh.nCells() << endl;
+
+        // Expected format is a simple ASCII list
+        cellToProc.setSize(mesh.nCells());
+        {
+            IFstream is(decompFile);
+
+            forAll(cellToProc, celli)
+            {
+                cellToProc[celli] = readLabel(is);
+            }
+        }
+
+        const label nDomains = max(cellToProc) + 1;
+
+        CompactListList<label> cellCells;
+        decompositionMethod::calcCellCells
+        (
+            mesh,
+            identity(mesh.nCells()),
+            mesh.nCells(),
+            false,
+            cellCells
+        );
+
+        decompositionInformation info
+        (
+            cellCells,
+            cellToProc,
+            nDomains
+        );
+
+        if (verbose)
+        {
+            info.printDetails(Info);
+            Info<< nl;
+        }
+        info.printSummary(Info);
+    }
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/decomposePar/Make/files b/applications/test/decomposePar/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..d9ed6fcd8bf61aa4c1108f537af357e91a5f9b29
--- /dev/null
+++ b/applications/test/decomposePar/Make/files
@@ -0,0 +1,3 @@
+Test-decomposePar.C
+
+EXE = $(FOAM_APPBIN)/Test-decomposePar
diff --git a/applications/test/decomposePar/Make/options b/applications/test/decomposePar/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..a81cfd44fcf5f1a2d7c6ba46e56c0c19002c5aae
--- /dev/null
+++ b/applications/test/decomposePar/Make/options
@@ -0,0 +1,13 @@
+EXE_INC = \
+    -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
+    -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
+    -I$(LIB_SRC)/finiteVolume/lnInclude \
+    -I$(LIB_SRC)/meshTools/lnInclude \
+    -I$(LIB_SRC)/regionModels/regionModel/lnInclude
+
+EXE_LIBS = \
+    -ldecompose \
+    -ldecompositionMethods \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lscotchDecomp \
+    -lregionModels
diff --git a/applications/test/decomposePar/Test-decomposePar.C b/applications/test/decomposePar/Test-decomposePar.C
new file mode 100644
index 0000000000000000000000000000000000000000..c90b5b52d735aeb69f20f915ceb2a0c455e10aea
--- /dev/null
+++ b/applications/test/decomposePar/Test-decomposePar.C
@@ -0,0 +1,278 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    decomposePar
+
+Group
+    grpParallelUtilities
+
+Description
+    Automatically decomposes a mesh and fields of a case for parallel
+    execution of OpenFOAM.
+
+Usage
+    \b decomposePar [OPTION]
+
+    Options:
+      - \par -region \<regionName\>
+        Decompose named region. Does not check for existence of processor*.
+
+      - \par -allRegions
+        Decompose all regions in regionProperties. Does not check for
+        existence of processor*.
+
+      - \par -constant
+
+      - \par -time xxx:yyy
+        Override controlDict settings and decompose selected times. Does not
+        re-decompose the mesh i.e. does not handle moving mesh or changing
+        mesh cases.
+
+\*---------------------------------------------------------------------------*/
+
+#include "OSspecific.H"
+#include "fvCFD.H"
+#include "cpuTime.H"
+#include "IOobjectList.H"
+#include "regionProperties.H"
+#include "decompositionInformation.H"
+#include "decompositionModel.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+    argList::addNote
+    (
+        "decompose a mesh and fields of a case for parallel execution"
+    );
+
+    argList::noParallel();
+    argList::addOption
+    (
+        "decomposeParDict",
+        "file",
+        "read decomposePar dictionary from specified location"
+    );
+    #include "addRegionOption.H"
+    argList::addBoolOption
+    (
+        "allRegions",
+        "operate on all regions in regionProperties"
+    );
+    argList::addBoolOption
+    (
+        "verbose",
+        "more information about decomposition"
+    );
+    argList::addOption
+    (
+        "domains",
+        "N"
+        "override numberOfSubdomains"
+    );
+
+    argList::addOption
+    (
+        "method",
+        "name"
+        "override method"
+    );
+
+    // Include explicit constant options, have zero from time range
+    timeSelector::addOptions(true, false);
+
+    #include "setRootCase.H"
+
+    const bool region     = args.optionFound("region");
+    const bool allRegions = args.optionFound("allRegions");
+    const bool verbose    = args.optionFound("verbose");
+
+    const label numSubdomains =
+        args.optionLookupOrDefault<label>("domains", 0);
+
+    const word methodName =
+        args.optionLookupOrDefault<word>("method", word::null);
+
+
+    // Set time from database
+    #include "createTime.H"
+    // Allow override of time
+    instantList times = timeSelector::selectIfPresent(runTime, args);
+
+    // Allow override of decomposeParDict location
+    fileName decompDictFile;
+    args.optionReadIfPresent("decomposeParDict", decompDictFile);
+
+    wordList regionNames;
+    wordList regionDirs;
+    if (allRegions)
+    {
+        Info<< "Decomposing all regions in regionProperties" << nl << endl;
+        regionProperties rp(runTime);
+        forAllConstIters(rp, iter)
+        {
+            const wordList& regions = iter();
+            forAll(regions, i)
+            {
+                if (!regionNames.found(regions[i]))
+                {
+                    regionNames.append(regions[i]);
+                }
+            }
+        }
+        regionDirs = regionNames;
+    }
+    else
+    {
+        word regionName;
+        if (args.optionReadIfPresent("region", regionName))
+        {
+            regionNames = wordList(1, regionName);
+            regionDirs = regionNames;
+        }
+        else
+        {
+            regionNames = wordList(1, fvMesh::defaultRegion);
+            regionDirs = wordList(1, word::null);
+        }
+    }
+
+
+    forAll(regionNames, regioni)
+    {
+        const word& regionName = regionNames[regioni];
+        const word& regionDir = regionDirs[regioni];
+
+        Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
+        Info<< "Create mesh..." << flush;
+
+        fvMesh mesh
+        (
+            IOobject
+            (
+                regionName,
+                runTime.timeName(),
+                runTime,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE,
+                false
+            )
+        );
+
+        Info<< " nCells = " << mesh.nCells() << endl;
+
+        Info<< "\nCalculating distribution of cells" << endl;
+        cpuTime decompositionTime;
+
+        const decompositionModel& model = decompositionModel::New
+        (
+            mesh,
+            decompDictFile
+        );
+
+        // Allow command-line override for quick testing
+
+        dictionary& modelDict = const_cast<decompositionModel&>(model);
+
+        if (numSubdomains)
+        {
+            modelDict.add
+            (
+                word("numberOfSubdomains"),
+                numSubdomains,
+                true
+            );
+        }
+
+        if (!methodName.empty())
+        {
+            modelDict.add
+            (
+                word("method"),
+                methodName,
+                true
+            );
+        }
+
+        scalarField cellWeights;
+        word weightName;
+        if (model.readIfPresent("weightField", weightName))
+        {
+            volScalarField weights
+            (
+                IOobject
+                (
+                    weightName,
+                    mesh.time().timeName(),
+                    mesh,
+                    IOobject::MUST_READ,
+                    IOobject::NO_WRITE
+                ),
+                mesh
+            );
+            cellWeights = weights.primitiveField();
+        }
+
+        decompositionMethod& method = model.decomposer();
+
+        CompactListList<label> cellCells;
+        decompositionMethod::calcCellCells
+        (
+            mesh,
+            identity(mesh.nCells()),
+            mesh.nCells(),
+            false,
+            cellCells
+        );
+
+        labelList cellToProc = method.decompose(mesh, cellWeights);
+
+        Info<< "\nFinished decomposition into "
+            << method.nDomains() << " domains in "
+            << decompositionTime.elapsedCpuTime()
+            << " s" << nl << endl;
+
+        decompositionInformation info
+        (
+            cellCells,
+            cellToProc,
+            method.nDomains()
+        );
+
+        if (verbose)
+        {
+            info.printDetails(Info);
+            Info<< nl;
+        }
+        info.printSummary(Info);
+    }
+
+    Info<< "\nEnd\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict
index 736f4263056db343c6d72614035505a19b98799c..5fd1c07e862c72bd9480427a2a5ac6c29dc39df6 100644
--- a/applications/test/dictionary/testDict
+++ b/applications/test/dictionary/testDict
@@ -13,18 +13,19 @@ FoamFile
     object      testDict;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-#inputMode  merge
+
 #includeIfPresent "someUnknownFile"
 #includeIfPresent "$FOAM_CASE/someUnknownFile"
 #includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME"
 
 internalField   uniform 1;
 
-// use 'protect' to supply defaults
-#inputMode  protect
-internalField   uniform 10;
-dimensions      [ 0 2 -2 0 0 0 0 ];
-#inputMode  merge
+// supply defaults
+#default internalField  uniform 10;
+#default dimensions     [ 1 2 -2 0 0 0 0 ];
+#overwrite dimensions   [ 0 2 -2 0 0 0 0 ];
+// #warn       dimensions      [ 0 2 -2 0 0 0 0 ];
+// #error      dimensions      [ 0 2 -2 0 0 0 0 ];
 
 active
 {
@@ -86,14 +87,22 @@ boundaryField
     #remove inactive
 
     inlet_7  { ${${varType}}}   // Test indirection/recursive expansion
-    #inputMode overwrite
     inlet_8  { $active }
+
+    #overwrite inlet_8  { type none; }
 }
 
-// NB: the inputMode has a global scope
-#inputMode merge
+
 #include "testDict2"
 
+verbatim #{
+
+    This is a somewhat larger chunk of verbatim text that we would much
+    prefer to move as a token rather than copying its entire content each
+    time we do parsing or need to resize the token list.
+
+#};
+
 foo
 {
     $active
diff --git a/applications/test/dictionary/testSubkeyword b/applications/test/dictionary/testSubkeyword
index f8ee14850114e03cb7256b61966628fdd6f43980..3465f0623efd821831b0cb346b8111011fd598ad 100644
--- a/applications/test/dictionary/testSubkeyword
+++ b/applications/test/dictionary/testSubkeyword
@@ -17,6 +17,8 @@ FoamFile
 // #inputMode  overwrite
 
 key1 val1;
+val1 val1;
+val2 val2;
 
 subdict
 {
@@ -35,19 +37,75 @@ update
         key3 val3;
         key2b ${..key2};
         key3b $^key1;
+        key100 100;
+        key200 200;
+        key300 300;
+        key400 400;
     }
 }
 
 
+// expands update into top-level
 $update
 
-// Can a leading '^' or  ':' as anchor for scoping
-key3 $^subdict.key1;
+
+_cleanup
+{
+    #remove    "/subdict/key300"
+    "/subdict/key400"    400000;
+
+    // Self-destruct not possible
+    // #remove "/_cleanup"
+}
+
+#remove "/_cleanup"
+
+// Can use a leading '^' or  ':' as anchor for scoping, but slashes are clearer
+key3dot   ${^subdict.key1};
+key3slash ${/subdict/key1};
 key3 ${^update.subdict.key3};
 key4 ${:update.subdict...subdict.key1};
 
-// This is currently not working
-#remove update.key1
-// #remove update
+// This will not work, but globs would be interesting:
+#remove "/update/subdict/key*"
+
+// This is okay, uses a regexp directly
+#remove "val.*"
+
+#remove "/update/subdict/key100"
+
+"/subdict/key2"  overridden;
+
+
+active
+{
+    type            turbulentIntensityKineticEnergyInlet;
+    intensity       0.1;
+    value           100;
+}
+
+// Some more with scoping
+
+"/active/value(pwd)"    200;
+"/active/'(pwd|foo)'"   200;   // Can use single or double quotes
+"/active/intensity"     0.05;
+
+// Auto-vivify intermediate dictionaries
+
+"/active/subdict/type"  anotherType;
+"/active/subdict/value/type"    anotherType;
+
+// This is an error - cannot change type of intermediate dictionaries!
+// "active/value/type/of/things"   newType;
+
+"/active/subdict/value"    change;
+
+"/active/subdict/value"    { entry1 value1; entry2 value2; }
+
+// Handle remove as per changeDictionary?  TBD
+// Removal:
+// "~/active/subdict/value"
+
+// "~active"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/test/dictionary2/Make/files b/applications/test/dictionary2/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..397d8d53cb6bc013bebd316e56ee2bff0e03ce21
--- /dev/null
+++ b/applications/test/dictionary2/Make/files
@@ -0,0 +1,3 @@
+Test-dictionary2.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-dictionary2
diff --git a/applications/test/dictionary2/Make/options b/applications/test/dictionary2/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..41306609f208806f0c6f42a2426867d3e10d4897
--- /dev/null
+++ b/applications/test/dictionary2/Make/options
@@ -0,0 +1 @@
+EXE_INC =
diff --git a/applications/test/dictionary2/Test-dictionary2.C b/applications/test/dictionary2/Test-dictionary2.C
new file mode 100644
index 0000000000000000000000000000000000000000..2541f5cba66da719a5674e32360fca77abbafd67
--- /dev/null
+++ b/applications/test/dictionary2/Test-dictionary2.C
@@ -0,0 +1,217 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    Test-dictionary2
+
+Description
+
+    Test dictionary insertion
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "IOstreams.H"
+#include "IOobject.H"
+#include "IFstream.H"
+#include "dictionary.H"
+#include "stringOps.H"
+
+using namespace Foam;
+
+void entryInfo(entry* e)
+{
+    if (e)
+    {
+        Info<<"added "
+            << e->keyword() << ": " << typeid(e).name() << nl;
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+//  Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noBanner();
+    argList::noParallel();
+
+    argList args(argc, argv);
+
+    dictionary dict1;
+    for (label i=0; i<5; ++i)
+    {
+        dictionary tmpdict;
+
+        {
+            entry* e = dict1.add
+            (
+                Foam::name("entry%d", i),
+                string("entry" + Foam::name(i))
+            );
+            entryInfo(e);
+        }
+
+        {
+            entry* e = tmpdict.add
+            (
+                Foam::name("subentry%d", i),
+                string("subentry" + Foam::name(i))
+            );
+            entryInfo(e);
+        }
+
+        {
+            entry* e = dict1.add
+            (
+                Foam::name("dict%d", i),
+                tmpdict
+            );
+            entryInfo(e);
+        }
+    }
+
+    // Insert new dictionary or merge into existing one
+    for (auto k : { "dict1", "dict10" })
+    {
+        const word key(k);
+        entry* e = dict1.add(key, dictionary(), true);
+
+        if (e && e->isDict())
+        {
+            e->dict().add(word("sub1" + key), 10);
+            e->dict().add(word("sub2" + key), 20);
+            e->dict().add(word("sub3" + key), 30);
+            e->dict().add(word("sub4" + key), 40);
+            e->dict().add(word("sub5" + key), 50);
+            e->dict().add(word("sub6" + key), 60);
+        }
+    }
+
+
+    // overwrite existing
+    {
+        dict1.set("entry3", 1000); // overwrite
+        entry* e = dict1.set(word("dict3"), 1000); // overwrite
+        entryInfo(e);
+    }
+
+    // merge into existing dictionary: returns pointer to existing dict
+    {
+        dictionary tmpdict;
+        tmpdict.add(word("something"), 3.14159);
+
+        entry* e = dict1.add(word("dict4"), tmpdict, true);  // merge
+        entryInfo(e);
+
+        if (e) Info<< nl << "=> " << *e << nl;
+
+        tmpdict.clear();
+        tmpdict.add(word("other"), 2.718281);
+
+        dict1.add(word("dict1"), tmpdict, true);  // merge
+    }
+
+    Info<< nl << "dictionary" << nl << nl;
+    dict1.write(Info, false);
+
+
+    {
+        dict1.foundCompat
+        (
+            "newEntry", {{"entry1", 1612}, {"entry15", 1606}}
+        );
+        dict1.foundCompat
+        (
+            "newEntry", {{"entry15", 1612}, {"entry2", 1606}}
+        );
+        dict1.foundCompat
+        (
+            "newEntry", {{"entry3", 240}, {"entry2", 1606}}
+        );
+
+        // And some success
+        dict1.foundCompat
+        (
+            "entry4", {{"none", 240}, {"entry2", 1606}}
+        );
+    }
+
+    {
+        label lval = readLabel
+        (
+            dict1.lookupCompat
+            (
+                "entry400", {{"none", 240}, {"entry3", 1606}}
+            )
+        );
+        Info<< "int value: " << lval << nl;
+    }
+
+
+    // Could have different dictionary names and different entries names etc.
+    // Quite ugly!
+    {
+        scalar sval = readScalar
+        (
+            dict1.csearchCompat
+            (
+                "newdictName", {{"dict4", 1706}, {"dict1", 1606}}
+            )
+            .dict()
+            .lookupCompat
+            (
+                "newval", {{"something", 1606}, {"other", 1612}}
+            )
+        );
+
+        Info<< "scalar value: " << sval << nl;
+
+        sval = readScalar
+        (
+            dict1.csearchCompat
+            (
+                "newdictName", {{"dict1", 1606}, {"dict4", 1706}}
+            )
+            .dict()
+            .lookupCompat
+            (
+                "newval", {{"something", 1606}, {"other", 1612}}
+            )
+        );
+
+        Info<< "scalar value = " << sval << nl;
+    }
+
+
+    Info<< nl << "dictionary" << nl << nl;
+    dict1.write(Info, false);
+
+    Info<< "\nDone\n" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/dictionaryTokens/Make/files b/applications/test/dictionaryTokens/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..413023a0147e5a538beccb4110b73dc332fa6bdf
--- /dev/null
+++ b/applications/test/dictionaryTokens/Make/files
@@ -0,0 +1,4 @@
+Test-dictionaryTokens.C
+dictionaryTokens.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens
diff --git a/applications/test/dictionaryTokens/Make/options b/applications/test/dictionaryTokens/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..41306609f208806f0c6f42a2426867d3e10d4897
--- /dev/null
+++ b/applications/test/dictionaryTokens/Make/options
@@ -0,0 +1 @@
+EXE_INC =
diff --git a/applications/test/dictionaryTokens/Test-dictionaryTokens.C b/applications/test/dictionaryTokens/Test-dictionaryTokens.C
new file mode 100644
index 0000000000000000000000000000000000000000..6e77cddc5f827e07b8a402e7fe713c4d7d4315c4
--- /dev/null
+++ b/applications/test/dictionaryTokens/Test-dictionaryTokens.C
@@ -0,0 +1,95 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    printDictionary
+
+Description
+
+    Test dictionaryTokens
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "IOstreams.H"
+#include "IOobject.H"
+#include "IFstream.H"
+
+#include "dictionaryTokens.H"
+
+using namespace Foam;
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+//  Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noBanner();
+    argList::noParallel();
+    argList::noFunctionObjects();
+    argList::addBoolOption("info", "report token info");
+    argList::addBoolOption("value", "report token value");
+
+    argList::validArgs.insert("dict .. dictN");
+    argList args(argc, argv, false, true);
+
+    const bool optInfo  = args.optionFound("info");
+    const bool optValue = args.optionFound("value");
+
+    for (label argi=1; argi < args.size(); ++argi)
+    {
+        IFstream is(args[argi]);
+
+        dictionary dict(is);
+
+        dictionaryTokens dictTokens(dict);
+
+        while (dictTokens.good())
+        {
+            if (optInfo)
+            {
+                // Token info
+                Info<< (*dictTokens).info() << nl;
+            }
+            else if (optValue)
+            {
+                // Token value
+                Info<< *dictTokens << nl;
+            }
+            else
+            {
+                // Token type
+                Info<< (*dictTokens).name() << nl;
+            }
+            ++dictTokens;
+        }
+
+        Info<< nl;
+    }
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.C
new file mode 100644
index 0000000000000000000000000000000000000000..28cb9f30cf6710686a05bab1ad3e20ea583bfbc7
--- /dev/null
+++ b/applications/test/dictionaryTokens/dictionaryTokens.C
@@ -0,0 +1,309 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "dictionaryTokens.H"
+#include "IOstream.H"
+
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+Foam::token Foam::dictionaryTokens::keywordToken(const entry& e)
+{
+    const keyType& k = e.keyword();
+
+    if (k.empty())
+    {
+        return token::undefinedToken;
+    }
+    if (k.isPattern())
+    {
+        return token(static_cast<string>(k)); // quoted
+    }
+    else
+    {
+        return token(static_cast<word>(k)); // unquoted
+    }
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+bool Foam::dictionaryTokens::setIterator() const
+{
+    primIter_.clear();
+    dictIter_.clear();
+
+    if (entryIter_ != dict_.cend())
+    {
+        const entry& base = *entryIter_;
+
+        if (isA<primitiveEntry>(base))
+        {
+            primIter_.reset
+            (
+                new dictionaryTokens::primitive_iterator
+                (
+                    dynamicCast<const primitiveEntry&>(base)
+                )
+            );
+
+            return true;
+        }
+        else if (isA<dictionaryListEntry>(base))
+        {
+            // Must check for isA<dictionaryListEntry> before checking
+            // for isA<dictionaryEntry> !
+
+            dictIter_.reset
+            (
+                new dictionaryTokens::dictionary_iterator
+                (
+                    dynamicCast<const dictionaryListEntry&>(base)
+                )
+            );
+
+            return true;
+        }
+        else if (isA<dictionaryEntry>(base))
+        {
+            dictIter_.reset
+            (
+                new dictionaryTokens::dictionary_iterator
+                (
+                    dynamicCast<const dictionaryEntry&>(base)
+                )
+            );
+
+            return true;
+        }
+
+    }
+
+    return false;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::dictionaryTokens::dictionaryTokens(const dictionary& dict)
+:
+    dict_(dict),
+    entryIter_(dict_.cbegin()),
+    primIter_(nullptr),
+    dictIter_(nullptr)
+{
+    rewind();
+}
+
+
+Foam::dictionaryTokens::primitive_iterator::primitive_iterator
+(
+    const primitiveEntry& e
+)
+:
+    tokensPtr_(&(static_cast<const tokenList&>(e))),
+    key_(dictionaryTokens::keywordToken(e)),
+    end_(token::punctuationToken::END_STATEMENT),
+    pos_((key_.good() ? -1 : 0))
+{}
+
+
+Foam::dictionaryTokens::dictionary_iterator::dictionary_iterator
+(
+    const dictionaryEntry& e
+)
+:
+    key_(dictionaryTokens::keywordToken(e)),
+    lbrace_(token::punctuationToken::BEGIN_BLOCK),
+    rbrace_(token::punctuationToken::END_BLOCK),
+    state_(key_.good() ? states::KEY : states::OPEN),
+    dictTokens_(e.dict())
+{}
+
+
+Foam::dictionaryTokens::dictionary_iterator::dictionary_iterator
+(
+    const dictionaryListEntry& e
+)
+:
+    key_(e.size()),
+    lbrace_(token::punctuationToken::BEGIN_LIST),
+    rbrace_(token::punctuationToken::END_LIST),
+    state_(states::KEY),
+    dictTokens_(e.dict())
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::dictionaryTokens::good() const
+{
+    return
+    (
+        entryIter_ != dict_.cend()
+     &&
+        (
+            (primIter_.valid() && primIter_().good())
+         || (dictIter_.valid() && dictIter_().good())
+        )
+    );
+}
+
+
+bool Foam::dictionaryTokens::primitive_iterator::good() const
+{
+    return (tokensPtr_ && pos_ <= tokensPtr_->size());
+}
+
+
+bool Foam::dictionaryTokens::dictionary_iterator::good() const
+{
+    return (state_ != states::END);
+}
+
+
+const Foam::token& Foam::dictionaryTokens::operator*() const
+{
+    if (good())
+    {
+        if (primIter_.valid()) return *(primIter_());
+        if (dictIter_.valid()) return *(dictIter_());
+    }
+
+    return token::undefinedToken;
+}
+
+
+const Foam::token&
+Foam::dictionaryTokens::primitive_iterator::operator*() const
+{
+    if (good())
+    {
+        if (pos_ == -1)
+        {
+            return key_;
+        }
+        else if (pos_ >= tokensPtr_->size())
+        {
+            return end_; // The trailing ';'
+        }
+
+        return tokensPtr_->operator[](pos_);
+    }
+
+    return token::undefinedToken;
+}
+
+
+const Foam::token&
+Foam::dictionaryTokens::dictionary_iterator::operator*() const
+{
+    if (good())
+    {
+        if (state_ == states::KEY)
+        {
+            return key_;  // keyword
+        }
+        if (state_ == states::OPEN)
+        {
+            return lbrace_;  // Opening '{'
+        }
+        if (state_ == states::CONTENT)
+        {
+            return *(dictTokens_);
+        }
+        if (state_ == states::CLOSE)
+        {
+            return rbrace_;  // Closing '}'
+        }
+    }
+
+    return token::undefinedToken;
+}
+
+
+bool Foam::dictionaryTokens::operator++()
+{
+    bool ok = good();
+
+    if (ok)
+    {
+        if (primIter_.valid()) ok = ++(primIter_());
+        if (dictIter_.valid()) ok = ++(dictIter_());
+
+        if (!ok)
+        {
+            ++entryIter_; // Next entry
+            setIterator();
+        }
+    }
+
+    return ok;
+}
+
+
+bool Foam::dictionaryTokens::primitive_iterator::operator++()
+{
+    // Advance good iterators.
+    //
+    // Going beyond trailing ';' makes it into an end iterator
+
+    if (tokensPtr_ && (++pos_ > tokensPtr_->size()))
+    {
+        tokensPtr_ = nullptr;
+        return false;
+    }
+
+    return this->good();
+}
+
+
+bool Foam::dictionaryTokens::dictionary_iterator::operator++()
+{
+    if
+    (
+        state_ == states::KEY
+     || state_ == states::OPEN
+     || state_ == states::CLOSE
+    )
+    {
+        ++state_;
+    }
+    else if (state_ == states::CONTENT && !(++dictTokens_))
+    {
+        ++state_;
+    }
+
+    return good();
+}
+
+
+void Foam::dictionaryTokens::rewind()
+{
+    entryIter_ = dict_.cbegin();
+    setIterator();
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/dictionaryTokens/dictionaryTokens.H b/applications/test/dictionaryTokens/dictionaryTokens.H
new file mode 100644
index 0000000000000000000000000000000000000000..f6866335679d3719233116a93d7ec62a7eb8e8ec
--- /dev/null
+++ b/applications/test/dictionaryTokens/dictionaryTokens.H
@@ -0,0 +1,289 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::dictionaryTokens
+
+Description
+    Provides a stream of tokens from a dictionary.
+
+    This can be used to return a stream of tokens from a dictionary
+    without overhead or needing to reparse information.
+
+    For example,
+
+    \code
+    OPstream os = ...;
+    dictionaryTokens toks(dict);
+
+    while (toks.good())
+    {
+       os.write(*toks);
+       ++toks;
+    }
+
+    \endcode
+    Or alternatively,
+
+    \code
+    dictionaryTokens toks(dict);
+
+    while (toks.good())
+    {
+       os << *toks << nl;
+       ++toks;
+    }
+    \endcode
+
+SourceFiles
+    dictionaryTokens.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef dictionaryTokens_H
+#define dictionaryTokens_H
+
+#include "dictionary.H"
+#include "primitiveEntry.H"
+#include "dictionaryEntry.H"
+#include "dictionaryListEntry.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declarations
+class dictionaryTokens;
+
+
+/*---------------------------------------------------------------------------*\
+                      Class dictionaryTokens Declaration
+\*---------------------------------------------------------------------------*/
+
+class dictionaryTokens
+{
+public:
+
+    // Forward declarations
+    class primitive_iterator;
+    class dictionary_iterator;
+
+
+private:
+
+    // Private Member Data
+
+        //- Reference to the dictionary being streamed.
+        const dictionary& dict_;
+
+        //- The current entry iterator
+        IDLList<entry>::const_iterator entryIter_;
+
+        //- The current entry iterator for primitiveEntry types
+        mutable autoPtr<primitive_iterator> primIter_;
+
+        //- The current entry iterator for dictionaryEntry and
+        //- dictionaryListEntry types
+        mutable autoPtr<dictionary_iterator> dictIter_;
+
+        //- Set/unset primitive and dictionary when changing to next entry
+        bool setIterator() const;
+
+
+    // Private Member Functions
+
+        //- Disallow bitwise copy/assignment
+        dictionaryTokens(const dictionaryTokens&) = delete;
+        void operator=(const dictionaryTokens&) = delete;
+
+
+public:
+
+    // Static Member Functions
+
+        //- The entry keyword as word or string token
+        static token keywordToken(const entry& e);
+
+
+    // Constructors
+
+        //- Construct from reference to dictionary to be streamed
+        dictionaryTokens(const dictionary& dict);
+
+
+    // Member Functions
+
+        //- True if the token stream is in a valid state
+        bool good() const;
+
+        //- The current token, or undefined if the stream is in an invalid
+        //- invalid state.
+        const token& operator*() const;
+
+        //- Advance to the next token and return the updated stream stream.
+        bool operator++();
+
+        //- Reset to beginning
+        void rewind();
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+            Class dictionaryTokens::primitive_iterator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An iterator for a primitiveEntry
+//
+//  The token stream output has the form
+//
+//  \verbatim
+//      keyword  content tokens ';'
+//  \endverbatim
+//
+class dictionaryTokens::primitive_iterator
+{
+    // Private Member Data
+
+        //- Reference to the tokenList being streamed.
+        const tokenList* tokensPtr_;
+
+        //- The keyword as a token (string, word or undefined)
+        const token key_;
+
+        //- The closing ';' as a token
+        const token end_;
+
+        //- The current position within the tokenList
+        label pos_;
+
+
+    // Private Member Functions
+
+        //- Disallow bitwise copy/assignment
+        primitive_iterator(const primitive_iterator&) = delete;
+        void operator=(const primitive_iterator&) = delete;
+
+public:
+
+    // Constructors
+
+        //- Construct from reference to primitiveEntry
+        primitive_iterator(const primitiveEntry& e);
+
+
+    // Member Functions
+
+        //- True if the entry has keyword or tokens and has not indexed beyond
+        //- the final trailing ';'
+        bool good() const;
+
+        //- The current token, or undefined if the stream is invalid.
+        const token& operator*() const;
+
+        //- Advance to the next token and return the updated stream stream.
+        bool operator++();
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+            Class dictionaryTokens::dictionary_iterator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An iterator for a dictionaryEntry and dictionaryListEntry
+//
+//  The token stream output has the form
+//
+//  \verbatim
+//      keyword '{' content '}'
+//  \endverbatim
+//
+//  or for the dictionaryListEntry the form
+//
+//  \verbatim
+//      size '(' content ')'
+//  \endverbatim
+//
+class dictionaryTokens::dictionary_iterator
+{
+    // Private Member Data
+
+        //- The possible output states
+        enum states { KEY=0, OPEN, CONTENT, CLOSE, END };
+
+        //- The keyword or the size (dictionaryListEntry) as a token
+        const token key_;
+
+        //- The opening brace '{' or bracket '('
+        const token lbrace_;
+
+        //- The closing brace ')' or bracket ')'
+        const token rbrace_;
+
+        //- The current output state
+        int state_;
+
+        //- A streamer for the dictionary content
+        dictionaryTokens dictTokens_;
+
+
+    // Private Member Functions
+
+        //- Disallow bitwise copy/assignment
+        dictionary_iterator(const dictionary_iterator&) = delete;
+        void operator=(const dictionary_iterator&) = delete;
+
+
+public:
+
+    // Constructors
+
+        //- Construct from reference to dictionaryEntry
+        dictionary_iterator(const dictionaryEntry& e);
+
+        //- Construct from reference to dictionaryListEntry
+        dictionary_iterator(const dictionaryListEntry& e);
+
+
+    // Member Functions
+
+        //- In a valid state
+        bool good() const;
+
+        //- The current token, or undefined if the stream is invalid.
+        const token& operator*() const;
+
+        //- Advance to the next token and return the updated stream stream.
+        bool operator++();
+
+};
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C
index 5de8912bd880e5c6c78dc80442abe76661031cd4..9ccd801245c3cb5d52dfa2b194e144b6809ba8b4 100644
--- a/applications/test/fileName/Test-fileName.C
+++ b/applications/test/fileName/Test-fileName.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -39,15 +39,135 @@ Description
 #include "POSIX.H"
 #include "Switch.H"
 #include "etcFiles.H"
+#include "Pair.H"
+#include "Tuple2.H"
+#include <fstream>
 
 using namespace Foam;
 
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+unsigned testStrip
+(
+    const bool doClean,
+    std::initializer_list
+    <
+        Tuple2<bool, std::string>
+    > tests
+)
+{
+    Info<< nl << "Checking with clean=" << Switch(doClean) << nl << endl;
+
+    unsigned nFail = 0;
+
+    for (const Tuple2<bool, std::string>& test : tests)
+    {
+        const bool expected = test.first();
+        const std::string& input = test.second();
+
+        fileName output(fileName::validate(input, doClean));
+
+        // Check for real failure (invalid chars) vs.
+        // spurious failure (removed double slashes with 'doClean').
+
+        const bool same =
+        (
+            doClean
+          ? fileName::equals(input, output)
+          : (input == output)
+        );
+
+        if (same)
+        {
+            if (expected)
+            {
+                Info<< "(pass) validated " << input << " = " << output << nl;
+            }
+            else
+            {
+                ++nFail;
+                Info<< "(fail) unexpected success for " << input << nl;
+            }
+        }
+        else
+        {
+            if (expected)
+            {
+                ++nFail;
+                Info<< "(fail) unexpected";
+            }
+            else
+            {
+                Info<< "(pass) expected";
+            }
+
+            Info<< " failure for " << input << nl;
+        }
+    }
+
+    return nFail;
+}
+
+
+unsigned testEquals
+(
+    std::initializer_list
+    <
+        Tuple2<bool, Pair<std::string>>
+    > tests
+)
+{
+    Info<< nl << "Checking fileName::equals()" << nl << endl;
+
+    unsigned nFail = 0;
+
+    for (const Tuple2<bool, Pair<std::string>>& test : tests)
+    {
+        const bool expected = test.first();
+        const std::string& s1 = test.second().first();
+        const std::string& s2 = test.second().second();
+
+        const bool same = fileName::equals(s1, s2);
+
+        if (same)
+        {
+            if (expected)
+            {
+                Info<< "(pass) success";
+            }
+            else
+            {
+                ++nFail;
+                Info<< "(fail) unexpected success";
+            }
+        }
+        else
+        {
+            if (expected)
+            {
+                ++nFail;
+                Info<< "(fail) unexpected failure";
+            }
+            else
+            {
+                Info<< "(pass) expected failure";
+            }
+
+        }
+
+        Info<< " for " << s1 << " == " << s2 << nl;
+    }
+    return nFail;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // Main program:
 
 int main(int argc, char *argv[])
 {
     argList::noParallel();
+    argList::addBoolOption("validate", "test fileName::validate");
     argList::addBoolOption("ext", "test handing of file extensions");
     argList::addBoolOption("construct", "test constructors");
     argList::addBoolOption("default", "reinstate default tests");
@@ -235,6 +355,69 @@ int main(int argc, char *argv[])
         Info<< nl;
     }
 
+
+    if (args.optionFound("validate"))
+    {
+        unsigned nFail = 0;
+        Info<< nl << "Test fileName::validate" << nl;
+
+        // Without clean
+        nFail += testEquals
+        (
+            {
+                { true,  { "abc", "abc/" } },
+                { true,  { "///abc/", "//abc///" } },
+                { false, { " ab //c/", "ab/c" } },
+            }
+        );
+
+        Info<< nl << "Test fileName::validate" << nl;
+
+        // Without clean
+        nFail += testStrip
+        (
+            false,
+            {
+                { true,  "abc/" },
+                { true,  "/", },
+                { true,  "//", },
+                { true,  "/abc/def", },
+                { true,  "/abc/def/", },
+                { false, "/abc  def" },
+                { true,  "/abc////def///", },
+                { false,  "/abc//// def///" },
+            }
+        );
+
+        // With clean
+        nFail += testStrip
+        (
+            true,
+            {
+                { true,  "abc/" },
+                { true,  "/" },
+                { true,  "//" },
+                { true,  "/abc/def" },
+                { true,  "/abc/def/" },
+                { false, "/abc  def" },
+                { true,  "/abc////def///" },
+                { false, "/abc//// def///" },
+            }
+        );
+
+        Info<< nl;
+        if (nFail)
+        {
+            Info<< "failed " << nFail;
+        }
+        else
+        {
+            Info<< "passed all";
+        }
+        Info<< " fileName::validate tests" << nl;
+    }
+
+
     if (!defaultTests)
     {
         return 0;
@@ -312,10 +495,32 @@ int main(int argc, char *argv[])
         Foam::rm(lnB);
         Foam::rmDir(dirB);
 
+        Info<< nl << "=========================" << nl
+            << "Test some copying and deletion" << endl;
+
 
         Info<< "Creating directory " << dirA << endl;
         Foam::mkDir(dirA);
 
+        Info<< "Populating with various files" << endl;
+        for
+        (
+            const std::string name
+          : { "file-1", "file-2", "bad name one", "bad name 2" }
+        )
+        {
+            // Full path, but without any stripping
+            const fileName file
+            (
+                (static_cast<const std::string&>(dirA) + "/" + name),
+                false
+            );
+
+            Info<<"    create: " << file << endl;
+
+            std::ofstream os(file);
+            os << "file=<" << file << ">" << nl;
+        }
 
         const int oldPosix = POSIX::debug;
         POSIX::debug = 1;
@@ -362,7 +567,7 @@ int main(int argc, char *argv[])
                     << " but is " << lnB.type(true) << exit(FatalError);
             }
 
-            // Delete
+            // Delete (link)
             Foam::rm(lnB);
         }
 
@@ -379,12 +584,13 @@ int main(int argc, char *argv[])
                     << " but is " << lnB.type(false) << exit(FatalError);
             }
 
-            // Delete
-            Foam::rm(lnB);
+            // Delete (directory, not link)
+            Foam::rmDir(lnB);
         }
 
         POSIX::debug = oldPosix;
 
+        // Verify that rmDir works with bad names too
         Foam::rmDir(dirA);
         Foam::rm(lnA);
     }
diff --git a/applications/test/foamToMetisGraph/Make/files b/applications/test/foamToMetisGraph/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..6c63ebbc7ffed052c18ec04da85d19ef19894563
--- /dev/null
+++ b/applications/test/foamToMetisGraph/Make/files
@@ -0,0 +1,3 @@
+foamToMetisGraph.C
+
+EXE = $(FOAM_USER_APPBIN)/foamToMetisGraph
diff --git a/applications/test/foamToMetisGraph/Make/options b/applications/test/foamToMetisGraph/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..4c3dd783cb4170feefb3f5385510a83257b43b18
--- /dev/null
+++ b/applications/test/foamToMetisGraph/Make/options
@@ -0,0 +1,3 @@
+EXE_INC =
+
+EXE_LIBS =
diff --git a/applications/test/foamToMetisGraph/foamToMetisGraph.C b/applications/test/foamToMetisGraph/foamToMetisGraph.C
new file mode 100644
index 0000000000000000000000000000000000000000..d4019842d483438716523e8f90fd2614c08008f8
--- /dev/null
+++ b/applications/test/foamToMetisGraph/foamToMetisGraph.C
@@ -0,0 +1,86 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+    Create a metis graph file representation of an OpenFOAM mesh
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "Time.H"
+#include "polyMesh.H"
+#include "OFstream.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noParallel();
+    argList::noFunctionObjects();
+    argList::addNote
+    (
+        "Create a metis graph file representation for an OpenFOAM mesh"
+    );
+
+    #include "setRootCase.H"
+    #include "createTime.H"
+    #include "createPolyMesh.H"
+
+    const labelListList& cellCells = mesh.cellCells();
+
+    // No. of Nodes = nCells
+    // No. of Edges connecting Nodes = nInternalFaces
+
+    OFstream os(args.caseName() + ".graph", IOstream::ASCII);
+
+    os  << "%% metis graph file, of an OpenFOAM mesh %%" << nl
+        << "%% nCells=" << mesh.nCells()
+        << " nFaces=" << mesh.nFaces()
+        << " nInternalFaces=" << mesh.nInternalFaces() << nl;
+
+    os  << cellCells.size() << " " << mesh.nInternalFaces() << nl;
+
+    for (const auto& edges : cellCells)
+    {
+        forAll(edges, i)
+        {
+            if (i) os << " ";
+            os << edges[i] + 1;  // index starts at 1.
+        }
+        os << nl;
+    }
+
+    Info<<"Wrote graph with "
+        << mesh.nCells() << " nodes and "
+        << mesh.nInternalFaces() << " edges to "
+        << os.name() << nl;
+
+    Info<< nl << "End\n" << endl;
+
+    return 0;
+}
+
+// ************************************************************************* //
diff --git a/applications/test/openmp/Make/files b/applications/test/openmp/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..c2749a9419f38c1d43718a57082b666f6e4dbd88
--- /dev/null
+++ b/applications/test/openmp/Make/files
@@ -0,0 +1,3 @@
+Test-openmp.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-openmp
diff --git a/applications/test/openmp/Make/options b/applications/test/openmp/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..54eed51fb98aec99bde724a061aff18cbc2c3e76
--- /dev/null
+++ b/applications/test/openmp/Make/options
@@ -0,0 +1,4 @@
+EXE_INC = ${COMP_OPENMP}
+
+/* Mostly do not need to explicitly link openmp libraries */
+/* EXE_LIBS = ${LINK_OPENMP} */
diff --git a/applications/test/openmp/Test-openmp.C b/applications/test/openmp/Test-openmp.C
new file mode 100644
index 0000000000000000000000000000000000000000..acb68e9ed86d6d6d96f131370dfbea08e6c39a27
--- /dev/null
+++ b/applications/test/openmp/Test-openmp.C
@@ -0,0 +1,69 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+    Simple test program for compiling/running openmp
+
+\*---------------------------------------------------------------------------*/
+
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+
+#ifdef USE_OMP
+#include <omp.h>
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    int nThreads, threadId;
+
+// Fork threads with their own copies of variables
+#ifdef USE_OMP
+#pragma omp parallel private(nThreads, threadId)
+    {
+        threadId = omp_get_thread_num();
+        nThreads = omp_get_num_threads();
+
+        // Printf rather than cout to ensure that it emits in one go
+        printf("Called from thread = %d\n", threadId);
+
+        // Master thread
+        if (threadId == 0)
+        {
+            // Printf rather than cout to ensure that it emits in one go
+            printf("Number of threads = %d\n", nThreads);
+        }
+    }
+#else
+    std::cout << "Compiled without openmp!\n";
+#endif
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/parallel/Test-parallel.C b/applications/test/parallel/Test-parallel.C
index 14ba97f7a561a39dd3ea5952b15553e04647f543..ec5546c6759aec5394afa3645a369e4ed4eee83e 100644
--- a/applications/test/parallel/Test-parallel.C
+++ b/applications/test/parallel/Test-parallel.C
@@ -120,6 +120,24 @@ void testMapDistribute()
 }
 
 
+// Print to Perr
+template<class T>
+Ostream& perrInfo(const T& data)
+{
+    Perr<< data;
+    return Perr;
+}
+
+
+// Print to Perr
+template<>
+Ostream& perrInfo(const string& data)
+{
+    Perr<< data << " (size: " << data.size() << ")";
+    return Perr;
+}
+
+
 template<class T>
 void testTransfer(const T& input)
 {
@@ -127,7 +145,8 @@ void testTransfer(const T& input)
 
     if (Pstream::master())
     {
-        Perr<<"test transfer (" << (typeid(T).name()) << "): " << data << nl << endl;
+        Perr<<"test transfer (" << (typeid(T).name()) << "): ";
+        perrInfo(data) << nl << endl;
     }
 
     if (Pstream::myProcNo() != Pstream::masterNo())
@@ -141,7 +160,7 @@ void testTransfer(const T& input)
         Perr<< "slave receiving from master " << Pstream::masterNo() << endl;
         IPstream fromMaster(Pstream::commsTypes::blocking, Pstream::masterNo());
         fromMaster >> data;
-        Perr<< data << endl;
+        perrInfo(data) << endl;
     }
     else
     {
@@ -155,7 +174,7 @@ void testTransfer(const T& input)
             Perr<< "master receiving from slave " << slave << endl;
             IPstream fromSlave(Pstream::commsTypes::blocking, slave);
             fromSlave >> data;
-            Perr<< data << endl;
+            perrInfo(data) << endl;
         }
 
         for
@@ -258,6 +277,15 @@ int main(int argc, char *argv[])
     testTransfer(scalar(3.14159));
     testTransfer(string("test   string"));
     testTransfer(string("  x "));
+
+    {
+        // Slightly roundabout way to construct with a nul in string
+        string str1("embedded. nul character in string");
+        str1[8] = '\0';
+
+        Info<< "len: " << str1.size() << endl;
+        testTransfer(str1);
+    }
     testTransfer(word("3.141 59"));  // bad word, but transfer doesn't care
 
     testTokenized(label(1234));
diff --git a/applications/test/primitives/Test-primitives.C b/applications/test/primitives/Test-primitives.C
index 72017bfee9d32e94053928cca75c90b896ded4ba..d45a9feb73676b2c9a67ea7c0bfb404f465f9b83 100644
--- a/applications/test/primitives/Test-primitives.C
+++ b/applications/test/primitives/Test-primitives.C
@@ -51,18 +51,22 @@ template<class TYPE>
 unsigned testParsing
 (
     TYPE (*function)(const std::string&),
-    const List<Tuple2<std::string, bool>>& tests
+    std::initializer_list
+    <
+        Tuple2<bool, std::string>
+    > tests
 )
 {
     unsigned nFail = 0;
+    string errMsg;
 
     // Expect some failures
     const bool prev = FatalIOError.throwExceptions();
 
-    for (const Tuple2<std::string, bool>& test : tests)
+    for (const Tuple2<bool, std::string>& test : tests)
     {
-        const std::string& str = test.first();
-        const bool expected = test.second();
+        const bool expected = test.first();
+        const std::string& str = test.second();
 
         bool parsed = true;
 
@@ -74,6 +78,7 @@ unsigned testParsing
         catch (Foam::error& err)
         {
             parsed = false;
+            errMsg = err.message();
         }
 
         if (parsed)
@@ -93,12 +98,15 @@ unsigned testParsing
             if (expected)
             {
                 ++nFail;
-                Info<< "(fail) unexpected failure " << str << nl;
+                Info<< "(fail) unexpected";
             }
             else
             {
-                Info<< "(pass) expected failure " << str << nl;
+                Info<< "(pass) expected";
             }
+
+            Info<< " failure " << str
+                << "  >> " << errMsg.c_str() << nl;
         }
     }
 
@@ -113,32 +121,44 @@ int main(int argc, char *argv[])
     unsigned nFail = 0;
 
     {
-        Info<< nl << "Test readDouble:" << nl;
+        Info<< nl << "Test readDouble: (small=" << doubleScalarVSMALL
+            << " great=" << doubleScalarVSMALL << "):" << nl;
         nFail += testParsing
         (
             &readDouble,
             {
-                { "", false },
-                { "  ", false },
-                { " xxx ", false },
-                { " 1234E-", false },
-                { " 1234E junk", false },
-                { " 3.14159 ", true },
-                { " 31.4159E-1 " , true },
+                { false, "" },
+                { false, "  " },
+                { false, " xxx " },
+                { false, " 1234E-" },
+                { false, " 1234E junk" },
+                { true,  " 3.14159 " },
+                { true,  " 31.4159E-1 "  },
+                { false, " 100E1000 "  },
+                { true,  " 1E-40 "  },
+                { true,  " 1E-305 "  },
+                { true,  " 1E-37 "  },
+                { true,  " 1E-300 "  },
             }
         );
     }
 
     {
-        Info<< nl << "Test readFloat:" << nl;
+        Info<< nl << "Test readFloat: (small=" << floatScalarVSMALL
+            << " great=" << floatScalarVGREAT << "):" << nl;
+
         nFail += testParsing
         (
             &readFloat,
             {
-                { " 3.14159 ", true },
-                { " 31.4159E-1 " , true },
-                { " 31.4159E200 " , false },
-                { " 31.4159E20 " , true },
+                { true,  " 3.14159 " },
+                { true,  " 31.4159E-1 "  },
+                { false, " 31.4159E200 "  },
+                { true,  " 31.4159E20 "  },
+                { true,  " 1E-40 "  },
+                { true,  " 1E-305 "  },
+                { true,  " 1E-37 "  },
+                { true,  " 1E-300 "  },
             }
         );
     }
@@ -149,38 +169,46 @@ int main(int argc, char *argv[])
         (
             &readNasScalar,
             {
-                { " 3.14159 ", true },
-                { " 31.4159E-1 " , true },
-                { " 314.159-2 " , true },
-                { " 31.4159E200 " , true },
-                { " 31.4159E20 " , true },
+                { true,  " 3.14159 " },
+                { true,  " 31.4159E-1 "  },
+                { true,  " 314.159-2 "  },
+                { true,  " 31.4159E200 "  },
+                { true,  " 31.4159E20 "  },
+                { true,  " 1E-40 "  },
+                { true,  " 1E-305 "  },
+                { true,  " 1E-37 "  },
+                { true,  " 1E-300 "  },
             }
         );
     }
 
     {
-        Info<< nl << "Test readInt32 (max= " << INT32_MAX << "):" << nl;
+        Info<< nl << "Test readInt32 (max=" << INT32_MAX << "):" << nl;
         nFail += testParsing
         (
             &readInt32,
             {
-                { " 3.14159 ", false },
-                { " 31.4159E-1 " , false },
-                { "100" , true },
-                { "	2147483644" , true },
-                { "   2147483700  " , false },
+                { false, " 3.14159 " },
+                { false, " 31E1 " },
+                { false, " 31.4159E-1 "  },
+                { true,  "100"  },
+                { true,  "	2147483644"  },
+                { false, "   2147483700  "  },
             }
         );
     }
 
     {
-        Info<< nl << "Test readUint32 (max= " << INT32_MAX << "):" << nl;
+        Info<< nl << "Test readUint32 (max="
+            << unsigned(UINT32_MAX) << "):" << nl;
         nFail += testParsing
         (
             &readUint32,
             {
-                { "	2147483644" , true },
-                { "   2147483700  " , true },
+                { true,  "\t2147483644"  },
+                { true,  " 2147483700  "  },
+                { true,  " 4294967295  "  },
+                { false, " 4294968000  "  },
             }
         );
     }
diff --git a/applications/test/regex/Test-regex.C b/applications/test/regex/Test-regex.C
index 6f506f76594bfa2bdda8dcc6437238e2d4c336de..6996d4445cee96fcea1dd060013df1a5750bbdb5 100644
--- a/applications/test/regex/Test-regex.C
+++ b/applications/test/regex/Test-regex.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
     Info<< "Test expressions:" << rawList << endl;
     IOobject::writeDivider(Info) << endl;
 
-    List<string> groups;
+    List<std::string> groups;
 
     // Report matches:
     forAll(rawList, elemI)
@@ -74,7 +74,23 @@ int main(int argc, char *argv[])
                 Info<< "false";
             }
         }
+
         Info<< endl;
+
+        if (false)
+        {
+            regExp re2(std::move(re));
+            Info<<"move construct: " << re.exists() << "/" << re2.exists()
+                << endl;
+
+            re = std::move(re2);
+            Info<<"move assign: " << re.exists() << "/" << re2.exists()
+                << endl;
+
+            re.swap(re2);
+            Info<<"swap: " << re.exists() << "/" << re2.exists()
+                << endl;
+        }
     }
 
     Info<< nl << "test regExp(const char*) ..." << endl;
diff --git a/applications/test/sizeof/Test-sizeof.C b/applications/test/sizeof/Test-sizeof.C
index a884d87fde936261a0bc8dade24510610ccdb814..93358f7af7bf0cccde3ec1b9f1f1d7564e8f5f90 100644
--- a/applications/test/sizeof/Test-sizeof.C
+++ b/applications/test/sizeof/Test-sizeof.C
@@ -61,6 +61,10 @@ int main(int argc, char *argv[])
         nil x;
         cout<<"nil:" << sizeof(x) << nl;
     }
+    {
+        zero x;
+        cout<<"zero:" << sizeof(x) << nl;
+    }
     {
         bool x(0);
         cout<<"bool:" << sizeof(x) << nl;
@@ -93,6 +97,10 @@ int main(int argc, char *argv[])
         cout<<"double:" << sizeof(double) << nl;
     }
 
+    {
+        cout<<"string:" << sizeof(Foam::string) << nl;
+    }
+
 
     Info << "---\nEnd\n" << endl;
 
diff --git a/applications/test/sort/Test-sortList.C b/applications/test/sort/Test-sortList.C
index d92a4a7ad429ba9d1ce16fb0759676e6ac8d24d5..8b208f4f50fce9f0dfd38470b89e4229e535974b 100644
--- a/applications/test/sort/Test-sortList.C
+++ b/applications/test/sort/Test-sortList.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,114 +27,291 @@ Description
 
 #include "SortableList.H"
 #include "ListOps.H"
+#include "HashSet.H"
+#include "stringOps.H"
 
 using namespace Foam;
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // Main program:
 
+
+template<class T>
+void printInfo(const SortableList<T>& list)
+{
+    Info<< "sorted:   " << list << nl
+        << "indices:  " << list.indices() << endl;
+}
+
+
 int main(int argc, char *argv[])
 {
-    labelList orig(8);
-    orig[0] = 7;
-    orig[1] = 9;
-    orig[2] = 1;
-    orig[3] = 2;
-    orig[4] = 4;
-    orig[5] = 7;
-    orig[6] = 4;
-    orig[7] = 0;
+    const labelList orig{7, 9, 1, 2, 4, 7, 4, 0};
 
     labelList order;
 
-    labelList a(orig);
-    sortedOrder(a, order);
+    labelList list1(orig);
+    sortedOrder(list1, order);
 
-    SortableList<label> aReverse(a.size());
-    aReverse = a;
+    SortableList<label> list1r(list1.size());
+    list1r = list1;
 
-    Info<< "unsorted: " << a << endl;
-    sort(a);
-    Info<< "sorted:   " << a << endl;
-    Info<< "indices:  " << order << endl;
+    Info<< "unsorted: " << orig << endl;
+    sort(list1);
+    Info<< "sorted:   " << list1 << nl
+        << "indices:  " << order << endl;
 
-    aReverse.reverseSort();
-    Info<< "reverse sorted:   " << aReverse << endl;
-    Info<< "reverse indices:  " << aReverse.indices() << endl;
+    list1r.reverseSort();
+    Info<< "reverse ..." << nl;
+    printInfo(list1r);
 
-    SortableList<label> b(orig);
-    Info<< "unsorted: " << orig << endl;
-    Info<< "sorted:   " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
+    SortableList<label> list2(orig);
+    Info<< "unsorted: " << orig << nl;
+    printInfo(list2);
 
-    Info<< "shrunk:   " << b.shrink() << endl;
-    Info<< "indices:  " << b.indices() << endl;
+    Info<< "shrunk:   " << list2.shrink() << endl;
+    Info<< "indices:  " << list2.indices() << endl;
 
     // repeat by assignment
-    b = orig;
-    Info<< "unsorted: " << b << endl;
-    b.sort();
+    list2 = orig;
+    Info<< "unsorted: " << list2 << endl;
+    list2.sort();
 
-    Info<< "sorted:   " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
+    printInfo(list2);
 
     // find unique/duplicate values
-    b = orig;
+    list2 = orig;
 
-    Info<< "unsorted: " << b << endl;
-    uniqueOrder(b, order);
+    Info<< "unsorted: " << list2 << endl;
+    uniqueOrder(list2, order);
     Info<< "unique:  " << order << endl;
-    duplicateOrder(b, order);
+    duplicateOrder(list2, order);
     Info<< "duplicate:" << order << endl;
 
     // sort reverse
-    Info<< "unsorted: " << b << endl;
-    b.reverseSort();
-    Info<< "rsort:    " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
+    Info<< "unsorted: " << list2 << endl;
+    list2.reverseSort();
+    Info<< "rsort:    " << list2 << endl;
+    Info<< "indices:  " << list2.indices() << endl;
 
     // transfer assignment
-    a = orig;
-    b.transfer(a);
-    Info<< "unsorted: " << b << endl;
-    b.sort();
+    {
+        list1 = orig;
+        list2.transfer(list1);
+        Info<< "unsorted: " << list2 << endl;
+        list2.sort();
 
-    Info<< "sorted:   " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
+        printInfo(list2);
 
-    a.transfer(b);
+        list1.transfer(list2);
 
-    Info<< "plain:    " << a << endl;
-    Info<< "sorted:   " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
+        Info<< "plain:    " << list1 << endl;
+        printInfo(list2);
+    }
 
     // sort/duplicate/unique with identical values
-    b.setSize(8);
-    b = 5;
+    list2.setSize(8);
+    list2 = 5;
 
-    Info<< "unsorted: " << b << endl;
+    Info<< "unsorted: " << list2 << endl;
 
-    uniqueOrder(b, order);
+    uniqueOrder(list2, order);
     Info<< "unique:  " << order << endl;
-    duplicateOrder(b, order);
+    duplicateOrder(list2, order);
     Info<< "duplicate:" << order << endl;
-    b.sort();
+    list2.sort();
 
-    Info<< "sorted:   " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
+    printInfo(list2);
 
     // with a single value
-    b.setSize(1);
+    list2.setSize(1);
 
-    Info<< "unsorted: " << b << endl;
-    uniqueOrder(b, order);
+    Info<< "unsorted: " << list2 << endl;
+    uniqueOrder(list2, order);
     Info<< "unique:  " << order << endl;
-    duplicateOrder(b, order);
+    duplicateOrder(list2, order);
     Info<< "duplicate:" << order << endl;
-    b.sort();
+    list2.sort();
+
+    printInfo(list2);
+
+    {
+        labelList tmp(orig);
+
+        Info<< nl << "move construct from List: " << tmp << endl;
+        SortableList<label> list3(std::move(tmp));
+
+        Info<< "input:    " << tmp << endl;
+        printInfo(list3);
+
+        list3.reverseSort();
+
+        Info<< nl << "move construct from SortableList: " << list3 << endl;
+
+        SortableList<label> list4(std::move(list3));
+        Info<< "input:   " << list3 << endl;
+        printInfo(list3);
+        printInfo(list4);
+
+        tmp = orig;
+
+        Info<< nl << "move assign from List: " << tmp << endl;
+        list3 = std::move(tmp);
+
+        Info<< "input:    " << tmp << endl;
+        printInfo(list3);
+
+        Info<< nl << "move assign from SortableList: " << list3 << endl;
+        list4 = std::move(list3);
+
+        Info<< "input:    " << list3 << endl;
+        printInfo(list3);
+        printInfo(list4);
+
+        labelList values;
+        Info<< "move to flat-list: " << list4 << endl;
+
+        values = std::move(list4);
+        Info<< "input:    " << list4 << endl;
+        printInfo(list4);
+        Info<< "flat = " << values << endl;
+    }
+
+    // Sort strings
+    {
+        HashSet<string> hashed
+        {
+            "2.txt",
+            "05.txt",
+            "15.txt",
+            "other.bak04",
+            "other.bak1",
+            "file1.txt",
+            "file10.txt",
+            "file2.txt",
+            "file100.txt",
+            "file.txt",
+            "file011.txt",
+            "file15.txt",
+            "file0009.txt",
+            "abcd.txt",
+
+         // Some regular processor directories
+            "processor0",
+            "processor1",
+            "processor9",
+            "processor10",
+            "processor11",
+            "processor20",
+            "processor21",
+            "processor35",
+            "processors",
+
+         // Aggregate processor directories
+            "processor0-31",
+            "processor32-63",
+            "processor64-95",
+            "processor96-127",
+            "processor128-159",
+            "processor160-191",
+            "processor192-223",
+            "processor224-255",
+        };
+
+        Info<< nl << "Test string sorting" << nl << endl;
+
+        // Using hash toc
+        if (true)
+        {
+            Info<< "Unsorted" << hashed.toc() << endl;
+            Info<< "sortedToc" << hashed.sortedToc() << endl;
+            Info<< "natural"
+                << hashed.sortedToc(stringOps::natural_sort()) << endl;
+
+            Info<< "reverse natural"
+                << hashed.sortedToc(stringOps::natural_sort::reverse())
+                << endl;
+        }
+
+        // Normal list
+        if (true)
+        {
+            labelList order;
+
+            List<string> strings(hashed.toc());
+            Info<< nl << "stringList:" << strings << endl;
+
+            sort(strings);
+            Info<< "normal sort:" << strings << endl;
+
+            shuffle(strings);
+            sort(strings, stringOps::natural_sort());
+            Info<< "natural sort:" << strings << endl;
+
+            shuffle(strings);
+            sort(strings, stringOps::natural_sort::reverse());
+            Info<< "reverse natural:" << strings << endl;
+
+            strings = hashed.toc();
+
+            Info<< nl << "test sorted order" << endl;
+            Info<< nl << "list:" << strings << endl;
+
+            sortedOrder(strings, order);
+            Info<< "sortedOrder:" << flatOutput(order) << endl;
+
+            shuffle(strings);
+            sort(strings, stringOps::natural_sort());
+            Info<< "reverse natural:" << strings << endl;
+
+            shuffle(strings);
+            sort(strings, stringOps::natural_sort::reverse());
+            Info<< "reverse natural:" << strings << endl;
+
+            sortedOrder
+            (
+                strings,
+                order,
+                stringOps::natural_sort::less<string>(strings)
+            );
+            Info<< "natural sortedOrder: " << flatOutput(order) << endl;
+        }
+
+        // SortableList
+        if (false)
+        {
+            SortableList<string> sortable;
+            Info<< nl << "Testing sortable list";
+
+            // Assign to ensure list is initially unsorted
+            sortable = hashed.toc();
+            Info<< nl << "input:" << sortable << endl;
+
+            sortable.sort();
+            Info<< nl << "normal:" << sortable << endl;
+
+            // This is still a bother (looks fairly ugly)
+            // so not implemented for now
+
+            ///  // Assign to ensure list is initially unsorted
+            ///  sortable = hashed.toc();
+            ///  sortable.sort
+            ///  (
+            ///      stringOps::natural_sort::less<string>(sortable)
+            ///  );
+            ///  Info<< nl << "natural:" << sortable << endl;
+
+            ///  // Assign to ensure list is initially unsorted
+            ///  sortable = hashed.toc();
+            ///  sortable.sort
+            ///  (
+            ///      stringOps::natural_sort::greater<string>(sortable)
+            ///  );
+            ///  Info<< nl << "natural:" << sortable << endl;
+        }
+
+    }
 
-    Info<< "sorted:   " << b << endl;
-    Info<< "indices:  " << b.indices() << endl;
 
     Info<< "\nEnd\n" << endl;
 
diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C
index 7975620442b1a47db7e6a9916b8ee527f371a2a0..73c703d170b4476a139b0860de91e6daa0bcd9ce 100644
--- a/applications/test/string/Test-string.C
+++ b/applications/test/string/Test-string.C
@@ -69,6 +69,65 @@ int main(int argc, char *argv[])
     Info<<"trimRight: " << stringOps::trimRight(test) << endl;
     Info<<"trim: " << stringOps::trim(test) << endl;
 
+    if (false)
+    {
+        Info<<"test move construct - string size:" << test.size() << nl;
+        string test2(std::move(test));
+
+        Info<<"input size:" << test.size() << nl;
+        Info<<"moved size:" << test2.size() << nl;
+
+        Info<<"test move assign - string sizes:"
+            << test.size() << "/" << test2.size() << nl;
+
+        test = std::move(test2);
+
+        Info<<"input size:" << test.size() << nl;
+        Info<<"moved size:" << test2.size() << nl;
+    }
+
+    if (false)
+    {
+        std::string str("some text");
+
+        Info<<"test move construct to string:" << str.size() << nl;
+
+        Foam::string test2(std::move(str));
+
+        Info<<"input/moved sizes:" << str.size() << "/" << test2.size() << nl;
+
+        str = std::move(test2);
+
+        Info<<"test move assign - sizes:"
+            << str.size() << "/" << test2.size() << nl;
+    }
+
+    if (false)
+    {
+        Foam::string str("thisIsAWord");
+
+        Info<<"test move construct to word:" << str.size() << nl;
+
+        word test2(std::move(str));
+
+        Info<<"input/moved sizes:" << str.size() << "/" << test2.size() << nl;
+
+        str = std::move(test2);
+
+        Info<<"test move assign - sizes:"
+            << str.size() << "/" << test2.size() << nl;
+
+        // move back
+        test2.swap(str);
+
+        Info<<"test move assign - sizes:"
+            << str.size() << "/" << test2.size() << nl;
+
+        string str2(std::move(test2));
+        Info<<"input/moved sizes:" << test2.size() << "/" << str2.size() << nl;
+
+    }
+
     {
         fileName test1("libFooBar.so");
 
diff --git a/applications/test/token/Make/files b/applications/test/token/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..27b95da13e1b3c148e380cb64825dad681a3ae19
--- /dev/null
+++ b/applications/test/token/Make/files
@@ -0,0 +1,3 @@
+Test-token.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-token
diff --git a/applications/test/token/Make/options b/applications/test/token/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..1f502ad153cfa3914fc7f4a23ca520c6c8dddd6a
--- /dev/null
+++ b/applications/test/token/Make/options
@@ -0,0 +1 @@
+/* EXE_INC = */
diff --git a/applications/test/token/Test-token.C b/applications/test/token/Test-token.C
new file mode 100644
index 0000000000000000000000000000000000000000..b8918c54b776b13aec32afd4db7a889f5730dcb8
--- /dev/null
+++ b/applications/test/token/Test-token.C
@@ -0,0 +1,75 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+    Test token construct assign etc.
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "IOobject.H"
+#include "IOstreams.H"
+#include "IFstream.H"
+#include "StringStream.H"
+#include "cpuTime.H"
+#include "DynamicList.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+//  Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noBanner();
+    argList::noParallel();
+
+    argList args(argc, argv, false, true);
+
+    token tok1;
+    Info<< "construct null: " << tok1.info() << endl;
+
+    tok1 = double(3.14159);
+    Info<< "assign double: " << tok1.info() << endl;
+
+    token tok2(tok1);
+    Info<< "copy construct: " << tok2.info() << endl;
+
+    tok1 = word("this-word");
+    Info<< "assign word: " << tok1.info() << endl;
+
+    token tok3(tok1);
+    Info<< "copy construct: " << tok3.info() << endl;
+    Info<< "orig: " << tok1.info() << endl;
+
+    token tok4(std::move(tok1));
+    Info<< "move construct: " << tok4.info() << endl;
+    Info<< "orig: " << tok1.info() << endl;
+
+    tok3 = tok4;
+    Info<< "assign token: " << tok3.info() << endl;
+    Info<< "orig: " << tok4.info() << endl;
+
+    return 0;
+}
+
+// ************************************************************************* //
diff --git a/applications/test/tokenize/Test-tokenize.C b/applications/test/tokenize/Test-tokenize.C
index bd2f84a4820580915d6a71c308aa2f55050e7c0b..f944036d6671903495dece8da7350894c9e8dfbb 100644
--- a/applications/test/tokenize/Test-tokenize.C
+++ b/applications/test/tokenize/Test-tokenize.C
@@ -33,6 +33,7 @@ Description
 #include "IFstream.H"
 #include "StringStream.H"
 #include "cpuTime.H"
+#include "DynamicList.H"
 
 using namespace Foam;
 
@@ -69,6 +70,8 @@ int main(int argc, char *argv[])
 
             IStringStream is(rawArg);
 
+            DynamicList<token> tokens;
+
             while (is.good())
             {
                 token tok(is);
@@ -83,12 +86,23 @@ int main(int argc, char *argv[])
                         << "  lookahead: '" << char(lookahead) << "'"
                         << endl;
                 }
+
+                if (tok.good())
+                {
+                    tokens.append(std::move(tok));
+                    if (verbose)
+                    {
+                        Info<< "after append: " << tok.info() << endl;
+                    }
+                }
             }
 
             if (verbose)
             {
                 Info<< nl;
                 IOobject::writeDivider(Info);
+
+                Info<< "tokenList:" << tokens << endl;
             }
         }
     }
diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C
index be1af08a5497ecf699bc0e539cc57c6501146620..5504e66a1ea931f8bd6e647349eb65631eb828f0 100644
--- a/applications/test/wordRe/Test-wordRe.C
+++ b/applications/test/wordRe/Test-wordRe.C
@@ -56,6 +56,56 @@ int main(int argc, char *argv[])
         {"file[a-b]", wordRe::REGEX},
     };
 
+    if (true)
+    {
+        Info<<"keyType: " << keyre << endl;
+
+        keyType key2(std::move(keyre));
+
+        Info<<"move construct: <" << keyre << "> <" << key2 << ">" << endl;
+
+        keyre = std::move(key2);
+
+        Info<<"move assign: <" << keyre << "> <" << key2 << ">" << endl;
+
+        keyType key3;
+
+        keyre.swap(key3);
+
+        Info<<"swap: <" << keyre << "> <" << key3 << ">" << endl;
+
+        keyre = std::move(key3);
+        Info<<"move assign: <" << keyre << "> <" << key3 << ">" << endl;
+
+        return 0;
+    }
+
+    if (false)
+    {
+        wordRe keyre("y.*", wordRe::REGEX);
+
+        Info<<"wordRe: " << keyre << endl;
+
+        wordRe key2(std::move(keyre));
+
+        Info<<"keyTypes: " << keyre << " " << key2 << endl;
+
+        keyre = std::move(key2);
+
+        Info<<"keyTypes: " << keyre << " " << key2 << endl;
+
+        wordRe key3;
+
+        keyre.swap(key3);
+
+        Info<<"keyTypes: <" << keyre << "> <" << key3 << ">" << endl;
+
+        keyre = std::move(key3);
+        Info<<"keyTypes: <" << keyre << "> <" << key3 << ">" << endl;
+
+        return 0;
+    }
+
     wordRes wrelist(wordrelist);
 
     Info<< "re-list:" << wrelist() << endl;
@@ -76,7 +126,7 @@ int main(int argc, char *argv[])
 
     wre = "this .* file";
 
-    Info<<"substring: " << wre(4) << endl;
+    Info<<"substring: " << wre.substr(4) << endl;
 
     wre.info(Info) << endl;
     wre = s1;
diff --git a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
index 0a2434e987d7b192f3538327815fcd5c56d9c26c..d6a7cffa96e13d9c10f82a371040312e85d45f91 100644
--- a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
+++ b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C
@@ -97,7 +97,7 @@ Foam::label Foam::cellSplitter::newOwner
 
         const cell& cFaces = mesh_.cells()[oldOwn];
 
-        return newCells[findIndex(cFaces, facei)];
+        return newCells[cFaces.find(facei)];
     }
 }
 
@@ -125,7 +125,7 @@ Foam::label Foam::cellSplitter::newNeighbour
 
         const cell& cFaces = mesh_.cells()[oldNbr];
 
-        return newCells[findIndex(cFaces, facei)];
+        return newCells[cFaces.find(facei)];
     }
 }
 
@@ -261,8 +261,8 @@ void Foam::cellSplitter::setRefinement
             // (since newly created cells are stored in cFaces order)
             const labelList& newCells = cellToCells[celli];
 
-            label cell0 = newCells[findIndex(cFaces, face0)];
-            label cell1 = newCells[findIndex(cFaces, face1)];
+            label cell0 = newCells[cFaces.find(face0)];
+            label cell1 = newCells[cFaces.find(face1)];
 
             if (cell0 < cell1)
             {
@@ -271,7 +271,7 @@ void Foam::cellSplitter::setRefinement
 
                 const face& f0 = mesh_.faces()[face0];
 
-                label index = findIndex(f0, e[0]);
+                label index = f0.find(e[0]);
 
                 bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);
 
@@ -317,7 +317,7 @@ void Foam::cellSplitter::setRefinement
 
                 const face& f1 = mesh_.faces()[face1];
 
-                label index = findIndex(f1, e[0]);
+                label index = f1.find(e[0]);
 
                 bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);
 
diff --git a/applications/utilities/mesh/advanced/splitCells/splitCells.C b/applications/utilities/mesh/advanced/splitCells/splitCells.C
index aecc10d2a1c6cf5757f6d5b2264736c87c9861dc..8cc704243dacdfa4e8f6bea44000b8c1e6388141 100644
--- a/applications/utilities/mesh/advanced/splitCells/splitCells.C
+++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C
@@ -225,8 +225,8 @@ bool splitHex
 
         const face& f = faces[facei];
 
-        label fp0 = findIndex(f, e[0]);
-        label fp1 = findIndex(f, e[1]);
+        label fp0 = f.find(e[0]);
+        label fp1 = f.find(e[1]);
 
         if (fp0 == -1)
         {
diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C
index cf878490790ce5e67475cb3a9aa562050ca4b912..ac8a33bcabdb5c3556f8bea5189768d6abb6f2e1 100644
--- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C
+++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C
@@ -136,7 +136,7 @@ label findFace(const primitivePatch& pp, const labelList& meshF)
 
         forAll(f, fp)
         {
-            if (findIndex(meshF, f[fp]) != -1)
+            if (meshF.found(f[fp]))
             {
                 nMatched++;
             }
@@ -168,7 +168,7 @@ label findInternalFace(const primitiveMesh& mesh, const labelList& meshF)
 
         forAll(f, fp)
         {
-            if (findIndex(meshF, f[fp]) != -1)
+            if (meshF.found(f[fp]))
             {
                 nMatched++;
             }
diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C
index 6ad6dfcd433517e33648136f380ca720a883726c..398351e3f803c8eaf20b38e5b38b71feecad6421 100644
--- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C
+++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C
@@ -68,9 +68,11 @@ namespace Foam
         return Hash<face>::operator()(t, 0);
     }
 }
+
 const string SEPARATOR("    -1");
 
-bool isSeparator(const string& line)
+
+bool isSeparator(const std::string& line)
 {
     return line.substr(0, 6) == SEPARATOR;
 }
@@ -100,7 +102,7 @@ label readTag(IFstream& is)
 
     } while (tag == SEPARATOR);
 
-    return readLabel(IStringStream(tag)());
+    return readLabel(tag);
 }
 
 
@@ -144,14 +146,14 @@ void skipSection(IFstream& is)
 }
 
 
-scalar readUnvScalar(const string& unvString)
+scalar readUnvScalar(const std::string& unvString)
 {
     string s(unvString);
 
     s.replaceAll("d", "E");
     s.replaceAll("D", "E");
 
-    return readScalar(IStringStream(s)());
+    return readScalar(s);
 }
 
 
@@ -170,13 +172,13 @@ void readUnits
     string line;
     is.getLine(line);
 
-    label l = readLabel(IStringStream(line.substr(0, 10))());
+    label l = readLabel(line.substr(0, 10));
     Info<< "l:" << l << endl;
 
     string units(line.substr(10, 20));
     Info<< "units:" << units << endl;
 
-    label unitType = readLabel(IStringStream(line.substr(30, 10))());
+    label unitType = readLabel(line.substr(30, 10));
     Info<< "unitType:" << unitType << endl;
 
     // Read lengthscales
@@ -215,7 +217,7 @@ void readPoints
         string line;
         is.getLine(line);
 
-        label pointi = readLabel(IStringStream(line.substr(0, 10))());
+        label pointi = readLabel(line.substr(0, 10));
 
         if (pointi == -1)
         {
@@ -589,7 +591,8 @@ void readDOFS
     is.getLine(line);
     {
         IStringStream lineStr(line);
-        patchNames.append(lineStr);
+        word pName(lineStr);
+        patchNames.append(pName);
     }
 
     Info<< "For DOF set " << group
@@ -805,7 +808,7 @@ int main(int argc, char *argv[])
             )
         );
 
-        if (findIndex(foamVerts, -1) != -1)
+        if (foamVerts.found(-1))
         {
             FatalErrorInFunction
                 << "Cell " << celli
@@ -824,7 +827,7 @@ int main(int argc, char *argv[])
     {
         labelList foamVerts(renumber(unvToFoam, boundaryFaces[bFacei]));
 
-        if (findIndex(foamVerts, -1) != -1)
+        if (foamVerts.found(-1))
         {
             FatalErrorInFunction
                 << "Boundary face " << bFacei
diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H
index 5e3afb3b3a898523dc1d740b9975960a61fe6af8..57919543e57d1797cf191cda930308213ecda7a5 100644
--- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H
+++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H
@@ -363,7 +363,7 @@ if
 
     if (pFaces[LINER][0].size() != newLinerFaces.size())
     {
-        Info<< "Transfered " << pFaces[LINER][0].size() - newLinerFaces.size()
+        Info<< "Transferred " << pFaces[LINER][0].size() - newLinerFaces.size()
             << " faces from liner region to cylinder head" << endl;
         pFaces[LINER][0] = newLinerFaces;
     }
@@ -392,7 +392,7 @@ if
 
     if (pFaces[CYLINDERHEAD][0].size() != newCylinderHeadFaces.size())
     {
-        Info<< "Transfered faces from cylinder-head region to linder" << endl;
+        Info<< "Transferred faces from cylinder-head region to linder" << endl;
         pFaces[CYLINDERHEAD][0] = newCylinderHeadFaces;
     }
 }
diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C
index fbcfe5c9082095463c11f2fd47739400bc837545..5ba1afc722b782c4779c2140a30610e319e5d80a 100644
--- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C
+++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C
@@ -29,7 +29,7 @@ License
 
 bool Foam::extrudedMesh::sameOrder(const face& f, const edge& e)
 {
-    label i = findIndex(f, e[0]);
+    label i = f.find(e[0]);
 
     label nextI = (i == f.size()-1 ? 0 : i+1);
 
diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C
index 2bbbf4a9f939521010a9afbea28e30ea5f9cb9f0..c36844e47ddd574731148c56580017b063945ff5 100644
--- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C
+++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C
@@ -464,7 +464,7 @@ public:
         {
             forAll(y, yi)
             {
-                if (findIndex(x, y[yi]) == -1)
+                if (!x.found(y[yi]))
                 {
                     label sz = x.size();
                     x.setSize(sz+1);
@@ -2488,14 +2488,14 @@ int main(int argc, char *argv[])
 
         if (isA<mappedWallPolyPatch>(pp))
         {
-            if (findIndex(interRegionTopPatch, patchi) != -1)
+            if (interRegionTopPatch.found(patchi))
             {
-                label zoneI = findIndex(interRegionTopPatch, patchi);
+                label zoneI = interRegionTopPatch.find(patchi);
                 topOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp);
             }
-            else if (findIndex(interRegionBottomPatch, patchi) != -1)
+            else if (interRegionBottomPatch.found(patchi))
             {
-                label zoneI = findIndex(interRegionBottomPatch, patchi);
+                label zoneI = interRegionBottomPatch.find(patchi);
                 bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp);
             }
         }
diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C
index 20ebc345168de757765ab8f15f3856e082a04edc..dc6a68444fc29c50f7f002019c80ea32ed1be309 100644
--- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C
+++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C
@@ -45,7 +45,7 @@ void Foam::patchToPoly2DMesh::flipFaceOrder()
 
         const face& f = localFaces[edgeOwner];
 
-        label fp = findIndex(f, e[0]);
+        label fp = f.find(e[0]);
 
         if (f.nextLabel(fp) != e[1])
         {
@@ -207,7 +207,7 @@ void Foam::patchToPoly2DMesh::addPatchFacesToOwner()
             {
                 const face& f = faces[owner_[bEdgeI]];
 
-                label fp = findIndex(f, e[0]);
+                label fp = f.find(e[0]);
 
                 newOwner[bFacei] = owner_[bEdgeI];
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options b/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options
index 386b66908388374398cef7b824739b8b7b58fca1..703a72fcc0fbc9a05a1980647a460d4b1fcc851c 100644
--- a/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/Make/options
@@ -28,5 +28,6 @@ EXE_LIBS =  \
     -lmeshTools \
     -lsampling \
     -ldecompositionMethods \
-    -L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \
     -ldynamicMesh
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C
index d9bf097d1d6d7023a378ca7d53232c0391795e03..302bd61b55360b706d8ee68df909e1cc79fcb2c2 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C
@@ -282,7 +282,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
 
         forAll(surface_, fI)
         {
-            faces[fI] = surface_.triSurface::operator[](fI).triFaceFace();
+            faces[fI] = surface_.triSurface::operator[](fI);
         }
 
         vtkSurfaceWriter().write
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C
index 141f36b93372175d0355c4770280843167ec42af..cc87adcb70269a011e9684212f3a3ae2cb628992 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C
@@ -660,7 +660,7 @@ Foam::face Foam::conformalVoronoiMesh::buildDualFace
 
             if (cc1I != cc2I)
             {
-                if (findIndex(verticesOnFace, cc1I) == -1)
+                if (!verticesOnFace.found(cc1I))
                 {
                     nUniqueVertices++;
                 }
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
index eb3ab47806c25a7b09d788a13a7bd1065fe57547..97e076055757c38c55f6c4107cbae4f75be21599 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
@@ -2119,8 +2119,8 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
 
                         patchIndex = max
                         (
-                            findIndex(procNeighbours, vA->procIndex()),
-                            findIndex(procNeighbours, vB->procIndex())
+                            procNeighbours.find(vA->procIndex()),
+                            procNeighbours.find(vB->procIndex())
                         );
 
                         // The lower processor index is the owner of the
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H
index 929eeb306b3a599b551453aeb583867a448be833..7f458dbed698f865881b6d111dd7f6833781f0b9 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H
@@ -465,12 +465,12 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
 
     forAll(c1Procs, aPI)
     {
-        if (findIndex(procsAttached, c1Procs[aPI] == -1))
+        if (!procsAttached.found(c1Procs[aPI]))
         {
             procsAttached.append(c1Procs[aPI]);
         }
 
-        if (findIndex(procsAttached, c2Procs[aPI] == -1))
+        if (!procsAttached.found(c2Procs[aPI]))
         {
             procsAttached.append(c2Procs[aPI]);
         }
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C
index ea6efff4f52260d4f9e5ccbfb029f5fde4d5bc20..c589f071d85ab4fce671bd602850218b360719d5 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C
@@ -306,7 +306,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
 //            )()
 //        );
 //
-//        label pointi = findIndex(pointDualAddressing, -1);
+//        label pointi = pointDualAddressing.find(-1);
 //        if (pointi != -1)
 //        {
 //            WarningInFunction
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C
index 99f28712983dc5f523100053d621cf90fd1ff28d..1f42b3e429d3fc0ad7473e352055c29e3f61025d 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C
@@ -471,7 +471,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
         // a faceZone
         if (surfHit.size() == 1 && surfHit[0].hit())
         {
-            if (findIndex(unclosedSurfaces, hitSurface[0]) != -1)
+            if (unclosedSurfaces.found(hitSurface[0]))
             {
                 vectorField norm;
                 geometryToConformTo().getNormal
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options
index 40373bec9dd802d38d751eab54dd7ef83d20045f..772de8d78a407a4ae2a62eac24ac84a8940a7d5f 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options
@@ -31,5 +31,6 @@ EXE_LIBS = \
     -lsampling \
     -ldecompositionMethods \
     -ldecompose \
-    -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp -lscotchDecomp \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \
     -ldynamicMesh
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
index 410182e01c2a68cda0484476d507ed1731a60bfb..ac840a07f74b0b5497ddf80e07c9f2ca638000fd 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
@@ -721,7 +721,7 @@ int main(int argc, char *argv[])
         isoFaces.setSize(iso.size());
         forAll(isoFaces, i)
         {
-            isoFaces[i] = iso[i].triFaceFace();
+            isoFaces[i] = iso[i];
         }
         isoPoints = iso.points();
     }
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options
index 66ddf81aac5a4b6b0d2321dbea504676c843aa89..67cd78a01af0213fad1ebabaebda4c75f5fd023e 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/Make/options
@@ -18,6 +18,8 @@ EXE_LIBS = \
     -L$(FASTDUALOCTREE_SRC_PATH) -lperf_main \
     -lGL \
     -lconformalVoronoiMesh \
-    -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lscotchDecomp \
+    -ldecompositionMethods \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lscotchDecomp \
     -lmeshTools \
     -ldynamicMesh
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options
index 1b509ac9df0949d66b38e630a9831798b859540f..ed15cdf94e31e764f44b6eae0b564f8e23ffb734 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options
@@ -31,4 +31,5 @@ EXE_LIBS = \
     -lsampling \
     -ldynamicMesh \
     -ldecompositionMethods \
-    -L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C
index 0e8d4963a5697df780c83482c13622ae2fc97c48..1e198578e90b902fad9cc73dc85c066f15f33f96 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/shortEdgeFilter2D.C
@@ -43,7 +43,7 @@ void Foam::shortEdgeFilter2D::addRegion
     {
         bPointRegions.append(regionI);
     }
-    else if (findIndex(bPointRegions, regionI) == -1)
+    else if (!bPointRegions.found(regionI))
     {
         bPointRegions.append(regionI);
     }
diff --git a/applications/utilities/mesh/generation/snappyHexMesh/Make/options b/applications/utilities/mesh/generation/snappyHexMesh/Make/options
index bb863797faeb443c5d540883c02023ecf37b864c..ed8acb579c14b1eb59551c4a5935b8c73c7bab2c 100644
--- a/applications/utilities/mesh/generation/snappyHexMesh/Make/options
+++ b/applications/utilities/mesh/generation/snappyHexMesh/Make/options
@@ -13,9 +13,8 @@ EXE_INC = \
 EXE_LIBS = \
     -lfiniteVolume \
     -ldecompositionMethods \
-    -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
-    /* note: scotch < 6.0 does not like both scotch and ptscotch together */ \
-    -lscotchDecomp \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \
     -lmeshTools \
     -ldynamicMesh \
     -ldecompose \
diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict
index bf257a8ff55b8cfa687a2c9400cace03604bdc89..3cc156d30c3a2f34bcc174b9d35ed35b7af2ffba 100644
--- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict
+++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict
@@ -101,8 +101,11 @@ castellatedMeshControls
 
     // The surface refinement loop might spend lots of iterations refining just
     // a few cells. This setting will cause refinement to stop if
-    // <= minimumRefine cells are selected for refinement. Note: it will
-    // at least do one iteration (unless the number of cells to refine is 0)
+    // <= minRefinementCells cells are selected for refinement. Note: it will
+    // at least do one iteration unless
+    //  a: the number of cells to refine is 0
+    //  b: minRefinementCells = -1. This is a special value indicating
+    //     no refinement.
     minRefinementCells 0;
 
     // Allow a certain level of imbalance during refining
@@ -375,6 +378,14 @@ castellatedMeshControls
     // Optional: do not refine surface cells with opposite faces of
     //           differing refinement levels
     //interfaceRefine false;
+
+    // Optional: use an erosion instead of region assignment to allocate
+    //           left-over cells to the background region (i.e. make cellZones
+    //           consistent with the intersections of the surface).
+    //           Erosion is specified as a number of erosion iterations.
+    //           Erosion has less chance of bleeding and changing the zone
+    //           for a complete region.
+    //nCellZoneErodeIter 2;
 }
 
 // Settings for the snapping.
@@ -448,7 +459,9 @@ snapControls
         //- When splitting the minimum area ratio of faces. If face split
         //  causes ratio of area less than this do not split. Default is 0.3
         //minAreaRatio 0.3;
-
+        //- Attract points only to the surface they originate from. Default
+        //  false. This can improve snapping of intersecting surfaces.
+        //  strictRegionSnap true;
 }
 
 // Settings for the layer addition.
diff --git a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C
index e813382bbecef2bf21d60141f26fe00d29c701b0..b90b4e28128bbd91e32a83f09b329b9612222655 100644
--- a/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C
+++ b/applications/utilities/mesh/manipulation/autoPatch/autoPatch.C
@@ -130,7 +130,7 @@ int main(int argc, char *argv[])
     while (true)
     {
         // Find first unset face.
-        label unsetFacei = findIndex(patchIDs, -1);
+        label unsetFacei = patchIDs.find(-1);
 
         if (unsetFacei == -1)
         {
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
index b68047b11db0f425641cf7d2d73387096f6bee0d..c9b6475f5e158f5086b14a4a96a18d7c9abea54c 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2015-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -104,7 +104,7 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
         << "    internal faces:   " << nIntFaces << nl
         << "    cells:            " << nCells << nl
         << "    faces per cell:   "
-        << scalar(nFaces + nIntFaces)/max(1, nCells) << nl
+        << (scalar(nFaces) + scalar(nIntFaces))/max(1, nCells) << nl
         << "    boundary patches: " << mesh.boundaryMesh().size() << nl
         << "    point zones:      " << mesh.pointZones().size() << nl
         << "    face zones:       " << mesh.faceZones().size() << nl
diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C
index 67eb9f5c7b7897c5f9f258affa42862d9c639718..24c6071423ee1dfc4cd05b37825538beaca7a3b8 100644
--- a/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C
+++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergeMeshes.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -84,6 +84,12 @@ int main(int argc, char *argv[])
         "name",
         "specify alternative mesh region for the additional mesh"
     );
+    argList::addOption
+    (
+        "resultTime",
+        "time",
+        "specify a time for the resulting mesh"
+    );
 
     argList args(argc, argv);
     if (!args.check())
@@ -94,20 +100,29 @@ int main(int argc, char *argv[])
     const bool overwrite = args.optionFound("overwrite");
 
     fileName masterCase = args[1];
-    word masterRegion = polyMesh::defaultRegion;
-    args.optionReadIfPresent("masterRegion", masterRegion);
-
     fileName addCase = args[2];
-    word addRegion = polyMesh::defaultRegion;
-    args.optionReadIfPresent("addRegion", addRegion);
+
+    const word masterRegion =
+        args.optionLookupOrDefault<word>
+        (
+            "masterRegion",
+            polyMesh::defaultRegion
+        );
+
+    const word addRegion =
+        args.optionLookupOrDefault<word>
+        (
+            "masterRegion",
+            polyMesh::defaultRegion
+        );
 
     // Since we don't use argList processor directory detection, add it to
     // the casename ourselves so it triggers the logic inside TimePath.
     const fileName& cName = args.caseName();
-    std::string::size_type pos = cName.find("processor");
+    const auto pos = cName.find("processor");
     if (pos != string::npos && pos != 0)
     {
-        fileName processorName = cName.substr(pos, cName.size()-pos);
+        fileName processorName = cName.substr(pos);
         masterCase += '/' + processorName;
         addCase += '/' + processorName;
     }
@@ -133,11 +148,8 @@ int main(int argc, char *argv[])
             runTimeMaster
         )
     );
-    const word oldInstance = masterMesh.pointsInstance();
-
 
     Info<< "Reading mesh to add for time = " << runTimeToAdd.timeName() << nl;
-
     Info<< "Create mesh\n" << endl;
     polyMesh meshToAdd
     (
@@ -149,7 +161,19 @@ int main(int argc, char *argv[])
         )
     );
 
-    if (!overwrite)
+    word meshInstance = masterMesh.pointsInstance();
+
+    const bool specifiedInstance =
+    (
+        !overwrite
+     && args.optionReadIfPresent("resultTime", meshInstance)
+    );
+
+    if (specifiedInstance)
+    {
+        runTimeMaster.setTime(instant(meshInstance), 0);
+    }
+    else if (!overwrite)
     {
         runTimeMaster++;
     }
@@ -159,9 +183,9 @@ int main(int argc, char *argv[])
     masterMesh.addMesh(meshToAdd);
     masterMesh.merge();
 
-    if (overwrite)
+    if (overwrite || specifiedInstance)
     {
-        masterMesh.setInstance(oldInstance);
+        masterMesh.setInstance(meshInstance);
     }
 
     masterMesh.write();
diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C
index 1a4deffd5fc589ff05376a26baef804fed3191fb..72f0a675d54347be198a988e47f9ec356a3286b8 100644
--- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C
+++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C
@@ -229,35 +229,23 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
     if (curPointZoneNames.size())
     {
         pointZoneNames_.setCapacity(2*curPointZoneNames.size());
-    }
-
-    forAll(curPointZoneNames, zoneI)
-    {
-        pointZoneNames_.append(curPointZoneNames[zoneI]);
+        pointZoneNames_.append(curPointZoneNames);
     }
 
     // Face zones
     wordList curFaceZoneNames = faceZones().names();
-
     if (curFaceZoneNames.size())
     {
         faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
-    }
-    forAll(curFaceZoneNames, zoneI)
-    {
-        faceZoneNames_.append(curFaceZoneNames[zoneI]);
+        faceZoneNames_.append(curFaceZoneNames);
     }
 
     // Cell zones
     wordList curCellZoneNames = cellZones().names();
-
     if (curCellZoneNames.size())
     {
         cellZoneNames_.setCapacity(2*curCellZoneNames.size());
-    }
-    forAll(curCellZoneNames, zoneI)
-    {
-        cellZoneNames_.append(curCellZoneNames[zoneI]);
+        cellZoneNames_.append(curCellZoneNames);
     }
 }
 
diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H
index 6ce6f6e4efc87c70ff42181806a00972e775bed3..94a934b22bcc3e045b4cbaa78623507e944eec01 100644
--- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H
+++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H
@@ -77,10 +77,10 @@ class mergePolyMesh
     // Private Member Functions
 
         //- Disallow default bitwise copy construct
-        mergePolyMesh(const mergePolyMesh&);
+        mergePolyMesh(const mergePolyMesh&) = delete;
 
         //- Disallow default bitwise assignment
-        void operator=(const mergePolyMesh&);
+        void operator=(const mergePolyMesh&) = delete;
 
 
         //- Return patch index given a name and type
diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C
index 01c5f5b3f1d229679ff08908a996fe40d64c70a0..52198fb3053df09b9f6d179912188bc651f3955f 100644
--- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C
+++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C
@@ -137,7 +137,7 @@ Foam::label Foam::meshDualiser::findDualCell
     }
     else
     {
-        label index = findIndex(mesh_.pointCells()[pointi], celli);
+        label index = mesh_.pointCells()[pointi].find(celli);
 
         return dualCells[index];
     }
@@ -421,7 +421,7 @@ void Foam::meshDualiser::createFacesAroundEdge
     }
     if (faceToDualPoint_[ie.faceLabel()] != -1)
     {
-        doneEFaces[findIndex(eFaces, ie.faceLabel())] = true;
+        doneEFaces[eFaces.find(ie.faceLabel())] = true;
         verts.append(faceToDualPoint_[ie.faceLabel()]);
     }
     if (cellToDualPoint_[ie.cellLabel()] != -1)
@@ -439,7 +439,7 @@ void Foam::meshDualiser::createFacesAroundEdge
         label facei = ie.faceLabel();
 
         // Mark face as visited.
-        doneEFaces[findIndex(eFaces, facei)] = true;
+        doneEFaces[eFaces.find(facei)] = true;
 
         if (faceToDualPoint_[facei] != -1)
         {
@@ -513,7 +513,7 @@ void Foam::meshDualiser::createFacesAroundEdge
             {
                 label startDual = faceToDualPoint_[startFaceLabel];
 
-                if (startDual != -1 && findIndex(verts, startDual) == -1)
+                if (startDual != -1 && !verts.found(startDual))
                 {
                     verts.append(startDual);
                 }
@@ -666,7 +666,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
 
         while (true)
         {
-            label index = findIndex(pFaces, facei-pp.start());
+            label index = pFaces.find(facei-pp.start());
 
             // Has face been visited already?
             if (donePFaces[index])
@@ -682,7 +682,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
 
             // Get the edge before the patchPointi
             const face& f = mesh_.faces()[facei];
-            label fp = findIndex(f, pointi);
+            label fp = f.find(pointi);
             label prevFp = f.rcIndex(fp);
             label edgeI = mesh_.faceEdges()[facei][prevFp];
 
@@ -763,7 +763,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
 
         // Find edge between pointi and next point on face.
         const labelList& fEdges = mesh_.faceEdges()[facei];
-        label nextEdgeI = fEdges[findIndex(mesh_.faces()[facei], pointi)];
+        label nextEdgeI = fEdges[mesh_.faces()[facei].find(pointi)];
         if (edgeToDualPoint_[nextEdgeI] != -1)
         {
             verts.append(edgeToDualPoint_[nextEdgeI]);
@@ -771,7 +771,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
 
         do
         {
-            label index = findIndex(pFaces, facei-pp.start());
+            label index = pFaces.find(facei-pp.start());
 
             // Has face been visited already?
             if (donePFaces[index])
@@ -786,7 +786,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
             // Find edge before pointi on facei
             const labelList& fEdges = mesh_.faceEdges()[facei];
             const face& f = mesh_.faces()[facei];
-            label prevFp = f.rcIndex(findIndex(f, pointi));
+            label prevFp = f.rcIndex(f.find(pointi));
             label edgeI = fEdges[prevFp];
 
             if (edgeToDualPoint_[edgeI] != -1)
@@ -912,7 +912,7 @@ void Foam::meshDualiser::setRefinement
         {
             featureFaceSet[featureFaces[i]] = true;
         }
-        label facei = findIndex(featureFaceSet, false);
+        label facei = featureFaceSet.find(false);
 
         if (facei != -1)
         {
@@ -929,7 +929,7 @@ void Foam::meshDualiser::setRefinement
         {
             featureEdgeSet[featureEdges[i]] = true;
         }
-        label edgeI = findIndex(featureEdgeSet, false);
+        label edgeI = featureEdgeSet.find(false);
 
         if (edgeI != -1)
         {
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options
index f073a1c4140abf625f7d2513c66f4bb933aa27ed..e2343e6ee6953e83522537601ec66d961244b7a5 100644
--- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options
+++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options
@@ -18,4 +18,5 @@ EXE_LIBS = \
     -lreconstruct \
     $(LINK_FLAGS) \
     -ldecompositionMethods \
-    -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lscotchDecomp
diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
index 0e1f3c253c798041a153e6e94c65c69a1d1f5c17..5326981c9bb51e4fb312ac190f3c989e1f0f40a4 100644
--- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
+++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
@@ -1574,7 +1574,7 @@ int main(int argc, char *argv[])
             << " This requires all"
             << " cells to be in one and only one cellZone." << nl << endl;
 
-        label unzonedCelli = findIndex(zoneID, -1);
+        label unzonedCelli = zoneID.find(-1);
         if (unzonedCelli != -1)
         {
             FatalErrorInFunction
@@ -1599,7 +1599,7 @@ int main(int argc, char *argv[])
     }
     else if (useCellZonesFile)
     {
-        const word zoneFile = args.option("cellZonesFileOnly");
+        const word zoneFile(args["cellZonesFileOnly"]);
         Info<< "Reading split from cellZones file " << zoneFile << endl
             << "This requires all"
             << " cells to be in one and only one cellZone." << nl << endl;
@@ -1623,7 +1623,7 @@ int main(int argc, char *argv[])
         labelList newNeiZoneID(mesh.nFaces()-mesh.nInternalFaces());
         getZoneID(mesh, newCellZones, newZoneID, newNeiZoneID);
 
-        label unzonedCelli = findIndex(newZoneID, -1);
+        label unzonedCelli = newZoneID.find(-1);
         if (unzonedCelli != -1)
         {
             FatalErrorInFunction
diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
index 1fa978d1259c95e8f8e92591cab8fc110045973c..ca0289a10e50a3a8c3407530c6e5b177ab401362 100644
--- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
+++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,7 +27,6 @@ Application
 Group
     grpMeshManipulationUtilities
 
-
 Description
     'Stitches' a mesh.
 
@@ -76,100 +75,102 @@ Description
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-label addPointZone(const polyMesh& mesh, const word& name)
+label addPointZone(polyMesh& mesh, const word& name)
 {
-    label zoneID = mesh.pointZones().findZoneID(name);
+    pointZoneMesh& zones = mesh.pointZones();
+    label zoneID = zones.findZoneID(name);
 
     if (zoneID != -1)
     {
-        Info<< "Reusing existing pointZone "
-            << mesh.pointZones()[zoneID].name()
+        Info<< "Reusing existing pointZone " << zones[zoneID].name()
             << " at index " << zoneID << endl;
+
+        return zoneID;
     }
-    else
-    {
-        pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh).pointZones();
-        zoneID = pointZones.size();
-        Info<< "Adding pointZone " << name << " at index " << zoneID << endl;
 
-        pointZones.setSize(zoneID+1);
-        pointZones.set
+    zoneID = zones.size();
+    Info<< "Adding pointZone " << name << " at index " << zoneID << endl;
+
+    zones.setSize(zoneID+1);
+    zones.set
+    (
+        zoneID,
+        new pointZone
         (
+            name,
+            labelList(0),
             zoneID,
-            new pointZone
-            (
-                name,
-                labelList(0),
-                zoneID,
-                pointZones
-            )
-        );
-    }
+            zones
+        )
+    );
+
     return zoneID;
 }
 
 
-label addFaceZone(const polyMesh& mesh, const word& name)
+label addFaceZone(polyMesh& mesh, const word& name)
 {
-    label zoneID = mesh.faceZones().findZoneID(name);
+    faceZoneMesh& zones = mesh.faceZones();
+    label zoneID = zones.findZoneID(name);
 
     if (zoneID != -1)
     {
-        Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name()
+        Info<< "Reusing existing faceZone " << zones[zoneID].name()
             << " at index " << zoneID << endl;
+
+        return zoneID;
     }
-    else
-    {
-        faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh).faceZones();
-        zoneID = faceZones.size();
-        Info<< "Adding faceZone " << name << " at index " << zoneID << endl;
 
-        faceZones.setSize(zoneID+1);
-        faceZones.set
+    zoneID = zones.size();
+    Info<< "Adding faceZone " << name << " at index " << zoneID << endl;
+
+    zones.setSize(zoneID+1);
+    zones.set
+    (
+        zoneID,
+        new faceZone
         (
+            name,
+            labelList(0),
+            boolList(),
             zoneID,
-            new faceZone
-            (
-                name,
-                labelList(0),
-                boolList(),
-                zoneID,
-                faceZones
-            )
-        );
-    }
+            zones
+        )
+    );
+
     return zoneID;
 }
 
 
-label addCellZone(const polyMesh& mesh, const word& name)
+label addCellZone(polyMesh& mesh, const word& name)
 {
-    label zoneID = mesh.cellZones().findZoneID(name);
+    cellZoneMesh& zones = mesh.cellZones();
+    label zoneID = zones.findZoneID(name);
 
     if (zoneID != -1)
     {
-        Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name()
+        Info<< "Reusing existing cellZone " << zones[zoneID].name()
             << " at index " << zoneID << endl;
+
+        return zoneID;
     }
-    else
-    {
-        cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh).cellZones();
-        zoneID = cellZones.size();
-        Info<< "Adding cellZone " << name << " at index " << zoneID << endl;
 
-        cellZones.setSize(zoneID+1);
-        cellZones.set
+    zoneID = zones.size();
+    Info<< "Adding cellZone " << name << " at index " << zoneID << endl;
+
+    zones.setSize(zoneID+1);
+    zones.set
+    (
+        zoneID,
+        new cellZone
         (
+            name,
+            labelList(0),
             zoneID,
-            new cellZone
-            (
-                name,
-                labelList(0),
-                zoneID,
-                cellZones
-            )
-        );
-    }
+            zones
+        )
+    );
+
     return zoneID;
 }
 
@@ -330,7 +331,8 @@ int main(int argc, char *argv[])
         isf[i] = masterPatch.start() + i;
     }
 
-    polyTopoChanger stitcher(mesh);
+    polyTopoChanger stitcher(mesh, IOobject::NO_READ);
+    stitcher.clear();
     stitcher.setSize(1);
 
     mesh.pointZones().clearAddressing();
@@ -340,13 +342,9 @@ int main(int argc, char *argv[])
     if (perfectCover)
     {
         // Add empty zone for resulting internal faces
-        label cutZoneID = addFaceZone(mesh, cutZoneName);
+        const label cutZoneID = addFaceZone(mesh, cutZoneName);
 
-        mesh.faceZones()[cutZoneID].resetAddressing
-        (
-            isf,
-            boolList(masterPatch.size(), false)
-        );
+        mesh.faceZones()[cutZoneID].resetAddressing(isf.xfer(), false);
 
         // Add the perfect interface mesh modifier
         stitcher.set
@@ -370,11 +368,7 @@ int main(int argc, char *argv[])
 
         label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone");
 
-        mesh.faceZones()[masterZoneID].resetAddressing
-        (
-            isf,
-            boolList(masterPatch.size(), false)
-        );
+        mesh.faceZones()[masterZoneID].resetAddressing(isf.xfer(), false);
 
         // Slave patch
         const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName];
@@ -387,19 +381,11 @@ int main(int argc, char *argv[])
         }
 
         label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone");
-        mesh.faceZones()[slaveZoneID].resetAddressing
-        (
-            osf,
-            boolList(slavePatch.size(), false)
-        );
+        mesh.faceZones()[slaveZoneID].resetAddressing(osf.xfer(), false);
 
         // Add empty zone for cut faces
-        label cutZoneID = addFaceZone(mesh, cutZoneName);
-        mesh.faceZones()[cutZoneID].resetAddressing
-        (
-            labelList(0),
-            boolList(0, false)
-        );
+        const label cutZoneID = addFaceZone(mesh, cutZoneName);
+        mesh.faceZones()[cutZoneID].resetAddressing(labelList(0), false);
 
 
         // Add the sliding interface mesh modifier
@@ -428,7 +414,6 @@ int main(int argc, char *argv[])
         );
     }
 
-
     // Search for list of objects for this time
     IOobjectList objects(mesh, runTime.timeName());
 
@@ -449,7 +434,7 @@ int main(int argc, char *argv[])
     PtrList<volTensorField> volTensorFields;
     ReadFields(mesh, objects, volTensorFields);
 
-    //- Uncomment if you want to interpolate surface fields (usually bad idea)
+    //- Uncomment if you want to interpolate surface fields (usually a bad idea)
     //Info<< "Reading all current surfaceFields" << endl;
     //PtrList<surfaceScalarField> surfaceScalarFields;
     //ReadFields(mesh, objects, surfaceScalarFields);
@@ -483,7 +468,7 @@ int main(int argc, char *argv[])
     // Bypass runTime write (since only writes at writeTime)
     if
     (
-       !runTime.objectRegistry::writeObject
+        !runTime.objectRegistry::writeObject
         (
             runTime.writeFormat(),
             IOstream::currentVersion,
diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
index 2947edb02b14a4c61c7281b3516fd7e4d3adde1e..2846045f6883f12f48fb39b3dd08ce49a8f54b04 100644
--- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
+++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
@@ -369,9 +369,6 @@ int main(int argc, char *argv[])
     #include "createTime.H"
     runTime.functionObjects().off();
 
-    Foam::word meshRegionName = polyMesh::defaultRegion;
-    args.optionReadIfPresent("region", meshRegionName);
-
     #include "createNamedMesh.H"
 
     const word setName = args[1];
diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C
index b082bf39c2bd9d826b0e53b1c29cbbc64843966f..e2cf5571ecd30f1aa42558ac0316ba71d8e20b39 100644
--- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C
+++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C
@@ -35,7 +35,7 @@ Usage
     Options are:
 
     -translate vector
-        Translates the points by the given vector,
+        Translates the points by the given vector before rotations
 
     -rotate (vector vector)
         Rotates the points from the first vector to the second,
@@ -145,45 +145,44 @@ int main(int argc, char *argv[])
 {
     argList::addNote
     (
-        "Transform (translate/rotate/scale) mesh points.\n"
-        "Note: roll=rotation about x, pitch=rotation about y, "
-        "yaw=rotation about z"
+        "Transform (translate / rotate / scale) mesh points.\n"
+        "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
     );
     argList::addOption
     (
         "translate",
         "vector",
-        "translate by the specified <vector> - eg, '(1 0 0)'"
+        "Translate by specified <vector> - eg, '(1 0 0)' before rotations"
     );
     argList::addOption
     (
         "rotate",
         "(vectorA vectorB)",
-        "transform in terms of a rotation between <vectorA> and <vectorB> "
+        "Transform as a rotation between <vectorA> and <vectorB> "
         "- eg, '( (1 0 0) (0 0 1) )'"
     );
     argList::addOption
     (
         "rollPitchYaw",
         "vector",
-        "rotate by '(roll pitch yaw)' in degrees"
+        "Rotate by '(roll pitch yaw)' in degrees"
     );
     argList::addOption
     (
         "yawPitchRoll",
         "vector",
-        "rotate by '(yaw pitch roll)' in degrees"
+        "Rotate by '(yaw pitch roll)' in degrees"
     );
     argList::addBoolOption
     (
         "rotateFields",
-        "read and transform vector and tensor fields too"
+        "Read and transform vector and tensor fields too"
     );
     argList::addOption
     (
         "scale",
         "scalar | vector",
-        "scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
+        "Scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
         "use either (0.001 0.001 0.001)' or simply '0.001'"
     );
 
diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C
index e4c31862614e380aafdfe8c12f0c9031308b9c8f..57210c5a576618100107d2939d802462ed5becfd 100644
--- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C
+++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2016-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -33,7 +33,7 @@ Usage
       - \par -entry \<name\>
         Selects an entry
 
-      - \par -keywords \<name\>
+      - \par -keywords
         Prints the keywords (of the selected entry or of the top level if
         no entry was selected
 
@@ -50,6 +50,10 @@ Usage
         Write differences with respect to the specified dictionary
         (or sub entry if -entry specified)
 
+      - \par -diffEtc \<dictionary\>
+        Write differences with respect to the specified dictionary
+        (or sub entry if -entry specified)
+
       - \par -expand
         Read the specified dictionary file, expand the macros etc. and write
         the resulting dictionary to standard output.
@@ -90,13 +94,13 @@ Usage
 
       - Write the differences with respect to a template dictionary:
         \verbatim
-          foamDictionary 0/U -diff $FOAM_ETC/templates/closedVolume/0/U
+          foamDictionary 0/U -diffEtc templates/closedVolume/0/U
         \endverbatim
 
       - Write the differences in boundaryField with respect to a
         template dictionary:
         \verbatim
-          foamDictionary 0/U -diff $FOAM_ETC/templates/closedVolume/0/U \
+          foamDictionary 0/U -diffEtc templates/closedVolume/0/U \
             -entry boundaryField
         \endverbatim
 
@@ -115,50 +119,78 @@ Usage
 #include "profiling.H"
 #include "Time.H"
 #include "Fstream.H"
+#include "etcFiles.H"
 #include "includeEntry.H"
 
 using namespace Foam;
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-//- Converts old scope syntax to new syntax
-word scope(const fileName& entryName)
+//- Convert older ':' scope syntax to newer '.' scope syntax,
+//  but leave anything with '/' delimiters untouched
+bool upgradeScope(word& entryName)
 {
-    if (entryName.find(':') != string::npos)
+    if
+    (
+        entryName.find('/') == string::npos
+     && entryName.find(':') != string::npos
+    )
     {
-        wordList entryNames(entryName.components(':'));
+        const wordList names(fileName(entryName).components(':'));
+
+        entryName.resize(0);
 
-        word entry(entryNames[0]);
-        for (label i = 1; i < entryNames.size(); i++)
+        for (const word& name : names)
         {
-            entry += word('.') + entryNames[i];
+            if (entryName.size()) entryName.append(".");
+
+            entryName.append(name);
         }
-        return entry;
-    }
-    else
-    {
-        return entryName;
+
+        return true;
     }
+
+    // Nothing changed
+    return false;
 }
 
 
-//- Extracts dict name and keyword
-Pair<word> dictAndKeyword(const word& scopedName)
+//- Split into dictionary name and the entry name
+class dictAndKeyword
 {
-    string::size_type i = scopedName.find_last_of(".");
-    if (i != string::npos)
+    word dict_;
+    word key_;
+
+public:
+    dictAndKeyword(const word& scopedName)
     {
-        return Pair<word>
-        (
-            scopedName.substr(0, i),
-            scopedName.substr(i+1, string::npos)
-        );
+        string::size_type i = scopedName.rfind('/');
+        if (i == string::npos)
+        {
+            i = scopedName.rfind('.');
+        }
+
+        if (i != string::npos)
+        {
+            dict_ = scopedName.substr(0, i);
+            key_  = scopedName.substr(i+1);
+        }
+        else
+        {
+            key_  = scopedName;
+        }
     }
-    else
+
+    inline const word& dict() const
     {
-        return Pair<word>("", scopedName);
+        return dict_;
     }
-}
+
+    inline const word& key() const
+    {
+        return key_;
+    }
+};
 
 
 const dictionary& lookupScopedDict
@@ -167,71 +199,56 @@ const dictionary& lookupScopedDict
     const word& subDictName
 )
 {
-    if (subDictName == "")
+    if (subDictName.empty())
     {
         return dict;
     }
-    else
+
+    const entry* eptr = dict.lookupScopedEntryPtr(subDictName, false, false);
+
+    if (!eptr || !eptr->isDict())
     {
-        const entry* entPtr = dict.lookupScopedEntryPtr
-        (
-            subDictName,
-            false,
-            false
-        );
-        if (!entPtr || !entPtr->isDict())
-        {
-            FatalIOErrorInFunction(dict)
-                << "keyword " << subDictName
-                << " is undefined in dictionary "
-                << dict.name() << " or is not a dictionary"
-                << endl
-                << "Valid keywords are " << dict.keys()
-                << exit(FatalIOError);
-        }
-        return entPtr->dict();
+        FatalIOErrorInFunction(dict)
+            << "keyword " << subDictName
+            << " is undefined in dictionary "
+            << dict.name() << " or is not a dictionary"
+            << endl
+            << "Valid keywords are " << dict.keys()
+            << exit(FatalIOError);
     }
+
+    return eptr->dict();
 }
 
 
-void remove(dictionary& dict, const dictionary& removeDict)
+void removeDict(dictionary& dict, const dictionary& dictToRemove)
 {
-    forAllConstIter(dictionary, removeDict, iter)
+    for (const entry& refEntry : dictToRemove)
     {
-        const entry* entPtr = dict.lookupEntryPtr
-        (
-            iter().keyword(),
-            false,
-            false
-        );
+        auto finder = dict.search(refEntry.keyword(), false, false);
 
-        if (entPtr)
+        bool purge = false;
+
+        if (finder.isDict())
         {
-            if (entPtr->isDict())
-            {
-                if (iter().isDict())
-                {
-                    remove
-                    (
-                        const_cast<dictionary&>(entPtr->dict()),
-                        iter().dict()
-                    );
-
-                    // Check if dictionary is empty
-                    if (!entPtr->dict().size())
-                    {
-                        dict.remove(iter().keyword());
-                    }
-                }
-            }
-            else if (!iter().isDict())
+            if (refEntry.isDict())
             {
-                if (*entPtr == iter())
-                {
-                    dict.remove(iter().keyword());
-                }
+                removeDict(finder.dict(), refEntry.dict());
+
+                // Purge if dictionary is empty
+                purge = finder.dict().empty();
             }
         }
+        else if (finder.found() && !refEntry.isDict())
+        {
+            // Purge if entries match
+            purge = (finder.ref() == refEntry);
+        }
+
+        if (purge)
+        {
+            dict.remove(refEntry.keyword());
+        }
     }
 }
 
@@ -243,7 +260,7 @@ int main(int argc, char *argv[])
     argList::noBanner();
     argList::noJobInfo();
     argList::validArgs.append("dictionary");
-    argList::addBoolOption("keywords", "list keywords");
+    argList::addBoolOption("keywords", "List keywords");
     argList::addOption("entry", "name", "report/select the named entry");
     argList::addBoolOption
     (
@@ -273,6 +290,12 @@ int main(int argc, char *argv[])
         "dict",
         "Write differences with respect to the specified dictionary"
     );
+    argList::addOption
+    (
+        "diffEtc",
+        "dict",
+        "As per -diff, but locate the file as per foamEtcFile"
+    );
     argList::addBoolOption
     (
         "includes",
@@ -303,13 +326,12 @@ int main(int argc, char *argv[])
     const bool disableEntries = args.optionFound("disableFunctionEntries");
     if (disableEntries)
     {
-        Info<< "Not expanding variables or dictionary directives"
-            << endl;
+        Info<< "Not expanding variables or dictionary directives" << endl;
         entry::disableFunctionEntries = true;
     }
 
 
-    fileName dictFileName(args[1]);
+    const fileName dictFileName(args[1]);
 
     autoPtr<IFstream> dictFile(new IFstream(dictFileName));
     if (!dictFile().good())
@@ -341,28 +363,55 @@ int main(int argc, char *argv[])
     }
 
 
-    // Second dictionary for -diff
+    // Has "diff" or "diffEtc"
+    bool optDiff = false;
+
+    // Reference dictionary for -diff / -diffEtc
     dictionary diffDict;
-    fileName diffFileName;
-    if (args.optionReadIfPresent("diff", diffFileName))
     {
-        autoPtr<IFstream> diffFile(new IFstream(diffFileName));
-        if (!diffFile().good())
+        fileName diffFileName;
+        if (args.optionReadIfPresent("diff", diffFileName))
         {
-            FatalErrorInFunction
-                << "Cannot open file " << diffFileName
-                << exit(FatalError, 1);
+            IFstream diffFile(diffFileName);
+            if (!diffFile.good())
+            {
+                FatalErrorInFunction
+                    << "Cannot open file " << diffFileName
+                    << exit(FatalError, 1);
+            }
+
+            // Read but preserve headers
+            diffDict.read(diffFile, true);
+            optDiff = true;
         }
+        else if (args.optionReadIfPresent("diffEtc", diffFileName))
+        {
+            fileName foundName = findEtcFile(diffFileName);
+            if (foundName.empty())
+            {
+                FatalErrorInFunction
+                    << "Cannot find etcFile " << diffFileName
+                    << exit(FatalError, 1);
+            }
 
-        // Read but preserve headers
-        diffDict.read(diffFile(), true);
-    }
+            IFstream diffFile(foundName);
+            if (!diffFile.good())
+            {
+                FatalErrorInFunction
+                    << "Cannot open file " << foundName
+                    << exit(FatalError, 1);
+            }
 
+            // Read but preserve headers
+            diffDict.read(diffFile, true);
+            optDiff = true;
+        }
+    }
 
-    word entryName;
-    if (args.optionReadIfPresent("entry", entryName))
+    word scopedName;  // Actually fileName, since it can contain '/' scoping
+    if (args.optionReadIfPresent("entry", scopedName))
     {
-        word scopedName(scope(entryName));
+        upgradeScope(scopedName);
 
         string newValue;
         if
@@ -371,13 +420,17 @@ int main(int argc, char *argv[])
          || args.optionReadIfPresent("add", newValue)
         )
         {
-            bool overwrite = args.optionFound("set");
+            const bool overwrite = args.optionFound("set");
 
-            Pair<word> dAk(dictAndKeyword(scopedName));
+            // Dictionary name and keyword
+            const dictAndKeyword dAk(scopedName);
 
-            IStringStream str(string(dAk.second()) + ' ' + newValue + ';');
+            // The context for the action
+            const dictionary& d(lookupScopedDict(dict, dAk.dict()));
+
+            // Create a new entry
+            IStringStream str(string(dAk.key()) + ' ' + newValue + ';');
             entry* ePtr(entry::New(str).ptr());
-            const dictionary& d(lookupScopedDict(dict, dAk.first()));
 
             if (overwrite)
             {
@@ -390,122 +443,116 @@ int main(int argc, char *argv[])
             changed = true;
 
             // Print the changed entry
-            const entry* entPtr = dict.lookupScopedEntryPtr
+            const auto finder = dict.csearchScoped
             (
                 scopedName,
                 false,
-                true            // Support wildcards
+                true  // Support wildcards
             );
-            if (entPtr)
+
+            if (finder.found())
             {
-                Info<< *entPtr;
+                Info<< finder.ref();
             }
         }
         else if (args.optionFound("remove"))
         {
-            // Extract dictionary name and keyword
-            Pair<word> dAk(dictAndKeyword(scopedName));
+            // Dictionary name and keyword
+            const dictAndKeyword dAk(scopedName);
+
+            // The context for the action
+            const dictionary& d(lookupScopedDict(dict, dAk.dict()));
 
-            const dictionary& d(lookupScopedDict(dict, dAk.first()));
-            const_cast<dictionary&>(d).remove(dAk.second());
+            const_cast<dictionary&>(d).remove(dAk.key());
             changed = true;
         }
         else
         {
             // Optionally remove a second dictionary
-            if (args.optionFound("diff"))
+            if (optDiff)
             {
-                Pair<word> dAk(dictAndKeyword(scopedName));
+                // Dictionary name and keyword
+                const dictAndKeyword dAk(scopedName);
 
-                const dictionary& d(lookupScopedDict(dict, dAk.first()));
-                const dictionary& d2(lookupScopedDict(diffDict, dAk.first()));
+                const dictionary& d1(lookupScopedDict(dict, dAk.dict()));
+                const dictionary& d2(lookupScopedDict(diffDict, dAk.dict()));
 
-                const entry* ePtr =
-                    d.lookupEntryPtr(dAk.second(), false, true);
-                const entry* e2Ptr =
-                    d2.lookupEntryPtr(dAk.second(), false, true);
+                const entry* e1Ptr = d1.lookupEntryPtr(dAk.key(), false, true);
+                const entry* e2Ptr = d2.lookupEntryPtr(dAk.key(), false, true);
 
-                if (ePtr && e2Ptr)
+                if (e1Ptr && e2Ptr)
                 {
-                    if (*ePtr == *e2Ptr)
+                    if (*e1Ptr == *e2Ptr)
                     {
-                        const_cast<dictionary&>(d).remove(dAk.second());
+                        const_cast<dictionary&>(d1).remove(dAk.key());
                     }
-                    else if (ePtr->isDict() && e2Ptr->isDict())
+                    else if (e1Ptr->isDict() && e2Ptr->isDict())
                     {
-                        remove
+                        removeDict
                         (
-                            const_cast<dictionary&>(ePtr->dict()),
+                            const_cast<dictionary&>(e1Ptr->dict()),
                             e2Ptr->dict()
                         );
                     }
                 }
             }
 
-
-            const entry* entPtr = dict.lookupScopedEntryPtr
+            const auto finder = dict.csearchScoped
             (
                 scopedName,
                 false,
-                true            // Support wildcards
+                true  // Support wildcards
             );
 
-            if (entPtr)
+            if (!finder.found())
             {
-                if (args.optionFound("keywords"))
+                FatalIOErrorInFunction(dictFile())
+                    << "Cannot find entry " << scopedName
+                    << exit(FatalIOError, 2);
+            }
+            else if (args.optionFound("keywords"))
+            {
+                for (const entry& e : finder.dict())
                 {
-                    const dictionary& dict = entPtr->dict();
-                    forAllConstIter(dictionary, dict, iter)
-                    {
-                        Info<< iter().keyword() << endl;
-                    }
+                    Info<< e.keyword() << endl;
+                }
+            }
+            else if (args.optionFound("value"))
+            {
+                if (finder.isDict())
+                {
+                    Info<< finder.dict();
                 }
-                else
+                else if (finder.ref().isStream())
                 {
-                    if (args.optionFound("value"))
+                    const tokenList& tokens = finder.ref().stream();
+                    forAll(tokens, i)
                     {
-                        if (entPtr->isStream())
+                        Info<< tokens[i];
+                        if (i < tokens.size() - 1)
                         {
-                            const tokenList& tokens = entPtr->stream();
-                            forAll(tokens, i)
-                            {
-                                Info<< tokens[i];
-                                if (i < tokens.size() - 1)
-                                {
-                                    Info<< token::SPACE;
-                                }
-                            }
-                            Info<< endl;
-                        }
-                        else if (entPtr->isDict())
-                        {
-                            Info<< entPtr->dict();
+                            Info<< token::SPACE;
                         }
                     }
-                    else
-                    {
-                        Info<< *entPtr;
-                    }
+                    Info<< endl;
                 }
             }
             else
             {
-                FatalIOErrorInFunction(dictFile)
-                    << "Cannot find entry " << entryName
-                    << exit(FatalIOError, 2);
+                Info<< finder.ref();
             }
         }
     }
     else if (args.optionFound("keywords"))
     {
-        forAllConstIter(dictionary, dict, iter)
+        for (const entry& e : dict)
         {
-            Info<< iter().keyword() << endl;
+            Info<< e.keyword() << endl;
         }
     }
-    else if (args.optionFound("diff"))
+    else if (optDiff)
     {
-        remove(dict, diffDict);
+        removeDict(dict, diffDict);
         dict.write(Info, false);
     }
     else
diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C
index 7a8e25a5b647808e1e43deabbd5e1290b04c3664..f405e232ffe2fc9d85609e9df196048bb5218041 100644
--- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C
+++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C
@@ -179,7 +179,7 @@ class uniqueEqOp
         }
         forAll(y, i)
         {
-            if (!y[i].empty() && findIndex(x, y[i]) == -1)
+            if (!y[i].empty() && !x.found(y[i]))
             {
                 newX[n++] = y[i];
             }
diff --git a/applications/utilities/miscellaneous/foamListTimes/Make/files b/applications/utilities/miscellaneous/foamListTimes/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..fe66ad822487d44cab4d6b56f3fc3013cb55aca7
--- /dev/null
+++ b/applications/utilities/miscellaneous/foamListTimes/Make/files
@@ -0,0 +1,3 @@
+foamListTimes.C
+
+EXE = $(FOAM_APPBIN)/foamListTimes
diff --git a/applications/utilities/miscellaneous/foamListTimes/Make/options b/applications/utilities/miscellaneous/foamListTimes/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..18e6fe47afacb902cddccf82632772447704fd88
--- /dev/null
+++ b/applications/utilities/miscellaneous/foamListTimes/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = */
+/* EXE_LIBS = */
diff --git a/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C
new file mode 100644
index 0000000000000000000000000000000000000000..5aa7389d7644204578521d661d7027be80e3e589
--- /dev/null
+++ b/applications/utilities/miscellaneous/foamListTimes/foamListTimes.C
@@ -0,0 +1,174 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Application
+    foamListTimes
+
+Group
+    grpPostProcessingUtilities
+
+Description
+    List times using timeSelector.
+    To simplify parsing of the output, the normal banner information
+    is suppressed.
+
+Usage
+    \b foamListTimes [OPTION]
+
+    Options:
+      - \par -rm
+        Remove selected time directories
+
+      - \par -processor
+        List times from processor0/ directory
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "profiling.H"
+#include "timeSelector.H"
+#include "Time.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+    argList::addNote("List times using timeSelector");
+
+    timeSelector::addOptions(true, true);
+    argList::noBanner();
+    argList::noParallel();
+    argList::noJobInfo();
+    argList::addBoolOption
+    (
+        "processor",
+        "list times from processor0/ directory"
+    );
+    argList::addBoolOption
+    (
+        "rm",
+        "remove selected time directories"
+    );
+    profiling::disable(); // Disable profiling (and its output)
+
+    #include "setRootCase.H"
+
+    label nProcs = 0;
+
+    // Create the processor databases
+    PtrList<Time> databases(1);
+
+    if (args.optionFound("processor"))
+    {
+        // Determine the processor count directly
+        while (isDir(args.path()/(word("processor") + name(nProcs))))
+        {
+            ++nProcs;
+        }
+
+        if (!nProcs)
+        {
+            FatalErrorInFunction
+                << "No processor* directories found"
+                << exit(FatalError);
+        }
+
+        // Create the processor databases
+        databases.setSize(nProcs);
+
+        forAll(databases, proci)
+        {
+            databases.set
+            (
+                proci,
+                new Time
+                (
+                    Time::controlDictName,
+                    args.rootPath(),
+                    args.caseName()/fileName(word("processor") + name(proci))
+                )
+            );
+        }
+    }
+    else
+    {
+        databases.set
+        (
+            0,
+            new Time
+            (
+                Time::controlDictName,
+                args.rootPath(),
+                args.caseName()
+            )
+        );
+    }
+
+    // Use the times list from the master processor
+    // and select a subset based on the command-line options
+    instantList timeDirs = timeSelector::select
+    (
+        databases[0].times(),
+        args
+    );
+
+    if (args.optionFound("rm"))
+    {
+        if (args.optionFound("processor"))
+        {
+            for (label proci=0; proci<nProcs; proci++)
+            {
+                fileName procPath
+                (
+                    args.path()/(word("processor") + name(proci))
+                );
+
+                forAll(timeDirs, timeI)
+                {
+                    rmDir(procPath/timeDirs[timeI].name());
+                }
+            }
+        }
+        else
+        {
+            forAll(timeDirs, timeI)
+            {
+                rmDir(args.path()/timeDirs[timeI].name());
+            }
+        }
+    }
+    else
+    {
+        forAll(timeDirs, timeI)
+        {
+            Info<< timeDirs[timeI].name() << endl;
+        }
+    }
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/miscellaneous/patchSummary/patchSummary.C b/applications/utilities/miscellaneous/patchSummary/patchSummary.C
index 6eb763747fe521d71681748ffa57a0ad882c1254..b5ebfe0806cc897eba17d88214e8947214bb9e18 100644
--- a/applications/utilities/miscellaneous/patchSummary/patchSummary.C
+++ b/applications/utilities/miscellaneous/patchSummary/patchSummary.C
@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
                 collectFieldList(psytf, patchi, fieldToType);
                 collectFieldList(ptf, patchi, fieldToType);
 
-                label groupI = findIndex(fieldToTypes, fieldToType);
+                label groupI = fieldToTypes.find(fieldToType);
                 if (groupI == -1)
                 {
                     DynamicList<label> group(1);
diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options
index cec9adc663b3feff9800d6a362cc32f27c436150..7e74790e00d943133bf8c778fb538b16c218e400 100644
--- a/applications/utilities/parallelProcessing/decomposePar/Make/options
+++ b/applications/utilities/parallelProcessing/decomposePar/Make/options
@@ -11,7 +11,9 @@ EXE_LIBS = \
     -ldynamicMesh \
     -ldecompose \
     -lgenericPatchFields \
-    -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \
+    -ldecompositionMethods \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lscotchDecomp \
     -llagrangian \
     -ldynamicMesh \
     -lregionModels
diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C
index b1d04b6d9bac0d825268a0184a7790d47e41cda0..b06da4f4a72e660d431c5eb0d403fc4051db3a3f 100644
--- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C
+++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C
@@ -306,7 +306,7 @@ int main(int argc, char *argv[])
             const wordList& regions = iter();
             forAll(regions, i)
             {
-                if (findIndex(regionNames, regions[i]) == -1)
+                if (!regionNames.found(regions[i]))
                 {
                     regionNames.append(regions[i]);
                 }
@@ -404,7 +404,11 @@ int main(int argc, char *argv[])
                 Info<< "Removing " << nProcs
                     << " existing processor directories" << endl;
 
-                fileHandler().rmDir(runTime.path()/word("processors"));
+                fileHandler().rmDir
+                (
+                    runTime.path()/word("processors"),
+                    true  // silent (may not have been collated)
+                );
 
                 // remove existing processor dirs
                 // reverse order to avoid gaps if someone interrupts the process
diff --git a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C
index 98457dc2b4e5e8ac5b80a94dd875f4aa4ff9a961..b475216f27329fa7edc6ef752e600edb18dfee21 100644
--- a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C
+++ b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C
@@ -67,11 +67,8 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
                 const indexedParticle& ppi = *iter();
                 particleIndices_[pi++] = ppi.index();
 
-                label mappedTetFace = findIndex
-                (
-                    decodedProcFaceAddressing,
-                    ppi.tetFace()
-                );
+                const label mappedTetFace =
+                    decodedProcFaceAddressing.find(ppi.tetFace());
 
                 if (mappedTetFace == -1)
                 {
diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
index 131598746a79a39481b65f02df4e95bd896d23cc..efc5f9b0f35e6a8aaa5acb3b8ba453714ba4c7a5 100644
--- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
+++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C
@@ -189,7 +189,7 @@ int main(int argc, char *argv[])
             const wordList& regions = iter();
             forAll(regions, i)
             {
-                if (findIndex(regionNames, regions[i]) == -1)
+                if (!regionNames.found(regions[i]))
                 {
                     regionNames.append(regions[i]);
                 }
diff --git a/applications/utilities/parallelProcessing/redistributePar/Make/options b/applications/utilities/parallelProcessing/redistributePar/Make/options
index 189902467f7ab2777e969adce463624c76ee1e15..46f67054e24985d3025e7cea0fca6a6be94ac402 100644
--- a/applications/utilities/parallelProcessing/redistributePar/Make/options
+++ b/applications/utilities/parallelProcessing/redistributePar/Make/options
@@ -11,7 +11,8 @@ EXE_LIBS = \
     -lfiniteVolume \
     -lgenericPatchFields \
     -ldecompositionMethods \
-    -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp -lscotchDecomp \
+    -L$(FOAM_LIBBIN)/dummy \
+    -lkahipDecomp -lmetisDecomp -lptscotchDecomp -lscotchDecomp \
     -ldecompose \
     -lmeshTools \
     -llagrangian \
diff --git a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C
index b219c65bcbe0067475ce40a6573529b659570ea4..b9f55ec82dfd38988698b2452f4c363cfaa76e91 100644
--- a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C
+++ b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2012-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -29,6 +29,10 @@ License
 #include "Time.H"
 //#include "IOPtrList.H"
 #include "polyBoundaryMeshEntries.H"
+#include "IOobjectList.H"
+#include "pointSet.H"
+#include "faceSet.H"
+#include "cellSet.H"
 
 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
 
@@ -375,6 +379,41 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
     }
 
 
+    // Determine sets
+    // ~~~~~~~~~~~~~~
+
+    wordList pointSetNames;
+    wordList faceSetNames;
+    wordList cellSetNames;
+    if (Pstream::master())
+    {
+        // Read sets
+        IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets");
+        pointSetNames = objects.sortedNames(pointSet::typeName);
+        faceSetNames = objects.sortedNames(faceSet::typeName);
+        cellSetNames = objects.sortedNames(cellSet::typeName);
+    }
+    Pstream::scatter(pointSetNames);
+    Pstream::scatter(faceSetNames);
+    Pstream::scatter(cellSetNames);
+
+    if (!haveMesh)
+    {
+        forAll(pointSetNames, i)
+        {
+            pointSet(mesh, pointSetNames[i], 0).write();
+        }
+        forAll(faceSetNames, i)
+        {
+            faceSet(mesh, faceSetNames[i], 0).write();
+        }
+        forAll(cellSetNames, i)
+        {
+            cellSet(mesh, cellSetNames[i], 0).write();
+        }
+    }
+
+
 //    if (!haveMesh)
 //    {
 //        // We created a dummy mesh file above. Delete it.
diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C
index e35562b6951ca0d561a53aaecd5a27865d553611..ed6c7579b25670c78b62be1823f25d90a53c39e6 100644
--- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C
+++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C
@@ -105,7 +105,7 @@ void Foam::parLagrangianRedistributor::findClouds
             // One of the objects is coordinates/positions so must be valid
             // cloud
 
-            label cloudI = findIndex(cloudNames, localCloudDirs[i]);
+            label cloudI = cloudNames.find(localCloudDirs[i]);
 
             objectNames[cloudI].setSize(sprayObjs.size());
             label objectI = 0;
diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
index ca116ce38e54a0904cb9b6850c680c7cbb17a588..e0ba52f7a7dca5eba84e560ca592134a0fd33e50 100644
--- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
+++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
@@ -857,7 +857,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
         // processors
         autoPtr<fvMeshSubset> subsetterPtr;
 
-        const bool allHaveMesh = (findIndex(haveMesh, false) == -1);
+        const bool allHaveMesh = !haveMesh.found(false);
         if (!allHaveMesh)
         {
             // Find last non-processor patch.
diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
index 98f14db9182f3f8cd03a27ec2d6f6c1860573f09..f5b742246383603a9af56c12606f14c48216bcd8 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C
@@ -79,7 +79,7 @@ Usage
 #include "tensorIOField.H"
 #include "passiveParticleCloud.H"
 #include "faceSet.H"
-#include "stringListOps.H"
+#include "stringOps.H"
 #include "wordReList.H"
 
 #include "meshSubsetHelper.H"
@@ -137,7 +137,7 @@ labelList getSelectedPatches
             Info<< "    discarding empty/processor patch " << patchi
                 << " " << pp.name() << endl;
         }
-        else if (findStrings(excludePatches, pp.name()))
+        else if (stringOps::match(excludePatches, pp.name()))
         {
             Info<< "    excluding patch " << patchi
                 << " " << pp.name() << endl;
diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C
index 317010c0de26070066c189d9d271706034559355..3475cb24cf6d14b1cdde89f6bd3852c93d0af57a 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C
@@ -412,7 +412,7 @@ void Foam::tecplotWriter::writeConnectivity
             // The face that uses the vertices of e in increasing order
             // is the left face.
 
-            const label fp = findIndex(f0, e[0]);
+            const label fp = f0.find(e[0]);
             const bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
 
             if (f0IsLeft)
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
index e84e12f118c18ca7f1c33c478b46546de0b44651..eb6b3b6dddcac13bc22cdbbe154b58f4fb69965c 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
@@ -154,7 +154,7 @@ Note
 #include "faceZoneMesh.H"
 #include "Cloud.H"
 #include "passiveParticle.H"
-#include "stringListOps.H"
+#include "stringOps.H"
 
 #include "meshSubsetHelper.H"
 #include "readFields.H"
@@ -1172,7 +1172,7 @@ int main(int argc, char *argv[])
             {
                 const polyPatch& pp = patches[patchi];
 
-                if (findStrings(excludePatches, pp.name()))
+                if (stringOps::match(excludePatches, pp.name()))
                 {
                     // Skip excluded patch
                     continue;
diff --git a/applications/utilities/postProcessing/postProcess/postProcess.C b/applications/utilities/postProcessing/postProcess/postProcess.C
index 8a01c21eb44bdccf327297c0ea0475c388d01d12..884fe1d39839dfa8035e8c07e5859de7d7ec46df 100644
--- a/applications/utilities/postProcessing/postProcess/postProcess.C
+++ b/applications/utilities/postProcessing/postProcess/postProcess.C
@@ -39,6 +39,7 @@ Description
 #include "surfaceFields.H"
 #include "pointFields.H"
 #include "uniformDimensionedFields.H"
+#include "fileFieldSelection.H"
 
 using namespace Foam;
 
@@ -153,14 +154,14 @@ int main(int argc, char *argv[])
     #include "createNamedMesh.H"
 
     // Initialize the set of selected fields from the command-line options
-    HashSet<word> selectedFields;
+    functionObjects::fileFieldSelection fields(mesh);
     if (args.optionFound("fields"))
     {
-        args.optionLookup("fields")() >> selectedFields;
+        args.optionLookup("fields")() >> fields;
     }
     if (args.optionFound("field"))
     {
-        selectedFields.insert(args.optionLookup("field")());
+        fields.insert(args.optionLookup("field")());
     }
 
     // Externally stored dictionary for functionObjectList
@@ -170,7 +171,13 @@ int main(int argc, char *argv[])
     // Construct functionObjectList
     autoPtr<functionObjectList> functionsPtr
     (
-        functionObjectList::New(args, runTime, functionsDict, selectedFields)
+        functionObjectList::New
+        (
+            args,
+            runTime,
+            functionsDict,
+            fields.selection()
+        )
     );
 
     forAll(timeDirs, timei)
@@ -179,6 +186,8 @@ int main(int argc, char *argv[])
 
         Info<< "Time = " << runTime.timeName() << endl;
 
+        fields.updateSelection();
+
         if (mesh.readUpdate() != polyMesh::UNCHANGED)
         {
             // Update functionObjectList if mesh changes
@@ -187,7 +196,7 @@ int main(int argc, char *argv[])
                 args,
                 runTime,
                 functionsDict,
-                selectedFields
+                fields.selection()
             );
         }
 
@@ -200,7 +209,7 @@ int main(int argc, char *argv[])
                 args,
                 runTime,
                 mesh,
-                selectedFields,
+                fields.selection(),
                 functionsPtr(),
                 timei == timeDirs.size()-1
             );
diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
index 62442c9ca39a87418442d2f7edd4e1f64b97422b..c6ef4bd6ff984fece6aba079b4848b77f49c1327 100644
--- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
+++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
@@ -206,7 +206,7 @@ labelList findMatches
             const wordList& keys = shortcuts[name];
             forAll(keys, j)
             {
-                label index = findIndex(thisKeys, keys[j]);
+                label index = thisKeys.find(keys[j]);
                 if (index != -1)
                 {
                     matches.append(index);
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
index db490161d8e1d95f93e38af4071dc262d4fe1403..d1ec8b77c1f46ba01a16276a3bead7774a1504b9 100755
--- a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
+++ b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
@@ -15,4 +15,4 @@ fi
 
 wmake
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H
index e17039cd03407bad863e3ff2ad513ebbf46d20da..53c4fa494e686dc5f16e49dad610ba8077440e2e 100644
--- a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H
+++ b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H
@@ -33,8 +33,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef IndexedPolyhedron_H
-#define IndexedPolyhedron_H
+#ifndef CGALIndexedPolyhedron_H
+#define CGALIndexedPolyhedron_H
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C
index 6dca6415bff19bd16b63ef731c50b24d76bb17d9..6588632eb9ef38c984e4e0e68f54e36fec11203b 100644
--- a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C
+++ b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C
@@ -416,7 +416,7 @@ void visitPointRegion
 
 
 
-        label index = findIndex(s.pointFaces()[pointI], nextFaceI);
+        label index = s.pointFaces()[pointI].find(nextFaceI);
 
         if (pFacesZone[index] == -1)
         {
diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C
index 09765e2d938c992bef366978581a35327593a6e5..43812170e1fd72aae248bce61aa8dfcb66c669d3 100644
--- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C
+++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C
@@ -150,7 +150,7 @@ void writeZoning
     faceList faces(surf.size());
     forAll(surf, i)
     {
-        faces[i] = surf[i].triFaceFace();
+        faces[i] = surf[i];
     }
 
     vtkSurfaceWriter().write
diff --git a/applications/utilities/surface/surfaceClean/collapseBase.C b/applications/utilities/surface/surfaceClean/collapseBase.C
index 17152e6a91f41dd9175bcb9bc8f047d7cc2f9c12..a1037613978b8873673a9a24051f7c386ab18bb0 100644
--- a/applications/utilities/surface/surfaceClean/collapseBase.C
+++ b/applications/utilities/surface/surfaceClean/collapseBase.C
@@ -99,7 +99,7 @@ static void splitTri
 {
     //label oldNTris = tris.size();
 
-    label fp = findIndex(f, e[0]);
+    label fp = f.find(e[0]);
     label fp1 = f.fcIndex(fp);
     label fp2 = f.fcIndex(fp1);
 
@@ -204,7 +204,7 @@ static bool insertSorted
     scalarField& sortedWeights
 )
 {
-    if (findIndex(sortedVerts, vertI) != -1)
+    if (sortedVerts.found(vertI))
     {
         FatalErrorInFunction
             << " which is already in list of sorted vertices "
@@ -562,7 +562,7 @@ static labelListList getOutsideVerts
             {
                 label v = e[eI];
 
-                if (findIndex(regionVerts, v) == -1)
+                if (!regionVerts.found(v))
                 {
                     label sz = regionVerts.size();
                     regionVerts.setSize(sz+1);
@@ -682,7 +682,7 @@ static void getSplitVerts
         else
         {
             // Copy upto (but not including) e[1]
-            label i1 = findIndex(orderedVerts, e[1]);
+            label i1 = orderedVerts.find(e[1]);
             splitVerts = SubList<label>(orderedVerts, i1, 0);
             splitWeights = SubList<scalar>(orderedWeights, i1, 0);
         }
@@ -703,7 +703,7 @@ static void getSplitVerts
         {
             // Copy downto (but not including) e[1]
 
-            label i1 = findIndex(orderedVerts, e[1]);
+            label i1 = orderedVerts.find(e[1]);
             splitVerts = SubList<label>(orderedVerts, sz-(i1+1), i1+1);
             reverse(splitVerts);
             splitWeights = SubList<scalar>(orderedWeights, sz-(i1+1), i1+1);
@@ -716,7 +716,7 @@ static void getSplitVerts
 
         // Copy upto (but not including) e[0]
 
-        label i0 = findIndex(orderedVerts, e[0]);
+        label i0 = orderedVerts.find(e[0]);
         splitVerts = SubList<label>(orderedVerts, i0, 0);
         reverse(splitVerts);
         splitWeights = SubList<scalar>(orderedWeights, i0, 0);
@@ -726,14 +726,14 @@ static void getSplitVerts
     {
         // Copy from (but not including) e[0] to end
 
-        label i0 = findIndex(orderedVerts, e[0]);
+        label i0 = orderedVerts.find(e[0]);
         splitVerts = SubList<label>(orderedVerts, sz-(i0+1), i0+1);
         splitWeights = SubList<scalar>(orderedWeights, sz-(i0+1), i0+1);
     }
     else
     {
-        label i0 = findIndex(orderedVerts, e[0]);
-        label i1 = findIndex(orderedVerts, e[1]);
+        label i0 = orderedVerts.find(e[0]);
+        label i1 = orderedVerts.find(e[1]);
 
         if (i0 == -1 || i1 == -1)
         {
diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
index ca7cba62cc624f7425d00d43a5f925221ff54cd9..eb7103faf1eab2ab0ef3da0d9096d3829acb27af 100644
--- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
+++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
@@ -368,7 +368,7 @@ int main(int argc, char *argv[])
             faces.setSize(surf.size());
             forAll(surf, fi)
             {
-                faces[fi] = surf[fi].triFaceFace();
+                faces[fi] = surf[fi];
             }
         }
 
diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C
index 57351df046e2787a90705d27b310eb2860f714e3..4b8dbe71473416eac0fd4abc95382e0a69f47c23 100644
--- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C
+++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C
@@ -63,7 +63,7 @@ void greenRefine
 
     // Find index of edge in face.
 
-    label fp0 = findIndex(f, e[0]);
+    label fp0 = f.find(e[0]);
     label fp1 = f.fcIndex(fp0);
     label fp2 = f.fcIndex(fp1);
 
@@ -235,16 +235,11 @@ public:
     {
         const treeDataEdge& shape = tree_.shapes();
 
-        forAll(indices, i)
+        for (const label index : indices)
         {
-            const label index = indices[i];
             const label edgeIndex = shape.edgeLabels()[index];
 
-            if
-            (
-                !shapeMask_.empty()
-             && findIndex(shapeMask_, edgeIndex) != -1
-            )
+            if (shapeMask_.found(edgeIndex))
             {
                 continue;
             }
@@ -256,7 +251,7 @@ public:
             // Only register hit if closest point is not an edge point
             if (nearHit.hit())
             {
-                scalar distSqr = sqr(nearHit.distance());
+                const scalar distSqr = sqr(nearHit.distance());
 
                 if (distSqr < nearestDistSqr)
                 {
diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C
index 3cfdb743bed41a6eb9aa873a20ef0f2edb731f2e..fe34422582d0a7835099a74aed00df13785bd4f0 100644
--- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C
+++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C
@@ -70,7 +70,7 @@ scalar calcVertexNormalWeight
     const pointField& points
 )
 {
-    label index = findIndex(f, pI);
+    label index = f.find(pI);
 
     if (index == -1)
     {
@@ -292,7 +292,7 @@ label detectIntersectionPoints
             if
             (
                 hits[pointI].hit()
-            &&  findIndex(localFaces[hits[pointI].index()], pointI) == -1
+            &&  !localFaces[hits[pointI].index()].found(pointI)
             )
             {
                 scale[pointI] = max(0.0, scale[pointI]-0.2);
diff --git a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C
index e7006475c78eed0f6320abc5a590172be70f3a52..538fb2cceeee614be46ab09c76b3eb5484e258cd 100644
--- a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C
+++ b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
 
     if (args.optionFound("featureFile"))
     {
-        const fileName featureFileName(args.option("featureFile"));
+        const fileName featureFileName(args["featureFile"]);
         Info<< "Reading features from " << featureFileName << " ..." << endl;
 
         edgeMesh feMesh(featureFileName);
diff --git a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
index 47a83a09f22bc38056af5b69e53a0d8e4bfb5e83..d844e0bb631f969efcb664b5d0264f608aeeb1ea 100644
--- a/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
+++ b/applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
@@ -154,14 +154,14 @@ void testSortedEdgeFaces(const triSurface& surf)
 
         forAll(myFaces, i)
         {
-            if (findIndex(sortMyFaces, myFaces[i]) == -1)
+            if (!sortMyFaces.found(myFaces[i]))
             {
                 FatalErrorInFunction << abort(FatalError);
             }
         }
         forAll(sortMyFaces, i)
         {
-            if (findIndex(myFaces, sortMyFaces[i]) == -1)
+            if (!myFaces.found(sortMyFaces[i]))
             {
                 FatalErrorInFunction << abort(FatalError);
             }
@@ -460,7 +460,7 @@ label sharedFace
 
     const triSurface::FaceType& f = surf.localFaces()[firstFacei];
 
-    label startIndex = findIndex(f, e.start());
+    label startIndex = f.find(e.start());
 
     // points in face in same order as edge
     bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end());
@@ -471,7 +471,7 @@ label sharedFace
     const labelList& eFaces = surf.sortedEdgeFaces()[sharedEdgeI];
 
     // Get position of face in sorted edge faces
-    label faceIndex = findIndex(eFaces, firstFacei);
+    label faceIndex = eFaces.find(firstFacei);
 
     if (edgeOrder)
     {
diff --git a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C
index 173bbf2e3a8a562c7e03714b93f9ae6f886fccb8..79e452685aa0dee654efe576243c2ffc6374d5e9 100644
--- a/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C
+++ b/applications/utilities/surface/surfaceTransformPoints/surfaceTransformPoints.C
@@ -60,10 +60,9 @@ int main(int argc, char *argv[])
 {
     argList::addNote
     (
-        "Transform (translate/rotate/scale) a surface. "
+        "Transform (translate / rotate / scale) surface points.\n"
         "Like transformPoints but for surfaces.\n"
-        "Note: roll=rotation about x, pitch=rotation about y, "
-        "yaw=rotation about z"
+        "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
     );
     argList::noParallel();
     argList::validArgs.append("surfaceFile");
@@ -72,33 +71,33 @@ int main(int argc, char *argv[])
     (
         "translate",
         "vector",
-        "translate by the specified <vector> - eg, '(1 0 0)'"
+        "Translate by specified <vector> - eg, '(1 0 0)' before rotations"
     );
     argList::addOption
     (
         "rotate",
         "(vectorA vectorB)",
-        "transform in terms of a rotation between <vectorA> and <vectorB> "
+        "Transform as a rotation between <vectorA> and <vectorB> "
         "- eg, '( (1 0 0) (0 0 1) )'"
     );
     argList::addOption
     (
         "scale",
         "scalar | vector",
-        "scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
+        "Scale by the specified amount - eg, for a uniform [mm] to [m] scaling "
         "use either (0.001 0.001 0.001)' or simply '0.001'"
     );
     argList::addOption
     (
         "rollPitchYaw",
         "vector",
-        "rotate by '(roll pitch yaw)' in degrees"
+        "Rotate by '(roll pitch yaw)' in degrees"
     );
     argList::addOption
     (
         "yawPitchRoll",
         "vector",
-        "rotate by '(yaw pitch roll)' in degrees"
+        "Rotate by '(yaw pitch roll)' in degrees"
     );
     argList args(argc, argv);
 
diff --git a/bin/foamCleanTutorials b/bin/foamCleanTutorials
index 8712bb25fae35e4d6ea908b22314bb649e39f9d8..c313a9a2a577b2c0aa7d9df2a553906530fbc83c 100755
--- a/bin/foamCleanTutorials
+++ b/bin/foamCleanTutorials
@@ -30,9 +30,7 @@
 #     and all its subdirectories.
 #
 #------------------------------------------------------------------------------
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 thisScript=$0
 if [ "/${thisScript#/}" != "$thisScript" ]
diff --git a/bin/foamRunTutorials b/bin/foamRunTutorials
index dac6fc894fcf7316a6f314c05c48aca0ede8d5c1..5c2b49435b4f76e98ba2f6bcee678212e6c7b1a2 100755
--- a/bin/foamRunTutorials
+++ b/bin/foamRunTutorials
@@ -30,19 +30,18 @@
 #     and all its subdirectories.
 #
 #------------------------------------------------------------------------------
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Normally use standard "make"
 make="make"
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
 thisScript=$0
 if [ "/${thisScript#/}" != "$thisScript" ]
 then
     thisScript="$PWD/$thisScript"
 fi
 
+unset passArgs runTests
 skipFirst=false
 
 # Parse options
@@ -51,23 +50,27 @@ do
     case "$1" in
     -t | -test)
         passArgs="-test"
-        shift
+        runTests=true
         ;;
     -s | -skipFirst)
         skipFirst=true
-        shift
         ;;
     *)
         break
         ;;
     esac
+    shift
 done
 
 # If an argument is supplied do not execute ./Allrun to avoid recursion
-if ! $skipFirst && [ -f "./Allrun" ]
+if ! $skipFirst && $runTests && [ -f "./Alltest" ]
+then
+    # Run speciallised Alltest script.
+    ./Alltest $passArgs $*
+elif ! $skipFirst && [ -f "./Allrun" ]
 then
     # Run specialised Allrun script.
-    ./Allrun $passArgs
+    ./Allrun $passArgs $*
 elif [ -d system ]
 then
     # Run normal case.
@@ -89,7 +92,7 @@ else
     # Run all cases which have not already been run
     $make -k -f $WM_PROJECT_DIR/bin/tools/MakefileDirs \
           FOAM_TARGETS="$FOAM_TARGETS" \
-          FOAM_APP="$thisScript" FOAM_ARGS="$passArgs"
+          FOAM_APP="$thisScript" FOAM_ARGS="$passArgs $*"
 fi
 
 #------------------------------------------------------------------------------
diff --git a/bin/mpirunDebug b/bin/mpirunDebug
index 3be74baa251afe9d78056913915df5072b9bf488..943ffee111e25d2a54f26f11c7514e0ddd445b76 100755
--- a/bin/mpirunDebug
+++ b/bin/mpirunDebug
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 #-------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -26,50 +26,90 @@
 #     mpirunDebug
 #
 # Description
-#     Driver script to run mpi jobs with the processes in separate
-#     windows or to separate log files.
+#     Driver script to run mpi jobs with the processes in a separate XTerm
+#     or to separate log files.
 #     Requires bash on all processors.
 #------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
 
-if [ `uname -s` = Linux ]
-then
+Usage: ${0##*/} [OPTION] -np <N> <executable> <args>
+
+options:
+  -method=MODE  Run mode
+                  (0) normal
+                  (1) gdb+xterm
+                  (2) gdb
+                  (3) log
+                  (4) log+xterm
+                  (5) xterm+valgrind
+                  (6) gperftools(callgrind)
+  -spawn=TYPE   Spawn type: (1) local (2) remote
+  -log          Alias for -method=3
+  -local        Alias for -spawn=1
+  -yes          Start without additional prompt
+  -help         Print the usage
+
+Invoke mpirun but with each process in a separate XTerm, or to separate logfile
+
+USAGE
+    exit 1
+}
+
+case "$(uname -s)" in
+Linux)
     ECHO='echo -e'
-else
+    ;;
+*)
     ECHO='echo'
-fi
+    ;;
+esac
 
+unset nProcs appName appArgs
+unset method spawn optNoAsk
 
-usage()
-{
-    cat<<USAGE
+# parse options
+while [ "$#" -gt 0 ]
+do
+    # echo "$1" 1>&2
+    case "$1" in
+    -help)
+        usage
+        ;;
 
-Usage: ${0##*/}  -np <dd> <executable> <args>
+    -method=[0-6])
+        method="${1#*=}"
+        ;;
 
-* This will run like mpirun but with each process in an XTerm
+    -spawn=[1-2])
+        spawn="${1#*=}"
+        ;;
 
-USAGE
-    exit 1
-}
+    -log)
+        method=3
+        ;;
 
-unset nProcs exec args
+    -local)
+        spawn=1
+        ;;
+
+    -yes)
+        optNoAsk=true
+        ;;
 
-while [ "$1" != "" ]
-do
-    echo "$1"
-    case $1 in
     -np)
         nProcs=$2
         shift
         ;;
+
     *)
-        if [ ! "$exec" ]
-        then
-            exec=$1
-        elif [ ! "$args" ]
+        if [ -z "$appName" ]
         then
-            args="\"$1\""
+            appName="$1"
         else
-            args="$args \"$1\""
+            appArgs="${appArgs}${appArgs:+ }\"$1\""
         fi
         ;;
     esac
@@ -77,54 +117,61 @@ do
 done
 
 echo "nProcs=$nProcs"
-echo "exec=$exec"
-echo "args=$args"
+echo "exec=$appName"
+echo "args=$appArgs"
 
-[ "$nProcs" ] || usage
-[ "$args" ] || usage
-[ "$exec" ] || usage
+[ -n "$nProcs" ] || usage
+[ -n "$appArgs" ] || usage
+[ -n "$appName" ] || usage
 
-exec=`which $exec`
-if [ ! -x "$exec" ]
-then
-    echo "Cannot find executable $exec or is not executable"
-    usage
-fi
+exec=$(command -v $appName)
+[ -x "$exec" ] || {
+     echo "Cannot find executable $appName or is not executable"
+     usage
+}
 
-if [ ! "$PWD" ]
-then
-    PWD=`pwd`
-fi
+[ -n "$PWD" ] || PWD=$(pwd)
 
-echo "run $args" > $PWD/gdbCommands
+echo "run $appArgs" > $PWD/gdbCommands
 echo "where" >> $PWD/gdbCommands
 echo "Constructed gdb initialization file $PWD/gdbCommands"
 
-$ECHO "Choose running method: 0)normal  1)gdb+xterm  2)gdb  3)log  4)log+xterm  5)xterm+valgrind  6)gperftools(callgrind): \c"
-read method
-case "$method" in
-0 | 1 | 2 | 3 | 4 | 5 | 6)
-    # okay
-    ;;
-*)
-    usage
-    ;;
-esac
+# Choose method
+if [ -z "$method" ]
+then
+    $ECHO "Choose running method: 0)normal  1)gdb+xterm  2)gdb  3)log  4)log+xterm  5)xterm+valgrind  6)gperftools(callgrind): \c"
+    read method
+    case "$method" in
+    0 | 1 | 2 | 3 | 4 | 5 | 6)
+        # okay
+        ;;
+    *)
+        usage
+        ;;
+    esac
+fi
 
-$ECHO "Run all processes local or distributed? 1)local  2)remote: \c"
-read spawn
-if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]
+# Choose spawn
+if [ -z "$spawn" ]
 then
-    usage
+    $ECHO "Run all processes local or distributed? 1)local  2)remote: \c"
+    read spawn
+    case "$spawn" in
+    1 | 2)
+        # okay
+        ;;
+    *)
+        usage
+        ;;
+    esac
 fi
 
 
 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
 # check ~/.$WM_PROJECT/
 # check <installedProject>/etc/
-if [ "$WM_PROJECT" ]
+if [ -n "$WM_PROJECT" ]
 then
-
     for i in \
         $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
         $HOME/.$WM_PROJECT \
@@ -143,7 +190,7 @@ fi
 # Source OpenFOAM settings if OpenFOAM environment not set.
 # attempt to preserve the installation directory 'FOAM_INST_DIR'
 # use FOAM_SETTINGS to pass command-line settings
-if [ "$FOAM_INST_DIR" ]
+if [ -n "$FOAM_INST_DIR" ]
 then
     sourceFoam="FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
 else
@@ -162,49 +209,53 @@ for ((proc=0; proc<$nProcs; proc++))
 do
     procCmdFile="$PWD/processor${proc}.sh"
     procLog="processor${proc}.log"
-    geom="-geometry 120x15+$xpos+$ypos"
+    xterm="xterm -font fixed -title processor${proc} -geometry 120x15+$xpos+$ypos"
 
+    unset node
     case "$WM_MPLIB" in
     *OPENMPI)
         node="-np 1 "
         ;;
-    *)
-        node=""
     esac
 
     echo "#!/bin/bash" > $procCmdFile
+    echo "$sourceFoam" >> $procCmdFile
+    echo "cd $PWD" >> $procCmdFile
+
     case "$method" in
     0)
-        echo "$sourceFoam; cd $PWD; $exec $args | tee $procLog" >> $procCmdFile
         echo "${node}$procCmdFile" >> $PWD/mpirun.schema
+        echo "$exec $appArgs | tee $procLog" >> $procCmdFile
         ;;
     1)
-        echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog; read dummy" >> $procCmdFile
-        #echo "$sourceFoam; cd $PWD; $exec $args; read dummy" >> $procCmdFile
-        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
+        echo "${node}$xterm -e $procCmdFile" >> $PWD/mpirun.schema
+        echo "gdb -command $PWD/gdbCommands $exec 2>&1 | tee $procLog"
+        echo "read dummy"
         ;;
     2)
-        echo "$sourceFoam; cd $PWD; gdb -command $PWD/gdbCommands $exec > $procLog 2>&1" >> $procCmdFile
         echo "${node}$procCmdFile" >> $PWD/mpirun.schema
+        echo "gdb -command $PWD/gdbCommands $exec > $procLog 2>&1"
         ;;
     3)
-        echo "$sourceFoam; cd $PWD; $exec $args > $procLog 2>&1" >> $procCmdFile
         echo "${node}$procCmdFile" >> $PWD/mpirun.schema
+        echo "$exec $appArgs > $procLog 2>&1"
         ;;
     4)
-        echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile
-        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
+        echo "${node}$xterm -e $procCmdFile" >> $PWD/mpirun.schema
+        echo "$exec $appArgs 2>&1 | tee $procLog"
+        echo "read dummy"
         ;;
     5)
-        echo "$sourceFoam; cd $PWD; valgrind --leak-check=full --show-reachable=yes $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile
-        echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $PWD/mpirun.schema
+        echo "${node}$xterm -e $procCmdFile" >> $PWD/mpirun.schema
+        echo "valgrind --leak-check=full --show-reachable=yes $exec $appArgs 2>&1 | tee $procLog"
+        echo "read dummy"
         ;;
     6)
-        echo "$sourceFoam; cd $PWD; CPUPROFILE=log.profiler_$proc $exec $args; \
-             pprof --callgrind $exec log.profiler_$proc > log.profiler_$proc.callgrind;" >> $procCmdFile
         echo "${node}$procCmdFile" >> $PWD/mpirun.schema
+        echo "CPUPROFILE=log.profiler_$proc $exec $appArgs"
+        echo "pprof --callgrind $exec log.profiler_$proc > log.profiler_$proc.callgrind"
         ;;
-    esac
+    esac >> $procCmdFile
 
     chmod +x $procCmdFile
 
@@ -255,11 +306,20 @@ MPICH)
 esac
 
 echo "Constructed $PWD/mpirun.schema file."
-echo ""
+echo
 echo "    $cmd"
-echo ""
-$ECHO "Press return to execute.\c"
-read dummy
+echo
+
+if [ -n "$optNoAsk" ]
+then
+    echo "starting: " $(date '+%Y-%m-%d %H:%M:%S %z' 2>/dev/null)
+    echo
+else
+    # Pause before running
+    $ECHO "Press return to execute.\c"
+    read dummy
+fi
+
 exec $cmd
 
 #------------------------------------------------------------------------------
diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions
index 91867f1051d3d52fe62c85cb1261eb141b1ce353..8bd95eea84ef4df84b33abdf400e237ec8c86efb 100644
--- a/bin/tools/CleanFunctions
+++ b/bin/tools/CleanFunctions
@@ -31,7 +31,7 @@
 
 cleanTimeDirectories()
 {
-    echo "Cleaning $PWD case"
+    echo "Cleaning case $PWD"
     zeros=""
     while [ ${#zeros} -lt 8 ]
     do
@@ -105,15 +105,13 @@ cleanCase()
     cleanSnappyFiles
     rm -f 0/cellDist > /dev/null 2>&1
 
-    if [ -d constant ]
-    then
-        (cd constant && \
-            rm -rf \
-            cellDecomposition cellToRegion cellLevel* pointLevel* \
-            polyMesh tetDualMesh \
-            > /dev/null 2>&1 \
-        )
-    fi
+    (
+        cd constant 2>/dev/null && \
+        rm -rf \
+          cellDecomposition cellToRegion cellLevel* pointLevel* \
+          polyMesh tetDualMesh \
+          > /dev/null 2>&1 \
+    )
 
     if [ -e system/blockMeshDict.m4 ]
     then
@@ -122,9 +120,17 @@ cleanCase()
 }
 
 
+# Frequently used - cleanCase and rm -rf 0/
+cleanCase0()
+{
+    cleanCase
+    rm -rf 0
+}
+
+
 removeCase()
 {
-    echo "Removing ${1:-unknown} case"
+    echo "Removing case ${1:-unknown}"
     [ "$#" -ge 1 ] && rm -rf "$1"
 }
 
@@ -143,7 +149,7 @@ cleanUcomponents()
 
 cleanApplication()
 {
-    echo "Cleaning $PWD application"
+    echo "Cleaning application $PWD"
     wclean
 }
 
diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions
index e4a49bef18166c39308aa3eb7cdff329fc20e091..55ab42d175b9b3e1000c4763a70008310c09f6c5 100644
--- a/bin/tools/RunFunctions
+++ b/bin/tools/RunFunctions
@@ -3,7 +3,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -43,6 +43,7 @@ isParallel()
     return 1
 }
 
+
 #
 # Look for '-test' in the argument list.
 #
@@ -52,6 +53,7 @@ isTest()
     return 1
 }
 
+
 #
 # Extract 'numberOfSubdomains' from system/decomposeParDict
 # (or alternative location).
@@ -100,120 +102,139 @@ getApplication()
     fi
 }
 
+
+#
+# Run given application in serial with logfile output.
+# The preexistence of the log file prevents rerunning.
+#
 runApplication()
 {
-    APP_RUN=
-    LOG_IGNORE=false
-    LOG_APPEND=false
-    LOG_SUFFIX=
-
-    # Parse options and executable
-    while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
-        key="$1"
-        case "$key" in
-            -append|-a)
-                LOG_IGNORE=true
-                LOG_APPEND=true
+    local appRun logFile logMode
+
+    # Any additional parsed arguments (eg, decomposeParDict)
+    local appArgs
+
+    # Parse options until executable is encountered
+    while [ $# -gt 0 -a -z "$appRun" ]
+    do
+        case "$1" in
+            -a | -append)
+                logMode=append
+                ;;
+            -o | -overwrite)
+                logMode=overwrite
                 ;;
-            -overwrite|-o)
-                LOG_IGNORE=true
+            -s | -suffix)
+                logFile=".$2"
+                shift
                 ;;
-            -suffix|-s)
-                LOG_SUFFIX=".$2"
+            -decomposeParDict)
+                appArgs="$appArgs $1 $2"
                 shift
                 ;;
+            '')
+                ;;
             *)
-                APP_RUN="$key"
-                APP_NAME="${key##*/}"
-                LOG_SUFFIX="${APP_NAME}${LOG_SUFFIX}"
+                appRun="$1"
                 ;;
         esac
         shift
     done
 
-    if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
+    local appName="${appRun##*/}"
+    logFile="log.$appName$logFile"
+
+    if [ -f "$logFile" -a -z "$logMode" ]
     then
-        echo "$APP_NAME already run on $PWD:" \
-             "remove log file 'log.$LOG_SUFFIX' to re-run"
+        echo "$appName already run on $PWD:" \
+             "remove log file '$logFile' to re-run"
     else
-        echo "Running $APP_RUN on $PWD"
-        if [ "$LOG_APPEND" = "true" ]; then
-            $APP_RUN "$@" >> log.$LOG_SUFFIX 2>&1
+        echo "Running $appRun on $PWD"
+        if [ "$logMode" = append ]
+        then
+            $appRun $appArgs "$@" >> $logFile 2>&1
         else
-            $APP_RUN "$@" > log.$LOG_SUFFIX 2>&1
+            $appRun $appArgs "$@" > $logFile 2>&1
         fi
     fi
 }
 
+
+#
+# Run given application in parallel with logfile output.
+# The preexistence of the log file prevents rerunning.
+#
 runParallel()
 {
-    APP_RUN=
-    LOG_IGNORE=false
-    LOG_APPEND=false
-    LOG_SUFFIX=
-
-    # Store any parsed additional arguments e.g. decomposeParDict
-    APP_PARARGS=
-
-    # Initialise number of procs to unset value
-    nProcs=-1
-
-    # Parse options and executable
-    while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
-        key="$1"
-        case "$key" in
-            -append|-a)
-                LOG_IGNORE=true
-                LOG_APPEND=true
+    local appRun logFile logMode nProcs
+
+    # Any additional parsed arguments (eg, decomposeParDict)
+    local appArgs="-parallel"
+
+    # Parse options until executable is encountered
+    while [ $# -gt 0 -a -z "$appRun" ]
+    do
+        case "$1" in
+            -a | -append)
+                logMode=append
                 ;;
-            -overwrite|-o)
-                LOG_IGNORE=true
+            -o | -overwrite)
+                logMode=overwrite
                 ;;
-            -suffix|-s)
-                LOG_SUFFIX=".$2"
+            -s | -suffix)
+                logFile=".$2"
                 shift
                 ;;
-            -np|-n)
+            -n | -np)
                 nProcs="$2"
                 shift
                 ;;
             -decomposeParDict)
+                appArgs="$appArgs $1 $2"
                 nProcs=$(getNumberOfProcessors "$2")
-                APP_PARARGS="$APP_PARARGS -decomposeParDict $2"
                 shift
                 ;;
+            '')
+                ;;
             *)
-                APP_RUN="$key"
-                APP_NAME="${key##*/}"
-                LOG_SUFFIX="${APP_NAME}${LOG_SUFFIX}"
+                appRun="$1"
                 ;;
         esac
-
         shift
     done
 
-    [ "$nProcs" -eq -1 ] && nProcs=$(getNumberOfProcessors system/decomposeParDict)
+    [ -n "$nProcs" ] || nProcs=$(getNumberOfProcessors system/decomposeParDict)
+
+    local appName="${appRun##*/}"
+    logFile="log.$appName$logFile"
 
-    if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
+    if [ -f "$logFile" -a -z "$logMode" ]
     then
-        echo "$APP_NAME already run on $PWD:" \
-             "remove log file 'log.$LOG_SUFFIX' to re-run"
+        echo "$appName already run on $PWD:" \
+             "remove log file '$logFile' to re-run"
     else
-        echo "Running $APP_RUN in parallel on $PWD using $nProcs processes"
-        if [ "$LOG_APPEND" = "true" ]; then
-            ( mpirun -np $nProcs $APP_RUN $APP_PARARGS -parallel "$@" < /dev/null >> log.$LOG_SUFFIX 2>&1 )
+        echo "Running $appRun ($nProcs processes) on $PWD "
+        if [ "$logMode" = append ]
+        then
+        (
+            mpirun -np $nProcs $appRun $appArgs "$@" </dev/null >> $logFile 2>&1
+        )
         else
-            ( mpirun -np $nProcs $APP_RUN $APP_PARARGS -parallel "$@" < /dev/null > log.$LOG_SUFFIX 2>&1 )
+        (
+            mpirun -np $nProcs $appRun $appArgs "$@" </dev/null > $logFile 2>&1
+        )
         fi
     fi
 }
 
+
 compileApplication()
 {
     echo "Compiling $1 application"
     wmake $1
 }
 
+
 #
 # cloneCase srcDir dstDir
 #
@@ -249,6 +270,7 @@ cloneCase()
     return 0
 }
 
+
 #
 # cloneParallelCase srcDir dstDir [...times]
 #
@@ -312,13 +334,14 @@ cloneParallelCase()
     return 0
 }
 
+
 # Overwrite 0/ with the contents of 0.orig/ if it exists.
 # The -processor option to do the processor directories instead
 #
 restore0Dir()
 {
-    if [ "$1" = "-processor" ]
-    then
+    case "$1" in
+    -processor | -processors)
         echo "Restore 0/ from 0.orig/ for processor directories"
         [ -d 0.orig ] || echo "    Warning: no 0.orig/ found"
 
@@ -326,7 +349,24 @@ restore0Dir()
         \ls -d processor* | xargs -I {} \rm -rf ./{}/0
         \ls -d processor* | xargs -I {} \cp -r 0.orig ./{}/0 > /dev/null 2>&1
 
-    else
+        # Remove '#include' directives from field dictionaries
+        # for collated format
+        if [ "$1" = "-processors" ]
+        then
+        (
+            echo "Filter #include directives in processors/0:"
+            cd processors/0 2>/dev/null || exit 0
+            for file in $(grep -l "#include" * 2> /dev/null)
+            do
+                foamDictionary "$file" > "$file.$$." && mv "$file.$$." "$file"
+                echo "    $file"
+            done | tr -d '\n'
+            echo
+        )
+        fi
+        ;;
+
+    *)
         echo "Restore 0/ from 0.orig/"
         if [ -d 0.orig ]
         then
@@ -335,7 +375,9 @@ restore0Dir()
         else
             echo "    Warning: no 0.orig/ found"
         fi
-    fi
+        ;;
+    esac
 }
 
+
 #------------------------------------------------------------------------------
diff --git a/bin/tools/doxyFilter.awk b/bin/tools/doxyFilter.awk
index 0a581a61a14c19581428a4083cdf2159fae741b9..a096684722b5d975c45141efa50b4a6a52486ee9 100644
--- a/bin/tools/doxyFilter.awk
+++ b/bin/tools/doxyFilter.awk
@@ -3,7 +3,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 #------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -29,40 +29,67 @@
 #
 #     Assumes comment strings are formatted as follows
 #         //- General description
-#         //  more information
+#         //  Detailed information
 #         //  and even more information
+#     or
+#         //- General description
+#         //- that spans several
+#         //- lines
+#         //  Detailed information
+#         //  and even more information
+#
 #     This should be re-formatted as the following
-#         //! general description
-#         /*!
-#         more information
+#         /*! \brief General description
+#          that spans several
+#          lines
+#         */
+#         /*! Detailed information
 #         and even more information
 #         */
+#
 #     The intermediate "/*! ... */" block is left-justified to handle
 #     possible verbatim text
+#
 #------------------------------------------------------------------------------
 
+# States: 0=normal, 1=brief, 2=details
 BEGIN {
     state = 0
 }
 
 /^ *\/\/-/ {
-    state = 1
-    sub(/\/\/-/, "//!")
+    if (state == 0)
+    {
+        # Changed from normal to brief (start of comment block)
+        printf "/*! \\brief"
+        state = 1
+    }
+
+    if (state == 1)
+    {
+        # Within brief: strip leading
+        if (!sub(/^ *\/\/-  /, ""))
+        {
+            sub(/^ *\/\/-/, "")
+        }
+    }
+
     print
     next
 }
 
 /^ *\/\// {
-    # Start comment block
     if (state == 1)
     {
+        # Change from brief to details
+        printf "*/\n"
         printf "/*! "
         state = 2
     }
 
-    # Inside comment block
     if (state == 2)
     {
+        # Within details: strip leading
         if (!sub(/^ *\/\/  /, ""))
         {
             sub(/^ *\/\//, "")
@@ -74,10 +101,10 @@ BEGIN {
 }
 
 {
-    # End comment block
-    if (state == 2)
+    # End comment filtering
+    if (state)
     {
-        printf "*/ "
+        printf "*/\n"
     }
     state = 0
     print
diff --git a/bin/tools/foamCreateModuleInclude b/bin/tools/foamCreateModuleInclude
new file mode 100755
index 0000000000000000000000000000000000000000..83877b495a609462e45ab335f3af7597123ce225
--- /dev/null
+++ b/bin/tools/foamCreateModuleInclude
@@ -0,0 +1,364 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  | Copyright (C) 2016-2017 CINECA
+#------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     foamCreateModuleInclude
+#
+# Description
+#     Script to create module settings.
+#     This is still incomplete, but can be a useful basis when using a module
+#     system.
+#------------------------------------------------------------------------------
+usage() {
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+usage: ${0##*/} [OPTION] projectDir
+options:
+  -output=file      The output name (default: ModuleInclude.tcl)
+  -preload=file     Specify (module) file to preload. Can use multiple times
+  -tmpdir=file      The tmp directory to use.
+  -help             print the usage
+
+Create module settings for inclusion in a top-level openfoam module.
+
+USAGE
+    exit 1
+}
+
+# Report error and exit
+die()
+{
+    exec 1>&2
+    echo
+    echo "Error encountered:"
+    while [ "$#" -ge 1 ]; do echo "    $1"; shift; done
+    echo
+    echo "See '${0##*/} -help' for usage"
+    echo
+    exit 1
+}
+
+#------------------------------------------------------------------------------
+
+unset optBackend optDebug preload projectDir
+unset moduleOutput moduleTmpDir
+
+# Parse some options
+while [ "$#" -gt 0 ]
+do
+    case "$1" in
+    '')
+        # Ignore empty args
+        ;;
+    -h | -help)
+        usage
+        ;;
+    -debug)
+        optDebug=true
+        ;;
+    -preload=*)
+        preload="$preload${preload:+ }${1#*=}"
+        ;;
+    --recursive-backend--)
+        optBackend=true
+        ;;
+    --output=*)
+        moduleOutput="${1#*=}"
+        ;;
+    --tmpdir=*)
+        moduleTmpDir="${1#*=}"
+        ;;
+    -*)
+        die "unknown option: $1"
+        ;;
+    *)
+        break
+        ;;
+    esac
+    shift
+done
+
+[ "$#" -eq 1 ] || die "missing projectDir, or too many arguments"
+projectDir="${1%/}"
+
+#------------------------------------------------------------------------------
+
+# Filter accepts system paths only
+syspath() {
+    local path
+
+    set -- $(echo "${1}" | tr ':' '\n' )
+    for i in $@
+    do
+        case $i in
+        /bin | /usr/bin | /usr/lib*)
+            path="${path}${path:+:}$i";;
+        esac
+    done
+    echo "$path"
+}
+
+
+# Frontend: do all basic sanity checks in the front-end only
+if [ -z "$optBackend" ]
+then
+    # Check that it appears to be an OpenFOAM installation
+    [ -d "$projectDir" -a -f "$projectDir/etc/bashrc" ] || \
+        die "Incorrect projectDir? $projectDir"
+
+    # Check preloads
+    for file in $preloads
+    do
+        [ -f "$file" ] || echo "No such file to preload: $file" 1>&2
+    done
+
+    # Call itself with clean environment.
+    # Tag the start/end of the original PATH, LD_LIBRARY_PATH
+    exec env -i \
+        HOME=$HOME \
+        USER=$USER \
+        PATH=":MOD_PREPEND:$(syspath $PATH):MOD_APPEND:" \
+        LD_LIBRARY_PATH=":MOD_PREPEND:$(syspath $LD_LIBRARY_PATH):MOD_APPEND:" \
+        $0 \
+        --recursive-backend-- \
+        "${optDebug:+-debug}" \
+        "${output:+-output=$moduleOutput}" \
+        "${preloads:+-preload=$preloads}" \
+        "${moduleTmpDir:+-tmpdir=$moduleTmpDir}" \
+        $projectDir
+
+    exitCode=$? # exec failed?
+
+    echo "exec somehow failed?" 1>&2
+    exit $exitCode
+fi
+
+#------------------------------------------------------------------------------
+# Backend
+
+: ${moduleOutput:=ModuleInclude.tcl}
+: ${moduleTmpDir:=${TMPDIR:-/tmp}}
+
+# Preload any/all modules
+for file in $preloads
+do
+    [ -f "$file" ] && . "$file" ''
+done
+
+# Temporary files
+tmpFiles="$moduleTmpDir/modules-$USER.$$"
+if [ -n "$optDebug" ]
+then
+    echo "Preserving intermediate files: $tmpFiles.*" 1>&2
+else
+    trap 'rm -f $tmpFiles.* 2>/dev/null; exit 0' EXIT TERM INT
+fi
+
+
+# Snapshot of aliases - sorted
+printAlias()
+{
+    alias | sort -f
+}
+
+
+# Snapshot of environment - without functions
+# Sorted as non-OpenFOAM, WM_*, FOAM_*
+printEnv()
+{
+    # Non FOAM_*, WM_* settings
+    echo "# non-OpenFOAM"
+    env | sed -n -e '\@^FOAM_@d' -e '\@^WM_@d' -e '\@^[^ {}]@p' \
+        | sort -f
+
+    # WM_* settings
+    echo "# OpenFOAM"
+    env | sed -n -e '\@^WM_@p' \
+        | sort -f
+
+    # FOAM_* settings
+    echo "# OpenFOAM"
+    env | sed -n -e '\@^FOAM_@p' \
+        | sort -f
+}
+
+#
+# Initial snapshot of the environment (without functions)
+#
+printEnv   > $tmpFiles.env.pre.log
+printAlias > $tmpFiles.alias.pre.log
+
+# OpenFOAM settings
+. $projectDir/etc/bashrc ''
+
+echo "Using openfoam: $WM_PROJECT_DIR" 1>&2
+echo "==> $moduleOutput" 1>&2
+
+# Remove some cruft
+unset FOAM_JOB_DIR FOAM_RUN FOAM_SETTINGS FOAM_INST_DIR
+unset WM_PROJECT_USER_DIR WM_THIRD_PARTY_DIR
+unset SCOTCH_VERSION
+
+
+# Also remove user directories as being unreliable
+
+foamOldDirs="$CEI_HOME $BOOST_ARCH_PATH $CGAL_ARCH_PATH $FFTW_ARCH_PATH $MPI_ARCH_PATH $SCOTCH_ARCH_PATH \
+$FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN $WM_PROJECT_SITE \
+$FOAM_USER_APPBIN $FOAM_USER_LIBBIN"
+foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
+
+if [ -x "$foamClean" ]
+then
+    cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned"
+    cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \
+        && LD_LIBRARY_PATH="$cleaned"
+
+    # May not have/need any third party at all
+    if [ -n "$FOAM_EXT_LIBBIN" -a ! -d "$FOAM_EXT_LIBBIN" ]
+    then
+        cleaned=$($foamClean "$LD_LIBRARY_PATH" "$FOAM_EXT_LIBBIN") \
+            && LD_LIBRARY_PATH="$cleaned"
+
+        unset FOAM_EXT_LIBBIN
+    fi
+fi
+unset CEI_HOME
+unset ENSIGHT9_INPUT  ENSIGHT9_READER
+unset ENSIGHT10_INPUT ENSIGHT10_READER
+
+# Always consider site to be bogus. If needed, should be done elsewhere.
+unset FOAM_SITE_APPBIN FOAM_SITE_LIBBIN WM_PROJECT_SITE
+
+# Remove non-essential aliases
+unalias wmDP        2>/dev/null
+unalias wmInt32     2>/dev/null
+unalias wmInt64     2>/dev/null
+unalias wmSP        2>/dev/null
+unalias wmSchedOff  2>/dev/null
+unalias wmSchedOn   2>/dev/null
+unalias wmSet       2>/dev/null
+unalias wmUnset     2>/dev/null
+unalias app         2>/dev/null
+unalias foamSite    2>/dev/null
+unalias lib         2>/dev/null
+unalias run         2>/dev/null
+unalias sol         2>/dev/null
+unalias src         2>/dev/null
+unalias tut         2>/dev/null
+unalias util        2>/dev/null
+
+#------------------------------------------------
+
+# Generalize environment.
+# This needs rethinking since it largely duplicates logic from the etc/config.sh/settings
+rewriteEnv()
+{
+    sed \
+    -e 's@^\(FOAM_USER_APPBIN=\).*@\1$env(HOME)/OpenFOAM/$env(USER)-$env(WM_PROJECT_VERSION)/platforms/$env(WM_OPTIONS)/bin@' \
+    -e 's@^\(FOAM_USER_LIBBIN=\).*@\1$env(HOME)/OpenFOAM/$env(USER)-$env(WM_PROJECT_VERSION)/platforms/$env(WM_OPTIONS)/lib@' \
+    ;
+}
+
+#
+# Updated snapshot of the environment (without functions)
+#
+printEnv   | rewriteEnv > $tmpFiles.env.post.log
+printAlias > $tmpFiles.alias.post.log
+
+
+# Create a diff of the environment and aliases
+diff $tmpFiles.env.pre.log    $tmpFiles.env.post.log   > $tmpFiles.env.diff.log
+diff $tmpFiles.alias.pre.log  $tmpFiles.alias.post.log > $tmpFiles.alias.diff.log
+
+echo "# -------------------"  > $moduleOutput
+
+# --------------------------------------------------
+# Environment other than PATH, LD_LIBRARY_PATH
+echo "# Environment"  >> $moduleOutput
+grep '> ' $tmpFiles.env.diff.log | \
+sed \
+    -e '/^> *PATH=/d' \
+    -e '/^> *LD_LIBRARY_PATH=/d' \
+    -e 's/^>/setenv     /' \
+    -e 's/=/ "/' -e 's/$/\"/' >> $moduleOutput
+
+
+# --------------------------------------------------
+# Changes in PATH - without junk and system directories
+echo "# PATH"  >> $moduleOutput
+
+sed -ne 's/^< *PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.path.pre.log
+sed -ne 's/^> *PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.path.post.log
+
+grep -vxFf $tmpFiles.path.pre.log $tmpFiles.path.post.log | \
+sed \
+    -e '\@^/bin$@d' \
+    -e '\@^/usr/bin$@d' \
+    -e '\@^/usr/local/bin$@d' \
+    -e '\@^[.]$@d' \
+    -e '\@^$@d' \
+    > $tmpFiles.path.diff.log
+
+sed \
+    -e 's/^/append-path PATH "/' \
+    -e 's/$/\"/' \
+    $tmpFiles.path.diff.log  >> $moduleOutput
+# --------------------------------------------------
+
+# --------------------------------------------------
+# Changes in LD_LIBRARY_PATH - without junk and system directories
+echo "# LD_LIBRARY_PATH"  >> $moduleOutput
+
+sed -ne 's/^< *LD_LIBRARY_PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.ldpath.pre.log
+sed -ne 's/^> *LD_LIBRARY_PATH=//p' $tmpFiles.env.diff.log | tr ':' '\n' > $tmpFiles.ldpath.post.log
+
+grep -vxFf $tmpFiles.ldpath.pre.log $tmpFiles.ldpath.post.log | \
+sed \
+    -e '\@^/lib.*$@d' \
+    -e '\@^/usr/lib.*$@d' \
+    -e '\@^/usr/local/lib.*$@d' \
+    -e '\@^[.]$@d' \
+    -e '\@^$@d' \
+    > $tmpFiles.ldpath.diff.log
+
+sed \
+    -e 's/^/append-path LD_LIBRARY_PATH "/' \
+    -e 's/$/\"/' \
+    $tmpFiles.ldpath.diff.log >> $moduleOutput
+
+
+# -------------------
+# aliases
+# Some diff give "> alias". Others give ">", needed extended regular expressions '-r'
+
+echo "# aliases"  >> $moduleOutput
+cat $tmpFiles.alias.diff.log | \
+    sed -r -n -e 's/^> (alias)?/set-alias   /p' | \
+    sed -e "s/='/ \"/" -e "s/'/\"/g" >> $moduleOutput
+
+echo "# -------------------"   >> $moduleOutput
+
+# -----------------------------------------------------------------------------
diff --git a/etc/bashrc b/etc/bashrc
index e2e887ac646048ac52fa5f7ef0845474bc7f4bec..dbe16c9d7a94b4ee1955a3d9d63103f1b212ef25 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -65,7 +65,7 @@ export WM_COMPILER_TYPE=system
 
 #- Compiler:
 #    WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL
-#                  | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL
+#                  | Clang | Clang3[8-9] | Gcc[45]0 | Icc | IccKNL | Cray
 export WM_COMPILER=Gcc
 unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
 
@@ -89,7 +89,7 @@ export WM_COMPILE_OPTION=Opt
 
 #- MPI implementation:
 #    WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI
-#               | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
+#               | MPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
 export WM_MPLIB=SYSTEMOPENMPI
 
 #- Operating System:
diff --git a/etc/caseDicts/foamyHexMeshDict b/etc/caseDicts/foamyHexMeshDict
index 088c1a0b987fc1e7cc3483026ba611aa28cc8e8c..ee8abb7e1548a4cbe86015425bbebd8be35186ef 100644
--- a/etc/caseDicts/foamyHexMeshDict
+++ b/etc/caseDicts/foamyHexMeshDict
@@ -14,8 +14,6 @@ FoamFile
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-#inputMode merge;
-
 surfaceConformation
 {
     pointPairDistanceCoeff              0.1;
diff --git a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone
index ed81df016e3de89b7b0c5d612e7290611e5c6ebb..5158dde377b666a1600a0cfe290842b7cd97db97 100644
--- a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone
+++ b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Web:      www.OpenFOAM.org
+    \\  /    A nd           | Web:      www.OpenFOAM.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 Description
diff --git a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg
index b68815887d55ad12bae367b048417a1580ae6f06..1ba17a794f97404ec60586c93f4fb6e2eb76dba8 100644
--- a/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg
+++ b/etc/caseDicts/postProcessing/flowRate/flowRateFaceZone.cfg
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 
diff --git a/etc/codeTemplates/BC/BC.C b/etc/codeTemplates/BC/BC.C
index 5e32969aa4c951fcdc23d99766c7ce3bbd0ac844..b0091f6900e4ea2ba2c2a36770d834a7729f56a9 100644
--- a/etc/codeTemplates/BC/BC.C
+++ b/etc/codeTemplates/BC/BC.C
@@ -220,11 +220,11 @@ void Foam::CLASS::write
 ) const
 {
     FVPATCHF::write(os);
-    os.writeKeyword("scalarData") << scalarData_ << token::END_STATEMENT << nl;
-    os.writeKeyword("data") << data_ << token::END_STATEMENT << nl;
+    os.writeEntry("scalarData", scalarData_);
+    os.writeEntry("data", data_);
     fieldData_.writeEntry("fieldData", os);
     timeVsData_->writeData(os);
-    os.writeKeyword("wordData") << wordData_ << token::END_STATEMENT << nl;
+    os.writeEntry("wordData", wordData_);
     this->writeEntry("value", os);
 }
 
diff --git a/etc/config.csh/compiler b/etc/config.csh/compiler
index 7494af8f452d2996a7a5dccb5ee4f40be53f15e7..fa9915788b8a5ef1703e1c891cbe48a9c3862c15 100644
--- a/etc/config.csh/compiler
+++ b/etc/config.csh/compiler
@@ -82,7 +82,10 @@ case ThirdParty:
         set clang_version=llvm-3.9.1
         breaksw
     case Clang40:
-        set clang_version=llvm-4.0.0
+        set clang_version=llvm-4.0.1
+        breaksw
+    case Clang50:
+        set clang_version=llvm-5.0.0
         breaksw
     default:
         /bin/cat << UNKNOWN_COMPILER
diff --git a/etc/config.csh/mpi b/etc/config.csh/mpi
index e2ec875e4f2abac26f047d2a9d69f374f3995a90..ae9a7c15a467a06e57000cdcc230930b3a8e70c6 100644
--- a/etc/config.csh/mpi
+++ b/etc/config.csh/mpi
@@ -141,6 +141,28 @@ case MPICH-GM:
     _foamAddLib     $GM_LIB_PATH
     breaksw
 
+case CRAY-MPICH:
+    if ( ! $?MPICH_DIR ) setenv MPICH_DIR /dev/null
+    setenv FOAM_MPI cray-mpich
+    setenv MPI_ARCH_PATH $MPICH_DIR
+
+    if ($?FOAM_VERBOSE && $?prompt) then
+        echo "Using $WM_MPLIB"
+        echo "    FOAM_MPI  : $FOAM_MPI"
+        echo "    MPICH_DIR : $MPI_ARCH_PATH"
+    endif
+
+    if ( ! -d "$MPI_ARCH_PATH" ) then
+        echo "Warning in $WM_PROJECT_DIR/etc/config.csh/mpi:"
+        echo "    Not a valid $WM_MPLIB installation directory."
+        echo "    Please set MPICH_DIR properly."
+        echo "    Currently using '$MPI_ARCH_PATH'"
+    endif
+
+    # _foamAddPath    $MPI_ARCH_PATH/bin
+    _foamAddLib     $MPI_ARCH_PATH/lib
+    breaksw
+
 case HPMPI:
     setenv FOAM_MPI hpmpi
     setenv MPI_HOME /opt/hpmpi
diff --git a/etc/config.csh/settings b/etc/config.csh/settings
index 98442b94a1e174f490edb62abddf7bd8df4877ed..40c3df898557536f4a10b424f488d4b2af8156a5 100644
--- a/etc/config.csh/settings
+++ b/etc/config.csh/settings
@@ -214,12 +214,17 @@ if (! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system
 # Adjustments for non-gcc compilers
 switch ("$WM_COMPILER")
 case Clang*:
-    # Using clang - not gcc
+    # Using clang compiler suite
     setenv WM_CC 'clang'
     setenv WM_CXX 'clang++'
     breaksw
+case Cray*:
+    # Using cray system compilers
+    setenv WM_CC 'cc'
+    setenv WM_CXX 'CC'
+    breaksw
 case Icc*:
-    # Using icc - not gcc
+    # Using intel compilers
     setenv WM_CC 'icc'
     setenv WM_CXX 'icpc'
     breaksw
diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases
index 23b8b636e80faa7c1bcf70d11cb1ac40ebbfe034..0543a09a708af5fe2a6ad120e1ea97bcbf0a298a 100644
--- a/etc/config.sh/aliases
+++ b/etc/config.sh/aliases
@@ -72,10 +72,10 @@ alias run='cd $FOAM_RUN'
 unset -f wmRefresh 2>/dev/null
 wmRefresh()
 {
-    wmProjectDir=$WM_PROJECT_DIR
-    foamSettings=$FOAM_SETTINGS
+    local projectDir=$WM_PROJECT_DIR
+    local foamSettings=$FOAM_SETTINGS
     wmUnset
-    . $wmProjectDir/etc/bashrc $foamSettings
+    . $projectDir/etc/bashrc $foamSettings
 }
 
 
@@ -84,12 +84,25 @@ wmRefresh()
 unset -f foamVersion 2>/dev/null
 foamVersion()
 {
-    if [ "$1" ]; then
+    if [ "$#" -gt 0 ]
+    then
+        local ver=$1
+        shift
+        # The variable foamInstDir had meaning for older OpenFOAM versions
         foamInstDir=$FOAM_INST_DIR
-        wmUnset
-        . $foamInstDir/OpenFOAM-$1/etc/bashrc
-        foam
-        echo "Changed to OpenFOAM-$1" 1>&2
+        if [ -f "$foamInstDir/OpenFOAM-$ver/etc/bashrc" ]
+        then
+            wmUnset
+            . $foamInstDir/OpenFOAM-$ver/etc/bashrc
+            unset foamInstDir
+            foam
+            echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2
+        else
+            unset foamInstDir
+            echo "No OpenFOAM-$ver available" 1>&2
+            echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2
+            return 1
+        fi
     else
         echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2
     fi
diff --git a/etc/config.sh/compiler b/etc/config.sh/compiler
index cb45f303940e4dd9b5dec8c7947ad20ac0058804..3a1aefd63f0f4365049152688825f21c155d82fb 100644
--- a/etc/config.sh/compiler
+++ b/etc/config.sh/compiler
@@ -81,7 +81,10 @@ ThirdParty)
         clang_version=llvm-3.9.1
         ;;
     Clang40)
-        clang_version=llvm-4.0.0
+        clang_version=llvm-4.0.1
+        ;;
+    Clang50)
+        clang_version=llvm-5.0.0
         ;;
     *)
         /bin/cat << UNKNOWN_COMPILER 1>&2
diff --git a/etc/config.sh/kahip b/etc/config.sh/kahip
new file mode 100644
index 0000000000000000000000000000000000000000..42557831c3463fdccbd51bb2a9b7e07c96f4a590
--- /dev/null
+++ b/etc/config.sh/kahip
@@ -0,0 +1,52 @@
+#----------------------------------*-sh-*--------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#------------------------------------------------------------------------------
+# This file is part of OpenFOAM, licensed under the GNU General Public License
+# <http://www.gnu.org/licenses/>.
+#
+# File
+#     etc/config.sh/kahip
+#
+# Description
+#     Setup for kahip include/libraries.
+#     Sourced during wmake process only.
+#
+#     Normally used to specify the kahip version and location for a
+#     ThirdParty installation.
+#
+#     If using system-wide installations, use the following setting:
+#
+#         KAHIP_VERSION=kahip-system
+#
+#     If the system kahip is unusable (eg, too old) and you don't
+#     have or want a ThirdParty installation:
+#
+#         KAHIP_VERSION=kahip-none
+#
+#     If using a central installation, but not located under ThirdParty:
+#         - specify kahip-system
+#         - provide full path for KAHIP_ARCH_PATH
+#
+# Note
+#     A csh version is not needed, since the values here are only sourced
+#     during the wmake process.
+#
+#     KaHIP can also be entirely disabled, by either renaming this file or
+#     by creating an empty one with the same name at a user or site location.
+#
+#     KaHIP is 32-bit precision only.
+#     An Int64 OpenFOAM version can use it, but the mesh size is limited
+#     accordingly.
+#
+#------------------------------------------------------------------------------
+# USER EDITABLE PART: Changes made here may be lost with the next upgrade
+
+KAHIP_VERSION=kahip-2.00
+export KAHIP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$KAHIP_VERSION
+
+# END OF (NORMAL) USER EDITABLE PART
+#------------------------------------------------------------------------------
diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi
index a2d676d76b54c0fe4dc1ef4c74a2676754e7dea2..1a87bf238f91ea1bbb5a322acba22090d9cd1ba8 100644
--- a/etc/config.sh/mpi
+++ b/etc/config.sh/mpi
@@ -160,6 +160,28 @@ MPICH-GM)
     _foamAddLib     $GM_LIB_PATH
     ;;
 
+CRAY-MPICH)
+    export FOAM_MPI=cray-mpich
+    export MPI_ARCH_PATH=$MPICH_DIR
+
+    if [ "$FOAM_VERBOSE" -a "$PS1" ]
+    then
+        echo "Using $WM_MPLIB" 1>&2
+        echo "    FOAM_MPI  : $FOAM_MPI" 1>&2
+        echo "    MPICH_DIR : $MPI_ARCH_PATH" 1>&2
+    fi
+
+    [ -d "$MPI_ARCH_PATH" ] || {
+        echo "Warning in $WM_PROJECT_DIR/etc/config.sh/mpi:" 1>&2
+        echo "    Not a valid $WM_MPLIB installation directory." 1>&2
+        echo "    Please set MPICH_DIR properly" 1>&2
+        echo "    Currently using '$MPI_ARCH_PATH'" 1>&2
+    }
+
+    # _foamAddPath    $MPI_ARCH_PATH/bin
+    _foamAddLib     $MPI_ARCH_PATH/lib
+    ;;
+
 HPMPI)
     export FOAM_MPI=hpmpi
     export MPI_HOME=/opt/hpmpi
diff --git a/etc/config.sh/settings b/etc/config.sh/settings
index ebc4bf435a71eb25df4c5702441b2913aba2a803..20821fae2e3dddfc028d5c98cb349c724fde3cd9 100644
--- a/etc/config.sh/settings
+++ b/etc/config.sh/settings
@@ -216,12 +216,17 @@ _foamAddLib  $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN
 # Adjust for non-gcc compilers
 case "$WM_COMPILER" in
 Clang*)
-    # Using clang - not gcc
+    # Using clang compiler suite
     export WM_CC='clang'
     export WM_CXX='clang++'
     ;;
+Cray*)
+    # Using cray system compilers
+    export WM_CC='cc'
+    export WM_CXX='CC'
+    ;;
 Icc*)
-    # Using icc - not gcc
+    # Using intel compilers
     export WM_CC='icc'
     export WM_CXX='icpc'
     ;;
diff --git a/etc/config.sh/unset b/etc/config.sh/unset
index fe8b8f18e10267cf5121e0e22c26c3872ad2185d..31710db372ce80745e4b39ca92d96fa1fcc61d4d 100644
--- a/etc/config.sh/unset
+++ b/etc/config.sh/unset
@@ -134,6 +134,7 @@ unset GPERFTOOLS_ARCH_PATH
 unset GMP_ARCH_PATH
 unset MPFR_ARCH_PATH
 unset MESA_ARCH_PATH
+unset KAHIP_ARCH_PATH
 unset METIS_ARCH_PATH
 unset SCOTCH_ARCH_PATH
 
diff --git a/etc/controlDict b/etc/controlDict
index 77a630c3fb8cfd1635a0d22245abc31546adfe95..7b205e29bf564a1aeee6d5b748689ae636992fcc 100644
--- a/etc/controlDict
+++ b/etc/controlDict
@@ -38,21 +38,24 @@ InfoSwitches
     // The default ASCII write precision
     writePrecision  6;
 
-    // Enable job info
-    writeJobInfo    0;
-
     writeDictionaries 0;
     writeOptionalEntries 0;
 
     // Write lagrangian "positions" file in v1706 format (at earlier)
     writeLagrangianPositions 0;
 
-    // Report list of slaves/pids used (parallel)
-    writeSlaves     1;
+    // Report hosts used (parallel)
+    // - 0 = none
+    // - 1 = per-host-count, but unsorted
+    // - 2 = long output of "slave.pid" ...
+    writeHosts      1;
 
     // Report list of roots used (parallel)
     writeRoots      1;
 
+    // Enable job info
+    writeJobInfo    0;
+
     // Allow profiling
     allowProfiling  1;
 
@@ -334,7 +337,6 @@ DebugSwitches
     SpalartAllmarasIDDES    0;
     SphereDrag          0;
     StandardWallInteraction 0;
-    StaticHashTable     0;
     StochasticDispersionRAS 0;
     SuperBee            0;
     SuperBeeV           0;
diff --git a/etc/cshrc b/etc/cshrc
index 7b8da52c26df1b5c353a78e11628d0229187d17e..4b186c3fce39653d500c3d233f3d3a53d1b4a1b0 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -61,7 +61,7 @@ setenv WM_COMPILER_TYPE system
 
 #- Compiler:
 #    WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | GccKNL
-#                  | Clang | Clang3[8-9] | Clang40 | Icc | IccKNL
+#                  | Clang | Clang3[8-9] | Gcc[45]0 | Icc | IccKNL | Cray
 setenv WM_COMPILER Gcc
 setenv WM_COMPILER_ARCH # defined but empty
 unsetenv WM_COMPILER_LIB_ARCH
@@ -86,7 +86,7 @@ setenv WM_COMPILE_OPTION Opt
 
 #- MPI implementation:
 #    WM_MPLIB = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPICH | MPICH-GM | HPMPI
-#               | MPI | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
+#               | MPI | CRAY-MPICH | FJMPI | QSMPI | SGIMPI | INTELMPI | USERMPI
 setenv WM_MPLIB SYSTEMOPENMPI
 
 #- Operating System:
diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C
index 708375bfadd8a8ce87dd64e8aa48943d983d222a..432dc8ccef4b3d683b0894ae6e35b12d55335692 100644
--- a/src/OSspecific/POSIX/POSIX.C
+++ b/src/OSspecific/POSIX/POSIX.C
@@ -109,6 +109,35 @@ static inline bool isBackupName(const Foam::fileName& name)
     );
 }
 
+
+// Like fileName "/" global operator, but retain any invalid characters
+static inline Foam::fileName fileNameConcat
+(
+    const std::string& a,
+    const std::string& b
+)
+{
+    if (a.size())
+    {
+        if (b.size())
+        {
+            // Two non-empty strings: can concatenate
+            return Foam::fileName((a + '/' + b), false);
+        }
+
+        return Foam::fileName(a, false);
+    }
+
+    // Or, if the first string is empty
+
+    if (b.size())
+    {
+        return Foam::fileName(b, false);
+    }
+
+    // Both strings are empty
+    return Foam::fileName();
+}
 //! \endcond
 
 
@@ -148,12 +177,10 @@ Foam::string Foam::getEnv(const std::string& envName)
     {
         return string(env);
     }
-    else
-    {
-        // Return null-constructed string rather than string::null
-        // to avoid cyclic dependencies in the construction of globals
-        return string();
-    }
+
+    // Return null-constructed string rather than string::null
+    // to avoid cyclic dependencies in the construction of globals
+    return string();
 }
 
 
@@ -220,10 +247,8 @@ Foam::string Foam::userName()
     {
         return pw->pw_name;
     }
-    else
-    {
-        return string();
-    }
+
+    return string();
 }
 
 
@@ -246,10 +271,8 @@ Foam::fileName Foam::home()
     {
         return pw->pw_dir;
     }
-    else
-    {
-        return fileName();
-    }
+
+    return fileName();
 }
 
 
@@ -266,10 +289,8 @@ Foam::fileName Foam::home(const std::string& userName)
     {
         return pw->pw_dir;
     }
-    else
-    {
-        return fileName();
-    }
+
+    return fileName();
 }
 
 
@@ -708,14 +729,15 @@ Foam::fileNameList Foam::readDir
     const bool followLink
 )
 {
-    // Initial filename list size
-    // also used as increment if initial size found to be insufficient
+    // Initial filename list size and the increment when resizing the list
     static const int maxNnames = 100;
 
     // Basic sanity: cannot strip '.gz' from directory names
     const bool stripgz = filtergz && (type != fileName::DIRECTORY);
     const word extgz("gz");
 
+    fileNameList dirEntries;
+
     // Open directory and set the structure pointer
     // Do not attempt to open an empty directory name
     DIR *source;
@@ -731,12 +753,12 @@ Foam::fileNameList Foam::readDir
                 << "cannot open directory " << directory << endl;
         }
 
-        return fileNameList();
+        return dirEntries;
     }
 
     if (POSIX::debug)
     {
-        //InfoInFunction
+        // InfoInFunction
         Pout<< FUNCTION_NAME << " : reading directory " << directory << endl;
         if ((POSIX::debug & 2) && !Pstream::master())
         {
@@ -744,22 +766,31 @@ Foam::fileNameList Foam::readDir
         }
     }
 
-    label nEntries = 0;
-    fileNameList dirEntries(maxNnames);
+    label nFailed = 0;     // Entries with invalid characters
+    label nEntries = 0;    // Number of selected entries
+    dirEntries.setSize(maxNnames);
 
     // Read and parse all the entries in the directory
     for (struct dirent *list; (list = ::readdir(source)) != nullptr; /*nil*/)
     {
-        const fileName name(list->d_name);
+        const std::string item(list->d_name);
 
         // Ignore files/directories beginning with "."
         // These are the ".", ".." directories and any hidden files/dirs
-        if (name.empty() || name[0] == '.')
+        if (item.empty() || item[0] == '.')
         {
             continue;
         }
 
-        if
+        // Validate filename without spaces, quotes, etc in the name.
+        // No duplicate slashes to strip - dirent will not have them anyhow.
+
+        const fileName name(fileName::validate(item));
+        if (name != item)
+        {
+            ++nFailed;
+        }
+        else if
         (
             (type == fileName::DIRECTORY)
          || (type == fileName::FILE && !isBackupName(name))
@@ -783,10 +814,18 @@ Foam::fileNameList Foam::readDir
             }
         }
     }
+    ::closedir(source);
 
-    // Reset the length of the entries list
+    // Finalize the length of the entries list
     dirEntries.setSize(nEntries);
-    ::closedir(source);
+
+    if (nFailed && POSIX::debug)
+    {
+        std::cerr
+            << "Foam::readDir() : reading directory " << directory << nl
+            << nFailed << " entries with invalid characters in their name"
+            << std::endl;
+    }
 
     return dirEntries;
 }
@@ -911,22 +950,22 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
         }
 
         // Copy files
-        fileNameList contents = readDir(src, fileName::FILE, false, followLink);
-        forAll(contents, i)
+        fileNameList files = readDir(src, fileName::FILE, false, followLink);
+        for (const fileName& item : files)
         {
             if (POSIX::debug)
             {
                 InfoInFunction
-                    << "Copying : " << src/contents[i]
-                    << " to " << destFile/contents[i] << endl;
+                    << "Copying : " << src/item
+                    << " to " << destFile/item << endl;
             }
 
             // File to file.
-            cp(src/contents[i], destFile/contents[i], followLink);
+            cp(src/item, destFile/item, followLink);
         }
 
         // Copy sub directories.
-        fileNameList subdirs = readDir
+        fileNameList dirs = readDir
         (
             src,
             fileName::DIRECTORY,
@@ -934,17 +973,17 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
             followLink
         );
 
-        forAll(subdirs, i)
+        for (const fileName& item : dirs)
         {
             if (POSIX::debug)
             {
                 InfoInFunction
-                    << "Copying : " << src/subdirs[i]
+                    << "Copying : " << src/item
                     << " to " << destFile << endl;
             }
 
             // Dir to Dir.
-            cp(src/subdirs[i], destFile, followLink);
+            cp(src/item, destFile, followLink);
         }
     }
     else
@@ -1002,12 +1041,10 @@ bool Foam::ln(const fileName& src, const fileName& dst)
     {
         return true;
     }
-    else
-    {
-        WarningInFunction
-            << "symlink from " << src << " to " << dst << " failed." << endl;
-        return false;
-    }
+
+    WarningInFunction
+        << "symlink from " << src << " to " << dst << " failed." << endl;
+    return false;
 }
 
 
@@ -1157,14 +1194,20 @@ bool Foam::rmDir(const fileName& directory, const bool silent)
     label nErrors = 0;
     for (struct dirent *list; (list = ::readdir(source)) != nullptr; /*nil*/)
     {
-        const fileName name(list->d_name);
-        if (name.empty() || name == "." || name == "..")
+        const std::string item(list->d_name);
+
+        // Ignore "." and ".." directories
+        if (item.empty() || item == "." || item == "..")
         {
-            // Ignore "." and ".." directories
             continue;
         }
 
-        const fileName path = directory/name;
+        // Allow invalid characters (spaces, quotes, etc),
+        // otherwise we cannot subdirs with these types of names.
+        // -> const fileName path = directory/name; <-
+
+        const fileName path(fileNameConcat(directory, item));
+
         if (path.type(false) == fileName::DIRECTORY)
         {
             if (!rmDir(path, true))  // Only report errors at the top-level
@@ -1548,10 +1591,8 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol)
         // symbol can be found if there was no error
         return !::dlerror();
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
@@ -1680,7 +1721,7 @@ Foam::label Foam::allocateThread()
         }
     }
 
-    label index = threads_.size();
+    const label index = threads_.size();
     if (POSIX::debug)
     {
         Pout<< "allocateThread : new index:" << index << endl;
@@ -1750,7 +1791,7 @@ Foam::label Foam::allocateMutex()
         }
     }
 
-    label index = mutexes_.size();
+    const label index = mutexes_.size();
 
     if (POSIX::debug)
     {
diff --git a/src/OSspecific/POSIX/cpuInfo/cpuInfo.C b/src/OSspecific/POSIX/cpuInfo/cpuInfo.C
index 6dbd6abf4b26869af931987db27be86f23d1abac..e394ec7b22231f1158faaa9bcd4c1e3e4d3920a9 100644
--- a/src/OSspecific/POSIX/cpuInfo/cpuInfo.C
+++ b/src/OSspecific/POSIX/cpuInfo/cpuInfo.C
@@ -174,26 +174,12 @@ void Foam::cpuInfo::write(Ostream& os) const
     {
         os.writeEntry("model_name", model_name);
     }
-    if (cpu_family != -1)
-    {
-        os.writeEntry("cpu_family", cpu_family);
-    }
-    if (model != -1)
-    {
-        os.writeEntry("model", model);
-    }
-    if (cpu_MHz > 0)
-    {
-        os.writeEntry("cpu_MHz", cpu_MHz);
-    }
-    if (cpu_cores > 0)
-    {
-        os.writeEntry("cpu_cores", cpu_cores);
-    }
-    if (siblings > 0)
-    {
-        os.writeEntry("siblings", siblings);
-    }
+
+    os.writeEntryIfDifferent<int>("cpu_family", -1, cpu_family);
+    os.writeEntryIfDifferent<int>("model", -1, model);
+    os.writeEntryIfDifferent<float>("cpu_MHz", 0, cpu_MHz);
+    os.writeEntryIfDifferent<int>("cpu_cores", 0, cpu_cores);
+    os.writeEntryIfDifferent<int>("siblings", 0, siblings);
 }
 
 
diff --git a/src/OSspecific/POSIX/regExp.H b/src/OSspecific/POSIX/regExp.H
index 6a03192cf27e7607e971f66e9749da252ec0d9ac..c5c78929092cda94c6c3038b8677814c332ca2ad 100644
--- a/src/OSspecific/POSIX/regExp.H
+++ b/src/OSspecific/POSIX/regExp.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -113,6 +113,9 @@ public:
         //- Construct from string, optionally ignore case
         inline regExp(const std::string& pattern, bool ignoreCase);
 
+        //- Move construct
+        inline regExp(regExp&& rgx);
+
 
     //- Destructor
     inline ~regExp();
@@ -146,6 +149,9 @@ public:
         //  \return True if expression had existed prior to the clear.
         bool clear();
 
+        //- Swap contents
+        inline void swap(regExp& rgx);
+
 
       // Matching/Searching
 
@@ -177,6 +183,10 @@ public:
         //- Assign and compile pattern from string
         //  Always case sensitive
         inline void operator=(const std::string& pattern);
+
+        //- Move assignment
+        inline void operator=(regExp&& rgx);
+
 };
 
 
diff --git a/src/OSspecific/POSIX/regExpI.H b/src/OSspecific/POSIX/regExpI.H
index 7302e02410bd8486372eca38d07dc6bda55faf04..60c7da3053b2d30a4af82700ff277a8bc2b3a488 100644
--- a/src/OSspecific/POSIX/regExpI.H
+++ b/src/OSspecific/POSIX/regExpI.H
@@ -23,6 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
+#include <algorithm>
+
 
 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
 
@@ -78,6 +80,14 @@ inline Foam::regExp::regExp(const std::string& pattern, bool ignoreCase)
 }
 
 
+inline Foam::regExp::regExp(regExp&& rgx)
+:
+    preg_(rgx.preg_)
+{
+    rgx.preg_ = nullptr;
+}
+
+
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 inline Foam::regExp::~regExp()
@@ -112,6 +122,12 @@ inline bool Foam::regExp::search(const std::string& text) const
 }
 
 
+inline void Foam::regExp::swap(regExp& rgx)
+{
+    std::swap(preg_, rgx.preg_);
+}
+
+
 // * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * * //
 
 inline bool Foam::regExp::operator()(const std::string& text) const
@@ -132,4 +148,11 @@ inline void Foam::regExp::operator=(const std::string& pattern)
 }
 
 
+inline void Foam::regExp::operator=(regExp&& rgx)
+{
+    clear();
+    swap(rgx);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index cc59794bae8d77cf4ae4fdcd905d596d4ae76017..130b48e5b3e32052e56d0ac36d81198ef4dc41ed 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -114,6 +114,7 @@ $(strings)/wordRe/wordRe.C
 $(strings)/wordRes/wordRes.C
 $(strings)/lists/hashedWordList.C
 $(strings)/stringOps/stringOps.C
+$(strings)/stringOps/stringOpsSort.C
 $(strings)/parsing/parsing.C
 
 ops = primitives/ops
@@ -146,7 +147,6 @@ primitives/Barycentric/barycentric/barycentric.C
 primitives/Barycentric2D/barycentric2D/barycentric2D.C
 
 containers/HashTables/HashTable/HashTableCore.C
-containers/HashTables/StaticHashTable/StaticHashTableCore.C
 containers/Lists/SortableList/ParSortableListName.C
 containers/Lists/PackedList/PackedListCore.C
 containers/Lists/PackedList/PackedBoolList.C
@@ -175,6 +175,9 @@ $(hashes)/base64Layer.C
 gzstream = $(Streams)/gzstream
 $(gzstream)/gzstream.C
 
+memstream = $(Streams)/memory
+$(memstream)/ListStream.C
+
 Fstreams = $(Streams)/Fstreams
 $(Fstreams)/IFstream.C
 $(Fstreams)/OFstream.C
@@ -199,6 +202,8 @@ $(Pstreams)/PstreamBuffers.C
 dictionary = db/dictionary
 $(dictionary)/dictionary.C
 $(dictionary)/dictionaryIO.C
+$(dictionary)/dictionarySearch.C
+$(dictionary)/dictionaryCompat.C
 
 entry = $(dictionary)/entry
 $(entry)/entry.C
@@ -213,7 +218,6 @@ $(dictionaryEntry)/dictionaryEntry.C
 $(dictionaryEntry)/dictionaryEntryIO.C
 
 dictionaryListEntry = $(dictionary)/dictionaryListEntry
-$(dictionaryListEntry)/dictionaryListEntry.C
 $(dictionaryListEntry)/dictionaryListEntryIO.C
 
 functionEntries = $(dictionary)/functionEntries
diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C
index 60b390223c2651a0d3e4d126582939ea16d382a5..2f95d40f713993a5b5ba4888845696ab0b68e738 100644
--- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C
+++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C
@@ -189,6 +189,17 @@ Foam::wordList Foam::DictionaryBase<IDLListType, T>::sortedToc() const
 }
 
 
+template<class IDLListType, class T>
+template<class Compare>
+Foam::wordList Foam::DictionaryBase<IDLListType, T>::sortedToc
+(
+    const Compare& comp
+) const
+{
+    return hashedTs_.sortedToc(comp);
+}
+
+
 template<class IDLListType, class T>
 void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr)
 {
diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H
index f4d864d82c746d51807a8ed2f82e7027f8940890..8c48737427298aadfd2339622de74f2f1d790ef3 100644
--- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H
+++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H
@@ -131,6 +131,10 @@ public:
             //- Return the table of contents as a sorted list
             wordList sortedToc() const;
 
+            //- Return table of contents sorted using the specified comparator
+            template<class Compare>
+            wordList sortedToc(const Compare& comp) const;
+
 
         // Editing
 
diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C
index 9370dd26edf59ee2f60dd2182250881d5df471a0..e7ad07ec2fd6b06036e19ac952fd3bf46af10aa0 100644
--- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C
+++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.C
@@ -28,6 +28,13 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
+template<class T, class Key, class Hash>
+Foam::HashPtrTable<T, Key, Hash>::HashPtrTable()
+:
+    parent_type()
+{}
+
+
 template<class T, class Key, class Hash>
 Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(const label size)
 :
@@ -157,6 +164,7 @@ void Foam::HashPtrTable<T, Key, Hash>::operator=
     }
 }
 
+
 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
 #include "HashPtrTableIO.C"
diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H
index f83c04e313905400600b2f1733ec49732281e6f8..548066d19f6c96449d65c36b457213c679e83f8c 100644
--- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H
+++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H
@@ -91,8 +91,11 @@ public:
 
     // Constructors
 
-        //- Construct given initial table size
-        HashPtrTable(const label size = 128);
+        //- Construct null with default table capacity
+        HashPtrTable();
+
+        //- Construct given initial table capacity
+        explicit HashPtrTable(const label size);
 
         //- Construct from Istream using given Istream constructor class
         template<class INew>
@@ -102,7 +105,7 @@ public:
         HashPtrTable(Istream& is);
 
         //- Construct from dictionary with default dictionary constructor class
-        HashPtrTable(const dictionary& dict);
+        explicit HashPtrTable(const dictionary& dict);
 
         //- Construct as copy
         HashPtrTable(const this_type& ht);
@@ -120,14 +123,14 @@ public:
         //  Includes a safeguard against the end-iterator.
         T* remove(iterator& iter);
 
-        //- Erase an entry specified by given iterator
+        //- Erase an entry specified by given iterator.
         //  Includes a safeguard against the end-iterator.
         bool erase(iterator& iter);
 
         //- Erase an entry specified by the given key
         bool erase(const Key& key);
 
-        //- Clear all entries from table
+        //- Clear all entries from table and deleting any allocated pointers
         void clear();
 
         //- Write
diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C
index 55004189fe0d6fb9123551e5764d72568849d1d2..bbc7351857e23dad60bcd34dfca08cf7efda1418 100644
--- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C
+++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C
@@ -41,7 +41,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
 
     is.fatalCheck
     (
-        "HashPtrTable<T, Key, Hash>::read(Istream&, const INew&) : "
+        "HashPtrTable::read(Istream&, const INew&) : "
         "reading first token"
     );
 
@@ -50,7 +50,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
         const label s = firstToken.labelToken();
 
         // Read beginning of contents
-        const char delimiter = is.readBeginList("HashPtrTable<T, Key, Hash>");
+        const char delimiter = is.readBeginList("HashPtrTable");
 
         if (s)
         {
@@ -69,8 +69,8 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
 
                     is.fatalCheck
                     (
-                        "HashPtrTable<T, Key, Hash>::"
-                        "read(Istream&, const INew&) : reading entry"
+                        "HashPtrTable::read(Istream&, const INew&) : "
+                        "reading entry"
                     );
                 }
             }
@@ -114,7 +114,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
 
             is.fatalCheck
             (
-                "HashPtrTable<T, Key, Hash>::read(Istream&, const INew&) : "
+                "HashPtrTable::read(Istream&, const INew&) : "
                 "reading entry"
             );
 
@@ -155,7 +155,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read
 template<class T, class Key, class Hash>
 void Foam::HashPtrTable<T, Key, Hash>::write(Ostream& os) const
 {
-    for (const_iterator iter = this->begin(); iter != this->end(); ++iter)
+    for (const_iterator iter = this->cbegin(); iter != this->cend(); ++iter)
     {
         const T* ptr = iter.object();
         if (ptr)
@@ -209,29 +209,34 @@ Foam::Ostream& Foam::operator<<
     const HashPtrTable<T, Key, Hash>& tbl
 )
 {
-    using const_iterator = typename HashPtrTable<T, Key, Hash>::const_iterator;
+    const label sz = tbl.size();
 
-    // Write size and start delimiter
-    os << nl << tbl.size() << nl << token::BEGIN_LIST << nl;
-
-    // Write contents
-    for (const_iterator iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
+    if (sz)
     {
-        const T* ptr = iter.object();
+        // Size and start list delimiter
+        os << nl << sz << nl << token::BEGIN_LIST << nl;
 
-        os << iter.key();
-        if (ptr)
+        // Contents
+        for (auto iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
         {
-            os << token::SPACE << *ptr;
+            const T* ptr = iter.object();
+
+            os << iter.key();
+            if (ptr)
+            {
+                os << token::SPACE << *ptr;
+            }
+            os << nl;
         }
-        os << nl;
+        os << token::END_LIST; // End list delimiter
+    }
+    else
+    {
+        // Empty hash table
+        os << sz << token::BEGIN_LIST << token::END_LIST;
     }
-
-    // Write end delimiter
-    os << token::END_LIST;
 
     os.check(FUNCTION_NAME);
-
     return os;
 }
 
diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C
index 5b1f45b8395a9cf7e57d1cf171bcfb645a7145d6..3070831f26af3bf1c9cdd450cf2c463dab7dc1f0 100644
--- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C
+++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.C
@@ -79,7 +79,7 @@ inline Foam::label Foam::HashSet<Key, Hash>::assignMultiple
 template<class Key, class Hash>
 Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
 :
-    HashTable<nil, Key, Hash>(2*lst.size())
+    parent_type(2*lst.size())
 {
     for (const auto& k : lst)
     {
@@ -92,7 +92,7 @@ template<class Key, class Hash>
 template<unsigned Size>
 Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst)
 :
-    HashTable<nil, Key, Hash>(2*lst.size())
+    parent_type(2*lst.size())
 {
     for (const auto& k : lst)
     {
@@ -104,7 +104,7 @@ Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst)
 template<class Key, class Hash>
 Foam::HashSet<Key, Hash>::HashSet(std::initializer_list<Key> lst)
 :
-    HashTable<nil, Key, Hash>(2*lst.size())
+    parent_type(2*lst.size())
 {
     for (const auto& k : lst)
     {
@@ -120,7 +120,7 @@ Foam::HashSet<Key, Hash>::HashSet
     const HashTable<AnyType, Key, AnyHash>& tbl
 )
 :
-    HashTable<nil, Key, Hash>(tbl.capacity())
+    parent_type(tbl.capacity())
 {
     using other_iter =
         typename HashTable<AnyType, Key, AnyHash>::const_iterator;
@@ -275,7 +275,20 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const HashSet<Key, Hash>& tbl)
 }
 
 
-/* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
+// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
+
+template<class Key, class Hash>
+inline void Foam::Swap
+(
+    HashSet<Key, Hash>& a,
+    HashSet<Key, Hash>& b
+)
+{
+    a.swap(b);
+}
+
+
+/* * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * */
 
 template<class Key, class Hash>
 Foam::HashSet<Key, Hash>
@@ -336,7 +349,7 @@ template<class Key, class Hash>
 inline typename Foam::HashSet<Key, Hash>::const_iterator
 Foam::HashSet<Key, Hash>::begin() const
 {
-    return HashTableCore::iterator_begin<const_iterator>
+    return HashTableCore::iterator_cbegin<const_iterator>
     (
         static_cast<const parent_type&>(*this)
     );
@@ -347,7 +360,7 @@ template<class Key, class Hash>
 inline typename Foam::HashSet<Key, Hash>::const_iterator
 Foam::HashSet<Key, Hash>::cbegin() const
 {
-    return HashTableCore::iterator_begin<const_iterator>
+    return HashTableCore::iterator_cbegin<const_iterator>
     (
         static_cast<const parent_type&>(*this)
     );
@@ -366,7 +379,7 @@ template<class Key, class Hash>
 inline const typename Foam::HashSet<Key, Hash>::const_iterator&
 Foam::HashSet<Key, Hash>::end() const
 {
-    return HashTableCore::iterator_end<const_iterator>();
+    return HashTableCore::iterator_cend<const_iterator>();
 }
 
 
diff --git a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H
index fe82253bc0fb205411c9bc54e8493f4cffac0196..5c467a256288fd6eaa3ce2ba3c15a7811fd8e52c 100644
--- a/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H
+++ b/src/OpenFOAM/containers/HashTables/HashSet/HashSet.H
@@ -25,7 +25,25 @@ Class
     Foam::HashSet
 
 Description
-    A HashTable with keys but without contents.
+    A HashTable with keys but without contents that is similar to
+    \c std::unordered_set.
+
+    The entries are considered \a unordered since their placement
+    depends on the method used to generate the hash key index, the
+    table capacity, insertion order etc. When the key order is
+    important, use the sortedToc() method to obtain a list of sorted
+    keys and use that for further access.
+
+Note
+    The HashSet iterator dereferences to the key, so the following
+    range-for works as expected:
+    \code
+        HashSet<label> someLabels{10, 20, 30, 40, ...};
+        for (const label i : someLabels)
+        {
+            Info<< "val:" << i << nl;
+        }
+    \endcode
 
 Typedef
     Foam::wordHashSet
@@ -45,7 +63,6 @@ Description
 #define HashSet_H
 
 #include "HashTable.H"
-#include "nil.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -66,7 +83,7 @@ Ostream& operator<<(Ostream& os, const HashSet<Key, Hash>& tbl);
 template<class Key=word, class Hash=string::hash>
 class HashSet
 :
-    public HashTable<nil, Key, Hash>
+    public HashTable<zero::null, Key, Hash>
 {
     // Private Member Functions
 
@@ -94,7 +111,7 @@ public:
     typedef HashSet<Key, Hash> this_type;
 
     //- The template instance used for the parent HashTable
-    typedef HashTable<nil, Key, Hash> parent_type;
+    typedef HashTable<zero::null, Key, Hash> parent_type;
 
     //- An iterator, returning reference to the key
     using iterator = typename parent_type::key_iterator;
@@ -105,13 +122,19 @@ public:
 
     // Constructors
 
-        //- Construct given initial size
-        HashSet(const label size = 128)
+        //- Construct null with default (128) table capacity
+        HashSet()
+        :
+            parent_type()
+        {}
+
+        //- Construct given initial table capacity
+        explicit HashSet(const label size)
         :
             parent_type(size)
         {}
 
-        //- Construct from Istream
+        //- Construct from Istream with default table capacity
         HashSet(Istream& is)
         :
             parent_type(is)
@@ -127,20 +150,26 @@ public:
         //- Construct from an initializer list of Key
         HashSet(std::initializer_list<Key> lst);
 
-        //- Construct as copy
-        HashSet(const HashSet<Key, Hash>& hs)
+        //- Copy construct
+        HashSet(const this_type& hs)
         :
             parent_type(hs)
         {}
 
+        //- Move construct
+        HashSet(this_type&& hs)
+        :
+            parent_type(std::move(hs))
+        {}
+
         //- Construct by transferring the parameter contents
-        HashSet(const Xfer<HashSet<Key, Hash>>& hs)
+        HashSet(const Xfer<this_type>& hs)
         :
             parent_type(hs)
         {}
 
         //- Construct by transferring the parameter contents
-        HashSet(const Xfer<HashTable<nil, Key, Hash>>& hs)
+        HashSet(const Xfer<parent_type>& hs)
         :
             parent_type(hs)
         {}
@@ -155,12 +184,12 @@ public:
 
       // Edit
 
-        //- Insert a new entry
+        //- Insert a new entry, not overwriting existing entries.
         //  \return True if the entry inserted, which means that it did
         //  not previously exist in the set.
         bool insert(const Key& key)
         {
-            return this->parent_type::insert(key, nil());
+            return this->parent_type::insert(key, zero::null());
         }
 
         //- Insert keys from the list of Key
@@ -176,26 +205,26 @@ public:
         //  \return The number of new elements inserted
         label insert(std::initializer_list<Key> lst);
 
-        //- Same as insert (cannot overwrite nil content)
+        //- Same as insert (no value to overwrite)
         bool set(const Key& key)
         {
             return insert(key);
         }
 
-        //- Same as insert (cannot overwrite nil content)
+        //- Same as insert (no value to overwrite)
         label set(const UList<Key>& lst)
         {
             return insert(lst);
         }
 
-        //- Same as insert (cannot overwrite nil content)
+        //- Same as insert (no value to overwrite)
         template<unsigned Size>
         label set(const FixedList<Key, Size>& lst)
         {
             return insert(lst);
         }
 
-        //- Same as insert (cannot overwrite nil content)
+        //- Same as insert (no value to overwrite)
         label set(std::initializer_list<Key> lst)
         {
             return insert(lst);
@@ -269,7 +298,8 @@ public:
     // Writing
 
         //- Write the unordered keys as a list, with line-breaks if list length
-        //  exceeds shortListLen. Using '0' suppresses line-breaks entirely.
+        //- exceeds shortListLen.
+        //  Using '0' suppresses line-breaks entirely.
         Ostream& writeList(Ostream& os, const label shortListLen=0) const
         {
             return this->writeKeys(os, shortListLen);
@@ -284,11 +314,25 @@ public:
         //- Return true if the entry exists, same as found().
         inline bool operator[](const Key& key) const;
 
+        using parent_type::operator=;
+
+        //- Copy assignment
+        void operator=(const this_type& rhs)
+        {
+            parent_type::operator=(rhs);
+        }
+
+        //- Move assignment
+        void operator=(this_type&& rhs)
+        {
+            parent_type::operator=(std::move(rhs));
+        }
+
 
       // Comparison
 
-        //- Equality. Two hashset are equal when they have the same keys.
-        //  Independent of table size or order.
+        //- Sets are equal if all keys are equal,
+        //- independent of order or underlying storage size.
         bool operator==(const this_type& rhs) const;
 
         //- The opposite of the equality operation.
@@ -311,22 +355,22 @@ public:
       // Logical operations
 
         //- Combine entries from HashSets
-        void operator|=(const HashSet<Key, Hash>& rhs);
+        void operator|=(const this_type& rhs);
 
         //- Only retain entries found in both HashSets
-        inline void operator&=(const HashSet<Key, Hash>& rhs);
+        inline void operator&=(const this_type& rhs);
 
         //- Only retain unique entries (xor)
-        void operator^=(const HashSet<Key, Hash>& rhs);
+        void operator^=(const this_type& rhs);
 
         //- Add entries listed in the given HashSet to this HashSet
-        inline void operator+=(const HashSet<Key, Hash>& rhs)
+        inline void operator+=(const this_type& rhs)
         {
             this->operator|=(rhs);
         }
 
         //- Remove entries listed in the given HashSet from this HashSet
-        inline void operator-=(const HashSet<Key, Hash>& rhs);
+        inline void operator-=(const this_type& rhs);
 
 
     // IOstream Operator
@@ -340,6 +384,17 @@ public:
 };
 
 
+// Global Functions
+
+// Exchange contents of HashSets - see HashSet::swap().
+template<class Key, class Hash>
+inline void Swap
+(
+    HashSet<Key, Hash>& a,
+    HashSet<Key, Hash>& b
+);
+
+
 // Global Operators
 
 //- Combine entries from HashSets
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
index bc887b7d3b9217107ec495e432a52eaf569cf5ec..68faaafb49f0688ee11a1d61cec3eb7cac273165 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C
@@ -61,21 +61,27 @@ Foam::label Foam::HashTable<T, Key, Hash>::eraseMultiple
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
+template<class T, class Key, class Hash>
+Foam::HashTable<T, Key, Hash>::HashTable()
+:
+    HashTable<T, Key, Hash>(128)
+{}
+
+
 template<class T, class Key, class Hash>
 Foam::HashTable<T, Key, Hash>::HashTable(const label size)
 :
     HashTableCore(),
-    nElmts_(0),
-    tableSize_(HashTableCore::canonicalSize(size)),
+    size_(0),
+    capacity_(HashTableCore::canonicalSize(size)),
     table_(nullptr)
 {
-    if (tableSize_)
+    if (capacity_)
     {
-        table_ = new hashedEntry*[tableSize_];
-
-        for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
+        table_ = new node_type*[capacity_];
+        for (label i=0; i < capacity_; ++i)
         {
-            table_[hashIdx] = nullptr;
+            table_[i] = nullptr;
         }
     }
 }
@@ -84,7 +90,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(const label size)
 template<class T, class Key, class Hash>
 Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
 :
-    HashTable<T, Key, Hash>(ht.tableSize_)
+    HashTable<T, Key, Hash>(ht.capacity_)
 {
     for (const_iterator iter = ht.cbegin(); iter != ht.cend(); ++iter)
     {
@@ -93,16 +99,22 @@ Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
 }
 
 
+template<class T, class Key, class Hash>
+Foam::HashTable<T, Key, Hash>::HashTable(HashTable<T, Key, Hash>&& ht)
+:
+    HashTable<T, Key, Hash>(0)
+{
+    transfer(ht);
+}
+
+
 template<class T, class Key, class Hash>
 Foam::HashTable<T, Key, Hash>::HashTable
 (
     const Xfer<HashTable<T, Key, Hash>>& ht
 )
 :
-    HashTableCore(),
-    nElmts_(0),
-    tableSize_(0),
-    table_(nullptr)
+    HashTable<T, Key, Hash>(0)
 {
     transfer(ht());
 }
@@ -139,125 +151,39 @@ Foam::HashTable<T, Key, Hash>::~HashTable()
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class T, class Key, class Hash>
-bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const
+Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
 {
-    if (nElmts_)
-    {
-        const label hashIdx = hashKeyIndex(key);
-
-        for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
-        {
-            if (key == ep->key_)
-            {
-                return true;
-            }
-        }
-    }
+    List<Key> keyLst(size_);
+    label count = 0;
 
-    #ifdef FULLDEBUG
-    if (debug)
+    for (const_iterator iter = cbegin(); iter != cend(); ++iter)
     {
-        InfoInFunction << "Entry " << key << " not found in hash table\n";
+        keyLst[count++] = iter.key();
     }
-    #endif
 
-    return false;
+    return keyLst;
 }
 
 
 template<class T, class Key, class Hash>
-typename Foam::HashTable<T, Key, Hash>::iterator
-Foam::HashTable<T, Key, Hash>::find
-(
-    const Key& key
-)
+Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const
 {
-    if (nElmts_)
-    {
-        const label hashIdx = hashKeyIndex(key);
-
-        for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
-        {
-            if (key == ep->key_)
-            {
-                return iterator(this, ep, hashIdx);
-            }
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        InfoInFunction << "Entry " << key << " not found in hash table\n";
-    }
-    #endif
+    List<Key> keyLst(this->toc());
+    Foam::sort(keyLst);
 
-    return iterator();
+    return keyLst;
 }
 
 
 template<class T, class Key, class Hash>
-typename Foam::HashTable<T, Key, Hash>::const_iterator
-Foam::HashTable<T, Key, Hash>::find
+template<class Compare>
+Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc
 (
-    const Key& key
+    const Compare& comp
 ) const
 {
-    return this->cfind(key);
-}
-
-
-template<class T, class Key, class Hash>
-typename Foam::HashTable<T, Key, Hash>::const_iterator
-Foam::HashTable<T, Key, Hash>::cfind
-(
-    const Key& key
-) const
-{
-    if (nElmts_)
-    {
-        const label hashIdx = hashKeyIndex(key);
-
-        for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
-        {
-            if (key == ep->key_)
-            {
-                return const_iterator(this, ep, hashIdx);
-            }
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        InfoInFunction << "Entry " << key << " not found in hash table\n";
-    }
-    #endif
-
-    return const_iterator();
-}
-
-
-template<class T, class Key, class Hash>
-Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
-{
-    List<Key> keyLst(nElmts_);
-    label count = 0;
-
-    for (const_iterator iter = cbegin(); iter != cend(); ++iter)
-    {
-        keyLst[count++] = iter.key();
-    }
-
-    return keyLst;
-}
-
-
-template<class T, class Key, class Hash>
-Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const
-{
-    List<Key> keyLst = this->toc();
-    Foam::sort(keyLst);
+    List<Key> keyLst(this->toc());
+    Foam::sort(keyLst, comp);
 
     return keyLst;
 }
@@ -271,7 +197,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocKeys
     const bool invert
 ) const
 {
-    List<Key> keyLst(nElmts_);
+    List<Key> keyLst(size_);
     label count = 0;
 
     for (const_iterator iter = cbegin(); iter != cend(); ++iter)
@@ -297,7 +223,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocValues
     const bool invert
 ) const
 {
-    List<Key> keyLst(nElmts_);
+    List<Key> keyLst(size_);
     label count = 0;
 
     for (const_iterator iter = cbegin(); iter != cend(); ++iter)
@@ -323,7 +249,7 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::tocEntries
     const bool invert
 ) const
 {
-    List<Key> keyLst(nElmts_);
+    List<Key> keyLst(size_);
     label count = 0;
 
     for (const_iterator iter = cbegin(); iter != cend(); ++iter)
@@ -412,36 +338,36 @@ bool Foam::HashTable<T, Key, Hash>::set
 (
     const Key& key,
     const T& obj,
-    const bool protect
+    const bool overwrite
 )
 {
-    if (!tableSize_)
+    if (!capacity_)
     {
         resize(2);
     }
 
-    const label hashIdx = hashKeyIndex(key);
+    const label index = hashKeyIndex(key);
 
-    hashedEntry* existing = nullptr;
-    hashedEntry* prev = nullptr;
+    node_type* curr = nullptr;
+    node_type* prev = nullptr;
 
-    for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
+    for (node_type* ep = table_[index]; ep; ep = ep->next_)
     {
-        if (key == ep->key_)
+        if (key == ep->key())
         {
-            existing = ep;
+            curr = ep;
             break;
         }
         prev = ep;
     }
 
-    if (!existing)
+    if (!curr)
     {
         // Not found, insert it at the head
-        table_[hashIdx] = new hashedEntry(key, obj, table_[hashIdx]);
-        nElmts_++;
+        table_[index] = new node_type(key, obj, table_[index]);
+        ++size_;
 
-        if (double(nElmts_)/tableSize_ > 0.8 && tableSize_ < maxTableSize)
+        if (double(size_)/capacity_ > 0.8 && capacity_ < maxTableSize)
         {
             #ifdef FULLDEBUG
             if (debug)
@@ -450,115 +376,60 @@ bool Foam::HashTable<T, Key, Hash>::set
             }
             #endif
 
-            resize(2*tableSize_);
+            resize(2*capacity_);
         }
     }
-    else if (protect)
+    else if (overwrite)
     {
-        // Found - but protected from overwriting
-        // this corresponds to the STL 'insert' convention
-        #ifdef FULLDEBUG
-        if (debug)
-        {
-            InfoInFunction
-                << "Cannot insert " << key << " already in hash table\n";
-        }
-        #endif
-        return false;
-    }
-    else
-    {
-        // Found - overwrite existing entry
-        // this corresponds to the Perl convention
-        hashedEntry* ep = new hashedEntry(key, obj, existing->next_);
+        // Overwrite current entry (Perl convention).
 
-        // Replace existing element - within list or insert at the head
-        if (prev)
-        {
-            prev->next_ = ep;
-        }
-        else
-        {
-            table_[hashIdx] = ep;
-        }
-
-        delete existing;
-    }
-
-    return true;
-}
+        node_type* ep = curr->next_;  // next in the linked list
 
+        // In some cases the delete/new could be avoided in favour of move
+        // assignment, but cannot be certain that all objects support this
+        // or that it behaves the same as a copy construct.
 
-template<class T, class Key, class Hash>
-bool Foam::HashTable<T, Key, Hash>::iterator_base::erase()
-{
-    // Note: entryPtr_ is nullptr for end(), so this catches that too
-    if (entryPtr_)
-    {
-        // Search element before entryPtr_
-        entry_type* prev = nullptr;
-
-        for
-        (
-            entry_type* ep = hashTable_->table_[hashIndex_];
-            ep;
-            ep = ep->next_
-        )
-        {
-            if (ep == entryPtr_)
-            {
-                break;
-            }
-            prev = ep;
-        }
+        delete curr;
+        ep = new node_type(key, obj, ep);
 
+        // Replace current element - within list or insert at the head
         if (prev)
         {
-            // Has an element before entryPtr - reposition to there
-            prev->next_ = entryPtr_->next_;
-            delete entryPtr_;
-            entryPtr_ = prev;
+            prev->next_ = ep;
         }
         else
         {
-            // entryPtr was first element on SLList
-            hashTable_->table_[hashIndex_] = entryPtr_->next_;
-            delete entryPtr_;
-
-            // Assign any non-nullptr value so it doesn't look like end()
-            entryPtr_ = reinterpret_cast<hashedEntry*>(this);
-
-            // Mark with special hashIndex value to signal it has been rewound.
-            // The next increment will bring it back to the present location.
-            //
-            // From the current position 'curPos', we wish to continue at
-            // prevPos='curPos-1', which we mark as markPos='-curPos-1'.
-            // The negative lets us notice it is special, the extra '-1'
-            // is needed to avoid ambiguity for position '0'.
-            // To retrieve prevPos, we would later use '-(markPos+1) - 1'
-            hashIndex_ = -hashIndex_ - 1;
+            table_[index] = ep;
         }
-
-        hashTable_->nElmts_--;
-
-        return true;
     }
     else
     {
+        // Do not overwrite existing entry (STL 'insert' convention)
+        #ifdef FULLDEBUG
+        if (debug)
+        {
+            InfoInFunction
+                << "Cannot insert " << key << " already in hash table\n";
+        }
+        #endif
         return false;
     }
+
+    return true;
 }
 
 
 template<class T, class Key, class Hash>
 bool Foam::HashTable<T, Key, Hash>::erase(const iterator& iter)
 {
-    // NOTE: We use (const iterator&) here, but manipulate its contents anyhow.
+    // NOTE: we use (const iterator&) here, but treat its contents as mutable.
+    //
     // The parameter should be (iterator&), but then the compiler doesn't find
     // it correctly and tries to call as (iterator) instead.
-    //
-    // Adjust iterator after erase
-    return const_cast<iterator&>(iter).erase();
+
+    iterator& it = const_cast<iterator&>(iter);
+
+    return iterator_erase(it.entry_, it.index_);
 }
 
 
@@ -573,7 +444,7 @@ bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
 template<class T, class Key, class Hash>
 Foam::label Foam::HashTable<T, Key, Hash>::erase(const UList<Key>& keys)
 {
-    return eraseMultiple(keys.begin(), keys.end());
+    return eraseMultiple(keys.cbegin(), keys.cend());
 }
 
 
@@ -584,7 +455,7 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
     const FixedList<Key, Size>& keys
 )
 {
-    return eraseMultiple(keys.begin(), keys.end());
+    return eraseMultiple(keys.cbegin(), keys.cend());
 }
 
 
@@ -608,17 +479,14 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
     const label nTotal = this->size();
     label changed = 0;
 
-    using other_iter =
-        typename HashTable<AnyType, Key, AnyHash>::const_iterator;
-
     if (other.size() <= nTotal)
     {
         // The other is smaller/same-size, use its keys for removal
 
         for
         (
-            other_iter iter = other.begin();
-            changed < nTotal && iter != other.end(); // terminate early
+            auto iter = other.cbegin();
+            changed < nTotal && iter != other.cend(); // Terminate early
             ++iter
         )
         {
@@ -634,7 +502,7 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase
         for
         (
             iterator iter = begin();
-            changed < nTotal && iter != end(); // terminate early
+            changed < nTotal && iter != end(); // Terminate early
             ++iter
         )
         {
@@ -685,9 +553,10 @@ Foam::label Foam::HashTable<T, Key, Hash>::retain
 template<class T, class Key, class Hash>
 void Foam::HashTable<T, Key, Hash>::resize(const label sz)
 {
-    const label newSize = HashTableCore::canonicalSize(sz);
+    const label newCapacity = HashTableCore::canonicalSize(sz);
+    const label oldCapacity = capacity_;
 
-    if (newSize == tableSize_)
+    if (newCapacity == oldCapacity)
     {
         #ifdef FULLDEBUG
         if (debug)
@@ -698,46 +567,85 @@ void Foam::HashTable<T, Key, Hash>::resize(const label sz)
 
         return;
     }
+    else if (!newCapacity)
+    {
+        // Special treatment for resize(0)
+        if (size_)
+        {
+            WarningInFunction
+                << "HashTable contains " << size_ << " cannot resize(0)"
+                << endl;
+        }
+        else
+        {
+            if (table_)
+            {
+                delete[] table_;
+                capacity_ = 0;
+            }
+
+            table_ = nullptr;
+        }
+
+        return;
+    }
 
-    HashTable<T, Key, Hash>* tmpTable = new HashTable<T, Key, Hash>(newSize);
+    // Swap primary table entries: size_ is left untouched
 
-    for (const_iterator iter = cbegin(); iter != cend(); ++iter)
+    auto oldTable = table_;
+    capacity_ = newCapacity;
+
+    table_ = new node_type*[capacity_];
+    for (label i=0; i < capacity_; ++i)
     {
-        tmpTable->insert(iter.key(), iter.object());
+        table_[i] = nullptr;
     }
 
-    const label oldSize = tableSize_;
-    tableSize_ = tmpTable->tableSize_;
-    tmpTable->tableSize_ = oldSize;
+    // Move to new table[] but with new chaining.
+
+    label nMove = size_;  // Allow early completion
+    for (label i=0; nMove && i < oldCapacity; ++i)
+    {
+        for (node_type* ep = oldTable[i]; ep; /*nil*/)
+        {
+            node_type* next = ep->next_;
 
-    hashedEntry** oldTable = table_;
-    table_ = tmpTable->table_;
-    tmpTable->table_ = oldTable;
+            // Move to new location
+            {
+                const label newIdx = hashKeyIndex(ep->key());
 
-    delete tmpTable;
+                ep->next_ = table_[newIdx];  // add to head
+                table_[newIdx] = ep;
+            }
+
+            ep = next;  // continue in the linked-list
+            --nMove;    // note any early completion
+        }
+        oldTable[i] = nullptr;
+    }
+
+    if (oldTable)
+    {
+        delete[] oldTable;
+    }
 }
 
 
 template<class T, class Key, class Hash>
 void Foam::HashTable<T, Key, Hash>::clear()
 {
-    if (nElmts_)
+    for (label i=0; size_ && i<capacity_; ++i)
     {
-        for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++)
+        for (node_type* ep = table_[i]; ep; /*nil*/)
         {
-            if (table_[hashIdx])
-            {
-                hashedEntry* ep = table_[hashIdx];
-                while (hashedEntry* next = ep->next_)
-                {
-                    delete ep;
-                    ep = next;
-                }
-                delete ep;
-                table_[hashIdx] = nullptr;
-            }
+            node_type* next = ep->next_;
+
+            delete ep;
+
+            ep = next;  // continue in the linked-list
+            --size_;    // note any early completion
         }
-        nElmts_ = 0;
+        table_[i] = nullptr;
     }
 }
 
@@ -750,24 +658,34 @@ void Foam::HashTable<T, Key, Hash>::clearStorage()
 }
 
 
+template<class T, class Key, class Hash>
+void Foam::HashTable<T, Key, Hash>::swap(HashTable<T, Key, Hash>& ht)
+{
+    Foam::Swap(size_, ht.size_);
+    Foam::Swap(capacity_, ht.capacity_);
+    Foam::Swap(table_, ht.table_);
+}
+
+
 template<class T, class Key, class Hash>
 void Foam::HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht)
 {
-    // As per the Destructor
+    // As per destructor
     if (table_)
     {
         clear();
         delete[] table_;
     }
 
-    tableSize_ = ht.tableSize_;
-    ht.tableSize_ = 0;
+    size_ = ht.size_;
+    ht.size_ = 0;
+
+    capacity_ = ht.capacity_;
+    ht.capacity_ = 0;
 
     table_ = ht.table_;
     ht.table_ = nullptr;
 
-    nElmts_ = ht.nElmts_;
-    ht.nElmts_ = 0;
 }
 
 
@@ -869,9 +787,9 @@ void Foam::HashTable<T, Key, Hash>::operator=
     }
 
     // Could be zero-sized from a previous transfer()
-    if (!tableSize_)
+    if (!capacity_)
     {
-        resize(rhs.tableSize_);
+        resize(rhs.capacity_);
     }
     else
     {
@@ -892,7 +810,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
 )
 {
     // Could be zero-sized from a previous transfer()
-    if (!tableSize_)
+    if (!capacity_)
     {
         resize(2*lst.size());
     }
@@ -908,6 +826,24 @@ void Foam::HashTable<T, Key, Hash>::operator=
 }
 
 
+template<class T, class Key, class Hash>
+void Foam::HashTable<T, Key, Hash>::operator=
+(
+    HashTable<T, Key, Hash>&& rhs
+)
+{
+    // Check for assignment to self
+    if (this == &rhs)
+    {
+        FatalErrorInFunction
+            << "attempted assignment to self"
+            << abort(FatalError);
+    }
+
+    transfer(rhs);
+}
+
+
 template<class T, class Key, class Hash>
 bool Foam::HashTable<T, Key, Hash>::operator==
 (
@@ -922,7 +858,7 @@ bool Foam::HashTable<T, Key, Hash>::operator==
 
     for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
     {
-        const_iterator other = this->cfind(iter.key());
+        const const_iterator other(this->cfind(iter.key()));
 
         if (!other.found() || other.object() != iter.object())
         {
@@ -944,8 +880,11 @@ bool Foam::HashTable<T, Key, Hash>::operator!=
 }
 
 
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// Iterators, Friend Operators
 
+#include "HashTableIter.C"
 #include "HashTableIO.C"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H
index cd50551d5d51405c2f8455f8edb226d84b0b22d8..85e19aed49b9dac27ae3a43bf3cef31da21e6cd5 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H
@@ -25,14 +25,16 @@ Class
     Foam::HashTable
 
 Description
-    An STL-conforming hash table.
+    A HashTable similar to \c std::unordered_map.
 
-Note
-    Hashing index collisions are handled via chaining using a singly-linked
-    list with the colliding entry being added to the head of the linked
-    list. Thus copying the hash table (or indeed even resizing it) will
-    often result in a different hash order. Use a sorted table-of-contents
-    when the hash order is important.
+    The entries are considered \a unordered since their placement
+    depends on the method used to generate the hash key index, the
+    table capacity, insertion order etc. When the key order is
+    important, use the sortedToc() method to obtain a list of sorted
+    keys and use that for further access.
+
+    Internally the table uses closed addressing into a flat storage space
+    with collisions handled by linked-list chaining.
 
     The end iterator of all hash-tables has a nullptr to the hash entry.
     Thus avoid separate allocation for each table and use a single one with
@@ -41,25 +43,49 @@ Note
     a nullptr as its first data member.
     The nullObject is such an item (with a nullptr data member).
 
+Note
+    For historical reasons, dereferencing the table iterator
+    (eg, \a *iter) returns a reference to the stored object value
+    value rather than the stored key/object value like std::unordered_map
+    does.
+
+    The HashTable iterator:
+    \code
+        forAllConstIters(table, iter)
+        {
+            Info<< "val:" << *iter << nl
+                << "key:" << iter.key() << nl;
+                << "val:" << iter.object() << nl;
+        }
+    \endcode
+    whereas for the \c std::unordered_map iterator:
+    \code
+        forAllConstIters(stdmap, iter)
+        {
+            Info<< "key/val:" << *iter << nl
+                << "key:" << iter->first << nl
+                << "val:" << iter->second << nl;
+        }
+    \endcode
+    This difference is most evident when using range-for syntax.
+
 SourceFiles
     HashTableI.H
+    HashTableIterI.H
     HashTable.C
-    HashTableCoreI.H
-    HashTableCore.C
     HashTableIO.C
+    HashTableIter.C
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef HashTable_H
 #define HashTable_H
 
-#include "label.H"
-#include "uLabel.H"
 #include "word.H"
+#include "zero.H"
 #include "Xfer.H"
 #include "Hash.H"
-#include "className.H"
-#include "nullObject.H"
+#include "HashTableCore.H"
 
 #include <initializer_list>
 #include <iterator>
@@ -85,88 +111,148 @@ Ostream& operator<<(Ostream& os, const HashTable<T, Key, Hash>& tbl);
 
 
 /*---------------------------------------------------------------------------*\
-                        Class HashTableCore Declaration
+                          Class HashTable Declaration
 \*---------------------------------------------------------------------------*/
 
-//- Bits that are independent of the HashTable template parameters.
-struct HashTableCore
+template<class T, class Key=word, class Hash=string::hash>
+class HashTable
+:
+    public HashTableCore
 {
-    //- Maximum allowable internal table size. Approximately labelMax/4
-    static const label maxTableSize;
+    // Private types for table entries
 
-    //- Return a canonical (power-of-two) of the requested size.
-    static label canonicalSize(const label requested_size);
+        //- Structure with a (K,V) tuple and a linked-list for collisions
+        //  Could store key/object as std::pair, but no particular advantage
+        //  unless the iterator dereference type changes.
+        struct pair_entry
+        {
+            //- Type of key
+            typedef Key key_type;
 
-    //- Construct null
-    HashTableCore()
-    {}
+            //- Object content type
+            typedef T mapped_type;
 
-    //- Define template name and debug
-    ClassName("HashTable");
+            //- The lookup key
+            key_type key_;
 
-    static_assert
-    (
-        sizeof(NullObject) >= sizeof(void*),
-        "NullObject is too small to reinterpret_cast as HashTable::iterator"
-    );
+            //- The data object
+            mapped_type obj_;
 
+            //- Addressing (next in collision list)
+            pair_entry* next_;
 
-    //- Factory method to create a non-const iterator begin
-    template<class IteratorType, class TableType>
-    inline static IteratorType iterator_begin(TableType& table);
+            //- Construct from key, object, next pointer
+            pair_entry(const Key& key, const T& obj, pair_entry* next)
+            :
+                key_(key),
+                obj_(obj),
+                next_(next)
+            {}
+
+            //- The key
+            const key_type& key() const
+            {
+                return key_;
+            }
+
+            //- The mapped object
+            const mapped_type& mapped() const
+            {
+                return obj_;
+            }
+            mapped_type& mapped()
+            {
+                return obj_;
+            }
 
-    //- Factory method to create a const iterator begin
-    template<class IteratorType, class TableType>
-    inline static IteratorType iterator_begin(const TableType& table);
+        private:
+            //- Disallow default bitwise copy construct / assignment
+            pair_entry(const pair_entry&) = delete;
+            void operator=(const pair_entry&) = delete;
+        };
 
-    //- Factory method to create a const iterator begin
-    template<class IteratorType, class TableType>
-    inline static IteratorType iterator_cbegin(const TableType& table);
 
-    //- Factory method to create a non-const iterator end
-    //  Simply reinterprets a NullObject as a hash-table iterator.
-    template<class IteratorType>
-    inline static const IteratorType& iterator_end();
+        //- Structure with a single (K) value and a linked-list for collisions
+        struct unary_entry
+        {
+            //- Type of key
+            typedef Key key_type;
 
-    //- Factory method to create a const iterator cend
-    //  Simply reinterprets a NullObject as a hash-table iterator.
-    template<class IteratorType>
-    inline static const IteratorType& iterator_cend();
+            //- Object content type
+            typedef zero::null mapped_type;
 
+            //- Content storage type to the entry
+            typedef key_type value_type;
 
-    //- Factory class for creating a begin/end pair for any const iterator.
-    template<class IteratorType, class TableType>
-    class const_iterator_pair
-    {
-        label size_;
-        IteratorType iter_;
+            //- The lookup key == content
+            key_type key_;
 
-    public:
+            //- Addressing (next in collision list)
+            unary_entry* next_;
 
-        inline const_iterator_pair(const TableType& tbl);
+            //- Construct from key, (ununsed) object, next pointer
+            unary_entry(const Key& key, const T&, unary_entry* next)
+            :
+                key_(key),
+                next_(next)
+            {}
 
-        inline label size() const;
-        inline bool empty() const;
+            //- The key
+            const key_type& key() const
+            {
+                return key_;
+            }
 
-        inline IteratorType begin() const;
-        inline IteratorType cbegin() const;
+            //- Dummy mapped object
+            const mapped_type& mapped() const
+            {
+                return zeroNullElement;
+            }
+            mapped_type& mapped()
+            {
+                return zeroNullElement;
+            }
 
-        inline const IteratorType& end() const;
-        inline const IteratorType& cend() const;
-    };
 
-};
+        private:
+            //- Disallow default bitwise copy construct / assignment
+            unary_entry(const unary_entry&) = delete;
+            void operator=(const unary_entry&) = delete;
+        };
 
 
-/*---------------------------------------------------------------------------*\
-                           Class HashTable Declaration
-\*---------------------------------------------------------------------------*/
+        //- Hashed node with a linked-list for collisions
+        typedef typename std::conditional
+        <
+            std::is_same<zero::null, typename std::remove_cv<T>::type>::value,
+            unary_entry,
+            pair_entry
+        >::type node_type;
+
+
+    // Private Data
+
+        //- The number of nodes currently stored in table
+        label size_;
+
+        //- Number of nodes allocated in table
+        label capacity_;
+
+        //- The table of primary nodes
+        node_type** table_;
+
+
+    // Private Member Functions
+
+        //- Return the hash index of the Key within the current table size.
+        //  No checks for zero-sized tables.
+        inline label hashKeyIndex(const Key& key) const;
+
+        //- Assign a new hash-entry to a possibly already existing key.
+        //  \return True if the new entry was set.
+        bool set(const Key& key, const T& obj, const bool overwrite);
+
 
-template<class T, class Key=word, class Hash=string::hash>
-class HashTable
-:
-    public HashTableCore
-{
 public:
 
     //- The template instance used for this HashTable
@@ -175,18 +261,25 @@ public:
 
     // STL type definitions
 
-        //- Type of keys that the HashTable uses.
+        //- The second template parameter, type of keys used.
         typedef Key key_type;
 
-        //- Type of values that the HashTable contains.
+        //- The first template parameter, type of objects contained.
+        typedef T mapped_type;
+
+        //- Same as mapped_type for OpenFOAM HashTables
+        //  Note that this is different than the std::map definition.
         typedef T value_type;
 
+        //- The third template parameter, the hash index method.
+        typedef Hash hasher;
+
         //- The type used for storing into value_type objects.
-        //  This type is usually value_type&.
+        //  This type is usually 'value_type*'.
         typedef T* pointer;
 
         //- The type used for storing into value_type objects.
-        //  This type is usually value_type&.
+        //  This type is usually 'value_type&'.
         typedef T& reference;
 
         //- The type used for reading from constant value_type objects.
@@ -208,65 +301,16 @@ public:
         //- Forward iterator with const access
         class const_iterator;
 
-
-private:
-
-    // Private data type for table entries
-
-        //- Structure to hold a hashed entry, with a linked-list for collisions
-        struct hashedEntry
-        {
-            //- The lookup key
-            Key key_;
-
-            //- The data object
-            T obj_;
-
-            //- Pointer to next hashedEntry in sub-list
-            hashedEntry* next_;
-
-            //- Construct from key, object, next pointer
-            inline hashedEntry(const Key& key, const T& obj, hashedEntry* next);
-
-        private:
-            //- Disallow default bitwise copy construct
-            hashedEntry(const hashedEntry&) = delete;
-
-            //- Disallow default bitwise assignment
-            void operator=(const hashedEntry&) = delete;
-        };
-
-
-    // Private data: size of table, the table and current number of elements
-
-        //- The current number of elements in table
-        label nElmts_;
-
-        //- Number of primary entries allocated in table
-        label tableSize_;
-
-        //- The table of primary entries
-        hashedEntry** table_;
-
-
-    // Private Member Functions
-
-        //- Return the hash index of the Key within the current table size.
-        //  No checks for zero-sized tables.
-        inline label hashKeyIndex(const Key& key) const;
-
-        //- Assign a new hash-entry to a possibly already existing key.
-        //  \return True if the new entry was set.
-        bool set(const Key& key, const T& obj, const bool protect);
-
-
 protected:
 
         //- Internally used base for iterator and const_iterator
-        class iterator_base;
+        template<bool Const> class Iterator;
 
-        //- Friendship with the iterator_base is required.
-        friend class iterator_base;
+        //- An iterator with const access to HashTable internals.
+        friend class Iterator<true>;
+
+        //- An iterator with non-const access to HashTable internals.
+        friend class Iterator<false>;
 
 
     // Protected Member Functions
@@ -284,17 +328,23 @@ public:
 
     // Constructors
 
-        //- Construct given initial table size
-        HashTable(const label size = 128);
+        //- Construct null with default (128) table capacity
+        HashTable();
+
+        //- Construct given initial table capacity
+        explicit HashTable(const label size);
 
-        //- Construct from Istream
+        //- Construct from Istream with default table capacity
         HashTable(Istream& is, const label size = 128);
 
         //- Construct as copy
-        HashTable(const HashTable<T, Key, Hash>& ht);
+        HashTable(const this_type& ht);
+
+        //- Move construct
+        HashTable(this_type&& ht);
 
         //- Construct by transferring the parameter contents
-        HashTable(const Xfer<HashTable<T, Key, Hash>>& ht);
+        HashTable(const Xfer<this_type>& ht);
 
         //- Construct from an initializer list
         HashTable(std::initializer_list<std::pair<Key, T>> lst);
@@ -318,19 +368,19 @@ public:
         inline bool empty() const;
 
         //- Return true if hashed entry is found in table
-        bool found(const Key& key) const;
+        inline bool found(const Key& key) const;
 
         //- Find and return an iterator set at the hashed entry
         //  If not found iterator = end()
-        iterator find(const Key& key);
+        inline iterator find(const Key& key);
 
         //- Find and return an const_iterator set at the hashed entry
         //  If not found iterator = end()
-        const_iterator find(const Key& key) const;
+        inline const_iterator find(const Key& key) const;
 
         //- Find and return an const_iterator set at the hashed entry
         //  If not found iterator = end()
-        const_iterator cfind(const Key& key) const;
+        inline const_iterator cfind(const Key& key) const;
 
         //- Return hashed entry if it exists, or return the given default
         inline const T& lookup(const Key& key, const T& deflt) const;
@@ -338,14 +388,22 @@ public:
 
       // Table of contents
 
-        //- Return the table of contents
+        //- The table of contents (the keys) in unsorted order.
         List<Key> toc() const;
 
-        //- Return the table of contents as a sorted list
+        //- The table of contents (the keys) in sorted order
         List<Key> sortedToc() const;
 
-        //- Return the sorted table of contents with keys that satisfy
-        //  the unary predicate, optionally with inverted logic.
+        //- The table of contents (the keys) sorted according to the
+        //- specified comparator
+        template<class Compare>
+        List<Key> sortedToc(const Compare& comp) const;
+
+        //- The table of contents (the keys) selected according to the
+        //- unary predicate applied to the \b keys.
+        //  \param invert changes the logic to select when the predicate
+        //      is false
+        //  \return sorted list of selected keys
         template<class UnaryPredicate>
         List<Key> tocKeys
         (
@@ -353,8 +411,11 @@ public:
             const bool invert = false
         ) const;
 
-        //- Return the sorted table of contents with values that satisfy
-        // the unary predicate, optionally with inverted logic.
+        //- The table of contents (the keys) selected according to the
+        //- unary predicate applied to the \b values.
+        //  \param invert changes the logic to select when the predicate
+        //      is false
+        //  \return sorted list of selected keys
         template<class UnaryPredicate>
         List<Key> tocValues
         (
@@ -362,8 +423,11 @@ public:
             const bool invert = false
         ) const;
 
-        //- Return the sorted table of contents with keys/values that satisfy
-        //  the binary predicate, optionally with inverted logic.
+        //- The table of contents (the keys) selected according to the
+        //- binary predicate applied to the \b keys and \b values.
+        //  \param invert changes the logic to select when the predicate
+        //      is false
+        //  \return sorted list of selected keys
         template<class BinaryPredicate>
         List<Key> tocEntries
         (
@@ -374,8 +438,9 @@ public:
 
       // Counting
 
-        //- Count the number of keys that satisfy the unary predicate,
-        //  optionally with inverted logic.
+        //- Count the number of keys that satisfy the unary predicate
+        //  \param invert changes the logic to select when the predicate
+        //      is false
         template<class UnaryPredicate>
         label countKeys
         (
@@ -383,8 +448,9 @@ public:
             const bool invert = false
         ) const;
 
-        //- Count the number of values that satisfy the unary predicate,
-        //  optionally with inverted logic.
+        //- Count the number of values that satisfy the unary predicate
+        //  \param invert changes the logic to select when the predicate
+        //      is false
         template<class UnaryPredicate>
         label countValues
         (
@@ -392,8 +458,9 @@ public:
             const bool invert = false
         ) const;
 
-        //- Count the number of entries that satisfy the binary predicate,
-        //  optionally with inverted logic.
+        //- Count the number of entries that satisfy the binary predicate.
+        //  \param invert changes the logic to select when the predicate
+        //      is false
         template<class BinaryPredicate>
         label countEntries
         (
@@ -404,7 +471,7 @@ public:
 
       // Edit
 
-        //- Insert a new entry
+        //- Insert a new entry, not overwriting existing entries.
         //  \return True if the entry inserted, which means that it did
         //  not previously exist in the table.
         inline bool insert(const Key& key, const T& obj);
@@ -528,6 +595,9 @@ public:
         //  Equivalent to clear() followed by resize(0)
         void clearStorage();
 
+        //- Swap contents of the argument table into this table
+        void swap(HashTable<T, Key, Hash>& ht);
+
         //- Transfer the contents of the argument table into this table
         //  and annul the argument table.
         void transfer(HashTable<T, Key, Hash>& ht);
@@ -561,11 +631,14 @@ public:
         //- Assignment from an initializer list
         void operator=(std::initializer_list<std::pair<Key, T>> lst);
 
-        //- Equality. Hash tables are equal if the keys and values are equal.
-        //  Independent of table storage size and table order.
+        //- Move assign
+        void operator=(HashTable<T, Key, Hash>&& rhs);
+
+        //- Equality. Tables are equal if all keys and values are equal,
+        //- independent of order or underlying storage size.
         bool operator==(const HashTable<T, Key, Hash>& rhs) const;
 
-        //- The opposite of the equality operation. Takes linear time.
+        //- The opposite of the equality operation.
         bool operator!=(const HashTable<T, Key, Hash>& rhs) const;
 
 
@@ -578,149 +651,157 @@ protected:
         //  and prevent most external usage.
         //  iterator and const_iterator have the same size, allowing
         //  us to reinterpret_cast between them (if desired)
-        class iterator_base
+
+        template<bool Const>
+        class Iterator
         {
         public:
-            // Public typedefs
-            using table_type = this_type;
-            using key_type   = this_type::key_type;
+          // Typedefs
             using iterator_category = std::forward_iterator_tag;
-            using difference_type  = this_type::difference_type;
+            using difference_type = this_type::difference_type;
+
+            //- The HashTable container type
+            using table_type = typename std::conditional
+            <
+                Const,
+                const this_type,
+                this_type
+            >::type;
+
+            //- The node-type being addressed
+            using node_type = typename std::conditional
+            <
+                Const,
+                const this_type::node_type,
+                this_type::node_type
+            >::type;
+
+            //- The key type
+            using key_type = this_type::key_type;
+
+            //- The object type being addressed
+            using mapped_type = typename std::conditional
+            <
+                Const,
+                const this_type::mapped_type,
+                this_type::mapped_type
+            >::type;
+
+
+          // Member Functions
 
-        private:
-            using entry_type = hashedEntry;
+            //- True if iterator points to an entry
+            //  This can be used directly instead of comparing to end()
+            inline bool found() const;
 
-          // Private Data
+            //- The key associated with the iterator
+            inline const Key& key() const;
 
-            //- Currently selected entry.
-            //  MUST be the first member for easy comparison between iterators
-            //  and for reinterpret_cast from nullObject
-            entry_type* entryPtr_;
+          // Member Operators
 
-            //- Pointer to the hash-table for which this is an iterator
-            //  This allows use of the default bitwise copy/assignment
-            table_type* hashTable_;
+            //- Compare hash-entry element pointers.
+            //  Independent of const/non-const access
+            inline bool operator==(const Iterator<true>& iter) const;
+            inline bool operator!=(const Iterator<true>& iter) const;
+
+            inline bool operator==(const Iterator<false>& iter) const;
+            inline bool operator!=(const Iterator<false>& iter) const;
 
-            //- Current hash index within the hash-table data.
-            //  A signed value, since erase() uses a negative value to signal
-            //  the erasure state.
-            label hashIndex_;
 
         protected:
+            friend class HashTable;  // For begin/find constructors
 
-          // Protected Member Functions
+          // Protected Data
 
-            //- Increment to the next position
-            inline void increment();
+            //- The selected entry.
+            //  MUST be the first member for easy comparison between iterators
+            //  and for reinterpret_cast from nullObject
+            node_type* entry_;
 
-            //- The referenced object/value element
-            inline T& element() const;
+            //- The hash-table container being iterated on.
+            //  Using a pointer allows default bitwise copy/assignment
+            table_type* container_;
 
-            //- Erase the entry at the current position
-            bool erase();
+            //- Index within the hash-table data.
+            //  A signed value, since iterator_erase() needs a negative value
+            //  to mark the position.
+            label index_;
 
 
-        public:
-
-          // Constructors
+          // Protected Constructors
 
             //- Construct null (end iterator)
-            inline iterator_base();
+            inline Iterator();
 
             //- Construct from begin of hash-table
-            inline explicit iterator_base(const table_type* hashTbl);
+            inline Iterator(bool, table_type* tbl);
 
-            //- Construct from hash table, element and hash index
-            inline iterator_base
-            (
-                const table_type* hashTbl,
-                const entry_type* elmt,
-                const label hashIndex
-            );
+            //- Construct by finding key in hash table
+            Iterator(table_type* tbl, const Key& key);
 
-          // Member functions/operators
 
-            //- True if iterator points to an entry
-            //  This can be used directly instead of comparing to end()
-            inline bool found() const;
+          // Protected Member Functions
 
-            //- Return the Key corresponding to the iterator
-            inline const Key& key() const;
+            //- Increment to the next position
+            inline void increment();
 
-            //- Compare hash-entry element pointers
-            inline bool operator==(const iterator_base& iter) const;
-            inline bool operator!=(const iterator_base& iter) const;
+            //- The object associated with the iterator
+            inline mapped_type& object() const
+            {
+                return entry_->mapped();
+            }
+
+            //- Permit an explicit cast to the other (const/non-const) searcher
+            inline explicit operator const Iterator<!Const>&() const
+            {
+                return *reinterpret_cast<const Iterator<!Const>*>(this);
+            }
         };
 
 
-public:
-
-        //- An iterator wrapper for returning a reference to the key
-        template<class WrappedIterator>
-        class key_iterator_base
-        :
-            public WrappedIterator
-        {
-        public:
-            using value_type = this_type::key_type;
-            using pointer    = const Key*;
-            using reference  = const Key&;
-
-            //- Implicit conversion
-            inline key_iterator_base(const WrappedIterator& iter);
-
-            //- Return the key
-            inline reference operator*() const;
-            inline reference operator()() const;
-
-            inline key_iterator_base& operator++();
-            inline key_iterator_base operator++(int);
-        };
-
+        //- Low-level entry erasure using iterator internals.
+        //  This invalidates the iterator until the next ++ operation.
+        //  \return True if the corresponding entry existed and was removed
+        bool iterator_erase(node_type*& entry, label& index);
 
-    // STL iterator
+public:
 
         //- Forward iterator with non-const access
         class iterator
         :
-            public iterator_base
+            public Iterator<false>
         {
-            friend class HashTable;  // Uses iterator::erase() method
-            using entry_type = hashedEntry;
-
         public:
+          // Typedefs
+            using iterator_category = std::forward_iterator_tag;
+            using difference_type   = this_type::difference_type;
 
-          // Public typedefs
-            using table_type = this_type;
-            using value_type = this_type::value_type;
-            using pointer    = this_type::pointer;
-            using reference  = this_type::reference;
+            using key_type    = this_type::key_type;
+            using mapped_type = this_type::mapped_type;
+            using value_type  = this_type::value_type;
+            using pointer     = this_type::pointer;
+            using reference   = this_type::reference;
 
           // Constructors
 
             //- Construct null (end iterator)
-            inline iterator();
+            inline iterator() {}
 
-            //- Construct from begin of hash-table
-            inline explicit iterator(table_type* hashTbl);
+            //- Copy construct from similar access type
+            inline explicit iterator(const Iterator<false>& iter)
+            :
+                Iterator<false>(iter)
+            {}
 
-            //- Construct from hash table, element and hash index
-            //  Used by the hash-table find() method.
-            inline iterator
-            (
-                table_type* hashTbl,
-                entry_type* elmt,
-                const label hashIndex
-            );
 
           // Member functions/operators
 
-            //- Return non-const access to referenced object
-            inline reference object() const;
+            //- Non-const access to referenced object
+            using Iterator<false>::object;
 
-            //- Return non-const access to referenced object
-            inline reference operator*() const;
-            inline reference operator()() const;
+            //- Non-const access to referenced object
+            inline reference operator*() const  { return this->object(); }
+            inline reference operator()() const { return this->object(); }
 
             inline iterator& operator++();
             inline iterator operator++(int);
@@ -732,54 +813,111 @@ public:
         //- Forward iterator with const access
         class const_iterator
         :
-            public iterator_base
+            public Iterator<true>
         {
-            using entry_type = const hashedEntry;
-
         public:
+          // Typedefs
+            using iterator_category = std::forward_iterator_tag;
+            using difference_type   = this_type::difference_type;
 
-          // Public typedefs
-            using table_type = const this_type;
-            using value_type = const this_type::value_type;
-            using pointer    = this_type::const_pointer;
-            using reference  = this_type::const_reference;
+            using key_type    = this_type::key_type;
+            using mapped_type = const this_type::mapped_type;
+            using value_type  = const this_type::value_type;
+            using pointer     = this_type::const_pointer;
+            using reference   = this_type::const_reference;
 
           // Constructors
 
             //- Construct null (end iterator)
-            inline const_iterator();
+            inline const_iterator() {}
+
+            //- Copy construct from similar access type
+            inline explicit const_iterator(const Iterator<true>& iter)
+            :
+                Iterator<true>(iter)
+            {}
+
+            //- Copy construct from dissimilar access type
+            inline explicit const_iterator(const Iterator<false>& iter)
+            :
+                Iterator<true>
+                (
+                    static_cast<const Iterator<true>&>(iter)
+                )
+            {}
+
+            //- Implicit conversion from dissimilar access type
+            inline const_iterator(const iterator& iter)
+            :
+                const_iterator(reinterpret_cast<const const_iterator&>(iter))
+            {}
 
-            //- Construct from begin of hash-table
-            inline explicit const_iterator(table_type* hashTbl);
-
-            //- Construct from hash table, element and hash index.
-            //  Used by the hash-table find() method.
-            inline const_iterator
-            (
-                table_type* hashTbl,
-                entry_type* elmt,
-                const label hashIndex
-            );
-
-            //- Copy construct from iterator
-            inline const_iterator(const iterator& iter);
 
           // Member functions/operators
 
-            //- Return const access to referenced object
-            inline reference object() const;
+            //- Const access to referenced object
+            using Iterator<true>::object;
 
-            //- Return const access to referenced object
-            inline reference operator*() const;
-            inline reference operator()() const;
+            //- Const access to referenced object
+            inline reference operator*() const  { return this->object(); }
+            inline reference operator()() const { return this->object(); }
 
             inline const_iterator& operator++();
             inline const_iterator operator++(int);
+
+          // Assignment
+
+            const_iterator& operator=(const const_iterator&) = default;
+
+            // Allow assign from iterator to const_iterator
+            const_iterator& operator=(const iterator& iter)
+            {
+                return this->operator=
+                (
+                    reinterpret_cast<const const_iterator&>(iter)
+                );
+            }
         };
 
 
     //- Iterating over keys only
 
+        //- An iterator wrapper for returning a reference to the key
+        template<class Iter>
+        class key_iterator_base
+        :
+            public Iter
+        {
+        public:
+            using value_type = this_type::key_type;
+            using pointer    = const Key*;
+            using reference  = const Key&;
+
+            //- Implicit conversion
+            inline key_iterator_base(const Iter& iter)
+            :
+                Iter(iter)
+            {}
+
+            //- Return the key
+            inline reference operator*() const  { return this->key(); }
+            inline reference operator()() const { return this->key(); }
+
+            inline key_iterator_base& operator++()
+            {
+                this->increment();
+                return *this;
+            }
+
+            inline key_iterator_base operator++(int)
+            {
+                key_iterator_base iter(*this);
+                this->increment();
+                return iter;
+            }
+        };
+
+
         //- Forward iterator returning the key
         using key_iterator = key_iterator_base<iterator>;
 
@@ -796,7 +934,7 @@ public:
 
     // Iterator access
 
-        //- Iterator set to the beginning of the HashTable
+        //- iterator set to the beginning of the HashTable
         inline iterator begin();
 
         //- const_iterator set to the beginning of the HashTable
@@ -821,7 +959,8 @@ public:
         Ostream& printInfo(Ostream& os) const;
 
         //- Write the unordered keys as a list, with line-breaks if list length
-        //  exceeds shortListLen. Using '0' suppresses line-breaks entirely.
+        //- exceeds shortListLen.
+        //  Using '0' suppresses line-breaks entirely.
         Ostream& writeKeys(Ostream& os, const label shortListLen=0) const;
 
 
@@ -841,14 +980,25 @@ public:
 };
 
 
+// Global Functions
+
+// Exchange contents of hash tables - see HashTable::swap().
+template<class T, class Key, class Hash>
+inline void Swap
+(
+    HashTable<T, Key, Hash>& a,
+    HashTable<T, Key, Hash>& b
+);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-#include "HashTableCoreI.H"
 #include "HashTableI.H"
+#include "HashTableIterI.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C
index 08805148a96da6a096a5332e5a0477832afdc1a6..059be27e3e0c09e36df6e426af1afa5b8f234507 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C
@@ -23,7 +23,7 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#include "HashTable.H"
+#include "HashTableCore.H"
 #include "uLabel.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -36,6 +36,8 @@ defineTypeNameAndDebug(HashTableCore, 0);
 // Approximately labelMax/4
 const Foam::label Foam::HashTableCore::maxTableSize(1L << (sizeof(label)*8-3));
 
+Foam::zero::null Foam::HashTableCore::zeroNullElement;
+
 
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
@@ -50,7 +52,7 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size)
         return maxTableSize;
     }
 
-    // Enforce power of two - makes for a very fast modulus.
+    // Enforce power of two for fast modulus in hash index calculations.
     // Use unsigned for these calculations.
     //
     // - The lower limit (8) is somewhat arbitrary, but if the hash table
@@ -65,7 +67,8 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size)
     {
         return powerOfTwo;
     }
-    else if (size & (size-1))  // <- Modulus of i^2
+
+    if (size & (size-1))  // <- Modulus of i^2
     {
         // Determine power-of-two. Brute-force is fast enough.
         while (powerOfTwo < size)
@@ -75,10 +78,8 @@ Foam::label Foam::HashTableCore::canonicalSize(const label requested_size)
 
         return powerOfTwo;
     }
-    else
-    {
-        return size;
-    }
+
+    return size;
 }
 
 
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H
new file mode 100644
index 0000000000000000000000000000000000000000..76feeb2105fa66fd28e1f8a9a068b641bb10516b
--- /dev/null
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.H
@@ -0,0 +1,138 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::HashTableCore
+
+Description
+    Template invariant parts of hash table implementation.
+
+SourceFiles
+    HashTableCoreI.H
+    HashTableCore.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef HashTableCore_H
+#define HashTableCore_H
+
+#include "label.H"
+#include "uLabel.H"
+#include "className.H"
+#include "nullObject.H"
+#include "zero.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                        Class HashTableCore Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Bits that are independent of HashTable template parameters.
+struct HashTableCore
+{
+    //- Maximum allowable internal table size. Approximately labelMax/4
+    static const label maxTableSize;
+
+    //- Return a canonical (power-of-two) of the requested size.
+    static label canonicalSize(const label requested_size);
+
+    //- Construct null
+    HashTableCore()
+    {}
+
+    //- Define template name and debug
+    ClassName("HashTable");
+
+    static_assert
+    (
+        sizeof(NullObject) >= sizeof(void*),
+        "NullObject is too small to reinterpret_cast as HashTable::iterator"
+    );
+
+
+    //- Factory method to create a non-const iterator begin
+    template<class IteratorType, class TableType>
+    inline static IteratorType iterator_begin(TableType& table);
+
+    //- Factory method to create a const iterator begin
+    template<class IteratorType, class TableType>
+    inline static IteratorType iterator_cbegin(const TableType& table);
+
+    //- Factory method to return an iterator end
+    //  Simply reinterprets a NullObject as a hash-table iterator.
+    template<class IteratorType>
+    inline static const IteratorType& iterator_end();
+
+    //- Factory method to return an iterator cend
+    //  Simply reinterprets a NullObject as a hash-table iterator.
+    template<class IteratorType>
+    inline static const IteratorType& iterator_cend();
+
+
+    //- Factory class for creating a begin/end pair for any const iterator.
+    template<class IteratorType, class TableType>
+    class const_iterator_pair
+    {
+        label size_;
+        IteratorType iter_;
+
+    public:
+
+        inline const_iterator_pair(const TableType& tbl);
+
+        inline label size() const;
+        inline bool empty() const;
+
+        inline IteratorType begin() const;
+        inline IteratorType cbegin() const;
+
+        inline const IteratorType& end() const;
+        inline const IteratorType& cend() const;
+    };
+
+
+protected:
+
+    //- A static zero::null for dereferencing as a dummy HashSet element
+    static zero::null zeroNullElement;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "HashTableCoreI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H
index 8198e2e4c33d4bcbfd99c820c9cc0dd8f2b853a5..1e59a0baa5aff00b8b6a9defc0e723ca7905ccfc 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCoreI.H
@@ -35,16 +35,6 @@ inline IteratorType Foam::HashTableCore::iterator_begin
 }
 
 
-template<class IteratorType, class TableType>
-inline IteratorType Foam::HashTableCore::iterator_begin
-(
-    const TableType& table
-)
-{
-    return IteratorType(table.begin());
-}
-
-
 template<class IteratorType, class TableType>
 inline IteratorType Foam::HashTableCore::iterator_cbegin
 (
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H
index 4d8028ca139e61ecd8a0d880d156e6888c199471..0373ed9c7fc626a5a1f83a051219bd27b2dac3bc 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H
@@ -25,30 +25,14 @@ License
 
 #include "error.H"
 
-// * * * * * * * * * * * * * Private Member Classes * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::hashedEntry::hashedEntry
-(
-    const Key& key,
-    const T& obj,
-    hashedEntry* next
-)
-:
-    key_(key),
-    obj_(obj),
-    next_(next)
-{}
-
-
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
 template<class T, class Key, class Hash>
 inline Foam::label
 Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const
 {
-    // size is power of two - this is the modulus
-    return Hash()(key) & (tableSize_ - 1);
+    // capacity is always a power of two - this is the modulus
+    return Hash()(key) & (capacity_ - 1);
 }
 
 
@@ -57,21 +41,76 @@ Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const
 template<class T, class Key, class Hash>
 inline Foam::label Foam::HashTable<T, Key, Hash>::capacity() const
 {
-    return tableSize_;
+    return capacity_;
 }
 
 
 template<class T, class Key, class Hash>
 inline Foam::label Foam::HashTable<T, Key, Hash>::size() const
 {
-    return nElmts_;
+    return size_;
 }
 
 
 template<class T, class Key, class Hash>
 inline bool Foam::HashTable<T, Key, Hash>::empty() const
 {
-    return !nElmts_;
+    return !size_;
+}
+
+
+template<class T, class Key, class Hash>
+inline bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const
+{
+    if (size_)
+    {
+        return Iterator<true>(this, key).found();
+    }
+
+    return false;
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::iterator
+Foam::HashTable<T, Key, Hash>::find
+(
+    const Key& key
+)
+{
+    if (size_)
+    {
+        return iterator(Iterator<false>(this, key));
+    }
+
+    return iterator();
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::const_iterator
+Foam::HashTable<T, Key, Hash>::find
+(
+    const Key& key
+) const
+{
+    return this->cfind(key);
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::const_iterator
+Foam::HashTable<T, Key, Hash>::cfind
+(
+    const Key& key
+) const
+{
+    if (size_)
+    {
+        return const_iterator(Iterator<true>(this, key));
+    }
+
+    return const_iterator();
 }
 
 
@@ -82,7 +121,7 @@ inline bool Foam::HashTable<T, Key, Hash>::insert
     const T& obj
 )
 {
-    return this->set(key, obj, true);
+    return this->set(key, obj, false);  // No overwrite
 }
 
 
@@ -93,7 +132,7 @@ inline bool Foam::HashTable<T, Key, Hash>::set
     const T& obj
 )
 {
-    return this->set(key, obj, false);
+    return this->set(key, obj, true);   // Overwrite
 }
 
 
@@ -112,7 +151,7 @@ inline const T& Foam::HashTable<T, Key, Hash>::lookup
     const T& deflt
 ) const
 {
-    const_iterator iter = this->find(key);
+    const const_iterator iter(this->cfind(key));
     return iter.found() ? iter.object() : deflt;
 }
 
@@ -122,7 +161,7 @@ inline const T& Foam::HashTable<T, Key, Hash>::lookup
 template<class T, class Key, class Hash>
 inline T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key)
 {
-    iterator iter = this->find(key);
+    const iterator iter(this->find(key));
 
     if (!iter.found())
     {
@@ -139,7 +178,7 @@ inline T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key)
 template<class T, class Key, class Hash>
 inline const T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) const
 {
-    const_iterator iter = this->find(key);
+    const const_iterator iter(this->cfind(key));
 
     if (!iter.found())
     {
@@ -156,14 +195,14 @@ inline const T& Foam::HashTable<T, Key, Hash>::operator[](const Key& key) const
 template<class T, class Key, class Hash>
 inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key)
 {
-    iterator iter = this->find(key);
+    const iterator iter(this->find(key));
 
     if (iter.found())
     {
         return iter.object();
     }
 
-    this->insert(key, T());
+    this->insert(key, mapped_type());
     return find(key).object();
 }
 
@@ -175,7 +214,7 @@ inline T& Foam::HashTable<T, Key, Hash>::operator()
     const T& deflt
 )
 {
-    iterator iter = this->find(key);
+    const iterator iter(this->find(key));
 
     if (iter.found())
     {
@@ -198,409 +237,16 @@ inline const T& Foam::HashTable<T, Key, Hash>::operator()
 }
 
 
-// * * * * * * * * * * * * * * * iterator base * * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::iterator_base::iterator_base()
-:
-    entryPtr_(nullptr),
-    hashTable_(nullptr),
-    hashIndex_(0)
-{}
-
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::iterator_base::iterator_base
-(
-    const table_type* hashTbl,
-    const entry_type* elmt,
-    const label hashIndex
-)
-:
-    entryPtr_(const_cast<entry_type*>(elmt)),
-    hashTable_(const_cast<table_type*>(hashTbl)),
-    hashIndex_(hashIndex)
-{}
-
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::iterator_base::iterator_base
-(
-    const table_type* hashTbl
-)
-:
-    entryPtr_(nullptr),
-    hashTable_(const_cast<table_type*>(hashTbl)),
-    hashIndex_(0)
-{
-    if (hashTable_ && hashTable_->nElmts_)
-    {
-        // find first non-nullptr table entry
-        while
-        (
-            !(entryPtr_ = hashTable_->table_[hashIndex_])
-         && ++hashIndex_ < hashTable_->tableSize_
-        )
-        {}
-
-        if (hashIndex_ >= hashTable_->tableSize_)
-        {
-            // make into an end iterator
-            entryPtr_ = nullptr;
-            hashIndex_ = 0;
-        }
-    }
-}
-
-
-template<class T, class Key, class Hash>
-inline void
-Foam::HashTable<T, Key, Hash>::iterator_base::increment()
-{
-    // A negative index is a special value from erase
-    if (hashIndex_ < 0)
-    {
-        // the markPos='-curPos-1', but we wish to continue at 'curPos-1'
-        // thus use '-(markPos+1) -1'
-        hashIndex_ = -(hashIndex_+1) - 1;
-    }
-    else if (entryPtr_)
-    {
-        if (entryPtr_->next_)
-        {
-            // Move to next element on the SLList
-            entryPtr_ = entryPtr_->next_;
-            return;
-        }
-    }
-    // else
-    // {
-    //     // if we reach here (entryPtr_ is nullptr) it is already at the end()
-    //     // we should probably stop
-    // }
-
-
-    // Step to the next table entry
-    while
-    (
-        ++hashIndex_ < hashTable_->tableSize_
-     && !(entryPtr_ = hashTable_->table_[hashIndex_])
-    )
-    {}
-
-    if (hashIndex_ >= hashTable_->tableSize_)
-    {
-        // make into an end iterator
-        entryPtr_ = nullptr;
-        hashIndex_ = 0;
-    }
-}
-
-
-template<class T, class Key, class Hash>
-inline bool
-Foam::HashTable<T, Key, Hash>::iterator_base::found() const
-{
-    return entryPtr_;
-}
-
-
-template<class T, class Key, class Hash>
-inline const Key& Foam::HashTable<T, Key, Hash>::iterator_base::key() const
-{
-    return entryPtr_->key_;
-}
-
-
-template<class T, class Key, class Hash>
-inline T& Foam::HashTable<T, Key, Hash>::iterator_base::element() const
-{
-    return entryPtr_->obj_;
-}
-
-
-template<class T, class Key, class Hash>
-inline bool Foam::HashTable<T, Key, Hash>::iterator_base::operator==
-(
-    const iterator_base& iter
-) const
-{
-    return entryPtr_ == iter.entryPtr_;
-}
-
-
-template<class T, class Key, class Hash>
-inline bool Foam::HashTable<T, Key, Hash>::iterator_base::operator!=
-(
-    const iterator_base& iter
-) const
-{
-    return entryPtr_ != iter.entryPtr_;
-}
-
-
-// * * * * * * * * * * * * * * key iterator base * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-template<class WrappedIterator>
-inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
-::key_iterator_base
-(
-    const WrappedIterator& iter
-)
-:
-    WrappedIterator(iter)
-{}
-
-
-template<class T, class Key, class Hash>
-template<class WrappedIterator>
-inline const Key&
-Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
-::operator*() const
-{
-    return this->key();
-}
-
-
-template<class T, class Key, class Hash>
-template<class WrappedIterator>
-inline const Key&
-Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
-::operator()() const
-{
-    return this->key();
-}
-
-
-template<class T, class Key, class Hash>
-template<class WrappedIterator>
-inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>&
-Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
-::operator++()
-{
-    this->increment();
-    return *this;
-}
-
-
-template<class T, class Key, class Hash>
-template<class WrappedIterator>
-inline Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
-Foam::HashTable<T, Key, Hash>::key_iterator_base<WrappedIterator>
-::operator++(int)
-{
-    key_iterator_base old = *this;
-    this->increment();
-    return old;
-}
-
-
-// * * * * * * * * * * * * * * * * STL iterator  * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::iterator::iterator()
-:
-    iterator_base()
-{}
-
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::iterator::iterator
-(
-    table_type* hashTbl
-)
-:
-    iterator_base(hashTbl)
-{}
-
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::iterator::iterator
-(
-    table_type* hashTbl,
-    entry_type* elmt,
-    const label hashIndex
-)
-:
-    iterator_base(hashTbl, elmt, hashIndex)
-{}
-
-
-template<class T, class Key, class Hash>
-inline T&
-Foam::HashTable<T, Key, Hash>::iterator::object() const
-{
-    return this->element();
-}
-
-
-template<class T, class Key, class Hash>
-inline T&
-Foam::HashTable<T, Key, Hash>::iterator::operator*() const
-{
-    return this->object();
-}
-
-
-template<class T, class Key, class Hash>
-inline T&
-Foam::HashTable<T, Key, Hash>::iterator::operator()() const
-{
-    return this->object();
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::iterator&
-Foam::HashTable<T, Key, Hash>::iterator::operator++()
-{
-    this->increment();
-    return *this;
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::iterator
-Foam::HashTable<T, Key, Hash>::iterator::operator++(int)
-{
-    iterator old = *this;
-    this->increment();
-    return old;
-}
-
-
-// * * * * * * * * * * * * * * * STL const_iterator  * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator()
-:
-    iterator_base()
-{}
-
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator
-(
-    const HashTable<T, Key, Hash>::iterator& iter
-)
-:
-    iterator_base(iter)
-{}
-
-
-template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator
-(
-    table_type* hashTbl
-)
-:
-    iterator_base(hashTbl)
-{}
-
+// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
 
 template<class T, class Key, class Hash>
-inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator
+inline void Foam::Swap
 (
-    table_type* hashTbl,
-    entry_type* elmt,
-    const label hashIndex
+    HashTable<T, Key, Hash>& a,
+    HashTable<T, Key, Hash>& b
 )
-:
-    iterator_base(hashTbl, elmt, hashIndex)
-{}
-
-
-template<class T, class Key, class Hash>
-inline const T&
-Foam::HashTable<T, Key, Hash>::const_iterator::object() const
-{
-    return this->element();
-}
-
-
-template<class T, class Key, class Hash>
-inline const T&
-Foam::HashTable<T, Key, Hash>::const_iterator::operator*() const
-{
-    return this->object();
-}
-
-
-template<class T, class Key, class Hash>
-inline const T&
-Foam::HashTable<T, Key, Hash>::const_iterator::operator()() const
-{
-    return this->object();
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::const_iterator&
-Foam::HashTable<T, Key, Hash>::const_iterator::operator++()
-{
-    this->increment();
-    return *this;
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::const_iterator
-Foam::HashTable<T, Key, Hash>::const_iterator::operator++(int)
-{
-    const_iterator old = *this;
-    this->increment();
-    return old;
-}
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::iterator
-Foam::HashTable<T, Key, Hash>::begin()
-{
-    return iterator(this);
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::const_iterator
-Foam::HashTable<T, Key, Hash>::begin() const
-{
-    return const_iterator(this);
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::HashTable<T, Key, Hash>::const_iterator
-Foam::HashTable<T, Key, Hash>::cbegin() const
-{
-    return const_iterator(this);
-}
-
-
-template<class T, class Key, class Hash>
-inline const typename Foam::HashTable<T, Key, Hash>::iterator&
-Foam::HashTable<T, Key, Hash>::end()
-{
-    return iterator_end<iterator>();
-}
-
-
-template<class T, class Key, class Hash>
-inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
-Foam::HashTable<T, Key, Hash>::end() const
-{
-    return iterator_end<const_iterator>();
-}
-
-
-template<class T, class Key, class Hash>
-inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
-Foam::HashTable<T, Key, Hash>::cend() const
 {
-    return iterator_cend<const_iterator>();
+    a.swap(b);
 }
 
 
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C
index 54cd7ed9220457492984a513f936009d09512a66..34392da5ee48b4cc4e091a14466ebd5513c4d509 100644
--- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C
@@ -33,17 +33,17 @@ template<class T, class Key, class Hash>
 Foam::HashTable<T, Key, Hash>::HashTable(Istream& is, const label size)
 :
     HashTableCore(),
-    nElmts_(0),
-    tableSize_(HashTableCore::canonicalSize(size)),
+    size_(0),
+    capacity_(HashTableCore::canonicalSize(size)),
     table_(nullptr)
 {
-    if (tableSize_)
+    if (capacity_)
     {
-        table_ = new hashedEntry*[tableSize_];
+        table_ = new node_type*[capacity_];
 
-        for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
+        for (label i=0; i < capacity_; ++i)
         {
-            table_[hashIdx] = nullptr;
+            table_[i] = nullptr;
         }
     }
 
@@ -60,10 +60,10 @@ Foam::Ostream& Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
     label maxChain = 0;
     unsigned avgChain = 0;
 
-    for (label hashIdx = 0; hashIdx < tableSize_; ++hashIdx)
+    for (label i=0; i < capacity_; ++i)
     {
         label count = 0;
-        for (hashedEntry* ep = table_[hashIdx]; ep; ep = ep->next_)
+        for (node_type* ep = table_[i]; ep; ep = ep->next_)
         {
             ++count;
         }
@@ -81,7 +81,7 @@ Foam::Ostream& Foam::HashTable<T, Key, Hash>::printInfo(Ostream& os) const
     }
 
     os  << "HashTable<T,Key,Hash>"
-        << " elements:" << size() << " slots:" << used << "/" << tableSize_
+        << " elements:" << size() << " slots:" << used << "/" << capacity_
         << " chaining(avg/max):" << (used ? (float(avgChain)/used) : 0)
         << "/" << maxChain << endl;
 
@@ -145,7 +145,7 @@ Foam::Istream& Foam::operator>>
 {
     is.fatalCheck(FUNCTION_NAME);
 
-    // Anull list
+    // Anull existing table
     L.clear();
 
     is.fatalCheck(FUNCTION_NAME);
@@ -154,7 +154,7 @@ Foam::Istream& Foam::operator>>
 
     is.fatalCheck
     (
-        "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
+        "operator>>(Istream&, HashTable&) : "
         "reading first token"
     );
 
@@ -163,11 +163,11 @@ Foam::Istream& Foam::operator>>
         const label s = firstToken.labelToken();
 
         // Read beginning of contents
-        const char delimiter = is.readBeginList("HashTable<T, Key, Hash>");
+        const char delimiter = is.readBeginList("HashTable");
 
         if (s)
         {
-            if (2*s > L.tableSize_)
+            if (2*s > L.capacity_)
             {
                 L.resize(2*s);
             }
@@ -182,7 +182,7 @@ Foam::Istream& Foam::operator>>
 
                     is.fatalCheck
                     (
-                        "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
+                        "operator>>(Istream&, HashTable&) : "
                         "reading entry"
                     );
                 }
@@ -224,15 +224,11 @@ Foam::Istream& Foam::operator>>
 
             Key key;
             is >> key;
-
-            T element;
-            is >> element;
-
-            L.insert(key, element);
+            L.insert(key, pTraits<T>(is));
 
             is.fatalCheck
             (
-                "operator>>(Istream&, HashTable<T, Key, Hash>&) : "
+                "operator>>(Istream&, HashTable&) : "
                 "reading entry"
             );
 
@@ -262,20 +258,27 @@ Foam::Ostream& Foam::operator<<
     const HashTable<T, Key, Hash>& tbl
 )
 {
-    using const_iterator = typename HashTable<T, Key, Hash>::const_iterator;
+    const label sz = tbl.size();
 
-    // Write size and start delimiter
-    os << nl << tbl.size() << nl << token::BEGIN_LIST << nl;
+    if (sz)
+    {
+        // Size and start list delimiter
+        os << nl << sz << nl << token::BEGIN_LIST << nl;
 
-    // Write contents
-    for (const_iterator iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
+        // Contents
+        for (auto iter = tbl.cbegin(); iter != tbl.cend(); ++iter)
+        {
+            os << iter.key() << token::SPACE << iter.object() << nl;
+        }
+
+        os << token::END_LIST;    // End list delimiter
+    }
+    else
     {
-        os << iter.key() << token::SPACE << iter.object() << nl;
+        // Empty hash table
+        os << sz << token::BEGIN_LIST << token::END_LIST;
     }
 
-    // Write end delimiter
-    os << token::END_LIST;
-
     os.check(FUNCTION_NAME);
     return os;
 }
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C
new file mode 100644
index 0000000000000000000000000000000000000000..9a1b792fcab0336ad922d5d85938e5a45d387b10
--- /dev/null
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIter.C
@@ -0,0 +1,123 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class T, class Key, class Hash>
+template<bool Const>
+Foam::HashTable<T, Key, Hash>::Iterator<Const>::Iterator
+(
+    table_type* tbl,
+    const Key& key
+)
+:
+    entry_(nullptr),
+    container_(tbl),
+    index_(0)
+{
+    if (tbl->size())
+    {
+        const label index = container_->hashKeyIndex(key);
+
+        for (node_type* ep = container_->table_[index]; ep; ep = ep->next_)
+        {
+            if (key == ep->key())
+            {
+                entry_ = ep;
+                index_ = index;
+                break;
+            }
+        }
+    }
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+//
+// Any changes here may need changes in the iterator increment() method
+//
+template<class T, class Key, class Hash>
+bool Foam::HashTable<T, Key, Hash>::iterator_erase
+(
+    node_type*& entry,
+    label& index
+)
+{
+    // Safeguard against the following:
+    // - empty table
+    // - nullptr entry
+    // - end iterator (which is also a nullptr)
+    // - negative index from a previous erase. See comment below.
+    if (!size_ || !entry || index < 0)
+    {
+        return false;
+    }
+
+    // Decrease count
+    size_--;
+
+    // The previous element in the singly linked list
+    node_type* prev = nullptr;
+
+    for (node_type* ep = table_[index]; ep; ep = ep->next_)
+    {
+        if (ep == entry)
+        {
+            break;
+        }
+        prev = ep;
+    }
+
+    if (prev)
+    {
+        // Had previous element in linked list - reposition to there
+        prev->next_ = entry->next_;
+        delete entry;
+        entry = prev;
+
+        return true;
+    }
+
+    // Was first element on linked list
+    table_[index] = entry->next_;
+    delete entry;
+
+    // Assign any non-nullptr value so it doesn't look like end()
+    entry = reinterpret_cast<node_type*>(this);
+
+    // Mark the present index to continue and bring it back to the present
+    // location with the next index.
+    //
+    // Save: (-index-1), which has no ambiguity for index 0.
+    // Retrieve:  (-(index+1))
+
+    index = (-index - 1);
+
+    return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H
new file mode 100644
index 0000000000000000000000000000000000000000..cc85a8b91402983e50ebdcb5ce73594a837ada46
--- /dev/null
+++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H
@@ -0,0 +1,263 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * iterator base * * * * * * * * * * * * * * * //
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline Foam::HashTable<T, Key, Hash>::Iterator<Const>::Iterator()
+:
+    entry_(nullptr),
+    container_(nullptr),
+    index_(0)
+{}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline Foam::HashTable<T, Key, Hash>::Iterator<Const>::Iterator
+(
+    bool, // Future use and to avoid implicit construct
+    table_type* tbl
+)
+:
+    entry_(nullptr),
+    container_(tbl),
+    index_(0)
+{
+    if (container_ && container_->size_)
+    {
+        // Locate the first non-nullptr table entry
+        while
+        (
+            !(entry_ = container_->table_[index_])
+         && ++index_ < container_->capacity_
+        )
+        {}
+
+        if (index_ >= container_->capacity_)
+        {
+            // Nothing found - make it an end iterator
+            entry_ = nullptr;
+            index_ = 0;
+        }
+    }
+}
+
+
+//
+// Any changes here may need changes in iterator_erase() method too
+//
+template<class T, class Key, class Hash>
+template<bool Const>
+inline void
+Foam::HashTable<T, Key, Hash>::Iterator<Const>::increment()
+{
+    if (index_ < 0)
+    {
+        // Negative index is a special value from erase
+        //
+        // Saved as (-index-1), retrieved as (-(index-1)) but to with an
+        // extra (-1) to compensate for the ++ in the following while loop
+        index_ = -(index_+1) - 1;
+    }
+    else if (index_ < container_->capacity_ && entry_ && entry_->next_)
+    {
+        // Move to next element on the linked-list
+        entry_ = entry_->next_;
+        return;
+    }
+
+    // Move to the next non-nullptr table entry
+    while
+    (
+        ++index_ < container_->capacity_
+     && !(entry_ = container_->table_[index_])
+    )
+    {}
+
+    if (index_ >= container_->capacity_)
+    {
+        // Nothing found - make it an end iterator
+        entry_ = nullptr;
+        index_ = 0;
+    }
+}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline bool
+Foam::HashTable<T, Key, Hash>::Iterator<Const>::found() const
+{
+    return entry_;
+}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline const Key& Foam::HashTable<T, Key, Hash>::Iterator<Const>::key() const
+{
+    return entry_->key();
+}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator==
+(
+    const Iterator<true>& iter
+) const
+{
+    return entry_ == iter.entry_;
+}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator!=
+(
+    const Iterator<true>& iter
+) const
+{
+    return entry_ != iter.entry_;
+}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator==
+(
+    const Iterator<false>& iter
+) const
+{
+    return entry_ == iter.entry_;
+}
+
+
+template<class T, class Key, class Hash>
+template<bool Const>
+inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator!=
+(
+    const Iterator<false>& iter
+) const
+{
+    return entry_ != iter.entry_;
+}
+
+
+// * * * * * * * * * * * * * * * * STL iterator  * * * * * * * * * * * * * * //
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::iterator&
+Foam::HashTable<T, Key, Hash>::iterator::operator++()
+{
+    this->increment();
+    return *this;
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::iterator
+Foam::HashTable<T, Key, Hash>::iterator::operator++(int)
+{
+    iterator iter(*this);
+    this->increment();
+    return iter;
+}
+
+
+// * * * * * * * * * * * * * * * STL const_iterator  * * * * * * * * * * * * //
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::const_iterator&
+Foam::HashTable<T, Key, Hash>::const_iterator::operator++()
+{
+    this->increment();
+    return *this;
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::const_iterator
+Foam::HashTable<T, Key, Hash>::const_iterator::operator++(int)
+{
+    const_iterator iter(*this);
+    this->increment();
+    return iter;
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::iterator
+Foam::HashTable<T, Key, Hash>::begin()
+{
+    return iterator(Iterator<false>(true, this));
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::const_iterator
+Foam::HashTable<T, Key, Hash>::begin() const
+{
+    return const_iterator(Iterator<true>(true, this));
+}
+
+
+template<class T, class Key, class Hash>
+inline typename Foam::HashTable<T, Key, Hash>::const_iterator
+Foam::HashTable<T, Key, Hash>::cbegin() const
+{
+    return const_iterator(Iterator<true>(true, this));
+}
+
+
+template<class T, class Key, class Hash>
+inline const typename Foam::HashTable<T, Key, Hash>::iterator&
+Foam::HashTable<T, Key, Hash>::end()
+{
+    return iterator_end<iterator>();
+}
+
+
+template<class T, class Key, class Hash>
+inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
+Foam::HashTable<T, Key, Hash>::end() const
+{
+    return iterator_cend<const_iterator>();
+}
+
+
+template<class T, class Key, class Hash>
+inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
+Foam::HashTable<T, Key, Hash>::cend() const
+{
+    return iterator_cend<const_iterator>();
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H
index 56f59128dd168c826b9b5c3e8d042ab3c68fc71a..f6910a73cdf09fd349eff97012ceb3471762cc14 100644
--- a/src/OpenFOAM/containers/HashTables/Map/Map.H
+++ b/src/OpenFOAM/containers/HashTables/Map/Map.H
@@ -27,6 +27,11 @@ Class
 Description
     A HashTable to objects of type \<T\> with a label key.
 
+Note
+    The Map contents are unordered.
+    When the key order is important, use the sortedToc() method to obtain
+    a list of sorted keys and use that for further access.
+
 See also
     PtrMap
 
@@ -43,7 +48,7 @@ namespace Foam
 {
 
 /*---------------------------------------------------------------------------*\
-                           Class Map Declaration
+                             Class Map Declaration
 \*---------------------------------------------------------------------------*/
 
 template<class T>
@@ -65,32 +70,44 @@ public:
 
     // Constructors
 
-        //- Construct given initial size
-        Map(const label size = 128)
+        //- Construct null with default table capacity
+        Map()
+        :
+            parent_type()
+        {}
+
+        //- Construct with given initial table capacity
+        explicit Map(const label size)
         :
             parent_type(size)
         {}
 
-        //- Construct from Istream
+        //- Construct from Istream with default table capacity
         Map(Istream& is)
         :
             parent_type(is)
         {}
 
-        //- Construct as copy
-        Map(const Map<T>& map)
+        //- Copy construct
+        Map(const this_type& map)
         :
             parent_type(map)
         {}
 
+        //- Move construct
+        Map(this_type&& map)
+        :
+            parent_type(std::move(map))
+        {}
+
         //- Construct by transferring the parameter contents
-        Map(const Xfer<Map<T>>& map)
+        Map(const Xfer<this_type>& map)
         :
             parent_type(map)
         {}
 
         //- Construct by transferring the parameter contents
-        Map(const Xfer<HashTable<T, label, Hash<label>>>& map)
+        Map(const Xfer<parent_type>& map)
         :
             parent_type(map)
         {}
@@ -100,6 +117,25 @@ public:
         :
             parent_type(map)
         {}
+
+
+    // Member Operators
+
+        using parent_type::operator=;
+
+        //- Copy assignment
+        void operator=(const this_type& rhs)
+        {
+            parent_type::operator=(rhs);
+        }
+
+        //- Move assignment
+        void operator=(this_type&& rhs)
+        {
+            parent_type::operator=(std::move(rhs));
+        }
+
+
 };
 
 
diff --git a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H
index 178bc670989b69fc12276b080d3a89ac62d52377..915edf49ad008ec89eb9ed69a0adec78365c70e2 100644
--- a/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H
+++ b/src/OpenFOAM/containers/HashTables/PtrMap/PtrMap.H
@@ -62,8 +62,14 @@ public:
 
     // Constructors
 
-        //- Construct given initial map size
-        PtrMap(const label size = 128)
+        //- Construct null with default table capacity
+        PtrMap()
+        :
+            parent_type()
+        {}
+
+        //- Construct with given initial table capacity
+        explicit PtrMap(const label size)
         :
             parent_type(size)
         {}
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C
deleted file mode 100644
index c024ff335e210a5cdc0ec34925e598fe5a4c2fd3..0000000000000000000000000000000000000000
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C
+++ /dev/null
@@ -1,530 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef StaticHashTable_C
-#define StaticHashTable_C
-
-#include "StaticHashTable.H"
-#include "List.H"
-#include "IOstreams.H"
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-Foam::StaticHashTable<T, Key, Hash>::StaticHashTable(const label size)
-:
-    StaticHashTableCore(),
-    keys_(StaticHashTableCore::canonicalSize(size)),
-    objects_(keys_.size()),
-    nElmts_(0),
-    endIter_(*this, keys_.size(), 0),
-    endConstIter_(*this, keys_.size(), 0)
-{
-    if (size < 1)
-    {
-        FatalErrorInFunction
-            << "Illegal size " << size << " for StaticHashTable."
-            << " Minimum size is 1" << abort(FatalError);
-    }
-}
-
-
-template<class T, class Key, class Hash>
-Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
-(
-    const StaticHashTable<T, Key, Hash>& ht
-)
-:
-    StaticHashTableCore(),
-    keys_(ht.keys_),
-    objects_(ht.objects_),
-    nElmts_(ht.nElmts_),
-    endIter_(*this, keys_.size(), 0),
-    endConstIter_(*this, keys_.size(), 0)
-{}
-
-
-template<class T, class Key, class Hash>
-Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
-(
-    const Xfer<StaticHashTable<T, Key, Hash>>& ht
-)
-:
-    StaticHashTableCore(),
-    keys_(0),
-    objects_(0),
-    nElmts_(0),
-    endIter_(*this, 0, 0),
-    endConstIter_(*this, 0, 0)
-{
-    transfer(ht());
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-Foam::StaticHashTable<T, Key, Hash>::~StaticHashTable()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-bool Foam::StaticHashTable<T, Key, Hash>::found(const Key& key) const
-{
-    if (nElmts_)
-    {
-        const label hashIdx = hashKeyIndex(key);
-        const List<Key>& localKeys = keys_[hashIdx];
-
-        forAll(localKeys, elemIdx)
-        {
-            if (key == localKeys[elemIdx])
-            {
-                return true;
-            }
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        InfoInFunction << "Entry " << key << " not found in hash table\n";
-    }
-    #endif
-
-    return false;
-}
-
-
-template<class T, class Key, class Hash>
-typename Foam::StaticHashTable<T, Key, Hash>::iterator
-Foam::StaticHashTable<T, Key, Hash>::find
-(
-    const Key& key
-)
-{
-    if (nElmts_)
-    {
-        const label hashIdx = hashKeyIndex(key);
-        const List<Key>& localKeys = keys_[hashIdx];
-
-        forAll(localKeys, elemIdx)
-        {
-            if (key == localKeys[elemIdx])
-            {
-                return iterator(*this, hashIdx, elemIdx);
-            }
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        InfoInFunction << "Entry " << key << " not found in hash table\n";
-    }
-    #endif
-
-    return end();
-}
-
-
-template<class T, class Key, class Hash>
-typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
-Foam::StaticHashTable<T, Key, Hash>::find
-(
-    const Key& key
-) const
-{
-    return this->cfind(key);
-}
-
-
-template<class T, class Key, class Hash>
-typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
-Foam::StaticHashTable<T, Key, Hash>::cfind
-(
-    const Key& key
-) const
-{
-    if (nElmts_)
-    {
-        const label hashIdx = hashKeyIndex(key);
-        const List<Key>& localKeys = keys_[hashIdx];
-
-        forAll(localKeys, elemIdx)
-        {
-            if (key == localKeys[elemIdx])
-            {
-                return const_iterator(*this, hashIdx, elemIdx);
-            }
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        InfoInFunction << "Entry " << key << " not found in hash table\n";
-    }
-    #endif
-
-    return cend();
-}
-
-
-template<class T, class Key, class Hash>
-Foam::List<Key> Foam::StaticHashTable<T, Key, Hash>::toc() const
-{
-    List<Key> keys(nElmts_);
-    label keyI = 0;
-
-    for (const_iterator iter = cbegin(); iter != cend(); ++iter)
-    {
-        keys[keyI++] = iter.key();
-    }
-
-    return keys;
-}
-
-
-template<class T, class Key, class Hash>
-bool Foam::StaticHashTable<T, Key, Hash>::set
-(
-    const Key& key,
-    const T& obj,
-    const bool protect
-)
-{
-    const label hashIdx = hashKeyIndex(key);
-    List<Key>& localKeys = keys_[hashIdx];
-
-    label existing = localKeys.size();
-    forAll(localKeys, elemIdx)
-    {
-        if (key == localKeys[elemIdx])
-        {
-            existing = elemIdx;
-            break;
-        }
-    }
-
-    if (existing == localKeys.size())
-    {
-        // Not found, append
-        List<T>& localObjects = objects_[hashIdx];
-
-        localKeys.setSize(existing+1);
-        localObjects.setSize(existing+1);
-
-        localKeys[existing] = key;
-        localObjects[existing] = obj;
-
-        nElmts_++;
-    }
-    else if (protect)
-    {
-        // Found - but protected from overwriting
-        // this corresponds to the STL 'insert' convention
-        #ifdef FULLDEBUG
-        if (debug)
-        {
-            InfoInFunction
-                << "Cannot insert " << key << " already in hash table\n";
-        }
-        #endif
-        return false;
-    }
-    else
-    {
-        // Found - overwrite existing entry
-        // this corresponds to the Perl convention
-        objects_[hashIdx][existing] = obj;
-    }
-
-    return true;
-}
-
-
-template<class T, class Key, class Hash>
-bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit)
-{
-    if (cit != end())
-    {
-        List<Key>& localKeys = keys_[cit.hashIndex_];
-        List<T>& localObjects = objects_[cit.hashIndex_];
-
-        // Copy down
-        for (label i = cit.elemIndex_+1; i < localKeys.size(); i++)
-        {
-            localKeys[i-1] = localKeys[i];
-            localObjects[i-1] = localObjects[i];
-        }
-        localKeys.setSize(localKeys.size()-1);
-        localObjects.setSize(localObjects.size()-1);
-
-        // Adjust iterator after erase
-        iterator& it = const_cast<iterator&>(cit);
-
-        it.elemIndex_--;
-        if (it.elemIndex_ < 0)
-        {
-            // No previous element in the local list
-            // Mark with as special value (see notes in HashTable)
-            it.hashIndex_ = -it.hashIndex_ - 1;
-            it.elemIndex_ = 0;
-        }
-
-        nElmts_--;
-
-        #ifdef FULLDEBUG
-        if (debug)
-        {
-            InfoInFunction << "hashedEntry removed.\n";
-        }
-        #endif
-
-        return true;
-    }
-    else
-    {
-        #ifdef FULLDEBUG
-        if (debug)
-        {
-            InfoInFunction
-                << "Cannot remove hashedEntry from hash table\n";
-        }
-        #endif
-
-        return false;
-    }
-}
-
-
-template<class T, class Key, class Hash>
-bool Foam::StaticHashTable<T, Key, Hash>::erase(const Key& key)
-{
-    iterator it = find(key);
-
-    if (it != end())
-    {
-        return erase(it);
-    }
-    else
-    {
-        return false;
-    }
-}
-
-
-template<class T, class Key, class Hash>
-Foam::label Foam::StaticHashTable<T, Key, Hash>::erase
-(
-    const StaticHashTable<T, Key, Hash>& rhs
-)
-{
-    label count = 0;
-
-    // Remove rhs elements from this table
-    // NOTE: could optimize depending on which hash is smaller
-    for (iterator iter = this->begin(); iter != this->end(); ++iter)
-    {
-        if (rhs.found(iter.key()) && erase(iter))
-        {
-            count++;
-        }
-    }
-
-   return count;
-}
-
-
-template<class T, class Key, class Hash>
-void Foam::StaticHashTable<T, Key, Hash>::resize(const label sz)
-{
-    label newSize = StaticHashTableCore::canonicalSize(sz);
-
-    if (newSize == keys_.size())
-    {
-        #ifdef FULLDEBUG
-        if (debug)
-        {
-            InfoInFunction << "New table size == old table size\n";
-        }
-        #endif
-
-        return;
-    }
-
-    if (newSize < 1)
-    {
-        FatalErrorInFunction
-            << "Illegal size " << newSize << " for StaticHashTable."
-            << " Minimum size is 1" << abort(FatalError);
-    }
-
-
-    StaticHashTable<T, Key, Hash> newTable(newSize);
-
-    for (const_iterator iter = cbegin(); iter != cend(); ++iter)
-    {
-        newTable.insert(iter.key(), *iter);
-    }
-
-    transfer(newTable);
-
-    // Adapt end() iterators
-    endIter_.hashIndex_ = keys_.size();
-    endConstIter_.hashIndex_ = keys_.size();
-}
-
-
-template<class T, class Key, class Hash>
-void Foam::StaticHashTable<T, Key, Hash>::clear()
-{
-    forAll(keys_, hashIdx)
-    {
-        keys_[hashIdx].clear();
-        objects_[hashIdx].clear();
-    }
-
-    nElmts_ = 0;
-}
-
-
-template<class T, class Key, class Hash>
-void Foam::StaticHashTable<T, Key, Hash>::clearStorage()
-{
-    clear();
-    resize(1);
-}
-
-
-template<class T, class Key, class Hash>
-void Foam::StaticHashTable<T, Key, Hash>::transfer
-(
-    StaticHashTable<T, Key, Hash>& ht
-)
-{
-    // Remove existing elements
-    clear();
-
-    // Copy data from ht
-    keys_.transfer(ht.keys_);
-    objects_.transfer(ht.objects_);
-
-    nElmts_ = ht.nElmts_;
-    ht.nElmts_ = 0;
-
-    // Adapt end() iterators
-    endIter_.hashIndex_ = keys_.size();
-    endConstIter_.hashIndex_ = keys_.size();
-
-    ht.endIter_.hashIndex_ = 0;
-    ht.endConstIter_.hashIndex_ = 0;
-}
-
-
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-void Foam::StaticHashTable<T, Key, Hash>::operator=
-(
-    const StaticHashTable<T, Key, Hash>& rhs
-)
-{
-    // Check for assignment to self
-    if (this == &rhs)
-    {
-        FatalErrorInFunction
-            << "attempted assignment to self"
-            << abort(FatalError);
-    }
-
-
-    // keys could be empty from a previous transfer()
-    if (keys_.empty())
-    {
-        keys_.setSize(rhs.keys_.size());
-        objects_.setSize(keys_.size());
-
-        // Adapt end() iterators
-        endIter_.hashIndex_ = keys_.size();
-        endConstIter_.hashIndex_ = keys_.size();
-    }
-    else
-    {
-        clear();
-        // keys_.size() does not change so neither does end() iterator.
-    }
-
-
-    for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
-    {
-        insert(iter.key(), *iter);
-    }
-}
-
-template<class T, class Key, class Hash>
-bool Foam::StaticHashTable<T, Key, Hash>::operator==
-(
-    const StaticHashTable<T, Key, Hash>& rhs
-) const
-{
-    // Sizes (number of keys) must match
-
-    for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
-    {
-        const_iterator fnd = find(iter.key());
-
-        if (fnd == cend() || fnd() != iter())
-        {
-            return false;
-        }
-    }
-
-    return true;
-}
-
-
-template<class T, class Key, class Hash>
-bool Foam::StaticHashTable<T, Key, Hash>::operator!=
-(
-    const StaticHashTable<T, Key, Hash>& rhs
-) const
-{
-    return !(operator==(rhs));
-}
-
-
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
-
-#include "StaticHashTableIO.C"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H
deleted file mode 100644
index 850eb1fc43d3bf5055c70c8c56a9f200de9a5b9b..0000000000000000000000000000000000000000
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H
+++ /dev/null
@@ -1,415 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-Class
-    Foam::StaticHashTable
-
-Description
-    STL conforming hash table.
-
-Note
-    Uses straight lists as underlying type.
-    Is slower to insert than the standard HashTable, but should be more
-    memory efficient and faster to access.
-
-SourceFiles
-    StaticHashTableI.H
-    StaticHashTable.C
-    StaticHashTableIO.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef StaticHashTable_H
-#define StaticHashTable_H
-
-#include "label.H"
-#include "uLabel.H"
-#include "word.H"
-#include "Xfer.H"
-#include "className.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-// Forward declaration of friend functions and operators
-
-template<class T> class List;
-template<class T, class Key, class Hash> class StaticHashTable;
-
-template<class T, class Key, class Hash> Istream& operator>>
-(
-    Istream&,
-    StaticHashTable<T, Key, Hash>&
-);
-
-template<class T, class Key, class Hash> Ostream& operator<<
-(
-    Ostream&,
-    const StaticHashTable<T, Key, Hash>&
-);
-
-
-/*---------------------------------------------------------------------------*\
-                     Class StaticHashTableCore Declaration
-\*---------------------------------------------------------------------------*/
-
-//- Template-invariant bits for StaticHashTable
-struct StaticHashTableCore
-{
-    //- Return a canonical (power-of-two) of the requested size.
-    static label canonicalSize(const label requested_size);
-
-    //- Construct null
-    StaticHashTableCore()
-    {}
-
-    //- Define template name and debug
-    ClassName("StaticHashTable");
-
-    //- A zero-sized end iterator
-    struct iteratorEnd
-    {
-        //- Construct null
-        iteratorEnd()
-        {}
-    };
-};
-
-
-
-/*---------------------------------------------------------------------------*\
-                       Class StaticHashTable Declaration
-\*---------------------------------------------------------------------------*/
-
-template<class T, class Key=word, class Hash=string::hash>
-class StaticHashTable
-:
-    public StaticHashTableCore
-{
-    // Private data type for table entries
-
-        //- The lookup keys, ordered per hash value
-        List<List<Key>> keys_;
-
-        //- For each key the corresponding object.
-        List<List<T>> objects_;
-
-        //- The current number of elements in table
-        label nElmts_;
-
-        //- Return the hash index of the Key within the current table size.
-        //  No checks for zero-sized tables.
-        inline label hashKeyIndex(const Key& key) const;
-
-        //- Assign a new hashed entry to a possibly already existing key
-        bool set(const Key& key, const T& obj, bool protect);
-
-
-public:
-
-
-    // Forward declaration of STL iterators
-
-        template<class TRef, class TableRef>
-        class Iterator;
-
-        typedef Iterator
-        <
-            T&,
-            StaticHashTable<T, Key, Hash>&
-        > iterator;
-
-        typedef Iterator
-        <
-            const T&,
-            const StaticHashTable<T, Key, Hash>&
-        > const_iterator;
-
-
-    // Declare friendship with the iterators
-
-        friend class Iterator
-        <
-            T&,
-            StaticHashTable<T, Key, Hash>&
-        >;
-
-        friend class Iterator
-        <
-            const T&,
-            const StaticHashTable<T, Key, Hash>&
-        >;
-
-
-    // Constructors
-
-        //- Construct given initial table size
-        StaticHashTable(const label size = 128);
-
-        //- Construct from Istream
-        StaticHashTable(Istream&, const label size = 128);
-
-        //- Construct as copy
-        StaticHashTable(const StaticHashTable<T, Key, Hash>&);
-
-        //- Construct by transferring the parameter contents
-        StaticHashTable(const Xfer<StaticHashTable<T, Key, Hash>>&);
-
-
-    //- Destructor
-    ~StaticHashTable();
-
-
-    // Member Functions
-
-        // Access
-
-            //- Return number of elements in table.
-            inline label size() const;
-
-            //- Return true if the hash table is empty
-            inline bool empty() const;
-
-            //- Return true if hashed entry is found in table
-            bool found(const Key& key) const;
-
-            //- Find and return an iterator set at the hashed entry
-            //  If not found iterator = end()
-            iterator find(const Key& key);
-
-            //- Find and return an const_iterator set at the hashed entry
-            //  If not found iterator = end()
-            const_iterator find(const Key& key) const;
-
-            //- Find and return an const_iterator set at the hashed entry
-            //  If not found iterator = end()
-            const_iterator cfind(const Key& key) const;
-
-            //- Return the table of contents
-            List<Key> toc() const;
-
-            //- Print information
-            Ostream& printInfo(Ostream&) const;
-
-
-        // Edit
-
-            //- Insert a new hashed entry
-            bool insert(const Key& key, const T& newElmt);
-
-            //- Assign a new hashed entry, overwriting existing entries
-            inline bool set(const Key&, const T& newElmt);
-
-            //- Erase an hashed entry specified by given iterator
-            bool erase(const iterator& it);
-
-            //- Erase an hashed entry specified by given key if in table
-            bool erase(const Key& key);
-
-            //- Resize the hash table for efficiency
-            void resize(const label newSize);
-
-            //- Remove entries in the given hash table from this hash table
-            //  Return the number of elements removed
-            label erase(const StaticHashTable<T, Key, Hash>&);
-
-            //- Clear all entries from table
-            void clear();
-
-            //- Clear the table entries and the table itself.
-            //  Equivalent to clear() followed by resize(1)
-            void clearStorage();
-
-            //- Transfer the contents of the argument table into this table
-            //  and annul the argument table.
-            void transfer(StaticHashTable<T, Key, Hash>&);
-
-            //- Transfer contents to the Xfer container
-            inline Xfer<StaticHashTable<T, Key, Hash>> xfer();
-
-
-    // Member Operators
-
-        //- Find and return an hashed entry
-        inline T& operator[](const Key&);
-
-        //- Find and return an hashed entry
-        inline const T& operator[](const Key&) const;
-
-        //- Find and return an hashed entry, create it null if not present.
-        inline T& operator()(const Key&);
-
-        //- Assignment
-        void operator=(const StaticHashTable<T, Key, Hash>&);
-
-        //- Equality. Two hash tables are equal if all contents of first are
-        //  also in second and vice versa.
-        bool operator==(const StaticHashTable<T, Key, Hash>&) const;
-
-        //- The opposite of the equality operation.
-        bool operator!=(const StaticHashTable<T, Key, Hash>&) const;
-
-
-    // STL type definitions
-
-        //- Type of values the StaticHashTable contains.
-        typedef T value_type;
-
-        //- Type that can be used for storing into StaticHashTable::value_type
-        //  objects.  This type is usually List::value_type&.
-        typedef T& reference;
-
-        //- Type that can be used for storing into constant
-        //  StaticHashTable::value_type objects.  This type is usually const
-        //  StaticHashTable::value_type&.
-        typedef const T& const_reference;
-
-        //- The type that can represent the size of a StaticHashTable.
-        typedef label size_type;
-
-
-    // STL iterator
-
-        //- An STL iterator
-        template<class TRef, class TableRef>
-        class Iterator
-        {
-            friend class StaticHashTable;
-
-            template<class TRef2, class TableRef2>
-            friend class Iterator;
-
-            // Private data
-
-                //- Reference to the StaticHashTable this is an iterator for
-                TableRef hashTable_;
-
-                //- Current hash index
-                label hashIndex_;
-
-                //- Index of current element at hashIndex
-                label elemIndex_;
-
-
-        public:
-
-            // Constructors
-
-                //- Construct from hash table, hash index and element index
-                inline Iterator
-                (
-                    TableRef,
-                    label hashIndex_,
-                    label elemIndex_
-                );
-
-                //- Construct from the non-const iterator
-                inline Iterator(const iterator&);
-
-
-            // Member operators
-
-                inline void operator=(const iterator&);
-
-                inline bool operator==(const iterator&) const;
-                inline bool operator==(const const_iterator&) const;
-
-                inline bool operator!=(const iterator&) const;
-                inline bool operator!=(const const_iterator&) const;
-
-                inline TRef operator*();
-                inline TRef operator()();
-
-                inline Iterator& operator++();
-                inline Iterator operator++(int);
-
-                inline const Key& key() const;
-        };
-
-
-        //- Iterator set to the beginning of the StaticHashTable
-        inline iterator begin();
-
-        //- Iterator set to beyond the end of the StaticHashTable
-        inline const iterator& end();
-
-        //- const_iterator set to the beginning of the StaticHashTable
-        inline const_iterator cbegin() const;
-
-        //- const_iterator set to beyond the end of the StaticHashTable
-        inline const const_iterator& cend() const;
-
-        //- const_iterator set to the beginning of the StaticHashTable
-        inline const_iterator begin() const;
-
-        //- const_iterator set to beyond the end of the StaticHashTable
-        inline const const_iterator& end() const;
-
-    // IOstream Operator
-
-        friend Istream& operator>> <T, Key, Hash>
-        (
-            Istream&,
-            StaticHashTable<T, Key, Hash>&
-        );
-
-        friend Ostream& operator<< <T, Key, Hash>
-        (
-            Ostream&,
-            const StaticHashTable<T, Key, Hash>&
-        );
-
-
-private:
-
-        //- Iterator returned by end()
-        iterator endIter_;
-
-        //- const_iterator returned by end()
-        const_iterator endConstIter_;
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#include "StaticHashTableI.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#ifndef NoStaticHashTableC
-#ifdef NoRepository
-    #include "StaticHashTable.C"
-#endif
-#endif
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C
deleted file mode 100644
index b53b5554bfa34a54f4a41780683f92cfa80e803d..0000000000000000000000000000000000000000
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C
+++ /dev/null
@@ -1,86 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-\*---------------------------------------------------------------------------*/
-
-#include "StaticHashTable.H"
-#include "uLabel.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-defineTypeNameAndDebug(StaticHashTableCore, 0);
-}
-
-
-// Approximately labelMax/4
-static const Foam::label maxTableSize(1L << (sizeof(Foam::label)*8-3));
-
-
-// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
-
-Foam::label Foam::StaticHashTableCore::canonicalSize(const label requested_size)
-{
-    if (requested_size < 1)
-    {
-        return 0;
-    }
-    else if (requested_size >= maxTableSize)
-    {
-        return maxTableSize;
-    }
-
-    // Enforce power of two - makes for a very fast modulus.
-    // Use unsigned for these calculations.
-    //
-    // - The lower limit (8) is somewhat arbitrary, but if the hash table
-    //   is too small, there will be many direct table collisions.
-    // - The upper limit (approx. labelMax/4) must be a power of two,
-    //   need not be extremely large for hashing.
-
-    uLabel powerOfTwo = 8u; // lower-limit
-
-    const uLabel size = requested_size;
-    if (size <= powerOfTwo)
-    {
-        return powerOfTwo;
-    }
-    else if (size & (size-1))  // <- Modulus of i^2
-    {
-        // Determine power-of-two. Brute-force is fast enough.
-        while (powerOfTwo < size)
-        {
-            powerOfTwo <<= 1;
-        }
-
-        return powerOfTwo;
-    }
-    else
-    {
-        return size;
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H
deleted file mode 100644
index 2e6b5db0ea0e597a30bd6e2fe4481bd41f79b774..0000000000000000000000000000000000000000
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H
+++ /dev/null
@@ -1,413 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-\*---------------------------------------------------------------------------*/
-
-#include "error.H"
-#include "IOstreams.H"
-
-// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline Foam::label
-Foam::StaticHashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const
-{
-    // size is power of two - this is the modulus
-    return Hash()(key) & (keys_.size() - 1);
-}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline Foam::label Foam::StaticHashTable<T, Key, Hash>::size() const
-{
-    return nElmts_;
-}
-
-
-template<class T, class Key, class Hash>
-inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const
-{
-    return !nElmts_;
-}
-
-
-template<class T, class Key, class Hash>
-inline bool Foam::StaticHashTable<T, Key, Hash>::insert
-(
-    const Key& key,
-    const T& obj
-)
-{
-    return set(key, obj, true);
-}
-
-
-template<class T, class Key, class Hash>
-inline bool Foam::StaticHashTable<T, Key, Hash>::set
-(
-    const Key& key,
-    const T& obj
-)
-{
-    return set(key, obj, false);
-}
-
-
-template<class T, class Key, class Hash>
-inline Foam::Xfer<Foam::StaticHashTable<T, Key, Hash>>
-Foam::StaticHashTable<T, Key, Hash>::xfer()
-{
-    return xferMove(*this);
-}
-
-
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-inline T& Foam::StaticHashTable<T, Key, Hash>::operator[](const Key& key)
-{
-    iterator iter = find(key);
-
-    if (iter == end())
-    {
-        FatalErrorInFunction
-            << toc()
-            << exit(FatalError);
-    }
-
-    return *iter;
-}
-
-
-template<class T, class Key, class Hash>
-inline const T& Foam::StaticHashTable<T, Key, Hash>::operator[]
-(
-    const Key& key
-) const
-{
-    const_iterator iter = find(key);
-
-    if (iter == cend())
-    {
-        FatalErrorInFunction
-            << toc()
-            << exit(FatalError);
-    }
-
-    return *iter;
-}
-
-
-template<class T, class Key, class Hash>
-inline T& Foam::StaticHashTable<T, Key, Hash>::operator()(const Key& key)
-{
-    iterator iter = find(key);
-
-    if (iter == end())
-    {
-        insert(key, T());
-        return *find(key);
-    }
-    else
-    {
-        return *iter;
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * STL iterator  * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::Iterator
-(
-    TableRef hashTbl,
-    label hashIndex,
-    label elemIndex
-)
-:
-    hashTable_(hashTbl),
-    hashIndex_(hashIndex),
-    elemIndex_(elemIndex)
-{}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::Iterator
-(
-    const iterator& iter
-)
-:
-    hashTable_(iter.hashTable_),
-    hashIndex_(iter.hashIndex_),
-    elemIndex_(iter.elemIndex_)
-{}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline void
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator=
-(
-    const iterator& iter
-)
-{
-    this->hashIndex_ = iter.hashIndex_;
-    this->elemIndex_ = iter.elemIndex_;
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline bool
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator==
-(
-    const iterator& iter
-) const
-{
-    return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_;
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline bool
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator==
-(
-    const const_iterator& iter
-) const
-{
-    return hashIndex_ == iter.hashIndex_ && elemIndex_ == iter.elemIndex_;
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline bool
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator!=
-(
-    const iterator& iter
-) const
-{
-    return !operator==(iter);
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline bool
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator!=
-(
-    const const_iterator& iter
-) const
-{
-    return !operator==(iter);
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline TRef
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator*()
-{
-    return hashTable_.objects_[hashIndex_][elemIndex_];
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline TRef
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::operator()()
-{
-    return operator*();
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline
-typename Foam::StaticHashTable<T, Key, Hash>::template Iterator
-<
-    TRef,
-    TableRef
->&
-Foam::StaticHashTable<T, Key, Hash>::Iterator
-<
-    TRef,
-    TableRef
->::operator++()
-{
-    // A negative index is a special value from erase
-    // (see notes in HashTable)
-    if (hashIndex_ < 0)
-    {
-        hashIndex_ = -(hashIndex_+1) - 1;
-    }
-    else
-    {
-        // Try the next element on the local list
-        elemIndex_++;
-
-        if (elemIndex_ < hashTable_.objects_[hashIndex_].size())
-        {
-            return *this;
-        }
-    }
-
-    // Step to the next table entry
-    elemIndex_ = 0;
-
-    while
-    (
-        ++hashIndex_ < hashTable_.objects_.size()
-     && !hashTable_.objects_[hashIndex_].size()
-    )
-    {}
-
-
-    if (hashIndex_ >= hashTable_.objects_.size())
-    {
-        // make end iterator
-        hashIndex_ = hashTable_.keys_.size();
-    }
-
-    return *this;
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline
-typename Foam::StaticHashTable<T, Key, Hash>::template Iterator
-<
-    TRef,
-    TableRef
->
-Foam::StaticHashTable<T, Key, Hash>::Iterator
-<
-    TRef,
-    TableRef
->::operator++
-(
-    int
-)
-{
-    iterator tmp = *this;
-    ++*this;
-    return tmp;
-}
-
-
-template<class T, class Key, class Hash>
-template<class TRef, class TableRef>
-inline const Key&
-Foam::StaticHashTable<T, Key, Hash>::Iterator<TRef, TableRef>::key() const
-{
-    return hashTable_.keys_[hashIndex_][elemIndex_];
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::StaticHashTable<T, Key, Hash>::iterator
-Foam::StaticHashTable<T, Key, Hash>::begin()
-{
-    // Find first non-empty entry
-    forAll(keys_, hashIdx)
-    {
-        if (keys_[hashIdx].size())
-        {
-            return iterator(*this, hashIdx, 0);
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        Info<< "StaticHashTable is empty\n";
-    }
-    #endif
-
-    return StaticHashTable<T, Key, Hash>::endIter_;
-}
-
-
-template<class T, class Key, class Hash>
-inline const typename Foam::StaticHashTable<T, Key, Hash>::iterator&
-Foam::StaticHashTable<T, Key, Hash>::end()
-{
-    return StaticHashTable<T, Key, Hash>::endIter_;
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
-Foam::StaticHashTable<T, Key, Hash>::cbegin() const
-{
-    // Find first non-empty entry
-    forAll(keys_, hashIdx)
-    {
-        if (keys_[hashIdx].size())
-        {
-            return const_iterator(*this, hashIdx, 0);
-        }
-    }
-
-    #ifdef FULLDEBUG
-    if (debug)
-    {
-        Info<< "StaticHashTable is empty\n";
-    }
-    #endif
-
-    return StaticHashTable<T, Key, Hash>::endConstIter_;
-}
-
-
-template<class T, class Key, class Hash>
-inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator&
-Foam::StaticHashTable<T, Key, Hash>::cend() const
-{
-    return StaticHashTable<T, Key, Hash>::endConstIter_;
-}
-
-
-template<class T, class Key, class Hash>
-inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
-Foam::StaticHashTable<T, Key, Hash>::begin() const
-{
-    return this->cbegin();
-}
-
-
-template<class T, class Key, class Hash>
-inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator&
-Foam::StaticHashTable<T, Key, Hash>::end() const
-{
-    return StaticHashTable<T, Key, Hash>::endConstIter_;
-}
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C
deleted file mode 100644
index c7e06724530eaf65ecea01c608937065c5fb45f2..0000000000000000000000000000000000000000
--- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C
+++ /dev/null
@@ -1,237 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-\*---------------------------------------------------------------------------*/
-
-#include "StaticHashTable.H"
-#include "Istream.H"
-#include "Ostream.H"
-
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
-(
-    Istream& is,
-    const label size
-)
-:
-    StaticHashTableCore(),
-    keys_(StaticHashTableCore::canonicalSize(size)),
-    objects_(StaticHashTableCore::canonicalSize(size)),
-    nElmts_(0),
-    endIter_(*this, keys_.size(), 0),
-    endConstIter_(*this, keys_.size(), 0)
-{
-    if (size < 1)
-    {
-        FatalErrorInFunction
-            << "Illegal size " << size << " for StaticHashTable."
-            << " Minimum size is 1" << abort(FatalError);
-    }
-
-    operator>>(is, *this);
-}
-
-
-// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-Foam::Ostream&
-Foam::StaticHashTable<T, Key, Hash>::printInfo(Ostream& os) const
-{
-    label used = 0;
-    label maxChain = 0;
-    unsigned avgChain = 0;
-
-    // Find first non-empty entry
-    forAll(keys_, hashIdx)
-    {
-        const label count = keys_[hashIdx].size();
-        if (count)
-        {
-            ++used;
-            avgChain += count;
-
-            if (maxChain < count)
-            {
-                maxChain = count;
-            }
-        }
-    }
-
-    os  << "StaticHashTable<T,Key,Hash>"
-        << " elements:" << size() << " slots:" << used << "/" << keys_.size()
-        << " chaining(avg/max):" << (used ? float(avgChain/used) : 0)
-        << "/" << maxChain << endl;
-
-    return os;
-}
-
-
-// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
-
-template<class T, class Key, class Hash>
-Foam::Istream& Foam::operator>>(Istream& is, StaticHashTable<T, Key, Hash>& L)
-{
-    is.fatalCheck(FUNCTION_NAME);
-
-    // Anull list
-    L.clear();
-
-    is.fatalCheck(FUNCTION_NAME);
-
-    token firstToken(is);
-
-    is.fatalCheck
-    (
-        "operator>>(Istream&, StaticHashTable<T, Key, Hash>&) : "
-        "reading first token"
-    );
-
-    if (firstToken.isLabel())
-    {
-        label s = firstToken.labelToken();
-
-        // Read beginning of contents
-        char delimiter = is.readBeginList("StaticHashTable<T, Key, Hash>");
-
-        if (s)
-        {
-            if (2*s > L.keys_.size())
-            {
-                L.resize(2*s);
-            }
-
-            if (delimiter == token::BEGIN_LIST)
-            {
-                for (label i=0; i<s; i++)
-                {
-                    Key key;
-                    is >> key;
-                    L.insert(key, pTraits<T>(is));
-
-                    is.fatalCheck
-                    (
-                        "operator>>(Istream&, StaticHashTable<T, Key, Hash>&)"
-                        " : reading entry"
-                    );
-                }
-            }
-            else
-            {
-                FatalIOErrorInFunction
-                (
-                    is
-                )   << "incorrect first token, '(', found " << firstToken.info()
-                    << exit(FatalIOError);
-            }
-        }
-
-        // Read end of contents
-        is.readEndList("StaticHashTable");
-    }
-    else if (firstToken.isPunctuation())
-    {
-        if (firstToken.pToken() != token::BEGIN_LIST)
-        {
-            FatalIOErrorInFunction
-            (
-                is
-            )   << "incorrect first token, '(', found " << firstToken.info()
-                << exit(FatalIOError);
-        }
-
-        token lastToken(is);
-        while
-        (
-           !(
-                lastToken.isPunctuation()
-             && lastToken.pToken() == token::END_LIST
-            )
-        )
-        {
-            is.putBack(lastToken);
-
-            Key key;
-            is >> key;
-
-            T element;
-            is >> element;
-
-            L.insert(key, element);
-
-            is.fatalCheck
-            (
-                "operator>>(Istream&, StaticHashTable<T, Key, Hash>&) : "
-                "reading entry"
-            );
-
-            is >> lastToken;
-        }
-    }
-    else
-    {
-        FatalIOErrorInFunction
-        (
-            is
-        )   << "incorrect first token, expected <int> or '(', found "
-            << firstToken.info()
-            << exit(FatalIOError);
-    }
-
-    is.fatalCheck(FUNCTION_NAME);
-
-    return is;
-}
-
-
-template<class T, class Key, class Hash>
-Foam::Ostream& Foam::operator<<
-(
-    Ostream& os,
-    const StaticHashTable<T, Key, Hash>& L)
-{
-    // Write size and start delimiter
-    os << nl << L.size() << nl << token::BEGIN_LIST << nl;
-
-    // Write contents
-    for
-    (
-        typename StaticHashTable<T, Key, Hash>::const_iterator iter = L.begin();
-        iter != L.end();
-        ++iter
-    )
-    {
-        os << iter.key() << token::SPACE << iter() << nl;
-    }
-
-    // Write end delimiter
-    os << token::END_LIST;
-
-    os.check(FUNCTION_NAME);
-    return os;
-}
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H
index eefabca3290bb76b3eece74e20a0b6b984bc709c..f16cf03d14d7f22ba8d291e5af66e0e47715a874 100644
--- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H
+++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H
@@ -110,13 +110,13 @@ public:
         {}
 
         //- Construct given initial T
-        LList(T a)
+        explicit LList(T a)
         :
             LListBase(new link(a))
         {}
 
         //- Construct from Istream
-        LList(Istream&);
+        explicit LList(Istream&);
 
         //- Construct as copy
         LList(const LList<LListBase, T>&);
diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H
index 66bd1cb397ad5df63b41c48fafd96f9f521ebdb4..371a64b5baca0b4443b3a5d2aaec219372ac12fc 100644
--- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H
+++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectList.H
@@ -65,7 +65,7 @@ public:
         (
             const UList<T>& posList,
             const UList<T>& negList,
-            const labelUList&
+            const labelUList& addr
         );
 
         //- Construct given the complete list and by transferring addressing
@@ -73,7 +73,7 @@ public:
         (
             const UList<T>& posList,
             const UList<T>& negList,
-            const Xfer<List<label>>&
+            const Xfer<List<label>>& addr
         );
 
 
@@ -94,14 +94,14 @@ public:
             inline const List<label>& addressing() const;
 
             //- Calculate index given whether index is into posList or negList
-            inline static label posIndex(const label);
-            inline static label negIndex(const label);
+            inline static label posIndex(const label i);
+            inline static label negIndex(const label i);
 
         // Edit
 
             //- Reset addressing
-            inline void resetAddressing(const labelUList&);
-            inline void resetAddressing(const Xfer<List<label>>&);
+            inline void resetAddressing(const labelUList& addr);
+            inline void resetAddressing(const Xfer<List<label>>& addr);
 
 
         // Member Operators
@@ -110,16 +110,16 @@ public:
             inline List<T> operator()() const;
 
             //- Return non-const access to an element
-            inline T& operator[](const label);
+            inline T& operator[](const label i);
 
             //- Return const access to an element
-            inline const T& operator[](const label) const;
+            inline const T& operator[](const label i) const;
 
             //- Assignment to UList of addressed elements
-            inline void operator=(const UList<T>&);
+            inline void operator=(const UList<T>& ae);
 
             //- Assignment of all entries to the given value
-            inline void operator=(const T&);
+            inline void operator=(const T& val);
 };
 
 
diff --git a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H
index 1f1dd4de5b3df3555f17cedef0f99d933f66c291..6b8a6c0b92e77c6f642d5fa82694b7d9301cf681 100644
--- a/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H
+++ b/src/OpenFOAM/containers/Lists/BiIndirectList/BiIndirectListI.H
@@ -23,6 +23,22 @@ License
 
 \*---------------------------------------------------------------------------*/
 
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+template<class T>
+inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i)
+{
+    return i;
+}
+
+
+template<class T>
+inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i)
+{
+    return -i-1;
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class T>
@@ -111,20 +127,6 @@ inline void Foam::BiIndirectList<T>::resetAddressing
 }
 
 
-template<class T>
-inline Foam::label Foam::BiIndirectList<T>::posIndex(const label i)
-{
-    return i;
-}
-
-
-template<class T>
-inline Foam::label Foam::BiIndirectList<T>::negIndex(const label i)
-{
-    return -i-1;
-}
-
-
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 template<class T>
@@ -144,7 +146,7 @@ inline Foam::List<T> Foam::BiIndirectList<T>::operator()() const
 template<class T>
 inline T& Foam::BiIndirectList<T>::operator[](const label i)
 {
-    label index = addressing_[i];
+    const label index = addressing_[i];
 
     if (index >= 0)
     {
@@ -160,7 +162,7 @@ inline T& Foam::BiIndirectList<T>::operator[](const label i)
 template<class T>
 inline const T& Foam::BiIndirectList<T>::operator[](const label i) const
 {
-    label index = addressing_[i];
+    const label index = addressing_[i];
 
     if (index >= 0)
     {
@@ -193,11 +195,11 @@ inline void Foam::BiIndirectList<T>::operator=(const UList<T>& ae)
 
 
 template<class T>
-inline void Foam::BiIndirectList<T>::operator=(const T& t)
+inline void Foam::BiIndirectList<T>::operator=(const T& val)
 {
     forAll(addressing_, i)
     {
-        operator[](i) = t;
+        operator[](i) = val;
     }
 }
 
diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C
index 363d6d98e49353e2a60e68b3049c581e6cb8d461..deb5b1e7f02d7f10087325c825ec17a778832636 100644
--- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C
+++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -24,23 +24,83 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "DynamicList.H"
+#include "labelRange.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+template<class T, int SizeMin>
+Foam::label Foam::DynamicList<T, SizeMin>::removeElements
+(
+    const labelRange& slice
+)
+{
+    if (!slice.size())
+    {
+        // Noop
+        return 0;
+    }
+    else if (slice.after() >= this->size())
+    {
+        // Remove tail
+        this->resize(slice.first());
+    }
+    else
+    {
+        // Copy (swap) down
+        label j = slice.first();
+        const label len = this->size();
+
+        for (label i = slice.after(); i < len; ++i, ++j)
+        {
+            Foam::Swap(this->operator[](i), this->operator[](j));
+        }
+
+        resize(this->size() - slice.size());
+    }
+
+    return slice.size();
+}
 
-// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
+template<class T, int SizeMin>
+Foam::label Foam::DynamicList<T, SizeMin>::subsetElements
+(
+    const labelRange& slice
+)
+{
+    if (slice.first() > 0)
+    {
+        // Copy (swap) down
+        label j = slice.first();
+        const label len = slice.size();
+
+        for (label i = 0; i < len; ++i, ++j)
+        {
+            Foam::Swap(this->operator[](i), this->operator[](j));
+        }
+    }
+
+    // Don't need min size, since slice size was already checked before
+    resize(slice.size());
+    return this->size();
+}
+
+
+// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList(Istream& is)
+template<class T, int SizeMin>
+Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is)
 :
     List<T>(is),
     capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Foam::Ostream& Foam::operator<<
 (
     Ostream& os,
-    const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    const DynamicList<T, SizeMin>& lst
 )
 {
     os << static_cast<const List<T>&>(lst);
@@ -48,11 +108,11 @@ Foam::Ostream& Foam::operator<<
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Foam::Istream& Foam::operator>>
 (
     Istream& is,
-    DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    DynamicList<T, SizeMin>& lst
 )
 {
     is >> static_cast<List<T>&>(lst);
diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H
index 6c03173401e8566d01371df78e450a2d664ef060..002a3e92274f6f87d40e1635da637fdf17ec116d 100644
--- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H
+++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H
@@ -52,21 +52,20 @@ namespace Foam
 {
 
 // Forward declaration of friend functions and operators
+template<class T, int SizeMin> class DynamicList;
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-class DynamicList;
-
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Ostream& operator<<
 (
     Ostream& os,
-    const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    const DynamicList<T, SizeMin>& lst
 );
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+
+template<class T, int SizeMin>
 Istream& operator>>
 (
     Istream& is,
-    DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    DynamicList<T, SizeMin>& lst
 );
 
 
@@ -74,22 +73,36 @@ Istream& operator>>
                            Class DynamicList Declaration
 \*---------------------------------------------------------------------------*/
 
-template<class T, unsigned SizeInc=0, unsigned SizeMult=2, unsigned SizeDiv=1>
+template<class T, int SizeMin = 16>
 class DynamicList
 :
     public List<T>
 {
-    static_assert
-    (
-        (SizeInc || SizeMult) && SizeDiv,
-        "Invalid sizing parameters"
-    );
+    static_assert(SizeMin > 0, "Invalid min size parameter");
 
     // Private data
 
         //- The capacity (allocated size) of the underlying list.
         label capacity_;
 
+private:
+
+    // Private Member Functions
+
+        //- Remove elements in range
+        label removeElements(const labelRange& slice);
+
+        //- Subset elements in range
+        label subsetElements(const labelRange& slice);
+
+
+protected:
+
+    // Protected Member Functions
+
+        //- Copy assignment from another list
+        template<class ListType>
+        inline void assignDynList(const ListType& lst);
 
 public:
 
@@ -104,22 +117,30 @@ public:
         //- Construct null
         inline DynamicList();
 
-        //- Construct given size.
+        //- Construct an empty list with given reserve size.
         explicit inline DynamicList(const label nElem);
 
         //- Construct with given size and value for all elements.
-        inline DynamicList(const label nElem, const T& a);
+        inline DynamicList(const label nElem, const T& val);
+
+        //- Construct with given size initializing all elements to zero
+        inline DynamicList(const label nElem, const zero);
 
-        //- Construct copy.
-        inline DynamicList
-        (
-            const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
-        );
+        //- Copy construct.
+        inline DynamicList(const DynamicList<T, SizeMin>& lst);
+
+        //- Copy construct from DynamicList with different sizing parameters
+        template<int AnySizeMin>
+        inline DynamicList(const DynamicList<T, AnySizeMin>& lst);
 
         //- Construct from UList. Size set to UList size.
         //  Also constructs from DynamicList with different sizing parameters.
         explicit inline DynamicList(const UList<T>& lst);
 
+        //- Construct from a FixedList
+        template<unsigned FixedSize>
+        inline DynamicList(const FixedList<T, FixedSize>& lst);
+
         //- Construct given begin/end iterators.
         //  Uses std::distance to determine the size.
         template<class InputIterator>
@@ -131,19 +152,36 @@ public:
         //- Construct from UIndirectList. Size set to UIndirectList size.
         explicit inline DynamicList(const UIndirectList<T>& lst);
 
-        //- Construct by transferring the parameter contents
+        //- Transfer (move) construct
         explicit inline DynamicList(const Xfer<List<T>>& lst);
 
+        //- Move construct.
+        inline DynamicList(DynamicList<T, SizeMin>&& lst);
+
+        //- Move construct with different sizing parameters
+        template<int AnySizeMin>
+        inline DynamicList(DynamicList<T, AnySizeMin>&& lst);
+
+        //- Move construct from List
+        inline DynamicList(List<T>&& lst);
+
+        //- Move construct from SortableList
+        DynamicList(SortableList<T>&& lst);
+
         //- Construct from Istream. Size set to size of list read.
         explicit DynamicList(Istream& is);
 
 
     // Member Functions
 
-        // Access
+      // Access
+
+        //- Normal lower capacity limit - the SizeMin template parameter
+        inline label min_size() const;
+
+        //- Size of the underlying storage.
+        inline label capacity() const;
 
-            //- Size of the underlying storage.
-            inline label capacity() const;
 
         // Edit
 
@@ -153,25 +191,23 @@ public:
             //  Use this or reserve() in combination with append().
             inline void setCapacity(const label nElem);
 
-            //- Alter the addressed list size.
+            //- Alter addressable list size.
             //  New space will be allocated if required.
             //  Use this to resize the list prior to using the operator[] for
             //  setting values (as per List usage).
             inline void setSize(const label nElem);
 
-            //- Alter the addressed list size and fill new space with a
-            //  constant.
-            inline void setSize(const label nElem, const T& t);
+            //- Alter addressable list size and fill new space with constant.
+            inline void setSize(const label nElem, const T& val);
 
-            //- Alter the addressed list size.
+            //- Alter addressable list size.
             //  New space will be allocated if required.
             //  Use this to resize the list prior to using the operator[] for
             //  setting values (as per List usage).
             inline void resize(const label nElem);
 
-            //- Alter the addressed list size and fill new space with a
-            //  constant.
-            inline void resize(const label nElem, const T& t);
+            //- Alter addressable list size and fill new space with constant.
+            inline void resize(const label nElem, const T& val);
 
             //- Reserve allocation space for at least this size.
             //  Never shrinks the allocated size, use setCapacity() for that.
@@ -184,103 +220,171 @@ public:
             //- Clear the list and delete storage.
             inline void clearStorage();
 
+            //- Expand the addressable size to fit the allocated capacity.
+            //  Returns the previous addressable size.
+            inline label expandStorage();
+
             //- Shrink the allocated space to the number of elements used.
             //  Returns a reference to the DynamicList.
-            inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& shrink();
+            inline DynamicList<T, SizeMin>& shrink();
+
+            //- Swap content with any sized DynamicList
+            template<int AnySizeMin>
+            inline void swap(DynamicList<T, AnySizeMin>& lst);
 
             //- Transfer contents of the argument List into this.
             inline void transfer(List<T>& lst);
 
-            //- Transfer contents of the argument DynamicList into this.
-            inline void transfer
-            (
-                DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
-            );
+            //- Transfer contents of any sized DynamicList into this.
+            template<int AnySizeMin>
+            inline void transfer(DynamicList<T, AnySizeMin>& lst);
+
+            //- Transfer contents  of the argument SortableList into this.
+            inline void transfer(SortableList<T>& lst);
 
             //- Transfer contents to the Xfer container as a plain List
             inline Xfer<List<T>> xfer();
 
 
-        // Member Operators
+            //- Append an element to the end of this list.
+            inline DynamicList<T, SizeMin>& append(const T& val);
 
-            //- Append an element at the end of the list
-            inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
-            (
-                const T& t
-            );
+            //- Move append an element
+            inline DynamicList<T, SizeMin>& append(T&& val);
 
-            //- Append a List at the end of this list
-            inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
-            (
-                const UList<T>& lst
-            );
+            //- Append another list to the end of this list.
+            inline DynamicList<T, SizeMin>& append(const UList<T>& lst);
+
+            //- Append a FixedList to the end of this list.
+            template<unsigned FixedSize>
+            inline DynamicList<T, SizeMin>&
+            append(const FixedList<T, FixedSize>& lst);
 
             //- Append an initializer list at the end of this list.
-            inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
-            (
-                std::initializer_list<T> lst
-            );
+            inline DynamicList<T, SizeMin>&
+            append(std::initializer_list<T> lst);
 
             //- Append a UIndirectList at the end of this list
-            inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
-            (
-                const UIndirectList<T>& lst
-            );
+            inline DynamicList<T, SizeMin>&
+            append(const UIndirectList<T>& lst);
+
+            //- Move append list
+            inline DynamicList<T, SizeMin>& append(List<T>&& lst);
+
+            //- Move append list
+            inline DynamicList<T, SizeMin>&
+            append(DynamicList<T, SizeMin>&& lst);
+
+            //- Move append list
+            template<int AnySizeMin>
+            inline DynamicList<T, SizeMin>&
+            append(DynamicList<T, AnySizeMin>&& lst);
+
+            //- Move append list
+            inline DynamicList<T, SizeMin>&
+            append(SortableList<T>&& lst);
 
-            //- Remove and return the top element
+            //- Remove and return the last element. Fatal on an empty list.
             inline T remove();
 
+            //- Remove and return the specified element. Fatal on an empty list.
+            //  With fast=true (operates in constant time), the place of the
+            //  removed element is swapped with the last one in the list, which
+            //  changes the ordering.
+            //  With fast=false (operates in linear time), the elements
+            //  are swapped down in the list to preserve ordering.
+            inline T remove(const label idx, const bool fast=false);
+
+            //- Remove a (start,size) subset from the list.
+            //  The range is subsetted with the list size itself to ensure
+            //  result always addresses a valid section of the list.
+            //  Remaining elements are moved down.
+            inline label remove(const labelRange& range);
+
+            //- Remove a (start,size) subset from the list.
+            inline label remove(std::initializer_list<label> start_size);
+
+            //- Retain a (start,size) subset from the list.
+            //  The range is subsetted with the list size itself to ensure
+            //  result always addresses a valid section of the list.
+            //  Remaining elements are moved down.
+            inline label subset(const labelRange& range);
+
+            //- Retain a (start,size) subset from List.
+            inline label subset(std::initializer_list<label> start_size);
+
+
+        // Member Operators
+
             //- Return non-const access to an element, resizing list if
             //  necessary
-            inline T& operator()(const label elemI);
+            inline T& operator()(const label i);
 
             //- Assignment of all addressed entries to the given value
-            inline void operator=(const T& t);
+            inline void operator=(const T& val);
 
-            //- Assignment to DynamicList
-            inline void operator=
-            (
-                const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
-            );
+            //- Assignment of all entries to zero
+            inline void operator=(const zero);
 
             //- Assignment to UList
             inline void operator=(const UList<T>& lst);
 
+            //- Assignment to FixedList
+            template<unsigned FixedSize>
+            inline void operator=(const FixedList<T, FixedSize>& lst);
+
+            //- Assignment to DynamicList
+            inline void operator=(const DynamicList<T, SizeMin>& lst);
+
+            //- Assignment from DynamicList with different sizing parameters
+            template<int AnySizeMin>
+            inline void operator=(const DynamicList<T, AnySizeMin>& lst);
+
             //- Assignment from initializer list
             inline void operator=(std::initializer_list<T> lst);
 
             //- Assignment to UIndirectList
             inline void operator=(const UIndirectList<T>& lst);
 
+            //- Move assignment
+            inline void operator=(List<T>&& lst);
 
-        // STL member functions
+            //- Move assignment
+            inline void operator=(DynamicList<T, SizeMin>&& lst);
 
-            //- Erase an element, move the remaining elements to fill the gap
-            //  and resize the List
-            typename UList<T>::iterator erase
-            (
-                typename UList<T>::iterator curIter
-            );
+            //- Move assignment
+            template<int AnySizeMin>
+            inline void operator=(DynamicList<T, AnySizeMin>&& lst);
+
+            //- Move assignment
+            inline void operator=(SortableList<T>&& lst);
 
 
         // IOstream operators
 
             // Write DynamicList to Ostream.
-            friend Ostream& operator<< <T, SizeInc, SizeMult, SizeDiv>
+            friend Ostream& operator<< <T, SizeMin>
             (
                 Ostream& os,
-                const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+                const DynamicList<T, SizeMin>& lst
             );
 
             //- Read from Istream, discarding contents of existing DynamicList.
-            friend Istream& operator>> <T, SizeInc, SizeMult, SizeDiv>
+            friend Istream& operator>> <T, SizeMin>
             (
                 Istream& is,
-                DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+                DynamicList<T, SizeMin>& lst
             );
 };
 
 
+// Global Functions
+
+// Exchange contents of lists - see DynamicList::swap().
+template<class T, int SizeMin1, int SizeMin2>
+inline void Swap(DynamicList<T, SizeMin1>& a, DynamicList<T, SizeMin2>& b);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
index e6ba973b48af96f1b5e83c46215745805f1dc588..81ec482e2121082d29e1356045b3001b02fae4cb 100644
--- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
+++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -23,100 +23,162 @@ License
 
 \*---------------------------------------------------------------------------*/
 
+#include "FixedList.H"
+
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
+
+template<class T, int SizeMin>
+template<class ListType>
+inline void Foam::DynamicList<T, SizeMin>::assignDynList
+(
+    const ListType& lst
+)
+{
+    const label newSize = lst.size();
+
+    if (capacity_ >= newSize)
+    {
+        // Can copy w/o reallocating - adjust addressable size accordingly.
+        List<T>::size(newSize);
+        List<T>::operator=(lst);
+    }
+    else
+    {
+        // Ensure list size consistency prior to copying.
+        List<T>::size(capacity_);
+
+        List<T>::operator=(lst);
+        capacity_ = List<T>::size();
+    }
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList()
 :
     capacity_(0)
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
-(
-    const label nElem
-)
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList(const label nElem)
 :
-    List<T>(nElem),
-    capacity_(nElem)
+    capacity_(0)
 {
-    // We could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
-    List<T>::size(0);
+    reserve(nElem);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
+(
+    const label nElem,
+    const T& val
+)
+:
+    List<T>(nElem, val),
+    capacity_(List<T>::size())
+{}
+
+
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
     const label nElem,
-    const T& a
+    const zero
 )
 :
-    List<T>(nElem, a),
-    capacity_(nElem)
+    List<T>(nElem, Zero),
+    capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
-    const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    const DynamicList<T, SizeMin>& lst
 )
 :
     List<T>(lst),
-    capacity_(lst.size())
+    capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+template<class T, int SizeMin>
+template<int AnySizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
+(
+    const DynamicList<T, AnySizeMin>& lst
+)
+:
+    List<T>(lst),
+    capacity_(List<T>::size())
+{}
+
+
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
     const UList<T>& lst
 )
 :
     List<T>(lst),
-    capacity_(lst.size())
+    capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
+template<unsigned FixedSize>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
+(
+    const FixedList<T, FixedSize>& lst
+)
+:
+    capacity_(0)
+{
+    this->operator=(lst);
+}
+
+
+template<class T, int SizeMin>
 template<class InputIterator>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
     InputIterator begIter,
     InputIterator endIter
 )
 :
     List<T>(begIter, endIter),
-    capacity_(this->size())
+    capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
     std::initializer_list<T> lst
 )
 :
     List<T>(lst),
-    capacity_(lst.size())
+    capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
     const UIndirectList<T>& lst
 )
 :
     List<T>(lst),
-    capacity_(lst.size())
+    capacity_(List<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
 (
     const Xfer<List<T>>& lst
 )
@@ -126,19 +188,61 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
 {}
 
 
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
+(
+    DynamicList<T, SizeMin>&& lst
+)
+:
+    capacity_(0)
+{
+    transfer(lst);
+}
+
+
+template<class T, int SizeMin>
+template<int AnySizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
+(
+    DynamicList<T, AnySizeMin>&& lst
+)
+:
+    capacity_(0)
+{
+    transfer(lst);
+}
+
+
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>::DynamicList
+(
+    List<T>&& lst
+)
+:
+    capacity_(0)
+{
+    transfer(lst);
+}
+
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::label Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::capacity()
-const
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::min_size() const
+{
+    return SizeMin;
+}
+
+
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const
 {
     return capacity_;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::setCapacity
 (
     const label nElem
 )
@@ -152,15 +256,15 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity
         nextFree = capacity_;
     }
 
-    // We could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
+    // We could also enforce sizing granularity
 
     List<T>::setSize(capacity_);
     List<T>::size(nextFree);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::reserve
 (
     const label nElem
 )
@@ -170,20 +274,25 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve
     {
         capacity_ = max
         (
-            nElem,
-            label(SizeInc + capacity_ * SizeMult / SizeDiv)
+            SizeMin,
+            max
+            (
+                nElem,
+                // label(SizeInc + capacity_ * SizeMult / SizeDiv)
+                label(2 * capacity_)
+            )
         );
 
         // Adjust allocated size, leave addressed size untouched
-        label nextFree = List<T>::size();
+        const label nextFree = List<T>::size();
         List<T>::setSize(capacity_);
         List<T>::size(nextFree);
     }
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::setSize
 (
     const label nElem
 )
@@ -193,8 +302,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
     {
         capacity_ = max
         (
-            nElem,
-            label(SizeInc + capacity_ * SizeMult / SizeDiv)
+            SizeMin,
+            max
+            (
+                nElem,
+                // label(SizeInc + capacity_ * SizeMult / SizeDiv)
+                label(2 * capacity_)
+            )
         );
 
         List<T>::setSize(capacity_);
@@ -205,11 +319,11 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::setSize
 (
     const label nElem,
-    const T& t
+    const T& val
 )
 {
     label nextFree = List<T>::size();
@@ -218,13 +332,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
     // Set new elements to constant value
     while (nextFree < nElem)
     {
-        this->operator[](nextFree++) = t;
+        this->operator[](nextFree++) = val;
     }
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::resize
 (
     const label nElem
 )
@@ -233,37 +347,49 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::resize
 (
     const label nElem,
-    const T& t
+    const T& val
 )
 {
-    this->setSize(nElem, t);
+    this->setSize(nElem, val);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear()
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::clear()
 {
     List<T>::size(0);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clearStorage()
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::clearStorage()
 {
     List<T>::clear();
     capacity_ = 0;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::expandStorage()
 {
-    label nextFree = List<T>::size();
+    const label nextFree = List<T>::size();
+
+    // Allow addressing into the entire list
+    List<T>::size(capacity_);
+
+    return nextFree;
+}
+
+
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::shrink()
+{
+    const label nextFree = List<T>::size();
     if (capacity_ > nextFree)
     {
         // Use the full list when resizing
@@ -278,9 +404,39 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
+template<int AnySizeMin>
+inline void Foam::DynamicList<T, SizeMin>::swap
+(
+    DynamicList<T, AnySizeMin>& lst
+)
+{
+    DynamicList<T, SizeMin>& cur = *this;
+
+    // Make addressable size identical to the allocated capacity
+    const label oldSize1 = cur.expandStorage();
+    const label oldSize2 = lst.expandStorage();
+
+    // Swap storage
+    Foam::Swap
+    (
+        static_cast<UList<T>&>(cur),
+        static_cast<UList<T>&>(lst)
+    );
+
+    // Match capacity to the underlying allocated list size
+    cur.setCapacity(cur.size());
+    lst.setCapacity(lst.size());
+
+    // Set addressable size
+    cur.setSize(oldSize2);
+    lst.setSize(oldSize1);
+}
+
+
+template<class T, int SizeMin>
 inline void
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst)
+Foam::DynamicList<T, SizeMin>::transfer(List<T>& lst)
 {
     // Take over storage, clear addressing for lst.
     capacity_ = lst.size();
@@ -288,46 +444,77 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst)
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
+template<int AnySizeMin>
 inline void
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
+Foam::DynamicList<T, SizeMin>::transfer
 (
-    DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    DynamicList<T, AnySizeMin>& lst
 )
 {
-    // Take over storage as-is (without shrink), clear addressing for lst.
-    capacity_ = lst.capacity_;
-    lst.capacity_ = 0;
+    // Take over storage as-is (without shrink, without using SizeMin)
+    // clear addressing and storage for old lst.
+    capacity_ = lst.capacity();
+
     List<T>::transfer(static_cast<List<T>&>(lst));
+    lst.clearStorage();  // Ensure capacity=0
+}
+
+
+template<class T, int SizeMin>
+inline void
+Foam::DynamicList<T, SizeMin>::transfer
+(
+    SortableList<T>& lst
+)
+{
+    lst.shrink();  // Shrink away sort indices
+    capacity_ = lst.size(); // Capacity after transfer == list size
+    List<T>::transfer(lst);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 inline Foam::Xfer<Foam::List<T>>
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer()
+Foam::DynamicList<T, SizeMin>::xfer()
 {
     return xferMoveTo<List<T>>(*this);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
+(
+    const T& val
+)
+{
+    const label idx = List<T>::size();
+    setSize(idx + 1);
+
+    this->operator[](idx) = val;  // copy element
+    return *this;
+}
+
+
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
-    const T& t
+    T&& val
 )
 {
-    const label elemI = List<T>::size();
-    setSize(elemI + 1);
+    const label idx = List<T>::size();
+    setSize(idx + 1);
 
-    this->operator[](elemI) = t;
+    this->operator[](idx) = std::move(val);  // move assign element
     return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
     const UList<T>& lst
 )
@@ -338,222 +525,395 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
             << "Attempted appending to self" << abort(FatalError);
     }
 
-    label nextFree = List<T>::size();
-    setSize(nextFree + lst.size());
+    label idx = List<T>::size();
+
+    setSize(idx + lst.size());
+
+    for (const T& val : lst)
+    {
+        this->operator[](idx++) = val;  // copy element
+    }
+    return *this;
+}
+
 
-    forAll(lst, elemI)
+template<class T, int SizeMin>
+template<unsigned FixedSize>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
+(
+    const FixedList<T, FixedSize>& lst
+)
+{
+    label idx = List<T>::size();
+    setSize(idx + lst.size());
+
+    for (const T& val : lst)
     {
-        this->operator[](nextFree++) = lst[elemI];
+        this->operator[](idx++) = val;  // copy element
     }
     return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
     std::initializer_list<T> lst
 )
 {
-    label nextFree = List<T>::size();
-    setSize(nextFree + lst.size());
+    label idx = List<T>::size();
+
+    setSize(idx + lst.size());
 
     for (const T& val : lst)
     {
-        this->operator[](nextFree++) = val;
+        this->operator[](idx++) = val;  // copy element
     }
     return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
     const UIndirectList<T>& lst
 )
 {
-    label nextFree = List<T>::size();
-    setSize(nextFree + lst.size());
+    label idx = List<T>::size();
+    const label n = lst.size();
 
-    forAll(lst, elemI)
+    setSize(idx + n);
+
+    for (label i=0; i<n; ++i)
     {
-        this->operator[](nextFree++) = lst[elemI];
+        this->operator[](idx++) = lst[i];  // copy element
     }
     return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
+(
+    List<T>&& lst
+)
 {
-    const label elemI = List<T>::size() - 1;
-
-    if (elemI < 0)
+    if (this == &lst)
     {
         FatalErrorInFunction
-            << "List is empty" << abort(FatalError);
+            << "Attempted appending to self" << abort(FatalError);
     }
 
-    const T& val = List<T>::operator[](elemI);
+    label idx = List<T>::size();
 
-    List<T>::size(elemI);
+    setSize(idx + lst.size());
 
-    return val;
-}
+    for (T& val : lst)
+    {
+        Foam::Swap(this->operator[](idx++), val);  // moved content
+    }
 
+    lst.clear();
+    return *this;
+}
 
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator()
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
-    const label elemI
+    DynamicList<T, SizeMin>&& lst
 )
 {
-    if (elemI >= List<T>::size())
-    {
-        setSize(elemI + 1);
-    }
-
-    return this->operator[](elemI);
+    append(std::move(static_cast<List<T>&>(lst)));
+    lst.clearStorage();  // Ensure capacity=0
+    return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+template<int AnySizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
-    const T& t
+    DynamicList<T, AnySizeMin>&& lst
 )
 {
-    UList<T>::operator=(t);
+    append(std::move(static_cast<List<T>&>(lst)));
+    lst.clearStorage();  // Ensure capacity=0
+    return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline Foam::DynamicList<T, SizeMin>&
+Foam::DynamicList<T, SizeMin>::append
 (
-    const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
+    SortableList<T>&& lst
 )
 {
-    if (this == &lst)
+    lst.shrink();  // Shrink away sort indices
+    append(std::move(static_cast<List<T>&>(lst)));
+    return *this;
+}
+
+
+template<class T, int SizeMin>
+inline T Foam::DynamicList<T, SizeMin>::remove()
+{
+    // Location of last element and simultaneously the new size
+    const label idx = List<T>::size() - 1;
+
+    if (idx < 0)
     {
         FatalErrorInFunction
-            << "Attempted assignment to self" << abort(FatalError);
+            << "List is empty" << abort(FatalError);
     }
 
-    if (capacity_ >= lst.size())
+    const T& val = List<T>::operator[](idx);
+
+    List<T>::size(idx);
+
+    return val;
+}
+
+
+template<class T, int SizeMin>
+inline T Foam::DynamicList<T, SizeMin>::remove
+(
+    const label idx,
+    const bool fast
+)
+{
+    if (fast)
     {
-        // Can copy w/o reallocating, match initial size to avoid reallocation
-        List<T>::size(lst.size());
-        List<T>::operator=(lst);
+        // Simply swap idx <=> last
+        this->swapLast(idx);
     }
     else
     {
-        // Make everything available for the copy operation
-        List<T>::size(capacity_);
-
-        List<T>::operator=(lst);
-        capacity_ = List<T>::size();
+        // Move element to the end and move everything down
+        this->moveLast(idx);
     }
+
+    // Element to remove is now at the end
+    return this->remove();
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::remove
 (
-    const UList<T>& lst
+    const labelRange& range
 )
 {
-    if (capacity_ >= lst.size())
+    return this->removeElements(this->validateRange(range));
+}
+
+
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::remove
+(
+    std::initializer_list<label> start_size
+)
+{
+    return this->removeElements(this->validateRange(start_size));
+}
+
+
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::subset
+(
+    const labelRange& range
+)
+{
+    return this->subsetElements(this->validateRange(range));
+}
+
+
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicList<T, SizeMin>::subset
+(
+    std::initializer_list<label> start_size
+)
+{
+    return this->subsetElements(this->validateRange(start_size));
+}
+
+
+// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
+
+template<class T, int SizeMin>
+inline T& Foam::DynamicList<T, SizeMin>::operator()
+(
+    const label i
+)
+{
+    if (i >= List<T>::size())
     {
-        // Can copy w/o reallocating, match initial size to avoid reallocation
-        List<T>::size(lst.size());
-        List<T>::operator=(lst);
+        setSize(i + 1);
     }
-    else
-    {
-        // Make everything available for the copy operation
-        List<T>::size(capacity_);
 
-        List<T>::operator=(lst);
-        capacity_ = List<T>::size();
-    }
+    return this->operator[](i);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
 (
-    std::initializer_list<T> lst
+    const T& val
+)
+{
+    UList<T>::operator=(val);
+}
+
+
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    const zero
 )
 {
-    if (capacity_ >= lst.size())
+    UList<T>::operator=(Zero);
+}
+
+
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    const UList<T>& lst
+)
+{
+    assignDynList(lst);
+}
+
+
+template<class T, int SizeMin>
+template<unsigned FixedSize>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    const FixedList<T, FixedSize>& lst
+)
+{
+    const label n = lst.size();
+
+    setSize(n);
+
+    for (label i=0; i<n; ++i)
     {
-        // Can copy w/o reallocating, match initial size to avoid reallocation
-        List<T>::size(lst.size());
-        List<T>::operator=(lst);
+        this->operator[](i) = lst[i];  // copy element
     }
-    else
-    {
-        // Make everything available for the copy operation
-        List<T>::size(capacity_);
+}
 
-        List<T>::operator=(lst);
-        capacity_ = List<T>::size();
+
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    const DynamicList<T, SizeMin>& lst
+)
+{
+    if (this == &lst)
+    {
+        FatalErrorInFunction
+            << "Attempted assignment to self" << abort(FatalError);
     }
+
+    assignDynList(lst);
+}
+
+
+template<class T, int SizeMin>
+template<int SizeMin2>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    const DynamicList<T, SizeMin2>& lst
+)
+{
+    assignDynList(lst);
+}
+
+
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    std::initializer_list<T> lst
+)
+{
+    assignDynList(lst);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
 (
     const UIndirectList<T>& lst
 )
 {
-    if (capacity_ >= lst.size())
+    assignDynList(lst);
+}
+
+
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    List<T>&& lst
+)
+{
+    clear();
+    transfer(lst);
+}
+
+
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    DynamicList<T, SizeMin>&& lst
+)
+{
+    if (this == &lst)
     {
-        // Can copy w/o reallocating, match initial size to avoid reallocation
-        List<T>::size(lst.size());
-        List<T>::operator=(lst);
+        FatalErrorInFunction
+            << "Attempted assignment to self" << abort(FatalError);
     }
-    else
-    {
-        // Make everything available for the copy operation
-        List<T>::size(capacity_);
 
-        List<T>::operator=(lst);
-        capacity_ = List<T>::size();
-    }
+    clear();
+    transfer(lst);
 }
 
 
-// * * * * * * * * * * * * * * STL Member Functions  * * * * * * * * * * * * //
-
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-typename Foam::UList<T>::iterator
-Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::erase
+template<class T, int SizeMin>
+template<int SizeMin2>
+inline void Foam::DynamicList<T, SizeMin>::operator=
 (
-    typename UList<T>::iterator curIter
+    DynamicList<T, SizeMin2>&& lst
 )
 {
-    typename Foam::UList<T>::iterator iter = curIter;
-    typename Foam::UList<T>::iterator nextIter = curIter;
+    clear();
+    transfer(lst);
+}
 
-    if (iter != this->end())
-    {
-        ++iter;
 
-        while (iter != this->end())
-        {
-            *nextIter++ = *iter++;
-        }
+template<class T, int SizeMin>
+inline void Foam::DynamicList<T, SizeMin>::operator=
+(
+    SortableList<T>&& lst
+)
+{
+    clear();
+    transfer(lst);
+}
 
-        this->setSize(this->size() - 1);
-    }
 
-    return curIter;
+// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
+
+template<class T, int SizeMin1, int SizeMin2>
+inline void Foam::Swap(DynamicList<T, SizeMin1>& a, DynamicList<T, SizeMin2>& b)
+{
+    a.swap(b);
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C
index 03c3d1676811d0ca915ef6672ad0322ef99e8dab..2a10efe4116ad07673afde138ab08ec778c8b188 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,19 +26,86 @@ License
 #include "FixedList.H"
 #include "ListLoopM.H"
 
-// * * * * * * * * * * * * * * STL Member Functions  * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class T, unsigned Size>
-void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& a)
+Foam::label Foam::FixedList<T, Size>::find
+(
+    const T& val,
+    const label start
+) const
 {
-    List_ACCESS(T, (*this), vp);
-    List_ACCESS(T, a, ap);
-    T tmp;
-    List_FOR_ALL((*this), i)
-        tmp = List_CELEM((*this), vp, i);
-        List_ELEM((*this), vp, i) = List_CELEM(a, ap, i);
-        List_ELEM(a, ap, i) = tmp;
-    List_END_FOR_ALL
+    if (start >= 0)
+    {
+        List_CONST_ACCESS(T, *this, lst);
+
+        for (label i = start; i < label(Size); ++i)
+        {
+            if (lst[i] == val)
+            {
+                return i;
+            }
+        }
+    }
+
+    return -1;
+}
+
+
+template<class T, unsigned Size>
+void Foam::FixedList<T, Size>::swap(FixedList<T, Size>& lst)
+{
+    Foam::Swap(v_, lst.v_);
+}
+
+
+template<class T, unsigned Size>
+void Foam::FixedList<T, Size>::moveFirst(const label i)
+{
+    checkIndex(i);
+
+    for (label lower = 0; lower < i; ++lower)
+    {
+        Foam::Swap(v_[lower], v_[i]);
+    }
+}
+
+
+template<class T, unsigned Size>
+void Foam::FixedList<T, Size>::moveLast(const label i)
+{
+    checkIndex(i);
+
+    for (label upper = label(Size - 1); upper > i; --upper)
+    {
+        Foam::Swap(v_[i], v_[upper]);
+    }
+}
+
+
+template<class T, unsigned Size>
+void Foam::FixedList<T, Size>::swapFirst(const label i)
+{
+    checkIndex(i);
+
+    if (i > 0)
+    {
+        Foam::Swap(v_[0], v_[i]);
+    }
+}
+
+
+template<class T, unsigned Size>
+void Foam::FixedList<T, Size>::swapLast(const label i)
+{
+    checkIndex(i);
+
+    const label upper = label(Size - 1);
+
+    if (i < upper)
+    {
+        Foam::Swap(v_[i], v_[upper]);
+    }
 }
 
 
@@ -52,10 +119,11 @@ bool Foam::FixedList<T, Size>::operator==(const FixedList<T, Size>& a) const
     List_CONST_ACCESS(T, (*this), vp);
     List_CONST_ACCESS(T, (a), ap);
 
-    List_FOR_ALL((*this), i)
-        equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i));
+    for (unsigned i = 0; i < Size; ++i)
+    {
+        equal = (vp[i] == ap[i]);
         if (!equal) break;
-    List_END_FOR_ALL
+    }
 
     return equal;
 }
@@ -71,8 +139,8 @@ bool Foam::FixedList<T, Size>::operator!=(const FixedList<T, Size>& a) const
 template<class T, unsigned Size>
 bool Foam::FixedList<T, Size>::operator<(const FixedList<T, Size>& a) const
 {
-    const T* const __restrict__ ptr1 = this->begin();
-    const T* const __restrict__ ptr2 = a.begin();
+    List_CONST_ACCESS(T, *this, ptr1);
+    List_CONST_ACCESS(T, a, ptr2);
 
     for (unsigned i=0; i<Size; ++i)
     {
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H
index dce2cad0c63a23bd6c797d67d630fc31702584e6..ecac3b57797fe0cce373f93d03007d3fcbd0dd49 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H
@@ -42,6 +42,8 @@ SourceFiles
 #include "uLabel.H"
 #include "Hash.H"
 #include "autoPtr.H"
+#include "Swap.H"
+
 #include <type_traits>
 #include <initializer_list>
 
@@ -125,11 +127,17 @@ public:
         inline FixedList();
 
         //- Construct from value
-        explicit inline FixedList(const T& t);
+        explicit inline FixedList(const T& val);
 
-        //- Construct from C-array
+        //- Copy construct from C-array
         explicit inline FixedList(const T lst[Size]);
 
+        //- Copy constructor
+        inline FixedList(const FixedList<T, Size>& lst);
+
+        //- Move constructor
+        inline FixedList(FixedList<T, Size>&& lst);
+
         //- Construct given begin/end iterators
         //  Uses std::distance when verifying the size.
         template<class InputIterator>
@@ -144,9 +152,6 @@ public:
         //- Construct from SLList
         explicit inline FixedList(const SLList<T>& lst);
 
-        //- Copy constructor
-        inline FixedList(const FixedList<T, Size>& lst);
-
         //- Construct from Istream
         FixedList(Istream& is);
 
@@ -158,22 +163,34 @@ public:
 
         // Access
 
-            //- Return the forward circular index, i.e. the next index
-            //  which returns to the first at the end of the list
+            //- Return the forward circular index, i.e. next index
+            //- which returns to the first at the end of the list
             inline label fcIndex(const label i) const;
 
-            //- Return the reverse circular index, i.e. the previous index
-            //  which returns to the last at the beginning of the list
+            //- Return forward circular value (ie, next value in the list)
+            inline const T& fcValue(const label i) const;
+
+            //- Return forward circular value (ie, next value in the list)
+            inline T& fcValue(const label i);
+
+            //- Return the reverse circular index, i.e. previous index
+            //- which returns to the last at the beginning of the list
             inline label rcIndex(const label i) const;
 
+            //- Return reverse circular value (ie, previous value in the list)
+            inline const T& rcValue(const label i) const;
+
+            //- Return reverse circular value (ie, previous value in the list)
+            inline T& rcValue(const label i);
 
-            //- Return a const pointer to the first data element,
-            //  similar to the STL front() method and the string::data() method
+
+            //- Return a const pointer to the first data element.
+            //  Similar to the STL front() method and the string::data() method
             //  This can be used (with caution) when interfacing with C code
             inline const T* cdata() const;
 
-            //- Return a pointer to the first data element,
-            //  similar to the STL front() method and the string::data() method
+            //- Return a pointer to the first data element.
+            //  Similar to the STL front() method and the string::data() method
             //  This can be used (with caution) when interfacing with C code
             inline T* data();
 
@@ -202,19 +219,42 @@ public:
             inline void checkIndex(const label i) const;
 
 
+      // Search
+
+        //- Find index of the first occurence of the value.
+        //  Linear search.
+        //  \return -1 if not found.
+        label find(const T& val, const label start=0) const;
+
+        //- True if the value if found in the list. Linear search.
+        inline bool found(const T& val, const label start=0) const;
+
+
         // Edit
 
-            //- Dummy resize function
-            //  needed to make FixedList consistent with List
-            inline void resize(const label s);
+        //- Dummy resize function
+        //  needed to make FixedList consistent with List
+        inline void resize(const label s);
+
+        //- Dummy setSize function
+        //  needed to make FixedList consistent with List
+        inline void setSize(const label s);
 
-            //- Dummy setSize function
-            //  needed to make FixedList consistent with List
-            inline void setSize(const label s);
+        //- Move element to the first position.
+        void moveFirst(const label i);
 
-            //- Copy (not transfer) the argument contents
-            //  needed to make FixedList consistent with List
-            void transfer(const FixedList<T, Size>& lst);
+        //- Move element to the last position.
+        void moveLast(const label i);
+
+        //- Swap element with the first element.
+        void swapFirst(const label i);
+
+        //- Swap element with the last element.
+        void swapLast(const label i);
+
+        //- Copy (not transfer) the argument contents
+        //  needed to make FixedList consistent with List
+        void transfer(const FixedList<T, Size>& lst);
 
 
     // Member operators
@@ -238,7 +278,13 @@ public:
         inline void operator=(std::initializer_list<T> lst);
 
         //- Assignment of all entries to the given value
-        inline void operator=(const T& t);
+        inline void operator=(const T& val);
+
+        //- Copy assignment
+        inline void operator=(const FixedList<T, Size>& lst);
+
+        //- Move assignment
+        inline void operator=(FixedList<T, Size>&& lst);
 
 
     // STL type definitions
@@ -246,16 +292,14 @@ public:
         //- Type of values the FixedList contains
         typedef T value_type;
 
-        //- Type that can be used for storing into
-        //  FixedList::value_type objects
+        //- The type used for storing into value_type objects
         typedef T& reference;
 
-        //- Type that can be used for storing into
-        //  constant FixedList::value_type objects
+        //- The type used for reading from constant value_type objects.
         typedef const T& const_reference;
 
         //- The type that can represent the difference between any two
-        //  FixedList iterator objects
+        //- FixedList iterator objects
         typedef label difference_type;
 
         //- The type that can represent the size of a FixedList
@@ -292,10 +336,86 @@ public:
         inline const_iterator end() const;
 
 
-    // STL reverse_iterator
+    // Reverse iterators
 
-        //- Reverse iterator for reverse traversal of FixedList
-        typedef T* reverse_iterator;
+        //- Generic const/non-const reverse iterator
+        template<bool Const>
+        class reverse_iterator_base
+        {
+        public:
+            //- The const/non-const type for entries
+            typedef typename std::conditional
+                <Const, const T, T>::type value_type;
+
+            //- A pointer to a const/non-const entry
+            typedef value_type* pointer;
+
+            //- A reference to a const/non-const entry
+            typedef value_type& reference;
+
+
+        private:
+
+            //- The element pointer
+            pointer ptr_;
+
+        public:
+
+            //- Construct null or from list element pointer
+            inline reverse_iterator_base(pointer ptr = nullptr)
+            :
+                ptr_(ptr)
+            {}
+
+            //- Copy construct
+            inline reverse_iterator_base(const reverse_iterator_base& iter)
+            :
+                ptr_(iter.ptr_)
+            {}
+
+
+            //- Reverse increment
+            inline void operator++()
+            {
+                --ptr_;
+            }
+
+            //- Reverse increment
+            inline reverse_iterator_base operator++(int)
+            {
+                reverse_iterator_base old(*this);
+                --ptr_;
+                return old;
+            }
+
+            //- Dereference iterator
+            reference operator*() const
+            {
+                return *ptr_;
+            }
+
+            //- Dereference iterator
+            pointer operator->() const
+            {
+                return ptr_;
+            }
+
+            //- Equality
+            bool operator==(const reverse_iterator_base& iter) const
+            {
+                return ptr_ == iter.ptr_;
+            }
+
+            //- inequality
+            bool operator!=(const reverse_iterator_base& iter) const
+            {
+                return ptr_ != iter.ptr_;
+            }
+        };
+
+
+        //- STL reverse_iterator
+        typedef reverse_iterator_base<false> reverse_iterator;
 
         //- Return reverse_iterator to begin reverse traversing the FixedList
         inline reverse_iterator rbegin();
@@ -304,10 +424,8 @@ public:
         inline reverse_iterator rend();
 
 
-    // STL const_reverse_iterator
-
-        //- Reverse iterator for reverse traversal of constant FixedList
-        typedef const T* const_reverse_iterator;
+        //- STL const reverse iterator
+        typedef reverse_iterator_base<true> const_reverse_iterator;
 
         //- Return const_reverse_iterator to begin reverse traversing FixedList
         inline const_reverse_iterator crbegin() const;
@@ -333,14 +451,14 @@ public:
         //- Always false since zero-sized FixedList is compile-time disabled.
         inline bool empty() const;
 
-        //- Swap two FixedLists of the same type in constant time
-        void swap(FixedList<T, Size>& a);
+        //- Swap content with another FixedList of the same type.
+        void swap(FixedList<T, Size>& lst);
 
 
     // STL member operators
 
         //- Equality operation on FixedLists of the same type.
-        //  Returns true when the FixedLists are elementwise equal
+        //  Returns true when the FixedLists are element-wise equal
         //  (using FixedList::value_type::operator==).  Takes linear time
         bool operator==(const FixedList<T, Size>& a) const;
 
@@ -366,7 +484,8 @@ public:
         void writeEntry(const word& keyword, Ostream& os) const;
 
         //- Write the List, with line-breaks in ASCII if the list length
-        //  exceeds shortListLen. Using '0' suppresses line-breaks entirely.
+        //- exceeds shortListLen.
+        //  Using '0' suppresses line-breaks entirely.
         Ostream& writeList(Ostream& os, const label shortListLen=0) const;
 
 
@@ -388,6 +507,13 @@ public:
 };
 
 
+// Global Functions
+
+// Exchange contents of lists - see FixedList::swap().
+template<class T, unsigned Size>
+inline void Swap(FixedList<T,Size>& a, FixedList<T,Size>& b);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H
index 1df4fb958a0ba6bf8d3c4c9b813e51072794e946..7e263d277280120a653b92f8fcc1d9bd30ef4376 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,6 +27,9 @@ License
 #include "SLList.H"
 #include "contiguous.H"
 
+#include <type_traits>
+#include <utility>
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class T, unsigned Size>
@@ -35,11 +38,11 @@ inline Foam::FixedList<T, Size>::FixedList()
 
 
 template<class T, unsigned Size>
-inline Foam::FixedList<T, Size>::FixedList(const T& t)
+inline Foam::FixedList<T, Size>::FixedList(const T& val)
 {
     for (unsigned i=0; i<Size; ++i)
     {
-        v_[i] = t;
+        v_[i] = val;
     }
 }
 
@@ -54,6 +57,29 @@ inline Foam::FixedList<T, Size>::FixedList(const T lst[Size])
 }
 
 
+template<class T, unsigned Size>
+inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& lst)
+{
+    for (unsigned i=0; i<Size; ++i)
+    {
+        v_[i] = lst[i];
+    }
+}
+
+
+template<class T, unsigned Size>
+inline Foam::FixedList<T, Size>::FixedList(FixedList<T, Size>&& lst)
+{
+    // No significant speedup observed for copy assignment on simple types,
+    // use move assignment for generality with more complex types
+
+    for (unsigned i=0; i<Size; ++i)
+    {
+        v_[i] = std::move(lst.v_[i]);
+    }
+}
+
+
 template<class T, unsigned Size>
 template<class InputIterator>
 Foam::FixedList<T, Size>::FixedList
@@ -113,16 +139,6 @@ inline Foam::FixedList<T, Size>::FixedList(const SLList<T>& lst)
 }
 
 
-template<class T, unsigned Size>
-inline Foam::FixedList<T, Size>::FixedList(const FixedList<T, Size>& lst)
-{
-    for (unsigned i=0; i<Size; ++i)
-    {
-        v_[i] = lst[i];
-    }
-}
-
-
 template<class T, unsigned Size>
 inline Foam::autoPtr<Foam::FixedList<T, Size>>
 Foam::FixedList<T, Size>::clone() const
@@ -147,6 +163,20 @@ inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
 }
 
 
+template<class T, unsigned Size>
+inline const T& Foam::FixedList<T, Size>::fcValue(const label i) const
+{
+    return this->operator[](this->fcIndex(i));
+}
+
+
+template<class T, unsigned Size>
+inline T& Foam::FixedList<T, Size>::fcValue(const label i)
+{
+    return this->operator[](this->fcIndex(i));
+}
+
+
 template<class T, unsigned Size>
 inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
 {
@@ -154,6 +184,20 @@ inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
 }
 
 
+template<class T, unsigned Size>
+inline const T& Foam::FixedList<T, Size>::rcValue(const label i) const
+{
+    return this->operator[](this->rcIndex(i));
+}
+
+
+template<class T, unsigned Size>
+inline T& Foam::FixedList<T, Size>::rcValue(const label i)
+{
+    return this->operator[](this->rcIndex(i));
+}
+
+
 template<class T, unsigned Size>
 inline void Foam::FixedList<T, Size>::checkStart(const label start) const
 {
@@ -190,6 +234,17 @@ inline void Foam::FixedList<T, Size>::checkIndex(const label i) const
 }
 
 
+template<class T, unsigned Size>
+inline bool Foam::FixedList<T, Size>::found
+(
+    const T& val,
+    const label start
+) const
+{
+    return (this->find(val, start) >= 0);
+}
+
+
 template<class T, unsigned Size>
 inline void Foam::FixedList<T, Size>::resize(const label s)
 {
@@ -206,6 +261,7 @@ inline void Foam::FixedList<T, Size>::setSize(const label s)
     #endif
 }
 
+
 template<class T, unsigned Size>
 inline void Foam::FixedList<T, Size>::transfer(const FixedList<T, Size>& lst)
 {
@@ -329,11 +385,31 @@ inline void Foam::FixedList<T, Size>::operator=(std::initializer_list<T> lst)
 }
 
 template<class T, unsigned Size>
-inline void Foam::FixedList<T, Size>::operator=(const T& t)
+inline void Foam::FixedList<T, Size>::operator=(const T& val)
+{
+    for (unsigned i=0; i<Size; ++i)
+    {
+        v_[i] = val;
+    }
+}
+
+template<class T, unsigned Size>
+inline void Foam::FixedList<T, Size>::operator=(const FixedList<T, Size>& lst)
 {
     for (unsigned i=0; i<Size; ++i)
     {
-        v_[i] = t;
+        v_[i] = lst.v_[i];
+    }
+}
+
+template<class T, unsigned Size>
+inline void Foam::FixedList<T, Size>::operator=(FixedList<T, Size>&& lst)
+{
+    // No significant speedup observed for copy assignment on simple types,
+    // use move assignment for generality with more complex types
+    for (unsigned i=0; i<Size; ++i)
+    {
+        v_[i] = std::move(lst.v_[i]);
     }
 }
 
@@ -389,50 +465,50 @@ Foam::FixedList<T, Size>::cend() const
 
 
 template<class T, unsigned Size>
-inline typename Foam::FixedList<T, Size>::iterator
+inline typename Foam::FixedList<T, Size>::reverse_iterator
 Foam::FixedList<T, Size>::rbegin()
 {
-    return &v_[Size-1];
+    return reverse_iterator(&v_[Size-1]);
 }
 
 
 template<class T, unsigned Size>
-inline typename Foam::FixedList<T, Size>::const_iterator
+inline typename Foam::FixedList<T, Size>::const_reverse_iterator
 Foam::FixedList<T, Size>::rbegin() const
 {
-    return &v_[Size-1];
+    return const_reverse_iterator(&v_[Size-1]);
 }
 
 
 template<class T, unsigned Size>
-inline typename Foam::FixedList<T, Size>::const_iterator
+inline typename Foam::FixedList<T, Size>::const_reverse_iterator
 Foam::FixedList<T, Size>::crbegin() const
 {
-    return &v_[Size-1];
+    return const_reverse_iterator(&v_[Size-1]);
 }
 
 
 template<class T, unsigned Size>
-inline typename Foam::FixedList<T, Size>::iterator
+inline typename Foam::FixedList<T, Size>::reverse_iterator
 Foam::FixedList<T, Size>::rend()
 {
-    return &v_[-1];
+    return reverse_iterator(&v_[-1]);
 }
 
 
 template<class T, unsigned Size>
-inline typename Foam::FixedList<T, Size>::const_iterator
+inline typename Foam::FixedList<T, Size>::const_reverse_iterator
 Foam::FixedList<T, Size>::rend() const
 {
-    return &v_[-1];
+    return const_reverse_iterator(&v_[-1]);
 }
 
 
 template<class T, unsigned Size>
-inline typename Foam::FixedList<T, Size>::const_iterator
+inline typename Foam::FixedList<T, Size>::const_reverse_iterator
 Foam::FixedList<T, Size>::crend() const
 {
-    return &v_[-1];
+    return const_reverse_iterator(&v_[-1]);
 }
 
 
@@ -485,4 +561,13 @@ inline unsigned Foam::FixedList<T, Size>::Hash<HashT>::operator()
 }
 
 
+// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
+
+template<class T, unsigned Size>
+void Foam::Swap(FixedList<T, Size>& a, FixedList<T, Size>& b)
+{
+    a.swap(b);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
index 6d1d65b20e21c2f2b7583fdcda1dfd2a54cf0579..87851fcef4a2ee0e9e0c110a8249c2de2a0043f0 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
@@ -91,10 +91,10 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
             // Write size (so it is valid dictionary entry) and start delimiter
             os << Size << token::BEGIN_BLOCK;
 
-            // Write contents
+            // Contents
             os << L[0];
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_BLOCK;
         }
         else if
@@ -103,31 +103,31 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
          || (Size <= unsigned(shortListLen) && contiguous<T>())
         )
         {
-            // Write start delimiter
+            // Start delimiter
             os << token::BEGIN_LIST;
 
-            // Write contents
+            // Contents
             forAll(L, i)
             {
                 if (i) os << token::SPACE;
                 os << L[i];
             }
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_LIST;
         }
         else
         {
-            // Write start delimiter
+            // Start delimiter
             os << nl << token::BEGIN_LIST << nl;
 
-            // Write contents
+            // Contents
             forAll(L, i)
             {
                 os << L[i] << nl;
             }
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_LIST << nl;
         }
     }
diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H
index a320682a60eacd62c713ad3da056f4458d8960aa..aa6c222ec262ba80be29e1aad69e7cda15c89f35 100644
--- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H
+++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectList.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -62,10 +62,10 @@ class IndirectListAddressing
     // Private Member Functions
 
         //- Disallow default bitwise copy construct
-        IndirectListAddressing(const IndirectListAddressing&);
+        IndirectListAddressing(const IndirectListAddressing&) = delete;
 
         //- Disallow default bitwise assignment
-        void operator=(const IndirectListAddressing&);
+        void operator=(const IndirectListAddressing&) = delete;
 
 
 protected:
@@ -81,16 +81,16 @@ protected:
 
     // Member Functions
 
-        // Access
+      // Access
 
-            //- Return the list addressing
-            inline const List<label>& addressing() const;
+        //- Return the list addressing
+        inline const List<label>& addressing() const;
 
-        // Edit
+      // Edit
 
-            //- Reset addressing
-            inline void resetAddressing(const labelUList&);
-            inline void resetAddressing(const Xfer<List<label>>&);
+        //- Reset addressing
+        inline void resetAddressing(const labelUList& addr);
+        inline void resetAddressing(const Xfer<List<label>>& addr);
 
 };
 
@@ -108,10 +108,10 @@ class IndirectList
     // Private Member Functions
 
         //- Disallow default assignment operator
-        void operator=(const IndirectList<T>&);
+        void operator=(const IndirectList<T>&) = delete;
 
         //- Disallow assignment from UIndirectList
-        void operator=(const UIndirectList<T>&);
+        void operator=(const UIndirectList<T>&) = delete;
 
 
 public:
@@ -119,37 +119,45 @@ public:
     // Constructors
 
         //- Construct given the complete list and the addressing array
-        inline IndirectList(const UList<T>&, const labelUList&);
+        inline IndirectList
+        (
+            const UList<T>& completeList,
+            const labelUList& addr
+        );
 
         //- Construct given the complete list and by transferring addressing
-        inline IndirectList(const UList<T>&, const Xfer<List<label>>&);
+        inline IndirectList
+        (
+            const UList<T>& completeList,
+            const Xfer<List<label>>& addr
+        );
 
         //- Copy constructor
-        inline IndirectList(const IndirectList<T>&);
+        inline IndirectList(const IndirectList<T>& lst);
 
         //- Construct from UIndirectList
-        explicit inline IndirectList(const UIndirectList<T>&);
+        explicit inline IndirectList(const UIndirectList<T>& lst);
 
 
     // Member Functions
 
+      // Access
 
-        // Access
+        //- Return the list addressing
+        using UIndirectList<T>::addressing;
 
-            //- Return the list addressing
-            using UIndirectList<T>::addressing;
 
+      // Edit
 
-        // Edit
+        //- Reset addressing
+        using IndirectListAddressing::resetAddressing;
 
-            //- Reset addressing
-            using IndirectListAddressing::resetAddressing;
 
+    // Member Operators
 
-        // Member Operators
+        //- Assignment operator
+        using UIndirectList<T>::operator=;
 
-            //- Assignment operator
-            using UIndirectList<T>::operator=;
 };
 
 
diff --git a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H
index 068b38ed9d21da56dbdff749bbd1baa1c9f3e037..1558c3a6611669b5c369c92d0c3d975ee17a9788 100644
--- a/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H
+++ b/src/OpenFOAM/containers/Lists/IndirectList/IndirectListI.H
@@ -25,7 +25,6 @@ License
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-
 inline Foam::IndirectListAddressing::IndirectListAddressing
 (
     const labelUList& addr
diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C
index ab8aea673f87fafe5b8bd987dbf4252a52fdc72c..556de7b6f35e3b64a35697bdfe6cb3489e46b7db 100644
--- a/src/OpenFOAM/containers/Lists/List/List.C
+++ b/src/OpenFOAM/containers/Lists/List/List.C
@@ -33,6 +33,8 @@ License
 #include "BiIndirectList.H"
 #include "contiguous.H"
 
+#include <utility>
+
 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
 
 template<class T>
@@ -52,7 +54,7 @@ Foam::List<T>::List(const label s)
 
 
 template<class T>
-Foam::List<T>::List(const label s, const T& a)
+Foam::List<T>::List(const label s, const T& val)
 :
     UList<T>(nullptr, s)
 {
@@ -69,8 +71,9 @@ Foam::List<T>::List(const label s, const T& a)
     {
         List_ACCESS(T, (*this), vp);
         List_FOR_ALL((*this), i)
-            List_ELEM((*this), vp, i) = a;
-        List_END_FOR_ALL
+        {
+            vp[i] = val;
+        }
     }
 }
 
@@ -93,8 +96,9 @@ Foam::List<T>::List(const label s, const zero)
     {
         List_ACCESS(T, (*this), vp);
         List_FOR_ALL((*this), i)
-            List_ELEM((*this), vp, i) = Zero;
-        List_END_FOR_ALL
+        {
+            vp[i] = Zero;
+        }
     }
 }
 
@@ -119,8 +123,9 @@ Foam::List<T>::List(const List<T>& a)
             List_ACCESS(T, (*this), vp);
             List_CONST_ACCESS(T, a, ap);
             List_FOR_ALL((*this), i)
-                List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
-            List_END_FOR_ALL
+            {
+                vp[i] = ap[i];
+            }
         }
     }
 }
@@ -139,19 +144,13 @@ Foam::List<T>::List(const List<T2>& a)
         List_ACCESS(T, (*this), vp);
         List_CONST_ACCESS(T2, a, ap);
         List_FOR_ALL((*this), i)
-            List_ELEM((*this), vp, i) = T(List_ELEM(a, ap, i));
-        List_END_FOR_ALL
+        {
+            vp[i] = T(ap[i]);
+        }
     }
 }
 
 
-template<class T>
-Foam::List<T>::List(const Xfer<List<T>>& lst)
-{
-    transfer(lst());
-}
-
-
 template<class T>
 Foam::List<T>::List(List<T>& a, bool reuse)
 :
@@ -159,6 +158,7 @@ Foam::List<T>::List(List<T>& a, bool reuse)
 {
     if (reuse)
     {
+        // swap content
         this->v_ = a.v_;
         a.v_ = nullptr;
         a.size_ = 0;
@@ -178,27 +178,29 @@ Foam::List<T>::List(List<T>& a, bool reuse)
             List_ACCESS(T, (*this), vp);
             List_CONST_ACCESS(T, a, ap);
             List_FOR_ALL((*this), i)
-                List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
-            List_END_FOR_ALL
+            {
+                vp[i] = ap[i];
+            }
         }
     }
 }
 
 
 template<class T>
-Foam::List<T>::List(const UList<T>& a, const labelUList& mapAddressing)
+Foam::List<T>::List(const UList<T>& lst, const labelUList& mapAddressing)
 :
     UList<T>(nullptr, mapAddressing.size())
 {
     if (this->size_)
     {
-        // Note: cannot use List_ELEM since third argument has to be index.
-
         alloc();
 
-        forAll(*this, i)
+        List_ACCESS(T, (*this), vp);
+
+        const label len = (*this).size();
+        for (label i=0; i < len; ++i)
         {
-            this->operator[](i) = a[mapAddressing[i]];
+            vp[i] = lst[mapAddressing[i]];
         }
     }
 }
@@ -263,6 +265,42 @@ Foam::List<T>::List(std::initializer_list<T> lst)
 {}
 
 
+template<class T>
+Foam::List<T>::List(const Xfer<List<T>>& lst)
+{
+    transfer(lst());
+}
+
+
+template<class T>
+Foam::List<T>::List(List<T>&& lst)
+:
+    UList<T>(nullptr, 0)
+{
+    // Can use transfer or swap to manage content
+    transfer(lst);
+}
+
+
+template<class T>
+template<int SizeMin>
+Foam::List<T>::List(DynamicList<T, SizeMin>&& lst)
+:
+    UList<T>(nullptr, 0)
+{
+    transfer(lst);
+}
+
+
+template<class T>
+Foam::List<T>::List(SortableList<T>&& lst)
+:
+    UList<T>(nullptr, 0)
+{
+    transfer(lst);
+}
+
+
 // * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * * //
 
 template<class T>
@@ -293,21 +331,24 @@ void Foam::List<T>::setSize(const label newSize)
         {
             T* nv = new T[label(newSize)];
 
-            if (this->size_)
-            {
-                label i = min(this->size_, newSize);
+            const label overlap = min(this->size_, newSize);
 
+            if (overlap)
+            {
                 #ifdef USEMEMCPY
                 if (contiguous<T>())
                 {
-                    memcpy(nv, this->v_, i*sizeof(T));
+                    memcpy(nv, this->v_, overlap*sizeof(T));
                 }
                 else
                 #endif
                 {
-                    T* vv = &this->v_[i];
-                    T* av = &nv[i];
-                    while (i--) *--av = *--vv;
+                    // No speedup observed for copy assignment on simple types
+                    List_ACCESS(T, *this, vp);
+                    for (label i = 0; i < overlap; ++i)
+                    {
+                        nv[i] = std::move(vp[i]);
+                    }
                 }
             }
 
@@ -324,49 +365,51 @@ void Foam::List<T>::setSize(const label newSize)
 
 
 template<class T>
-void Foam::List<T>::setSize(const label newSize, const T& a)
+void Foam::List<T>::setSize(const label newSize, const T& val)
 {
     const label oldSize = label(this->size_);
     this->setSize(newSize);
 
-    if (newSize > oldSize)
+    List_ACCESS(T, *this, vp);
+    for (label i = oldSize; i < newSize; ++i)
     {
-        label i = newSize - oldSize;
-        T* vv = &this->v_[newSize];
-        while (i--) *--vv = a;
+        vp[i] = val;
     }
 }
 
 
 template<class T>
-void Foam::List<T>::transfer(List<T>& a)
+void Foam::List<T>::transfer(List<T>& lst)
 {
+    // Clear and swap - could also check for self assignment
     clear();
-    this->size_ = a.size_;
-    this->v_ = a.v_;
+    this->size_ = lst.size_;
+    this->v_ = lst.v_;
 
-    a.size_ = 0;
-    a.v_ = nullptr;
+    lst.size_ = 0;
+    lst.v_ = nullptr;
 }
 
 
 template<class T>
-template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a)
+template<int SizeMin>
+void Foam::List<T>::transfer(DynamicList<T, SizeMin>& lst)
 {
     // Shrink the allocated space to the number of elements used
-    a.shrink();
-    transfer(static_cast<List<T>&>(a));
-    a.clearStorage();
+    lst.shrink();
+    transfer(static_cast<List<T>&>(lst));
+
+    // Ensure DynamicList has proper capacity=0 too
+    lst.clearStorage();
 }
 
 
 template<class T>
-void Foam::List<T>::transfer(SortableList<T>& a)
+void Foam::List<T>::transfer(SortableList<T>& lst)
 {
     // Shrink away the sort indices
-    a.shrink();
-    transfer(static_cast<List<T>&>(a));
+    lst.shrink();
+    transfer(static_cast<List<T>&>(lst));
 }
 
 
@@ -390,24 +433,25 @@ void Foam::List<T>::operator=(const UList<T>& a)
             List_ACCESS(T, (*this), vp);
             List_CONST_ACCESS(T, a, ap);
             List_FOR_ALL((*this), i)
-                List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
-            List_END_FOR_ALL
+            {
+                vp[i] = ap[i];
+            }
         }
     }
 }
 
 
 template<class T>
-void Foam::List<T>::operator=(const List<T>& a)
+void Foam::List<T>::operator=(const List<T>& lst)
 {
-    if (this == &a)
+    if (this == &lst)
     {
         FatalErrorInFunction
             << "attempted assignment to self"
             << abort(FatalError);
     }
 
-    operator=(static_cast<const UList<T>&>(a));
+    operator=(static_cast<const UList<T>&>(lst));
 }
 
 
@@ -448,12 +492,40 @@ void Foam::List<T>::operator=(std::initializer_list<T> lst)
 {
     reAlloc(lst.size());
 
-    auto iter = lst.begin();
-    forAll(*this, i)
+    label i = 0;
+    for (const auto& val : lst)
+    {
+        this->operator[](i++) = val;
+    }
+}
+
+
+template<class T>
+void Foam::List<T>::operator=(List<T>&& lst)
+{
+    if (this == &lst)
     {
-        this->operator[](i) = *iter;
-        ++iter;
+        FatalErrorInFunction
+            << "attempted assignment to self"
+            << abort(FatalError);
     }
+
+    transfer(lst);
+}
+
+
+template<class T>
+template<int SizeMin>
+void Foam::List<T>::operator=(DynamicList<T, SizeMin>&& lst)
+{
+    transfer(lst);
+}
+
+
+template<class T>
+void Foam::List<T>::operator=(SortableList<T>&& lst)
+{
+    transfer(lst);
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H
index c8e3219d9928ad7eaf106a1bbe3c437b1ccf827f..7fd057a02fa3c5ab26750ef51bdf0d58e9af5e55 100644
--- a/src/OpenFOAM/containers/Lists/List/List.H
+++ b/src/OpenFOAM/containers/Lists/List/List.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -68,14 +68,15 @@ template<class LListBase, class T> class LList;
 template<class T>
 using SLList = LList<SLListBase, T>;
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-class DynamicList;
+template<class T, int SizeMin> class DynamicList;
 
 template<class T> class SortableList;
 template<class T> class IndirectList;
 template<class T> class UIndirectList;
 template<class T> class BiIndirectList;
 
+typedef List<char> charList;
+
 /*---------------------------------------------------------------------------*\
                            Class List Declaration
 \*---------------------------------------------------------------------------*/
@@ -112,13 +113,6 @@ class List
         );
 
 
-protected:
-
-    //- Override size to be inconsistent with allocated storage.
-    //  Use with care
-    inline void size(const label n);
-
-
 public:
 
     // Static Member Functions
@@ -136,26 +130,25 @@ public:
         explicit List(const label s);
 
         //- Construct with given size and value for all elements
-        List(const label s, const T& a);
+        List(const label s, const T& val);
 
         //- Construct with given size initializing all elements to zero
         List(const label s, const zero);
 
-        //- Copy constructor
+        //- Copy constructor from list
         List(const List<T>& a);
 
-        //- Copy constructor from list containing another type
+        //- Copy constructor from list containing another type.
+        //  This is primarily useful to convert a list of ints into floats,
+        //  for example.
         template<class T2>
         explicit List(const List<T2>& a);
 
-        //- Construct by transferring the parameter contents
-        List(const Xfer<List<T>>& lst);
-
         //- Construct as copy or re-use as specified
         List(List<T>& a, bool reuse);
 
         //- Construct as subset
-        List(const UList<T>& a, const labelUList& mapAddressing);
+        List(const UList<T>& lst, const labelUList& mapAddressing);
 
         //- Construct given begin/end iterators.
         //  Uses std::distance to determine the size.
@@ -181,6 +174,19 @@ public:
         //- Construct from an initializer list
         List(std::initializer_list<T> lst);
 
+        //- Transfer (move) construct
+        List(const Xfer<List<T>>& lst);
+
+        //- Move construct from List
+        List(List<T>&& lst);
+
+        //- Move construct from DynamicList
+        template<int SizeMin>
+        List(DynamicList<T, SizeMin>&& lst);
+
+        //- Move construct from SortableList
+        List(SortableList<T>&& lst);
+
         //- Construct from Istream
         List(Istream& is);
 
@@ -200,54 +206,53 @@ public:
 
     // Member Functions
 
-        //- Return the number of elements in the UList
-        inline label size() const;
-
-
         // Edit
 
             //- Alias for setSize(const label)
             inline void resize(const label newSize);
 
             //- Alias for setSize(const label, const T&)
-            inline void resize(const label newSize, const T& a);
+            inline void resize(const label newSize, const T& val);
 
             //- Reset size of List
             void setSize(const label newSize);
 
             //- Reset size of List and value for new elements
-            void setSize(const label newSize, const T& a);
+            void setSize(const label newSize, const T& val);
 
             //- Clear the list, i.e. set size to zero
             inline void clear();
 
             //- Append an element at the end of the list
-            inline void append(const T& t);
+            inline void append(const T& val);
 
-            //- Append a List at the end of this list
+            //- Move append an element at the end of the list
+            inline void append(T&& val);
+
+            //- Append a List to the end of this list
             inline void append(const UList<T>& lst);
 
             //- Append a UIndirectList at the end of this list
             inline void append(const UIndirectList<T>& lst);
 
             //- Transfer the contents of the argument List into this list
-            //  and annul the argument list
-            void transfer(List<T>& a);
+            //- and annul the argument list
+            void transfer(List<T>& lst);
 
             //- Transfer the contents of the argument List into this list
-            //  and annul the argument list
-            template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-            void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a);
+            //- and annul the argument list
+            template<int SizeMin>
+            void transfer(DynamicList<T, SizeMin>& lst);
 
             //- Transfer the contents of the argument List into this list
-            //  and annul the argument list
-            void transfer(SortableList<T>& a);
+            //- and annul the argument list
+            void transfer(SortableList<T>& lst);
 
             //- Transfer contents to the Xfer container
             inline Xfer<List<T>> xfer();
 
-            //- Return subscript-checked element of UList.
-            //  Resize list if required.
+            //- Return subscript-checked element of UList and resizing the list
+            //- if required.
             inline T& newElmt(const label i);
 
 
@@ -261,7 +266,7 @@ public:
         void operator=(const UList<T>& a);
 
         //- Assignment operator. Takes linear time
-        void operator=(const List<T>& a);
+        void operator=(const List<T>& lst);
 
         //- Assignment to SLList operator. Takes linear time
         void operator=(const SLList<T>& lst);
@@ -276,17 +281,30 @@ public:
         void operator=(std::initializer_list<T> lst);
 
         //- Assignment of all entries to the given value
-        inline void operator=(const T& t);
+        inline void operator=(const T& val);
 
         //- Assignment of all entries to zero
         inline void operator=(const zero);
 
+        //- Move assignment. Takes constant time
+        void operator=(List<T>&& lst);
+
+        //- Move assignment. Takes constant time.
+        template<int SizeMin>
+        void operator=(DynamicList<T, SizeMin>&& lst);
+
+        //- Move assignment. Takes constant time.
+        void operator=(SortableList<T>&& lst);
+
 
     // Istream operator
 
         //- Read List from Istream, discarding contents of existing List
         friend Istream& operator>> <T>
-        (Istream& is, List<T>& L);
+        (
+            Istream& is,
+            List<T>& L
+        );
 };
 
 
diff --git a/src/OpenFOAM/containers/Lists/List/ListI.H b/src/OpenFOAM/containers/Lists/List/ListI.H
index 8aa5bc016aaad44c4cb7f46a2085aab832a2b5b0..b815a32d8714e79421b3fc5430c7f173d82fe778 100644
--- a/src/OpenFOAM/containers/Lists/List/ListI.H
+++ b/src/OpenFOAM/containers/Lists/List/ListI.H
@@ -89,7 +89,7 @@ inline Foam::List<T>::List
         alloc();
 
         InputIterator iter = begIter;
-        forAll(*this, i)
+        for (label i = 0; i < s; ++i)
         {
             this->operator[](i) = *iter;
             ++iter;
@@ -142,18 +142,20 @@ inline void Foam::List<T>::resize(const label newSize)
 
 
 template<class T>
-inline void Foam::List<T>::resize(const label newSize, const T& a)
+inline void Foam::List<T>::resize(const label newSize, const T& val)
 {
-    this->setSize(newSize, a);
+    this->setSize(newSize, val);
 }
 
 
 template<class T>
 inline T& Foam::List<T>::newElmt(const label i)
 {
-    if (i >= this->size())
+    const label n = this->size();
+
+    if (i >= n)
     {
-        setSize(2*this->size());
+        setSize(2*n);
     }
 
     return UList<T>::operator[](i);
@@ -161,30 +163,26 @@ inline T& Foam::List<T>::newElmt(const label i)
 
 
 template<class T>
-inline void Foam::List<T>::size(const label n)
+inline Foam::Xfer<Foam::List<T>> Foam::List<T>::xfer()
 {
-    UList<T>::size_ = n;
+    return xferMove(*this);
 }
 
 
 template<class T>
-inline Foam::label Foam::List<T>::size() const
+inline void Foam::List<T>::append(const T& val)
 {
-    return UList<T>::size_;
+    setSize(this->size() + 1, val);  // copy element
 }
 
 
 template<class T>
-inline Foam::Xfer<Foam::List<T>> Foam::List<T>::xfer()
+inline void Foam::List<T>::append(T&& val)
 {
-    return xferMove(*this);
-}
-
+    const label idx = this->size();
+    setSize(idx + 1);
 
-template<class T>
-inline void Foam::List<T>::append(const T& t)
-{
-    setSize(size()+1, t);
+    this->operator[](idx) = std::move(val);  // move assign element
 }
 
 
@@ -197,12 +195,14 @@ inline void Foam::List<T>::append(const UList<T>& lst)
             << "attempted appending to self" << abort(FatalError);
     }
 
-    label nextFree = this->size();
-    setSize(nextFree + lst.size());
+    label idx = this->size();
+    const label n = lst.size();
+
+    setSize(idx + n);
 
-    forAll(lst, elemI)
+    for (label i=0; i<n; ++i)
     {
-        this->operator[](nextFree++) = lst[elemI];
+        this->operator[](idx++) = lst[i];  // copy element
     }
 }
 
@@ -210,12 +210,14 @@ inline void Foam::List<T>::append(const UList<T>& lst)
 template<class T>
 inline void Foam::List<T>::append(const UIndirectList<T>& lst)
 {
-    label nextFree = this->size();
-    setSize(nextFree + lst.size());
+    label idx = this->size();
+    const label n = lst.size();
+
+    setSize(idx + n);
 
-    forAll(lst, elemI)
+    for (label i=0; i<n; ++i)
     {
-        this->operator[](nextFree++) = lst[elemI];
+        this->operator[](idx++) = lst[i];  // copy element
     }
 }
 
@@ -223,9 +225,9 @@ inline void Foam::List<T>::append(const UIndirectList<T>& lst)
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 template<class T>
-inline void Foam::List<T>::operator=(const T& t)
+inline void Foam::List<T>::operator=(const T& val)
 {
-    UList<T>::operator=(t);
+    UList<T>::operator=(val);
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C
index b21b6a86648404ed633256ba9d503cf0ec84781f..aa8cd447f15be0ce9f17f962866fccfe1a9230aa 100644
--- a/src/OpenFOAM/containers/Lists/List/ListIO.C
+++ b/src/OpenFOAM/containers/Lists/List/ListIO.C
@@ -64,10 +64,10 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
     }
     else if (firstToken.isLabel())
     {
-        const label s = firstToken.labelToken();
+        const label sz = firstToken.labelToken();
 
         // Set list length to that read
-        L.setSize(s);
+        L.setSize(sz);
 
         // Read list contents depending on data format
 
@@ -76,11 +76,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
             // Read beginning of contents
             const char delimiter = is.readBeginList("List");
 
-            if (s)
+            if (sz)
             {
                 if (delimiter == token::BEGIN_LIST)
                 {
-                    for (label i=0; i<s; ++i)
+                    for (label i=0; i<sz; ++i)
                     {
                         is >> L[i];
 
@@ -92,7 +92,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
                 }
                 else
                 {
-                    // uniform content (delimiter == token::BEGIN_BLOCK)
+                    // Uniform content (delimiter == token::BEGIN_BLOCK)
 
                     T element;
                     is >> element;
@@ -103,7 +103,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
                         "reading the single entry"
                     );
 
-                    for (label i=0; i<s; ++i)
+                    for (label i=0; i<sz; ++i)
                     {
                         L[i] = element;
                     }
@@ -115,11 +115,11 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
         }
         else
         {
-            // contents are binary and contiguous
+            // Contents are binary and contiguous
 
-            if (s)
+            if (sz)
             {
-                is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T));
+                is.read(reinterpret_cast<char*>(L.data()), sz*sizeof(T));
 
                 is.fatalCheck
                 (
@@ -141,7 +141,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
         // Putback the opening bracket
         is.putBack(firstToken);
 
-        // Now read as a singly-linked list
+        // Read as a singly-linked list
         SLList<T> sll(is);
 
         // Convert the singly-linked list to this list
@@ -176,8 +176,11 @@ Foam::List<T> Foam::readList(Istream& is)
                 << exit(FatalIOError);
         }
 
-        // Read via a singly-linked list
-        L = SLList<T>(is);
+        // Read as singly-linked list
+        SLList<T> sll(is);
+
+        // Convert the singly-linked list to this list
+        L = sll;
     }
     else
     {
diff --git a/src/OpenFOAM/containers/Lists/List/ListLoopM.H b/src/OpenFOAM/containers/Lists/List/ListLoopM.H
index 032edb3052e8024c0f28c4fcafb8c1f561d4c3b4..3a9b341837c645f6a8e94a64576d1bbd8d06abab 100644
--- a/src/OpenFOAM/containers/Lists/List/ListLoopM.H
+++ b/src/OpenFOAM/containers/Lists/List/ListLoopM.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,59 +26,26 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef ListLoop_H
-#define ListLoop_H
+#ifndef ListLoopM_H
+#define ListLoopM_H
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Element access looping
 
-#ifdef vectorMachine
-
-// Element access looping using [] for vector machines
-
-#define List_FOR_ALL(f, i)                      \
-        const label _n##i = (f).size();         \
-        for (label i=0; i<_n##i; ++i)           \
-        {
-
-#define List_END_FOR_ALL  }
-
-// Provide current element
-#define List_CELEM(f, fp, i)  (fp[i])
-
-// Provide current element
-#define List_ELEM(f, fp, i)  (fp[i])
-
-#define List_ACCESS(type, f, fp) \
+// Initial non-const access to list
+#define List_ACCESS(type, f, fp)                \
     type* const __restrict__ fp = (f).begin()
 
-#define List_CONST_ACCESS(type, f, fp) \
+// Initial const access to list
+#define List_CONST_ACCESS(type, f, fp)          \
     const type* const __restrict__ fp = (f).begin()
 
-#else
-
-// Pointer looping for scalar machines
-
 #define List_FOR_ALL(f, i)                      \
-        label i = (f).size();                   \
-        while (i--)                             \
-        {                                       \
-
-#define List_END_FOR_ALL  }
-
-// Provide current element without incrementing pointer
-#define List_CELEM(f, fp, i)  (*fp)
-
-// Provide current element and increment pointer
-#define List_ELEM(f, fp, i)  (*fp++)
-
-#define List_ACCESS(type, f, fp) \
-    type* __restrict__ fp = (f).begin()
-
-#define List_CONST_ACCESS(type, f, fp) \
-    const type* __restrict__ fp = (f).begin()
-
-#endif
+        const label _n##i = (f).size();         \
+        for (label i=0; i<_n##i; ++i)
 
+// Current element (non-const access)
+#define List_ELEM(fp, i)  (fp[i])
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H
index d7c93bef0235e0cb1198e65bdb689f908617e015..98267e1c4152401ffb04fae19c28f4f1141304e2 100644
--- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H
+++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H
@@ -110,24 +110,44 @@ void inplaceMapKey(const labelUList& oldToNew, Container& lst);
 template<class T>
 void sortedOrder(const UList<T>& lst, labelList& order);
 
-template<class T, class Cmp>
-void sortedOrder(const UList<T>& lst, labelList& order, const Cmp& cmp);
+//- Sort using specified list compare predicate
+template<class T, class ListComparePredicate>
+void sortedOrder
+(
+    const UList<T>& lst,
+    labelList& order,
+    const ListComparePredicate& comp
+);
 
 
 //- Generate (sorted) indices corresponding to duplicate list values
 template<class T>
 void duplicateOrder(const UList<T>& lst, labelList& order);
 
-template<class T, class Cmp>
-void duplicateOrder(const UList<T>& lst, labelList& order, const Cmp& cmp);
+//- Generate (sorted) indices corresponding to duplicate list values
+//  sort using specified list compare predicate
+template<class T, class ListComparePredicate>
+void duplicateOrder
+(
+    const UList<T>& lst,
+    labelList& order,
+    const ListComparePredicate& comp
+);
 
 
 //- Generate (sorted) indices corresponding to unique list values
 template<class T>
 void uniqueOrder(const UList<T>& lst, labelList& order);
 
-template<class T, class Cmp>
-void uniqueOrder(const UList<T>& lst, labelList& order, const Cmp& cmp);
+//- Generate (sorted) indices corresponding to unique list values
+//  sort using specified list compare predicate
+template<class T, class ListComparePredicate>
+void uniqueOrder
+(
+    const UList<T>& lst,
+    labelList& order,
+    const ListComparePredicate& comp
+);
 
 
 //- Inplace sorting and removal of duplicates.
@@ -137,8 +157,12 @@ void inplaceUniqueSort(ListType& lst);
 
 //- Inplace sorting and removal of duplicates.
 //  Do not use FixedList for the input list, since it doesn't resize.
-template<class ListType, class Cmp>
-void inplaceUniqueSort(ListType& lst, const Cmp& cmp);
+template<class ListType, class ListComparePredicate>
+void inplaceUniqueSort
+(
+    ListType& lst,
+    const ListComparePredicate& comp
+);
 
 
 //- Extract elements of List when select is a certain value.
@@ -222,6 +246,7 @@ labelList identity(const label len);
 
 //- Find first occurence of given element and return index,
 //  return -1 if not found. Linear search.
+//  \deprecated prefer UList find/found methods (deprecated Oct 2017)
 template<class ListType>
 label findIndex
 (
diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
index bf5af3080db498a0029df0febd19c72ce8d3f7b1..45f28b9ef9bbc68b0c234ec94372d1864c29f3ee 100644
--- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
+++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
@@ -211,27 +211,30 @@ void Foam::sortedOrder
 }
 
 
-template<class T, class Cmp>
+template<class T, class ListComparePredicate>
 void Foam::sortedOrder
 (
     const UList<T>& lst,
     labelList& order,
-    const Cmp& cmp
+    const ListComparePredicate& comp
 )
 {
+    const label len = lst.size();
+
     // list lengths must be identical
-    if (order.size() != lst.size())
+    if (order.size() != len)
     {
-        // avoid copying any elements, they are overwritten anyhow
+        // Avoid copying any elements, they are overwritten anyhow
         order.clear();
-        order.setSize(lst.size());
+        order.setSize(len);
     }
 
-    forAll(order, elemI)
+    for (label i=0; i<len; ++i)
     {
-        order[elemI] = elemI;
+        order[i] = i; // identity
     }
-    Foam::stableSort(order, cmp);
+
+    Foam::stableSort(order, comp);
 }
 
 
@@ -246,12 +249,12 @@ void Foam::duplicateOrder
 }
 
 
-template<class T, class Cmp>
+template<class T, class ListComparePredicate>
 void Foam::duplicateOrder
 (
     const UList<T>& lst,
     labelList& order,
-    const Cmp& cmp
+    const ListComparePredicate& comp
 )
 {
     if (lst.size() < 2)
@@ -260,7 +263,7 @@ void Foam::duplicateOrder
         return;
     }
 
-    sortedOrder(lst, order, cmp);
+    sortedOrder(lst, order, comp);
 
     const label last = (order.size()-1);
     label n = 0;
@@ -286,15 +289,15 @@ void Foam::uniqueOrder
 }
 
 
-template<class T, class Cmp>
+template<class T, class ListComparePredicate>
 void Foam::uniqueOrder
 (
     const UList<T>& lst,
     labelList& order,
-    const Cmp& cmp
+    const ListComparePredicate& comp
 )
 {
-    sortedOrder(lst, order, cmp);
+    sortedOrder(lst, order, comp);
 
     if (order.size() > 1)
     {
@@ -324,18 +327,24 @@ void Foam::inplaceUniqueSort(ListType& lst)
 }
 
 
-template<class ListType, class Cmp>
-void Foam::inplaceUniqueSort(ListType& lst, const Cmp& cmp)
+template<class ListType, class ListComparePredicate>
+void Foam::inplaceUniqueSort
+(
+    ListType& lst,
+    const ListComparePredicate& comp
+)
 {
     labelList order;
-    uniqueOrder(lst, order, cmp);
+    uniqueOrder(lst, order, comp);
+
+    const label len = order.size();
 
-    ListType newLst(order.size());
-    newLst.setSize(order.size()); // Consistent sizing (eg, DynamicList)
+    ListType newLst(len);
+    newLst.setSize(len);  // Consistent sizing (eg, DynamicList)
 
-    forAll(order, elemI)
+    for (label i=0; i<len; ++i)
     {
-        newLst[elemI] = lst[order[elemI]];
+        newLst[i] = lst[order[i]];
     }
 
     lst.transfer(newLst);
@@ -849,7 +858,7 @@ void Foam::ListUniqueEqOp<T>::operator()(List<T>& x, const List<T>& y) const
         {
             forAll(y, i)
             {
-                if (findIndex(x, y[i]) == -1)
+                if (!x.found(y[i]))
                 {
                     x.append(y[i]);
                 }
@@ -890,7 +899,7 @@ void Foam::inplaceReverseList(ListType& list)
     label elemI = 0;
     while (elemI < nIterations)
     {
-        Swap(list[elemI], list[lastIndex - elemI]);
+        Foam::Swap(list[elemI], list[lastIndex - elemI]);
 
         elemI++;
     }
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
index 4b01a43dd61ecff39fb00d54168ea8af5f37589b..543c5b855843521d521ef93079106683bc03ebb0 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
@@ -92,13 +92,15 @@ bool Foam::PackedBoolList::bitorPrepare
 template<class LabelListType>
 Foam::label Foam::PackedBoolList::setIndices(const LabelListType& indices)
 {
-    // no better information, just guess something about the size
-    reserve(indices.size());
+    const label len = indices.size();
+
+    // No better information, just guess something from the size
+    reserve(len);
 
     label cnt = 0;
-    forAll(indices, elemI)
+    for (label i = 0; i < len; ++i)
     {
-        if (set(indices[elemI]))
+        if (set(indices[i]))
         {
             ++cnt;
         }
@@ -112,9 +114,10 @@ template<class LabelListType>
 Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices)
 {
     label cnt = 0;
-    forAll(indices, elemI)
+    const label len = indices.size();
+    for (label i = 0; i < len; ++i)
     {
-        if (unset(indices[elemI]))
+        if (unset(indices[i]))
         {
             ++cnt;
         }
@@ -127,29 +130,30 @@ Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices)
 template<class LabelListType>
 Foam::label Foam::PackedBoolList::subsetIndices(const LabelListType& indices)
 {
-    // handle trivial case
-    if (empty() || indices.empty())
+    const label len = indices.size();
+
+    // Handle trivial case
+    if (empty() || !len)
     {
         clear();
         return 0;
     }
 
-    // normal case
-    PackedBoolList anded;
-    anded.reserve(size());
+    PackedBoolList result;
+    result.reserve(size());
 
     label cnt = 0;
-    forAll(indices, elemI)
+    for (label i = 0; i < len; ++i)
     {
-        const label& index = indices[elemI];
-        if (operator[](index))
+        const label index = indices[i];
+        if (get(index))
         {
-            anded.set(index);
+            result.set(index);
             ++cnt;
         }
     }
 
-    transfer(anded);
+    transfer(result);
     return cnt;
 }
 
@@ -176,7 +180,7 @@ void Foam::PackedBoolList::set(const PackedList<1>& lst)
     StorageList& lhs = this->storage();
     const StorageList& rhs = lst.storage();
 
-    for (label i=0; i < len; ++i)
+    for (label i = 0; i < len; ++i)
     {
         lhs[i] |= rhs[i];
     }
@@ -209,7 +213,7 @@ void Foam::PackedBoolList::unset(const PackedList<1>& lst)
     // overlapping storage size
     const label len = min(this->packedLength(), lst.packedLength());
 
-    for (label i=0; i < len; ++i)
+    for (label i = 0; i < len; ++i)
     {
         lhs[i] &= ~rhs[i];
     }
@@ -242,7 +246,7 @@ void Foam::PackedBoolList::subset(const PackedList<1>& lst)
 
     const label len = this->packedLength();
 
-    for (label i=0; i < len; ++i)
+    for (label i = 0; i < len; ++i)
     {
         lhs[i] &= rhs[i];
     }
@@ -288,12 +292,13 @@ Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const
 
 void Foam::PackedBoolList::operator=(const UList<bool>& lst)
 {
-    this->setSize(lst.size());
+    const label len = lst.size();
+    this->setSize(len);
 
-    // overwrite with new true/false values
-    forAll(*this, elemI)
+    // Overwrite with new true/false values
+    for (label i = 0; i < len; ++i)
     {
-        set(elemI, lst[elemI]);
+        set(i, lst[i]);
     }
 }
 
@@ -301,15 +306,15 @@ void Foam::PackedBoolList::operator=(const UList<bool>& lst)
 Foam::PackedBoolList&
 Foam::PackedBoolList::operator^=(const PackedList<1>& lst)
 {
-    // extend addressable area if needed, return maximum size possible
+    // Extend addressable area if needed, return maximum size possible
     label len = 0;
     const bool needTrim = bitorPrepare(lst, len);
 
-    // operate directly with the underlying storage
+    // Operate directly with the underlying storage
     StorageList& lhs = this->storage();
     const StorageList& rhs = lst.storage();
 
-    for (label i=0; i < len; ++i)
+    for (label i = 0; i < len; ++i)
     {
         lhs[i] ^= rhs[i];
     }
@@ -334,7 +339,7 @@ Foam::PackedBoolList Foam::operator&
     PackedBoolList result(lst1);
     result &= lst2;
 
-    // trim to bits actually used
+    // Trim to bits actually used
     result.trim();
 
     return result;
@@ -350,7 +355,7 @@ Foam::PackedBoolList Foam::operator^
     PackedBoolList result(lst1);
     result ^= lst2;
 
-    // trim to bits actually used
+    // Trim to bits actually used
     result.trim();
 
     return result;
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
index f98545a9bd64e3270c8d894564c5eed5f304dce1..a667e8aecf17f4d3ea49b4f3c67b242a84c22ce7 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -96,7 +96,7 @@ public:
         //- Construct from Istream
         PackedBoolList(Istream& is);
 
-        //- Construct with given size, initializes list to 0
+        //- Construct with given size, initializes list to 0 (false)
         explicit inline PackedBoolList(const label size);
 
         //- Construct with given size and value for all elements
@@ -114,6 +114,20 @@ public:
         //- Construct by transferring the parameter contents
         inline PackedBoolList(const Xfer<PackedList<1>>& lst);
 
+        //- Construct with given size and list of labels to set as true.
+        inline PackedBoolList
+        (
+            const label size,
+            const labelUList& indices
+        );
+
+        //- Construct with given size and list of labels to set as true.
+        inline PackedBoolList
+        (
+            const label size,
+            const UIndirectList<label>& indices
+        );
+
         //- Construct from a list of bools
         explicit inline PackedBoolList(const UList<bool>& lst);
 
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
index a0702f9a30e92aced06170a0feb317eb92408b2c..4c713dc005d4358aa4210ab47e3d9edf7883f869 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -75,23 +75,52 @@ inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedList<1>>& lst)
 
 inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
 :
-    PackedList<1>()
+    PackedList<1>(lst.size())
 {
-    operator=(lst);
+    // Set according to indices that are true
+    const label len = lst.size();
+
+    for (label i = 0; i < len; ++i)
+    {
+        if (lst[i])
+        {
+            this->set(i, 1u);
+        }
+    }
 }
 
 
 inline Foam::PackedBoolList::PackedBoolList(const labelUList& indices)
 :
-    PackedList<1>(indices.size(), 0u)
+    PackedBoolList(indices.size(), indices)
+{}
+
+
+inline Foam::PackedBoolList::PackedBoolList(const UIndirectList<label>& indices)
+:
+    PackedBoolList(indices.size(), indices)
+{}
+
+
+inline Foam::PackedBoolList::PackedBoolList
+(
+    const label size,
+    const labelUList& indices
+)
+:
+    PackedList<1>(size)
 {
     set(indices);
 }
 
 
-inline Foam::PackedBoolList::PackedBoolList(const UIndirectList<label>& indices)
+inline Foam::PackedBoolList::PackedBoolList
+(
+    const label size,
+    const UIndirectList<label>& indices
+)
 :
-    PackedList<1>(indices.size(), 0u)
+    PackedList<1>(size)
 {
     set(indices);
 }
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
index 18720fc2ae929fc8bd697161550eae1ea68a5d87..842a1a100a7d2b3b1e8e0afd4490e90cfdefc3ba 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H
@@ -48,8 +48,9 @@ Note
         list[1] = list[5] = list[6];  // propagates value
     \endcode
 
-    Using get() or the '[]' operator are similarly fast. Looping and reading
-    via an iterator is approx. 15% slower, but can be more flexible.
+    Reading via the get() or the '[]' operator are identical.
+    Looping and reading via an iterator is approx. 15% slower,
+    but can be more flexible.
 
     Using the set() operator (and the '[]' operator) are marginally slower
     (approx. 5%) than using an iterator, but the set() method has the
@@ -157,7 +158,7 @@ protected:
     // Protected Member Functions
 
         //- Calculate the list length when packed
-        inline static label packedLength(const label);
+        inline static label packedLength(const label nElem);
 
         //- Read a list entry (allows for specialization)
         inline static unsigned int readValue(Istream& is);
@@ -200,14 +201,14 @@ public:
 
         //- The max. number of bits that can be templated.
         //  Might someday be useful for a template assert.
-        inline static unsigned int max_bits();
+        inline static constexpr unsigned int max_bits();
 
         //- The max. value for an entry, which simultaneously the bit-mask
         //  eg, ((1 << 2) - 1) yields 0b0011
-        inline static unsigned int max_value();
+        inline static constexpr unsigned int max_value();
 
         //- The number of entries per packed storage element
-        inline static unsigned int packing();
+        inline static constexpr unsigned int packing();
 
         //- Masking for all bits below the offset
         inline static unsigned int maskLower(unsigned offset);
@@ -267,13 +268,14 @@ public:
         //  Never auto-vivify entries.
         inline unsigned int get(const label i) const;
 
-        //- Set value at index I. Return true if value changed.
+        //- Set value at index I, default value set is the max_value.
         //  Does auto-vivify for non-existent, non-zero entries.
-        //  Default value set is the max_value.
+        //  \return true if value changed.
         inline bool set(const label i, const unsigned int val = ~0u);
 
-        //- Unset the entry at index I. Return true if value changed.
+        //- Unset the entry at index I.
         //  Never auto-vivify entries.
+        //  \return true if value changed.
         inline bool unset(const label i);
 
         //- Return the underlying packed storage
@@ -286,8 +288,7 @@ public:
         //- The list length when packed
         inline label packedLength() const;
 
-        //- Return the binary size in number of characters
-        //  used in the underlying storage
+        //- The number of bytes used in the underlying storage
         inline std::streamsize byteSize() const;
 
         //- Count number of bits set, O(log(n))
@@ -365,7 +366,8 @@ public:
         Istream& read(Istream& is);
 
         //- Write the List, with line-breaks in ASCII if the list length
-        //  exceeds shortListLen. Using '0' suppresses line-breaks entirely.
+        //- exceeds shortListLen.
+        //  Using '0' suppresses line-breaks entirely.
         //  A special indexed output (ASCII only) is triggered by specifying
         //  a negative value for shortListLen.
         //
@@ -393,11 +395,11 @@ public:
         //- Remove and return the last element
         inline unsigned int remove();
 
-        //- Get value at index I
+        //- Identical to get() - get value at index.
         //  Never auto-vivify entries.
         inline unsigned int operator[](const label i) const;
 
-        //- Set value at index I.
+        //- Non-const access to value at index.
         //  Returns iterator to perform the actual operation.
         //  Does not auto-vivify entries, but will when assigned to.
         inline iteratorBase operator[](const label i);
@@ -496,11 +498,11 @@ public:
 
             //- Disallow copy constructor from const_iterator
             //  This would violate const-ness!
-            iterator(const const_iterator& iter);
+            iterator(const const_iterator& iter) = delete;
 
             //- Disallow assignment from const_iterator
             //  This would violate const-ness!
-            void operator=(const const_iterator& iter);
+            void operator=(const const_iterator& iter) = delete;
 
 
         public:
diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
index ad136b903fafd6ba25109c81b339274985f01bab..4f9c58644ad29ef91da1fbfba10b911db1196df8 100644
--- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
+++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,24 +25,24 @@ License
 
 #include <climits>
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
 
 template<unsigned nBits>
-inline unsigned int Foam::PackedList<nBits>::max_bits()
+inline constexpr unsigned int Foam::PackedList<nBits>::max_bits()
 {
     return sizeof(StorageType)*CHAR_BIT - 1;
 }
 
 
 template<unsigned nBits>
-inline unsigned int Foam::PackedList<nBits>::max_value()
+inline constexpr unsigned int Foam::PackedList<nBits>::max_value()
 {
     return (1u << nBits) - 1;
 }
 
 
 template<unsigned nBits>
-inline unsigned int Foam::PackedList<nBits>::packing()
+inline constexpr unsigned int Foam::PackedList<nBits>::packing()
 {
     return sizeof(StorageType)*CHAR_BIT / nBits;
 }
@@ -65,6 +65,8 @@ inline Foam::label Foam::PackedList<nBits>::packedLength(const label nElem)
 }
 
 
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
 namespace Foam
 {
     // Template specialization for bool entries
@@ -88,13 +90,10 @@ namespace Foam
         if (this->get())
         {
             os  << index_;
-
             return true;
         }
-        else
-        {
-            return false;
-        }
+
+        return false;
     }
 }
 
@@ -119,12 +118,12 @@ inline unsigned int Foam::PackedList<nBits>::readValue(Istream& is)
 template<unsigned nBits>
 inline void Foam::PackedList<nBits>::setPair(Istream& is)
 {
-    is.readBegin("Tuple2<label, unsigned int>");
+    is.readBegin("Tuple2<label,unsigned int>");
 
     const label ind = readLabel(is);
     const unsigned int val = readLabel(is);
 
-    is.readEnd("Tuple2<label, unsigned int>");
+    is.readEnd("Tuple2<label,unsigned int>");
 
     if (val > max_value())
     {
@@ -154,10 +153,8 @@ inline bool Foam::PackedList<nBits>::iteratorBase::writeIfSet(Ostream& os) const
 
         return true;
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
@@ -233,7 +230,8 @@ inline Foam::PackedList<nBits>::PackedList(const labelUList& lst)
     StorageList(packedLength(lst.size()), 0u),
     size_(lst.size())
 {
-    forAll(lst, i)
+    const label len = lst.size();
+    for (label i = 0; i < len; ++i)
     {
         set(i, lst[i]);
     }
@@ -247,7 +245,8 @@ inline Foam::PackedList<nBits>::PackedList(const UIndirectList<label>& lst)
     StorageList(packedLength(lst.size()), 0u),
     size_(lst.size())
 {
-    forAll(lst, i)
+    const label len = lst.size();
+    for (label i = 0; i < len; ++i)
     {
         set(i, lst[i]);
     }
@@ -862,16 +861,16 @@ inline void Foam::PackedList<nBits>::reserve(const label nElem)
 {
     const label len = packedLength(nElem);
 
-    // Need more capacity?
+    // Allocate more capacity if necessary
     if (len > StorageList::size())
     {
-        // Like DynamicList with SizeInc=0, SizeMult=2, SizeDiv=1
         StorageList::setSize
         (
             max
             (
                 len,
-                StorageList::size()*2
+                // SizeInc=0, SizeMult=2, SizeDiv=1
+                2 * StorageList::size()
             ),
             0u
         );
@@ -964,27 +963,17 @@ inline unsigned int Foam::PackedList<nBits>::get(const label i) const
     // Lazy evaluation - return 0 for out-of-range
     if (i < 0 || i >= size_)
     {
-        return 0;
-    }
-    else
-    {
-        return iteratorBase(this, i).get();
+        return 0u;
     }
+
+    return iteratorBase(this, i).get();
 }
 
 
 template<unsigned nBits>
 inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
 {
-    // Lazy evaluation - return 0 for out-of-range
-    if (i < 0 || i >= size_)
-    {
-        return 0;
-    }
-    else
-    {
-        return iteratorBase(this, i).get();
-    }
+    return get(i);
 }
 
 
@@ -1024,10 +1013,8 @@ inline bool Foam::PackedList<nBits>::unset(const label i)
     {
         return false;
     }
-    else
-    {
-        return iteratorBase(this, i).set(0u);
-    }
+
+    return iteratorBase(this, i).set(0u);
 }
 
 
@@ -1035,11 +1022,11 @@ template<unsigned nBits>
 inline Foam::PackedList<nBits>&
 Foam::PackedList<nBits>::append(const unsigned int val)
 {
-    const label elemI = size_;
-    reserve(elemI + 1);
+    const label idx = size_;
+    reserve(idx + 1);
     size_++;
 
-    iteratorBase(this, elemI).set(val);
+    iteratorBase(this, idx).set(val);
     return *this;
 }
 
@@ -1047,15 +1034,17 @@ Foam::PackedList<nBits>::append(const unsigned int val)
 template<unsigned nBits>
 inline unsigned int Foam::PackedList<nBits>::remove()
 {
-    if (!size_)
+    // Location of last element and simultaneously the new size
+    const label idx = size_ - 1;
+
+    if (idx < 0)
     {
         FatalErrorInFunction
             << "List is empty" << abort(FatalError);
     }
 
-    label elemI = size_ - 1;
-    const unsigned int val = iteratorBase(this, elemI).get();
-    resize(elemI);
+    const unsigned int val = iteratorBase(this, idx).get();
+    resize(idx);
 
     return val;
 }
diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C b/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C
index 6aff9ed81e06d6d7578419172a584f261250f73f..594aa01e4dd0171902b2d53726b71c77f6d08c0f 100644
--- a/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C
+++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListIO.C
@@ -48,19 +48,19 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
     if (firstToken.isLabel())
     {
         // Read size of list
-        const label s = firstToken.labelToken();
+        const label sz = firstToken.labelToken();
 
         // Set list length to that read
-        setSize(s);
+        setSize(sz);
 
         // Read beginning of contents
         const char delimiter = is.readBeginList("PtrList");
 
-        if (s)
+        if (sz)
         {
             if (delimiter == token::BEGIN_LIST)
             {
-                forAll(*this, i)
+                for (label i=0; i<sz; ++i)
                 {
                     set(i, inewt(is));
 
@@ -82,7 +82,7 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
                     "reading the single entry"
                 );
 
-                for (label i=1; i<s; ++i)
+                for (label i=1; i<sz; ++i)
                 {
                     set(i, tPtr->clone());
                 }
diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
index a35334507aa58d979fa3263ea3ef1b4bbc3c0ef8..6d2d2698dca17ff64e380e4915f472deec870808 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
+++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -33,43 +33,60 @@ inline Foam::SortableList<T>::SortableList()
 
 
 template<class T>
-Foam::SortableList<T>::SortableList(const UList<T>& values)
+inline Foam::SortableList<T>::SortableList(const label size)
 :
-    List<T>(values)
-{
-    sort();
-}
+    List<T>(size)
+{}
 
 
 template<class T>
-Foam::SortableList<T>::SortableList(const Xfer<List<T>>& values)
+inline Foam::SortableList<T>::SortableList(const label size, const T& val)
 :
-    List<T>(values)
-{
-    sort();
-}
+    List<T>(size, val)
+{}
 
 
 template<class T>
-inline Foam::SortableList<T>::SortableList(const label size)
+inline Foam::SortableList<T>::SortableList(const SortableList<T>& lst)
 :
-    List<T>(size)
+    List<T>(lst),
+    indices_(lst.indices())
 {}
 
 
 template<class T>
-inline Foam::SortableList<T>::SortableList(const label size, const T& val)
+inline Foam::SortableList<T>::SortableList(SortableList<T>&& lst)
 :
-    List<T>(size, val)
+    List<T>(std::move(lst)),
+    indices_(std::move(lst.indices_))
 {}
 
 
 template<class T>
-Foam::SortableList<T>::SortableList(const SortableList<T>& lst)
+Foam::SortableList<T>::SortableList(const UList<T>& values)
 :
-    List<T>(lst),
-    indices_(lst.indices())
-{}
+    List<T>(values)
+{
+    sort();
+}
+
+
+template<class T>
+Foam::SortableList<T>::SortableList(List<T>&& values)
+:
+    List<T>(std::move(values))
+{
+    sort();
+}
+
+
+template<class T>
+Foam::SortableList<T>::SortableList(const Xfer<List<T>>& values)
+:
+    List<T>(values)
+{
+    sort();
+}
 
 
 template<class T>
@@ -97,7 +114,6 @@ Foam::SortableList<T>::SortableList(std::initializer_list<T> values)
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-
 template<class T>
 void Foam::SortableList<T>::clear()
 {
@@ -117,14 +133,9 @@ Foam::List<T>& Foam::SortableList<T>::shrink()
 template<class T>
 void Foam::SortableList<T>::sort()
 {
-    sortedOrder(*this, indices_);
-
-    List<T> lst(this->size());
-    forAll(indices_, i)
-    {
-        lst[i] = this->operator[](indices_[i]);
-    }
+    Foam::sortedOrder(*this, indices_);
 
+    List<T> lst(*this, indices_); // Copy with indices for mapping
     List<T>::transfer(lst);
 }
 
@@ -132,18 +143,21 @@ void Foam::SortableList<T>::sort()
 template<class T>
 void Foam::SortableList<T>::reverseSort()
 {
-    sortedOrder(*this, indices_, typename UList<T>::greater(*this));
-
-    List<T> lst(this->size());
-    forAll(indices_, i)
-    {
-        lst[i] = this->operator[](indices_[i]);
-    }
+    Foam::sortedOrder(*this, indices_, typename UList<T>::greater(*this));
 
+    List<T> lst(*this, indices_); // Copy with indices for mapping
     List<T>::transfer(lst);
 }
 
 
+template<class T>
+void Foam::SortableList<T>::swap(SortableList<T>& lst)
+{
+    List<T>::swap(lst);
+    indices_.swap(lst.indices_);
+}
+
+
 template<class T>
 Foam::Xfer<Foam::List<T>> Foam::SortableList<T>::xfer()
 {
@@ -156,6 +170,7 @@ Foam::Xfer<Foam::List<T>> Foam::SortableList<T>::xfer()
 template<class T>
 inline void Foam::SortableList<T>::operator=(const T& val)
 {
+    indices_.clear();
     UList<T>::operator=(val);
 }
 
@@ -163,8 +178,8 @@ inline void Foam::SortableList<T>::operator=(const T& val)
 template<class T>
 inline void Foam::SortableList<T>::operator=(const UList<T>& lst)
 {
-    List<T>::operator=(lst);
     indices_.clear();
+    List<T>::operator=(lst);
 }
 
 
@@ -176,6 +191,22 @@ inline void Foam::SortableList<T>::operator=(const SortableList<T>& lst)
 }
 
 
+template<class T>
+inline void Foam::SortableList<T>::operator=(List<T>&& lst)
+{
+    indices_.clear();
+    List<T>::operator=(std::move(lst));
+}
+
+
+template<class T>
+inline void Foam::SortableList<T>::operator=(SortableList<T>&& lst)
+{
+    clear();
+    this->swap(lst);
+}
+
+
 template<class T>
 inline void Foam::SortableList<T>::operator=(std::initializer_list<T> lst)
 {
@@ -184,4 +215,13 @@ inline void Foam::SortableList<T>::operator=(std::initializer_list<T> lst)
 }
 
 
+// * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
+
+template<class T>
+inline void Foam::Swap(SortableList<T>& a, SortableList<T>& b)
+{
+    a.swap(b);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
index cd005a09c2f42e2905ab509642627a6de5bd8fab..083e69386f01603229095378eaf777f65426d589 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
+++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -67,13 +67,7 @@ public:
         //- Null constructor, sort later (eg, after assignment or transfer)
         inline SortableList();
 
-        //- Construct from UList, sorting immediately
-        explicit SortableList(const UList<T>& values);
-
-        //- Construct from transferred List, sorting immediately
-        explicit SortableList(const Xfer<List<T>>& values);
-
-        //- Construct given size. Sort later on
+        //- Construct given size, sort later.
         //  The indices remain empty until the list is sorted
         explicit inline SortableList(const label size);
 
@@ -81,17 +75,29 @@ public:
         //  The indices remain empty until the list is sorted
         inline SortableList(const label size, const T& val);
 
+        //- Copy construct
+        inline SortableList(const SortableList<T>& lst);
+
+        //- Move construct
+        inline SortableList(SortableList<T>&& lst);
+
+        //- Copy construct from UList, sorting immediately
+        explicit SortableList(const UList<T>& values);
+
+        //- Move construct from List, sorting immediately
+        SortableList(List<T>&& values);
+
         //- Construct given begin/end iterators.
         //  Uses std::distance to determine the size.
         template<class InputIterator>
         inline SortableList(InputIterator begIter, InputIterator endIter);
 
-        //- Construct as copy
-        inline SortableList(const SortableList<T>& lst);
-
         //- Construct from an initializer list, sorting immediately
         SortableList(std::initializer_list<T> values);
 
+        //- Construct from transferred List, sorting immediately
+        explicit SortableList(const Xfer<List<T>>& values);
+
 
     // Member Functions
 
@@ -113,33 +119,49 @@ public:
         //- Clear the indices and return a reference to the underlying List
         List<T>& shrink();
 
-        //- (stable) sort the list (if changed after construction time)
-        //  also resizes the indices as required
+        //- (stable) sort the list (if changed after construction time).
+        //  Resizes the indices as required
         void sort();
 
         //- Reverse (stable) sort the list
         void reverseSort();
 
+        //- Swap content with another SortableList in constant time
+        inline void swap(SortableList<T>& lst);
+
         //- Transfer contents to the Xfer container as a plain List
         inline Xfer<List<T>> xfer();
 
 
     // Member Operators
 
-        //- Assignment of all entries to the given value
+        //- Assignment of all entries to the given value, removing indices.
         inline void operator=(const T& val);
 
-        //- Assignment to UList operator. Takes linear time
+        //- Assignment to UList operator, removing indices. Takes linear time
         inline void operator=(const UList<T>& lst);
 
         //- Assignment operator. Takes linear time
         inline void operator=(const SortableList<T>& lst);
 
+        //- Move assignment, removing indices. Takes linear time
+        inline void operator=(List<T>&& lst);
+
+        //- Move operator. Takes linear time
+        inline void operator=(SortableList<T>&& lst);
+
         //- Assignment to an initializer list
         void operator=(std::initializer_list<T> lst);
 };
 
 
+// Global Functions
+
+// Exchange contents of lists - see SortableList::swap().
+template<class T>
+inline void Swap(SortableList<T>& a, SortableList<T>& b);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C
new file mode 100644
index 0000000000000000000000000000000000000000..931e93efb11bd8023eb3f8b9c147321599d42b32
--- /dev/null
+++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.C
@@ -0,0 +1,87 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class T>
+inline Foam::label Foam::UIndirectList<T>::find
+(
+    const T& val,
+    const label start
+) const
+{
+    if (start >= 0)
+    {
+        List_CONST_ACCESS(T, completeList_, lst);
+        List_CONST_ACCESS(label, addressing_, addr);
+
+        const label len = addressing_.size();
+
+        for (label i = start; i < len; ++i)
+        {
+            if (lst[addr[i]] == val)
+            {
+                return i;
+            }
+        }
+    }
+
+    return -1;
+}
+
+
+template<class T>
+inline Foam::label Foam::UIndirectList<T>::rfind
+(
+    const T& val,
+    const label pos
+) const
+{
+    List_CONST_ACCESS(T, completeList_, lst);
+    List_CONST_ACCESS(label, addressing_, addr);
+
+    for
+    (
+        label i =
+        (
+            pos < 0
+          ? (addressing_.size()-1)
+          : min(pos, (addressing_.size()-1))
+        );
+        i >= 0;
+        --i
+    )
+    {
+        if (lst[addr[i]] == val)
+        {
+            return i;
+        }
+    }
+
+    return -1;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H
index e39d899f899be9426ba25d2474ed11596f4492bc..eac9eaf4151235a2837672ff46659408a9253547 100644
--- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H
+++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H
@@ -79,69 +79,85 @@ public:
 
     // Member Functions
 
-        // Access
+      // Access
 
-            //- Return the number of elements in the list
-            inline label size() const;
+        //- Return the number of elements in the list
+        inline label size() const;
 
-            //- Return true if the list is empty (ie, size() is zero).
-            inline bool empty() const;
+        //- Return true if the list is empty (ie, size() is zero).
+        inline bool empty() const;
 
-            //- Return the first element of the list.
-            inline T& first();
+        //- Return the first element of the list.
+        inline T& first();
 
-            //- Return first element of the list.
-            inline const T& first() const;
+        //- Return first element of the list.
+        inline const T& first() const;
 
-            //- Return the last element of the list.
-            inline T& last();
+        //- Return the last element of the list.
+        inline T& last();
 
-            //- Return the last element of the list.
-            inline const T& last() const;
+        //- Return the last element of the list.
+        inline const T& last() const;
 
-            //- Return the complete list
-            inline const UList<T>& completeList() const;
+        //- Return the complete list
+        inline const UList<T>& completeList() const;
 
-            //- Return the list addressing
-            inline const List<label>& addressing() const;
+        //- Return the list addressing
+        inline const List<label>& addressing() const;
 
 
-        // Member Operators
+      // Search
 
-            //- Return the addressed elements as a List
-            inline List<T> operator()() const;
+        //- Find index of the first occurence of the value.
+        //  When start is specified, any occurences before start are ignored.
+        //  Linear search.
+        //  \return -1 if not found.
+        label find(const T& val, const label start=0) const;
 
-            //- Return non-const access to an element
-            inline T& operator[](const label i);
+        //- Find index of the last occurence of the value.
+        //  When pos is specified, any occurences after pos are ignored.
+        //  Linear search.
+        //  \return -1 if not found.
+        label rfind(const T& val, const label pos=-1) const;
 
-            //- Return const access to an element
-            inline const T& operator[](const label i) const;
+        //- True if the value if found in the list. Linear search.
+        inline bool found(const T& val, const label start=0) const;
 
-            //- Assignment to UList of addressed elements
-            inline void operator=(const UList<T>& ae);
 
-            //- Assignment to UIndirectList of addressed elements
-            inline void operator=(const UIndirectList<T>& ae);
+    // Member Operators
 
-            //- Assignment of all entries to the given value
-            inline void operator=(const T& t);
+        //- Return the addressed elements as a List
+        inline List<T> operator()() const;
+
+        //- Return non-const access to an element
+        inline T& operator[](const label i);
+
+        //- Return const access to an element
+        inline const T& operator[](const label i) const;
+
+        //- Assignment to UList of addressed elements
+        inline void operator=(const UList<T>& ae);
+
+        //- Assignment to UIndirectList of addressed elements
+        inline void operator=(const UIndirectList<T>& ae);
+
+        //- Assignment of all entries to the given value
+        inline void operator=(const T& t);
 
 
     // STL type definitions
 
-        //- Type of values the UList contains.
+        //- Type of values the list contains.
         typedef T value_type;
 
-        //- Type that can be used for storing into
-        //  UList::value_type objects.
+        //- The type used for storing into UList::value_type objects.
         typedef T& reference;
 
-        //- Type that can be used for storing into
-        //  constant UList::value_type objects
+        //- The type used for reading from constant UList::value_type objects
         typedef const T& const_reference;
 
         //- The type that can represent the difference between any two
-        //  UList iterator objects.
+        //- UList iterator objects.
         typedef label difference_type;
 
         //- The type that can represent the size of a UList.
@@ -151,8 +167,8 @@ public:
     // Writing
 
         //- Write the List, with line-breaks in ASCII if the list length
-        //  exceeds shortListLen. Using '0' suppresses line-breaks entirely.
-        //  Binary output is currently still a bit of an annoyance.
+        //- exceeds shortListLen.
+        //  Using '0' suppresses line-breaks entirely.
         Ostream& writeList(Ostream& os, const label shortListLen=0) const;
 
 
@@ -162,7 +178,7 @@ public:
         friend Ostream& operator<< <T>
         (
             Ostream& os,
-            const UIndirectList<T>& L
+            const UIndirectList<T>& lst
         );
 };
 
@@ -176,6 +192,7 @@ public:
 #include "UIndirectListI.H"
 
 #ifdef NoRepository
+    #include "UIndirectList.C"
     #include "UIndirectListIO.C"
 #endif
 
diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H
index c26efd9ac744b91e1671010c17aaa679fc6e9976..15daa10969f02763074f05cc6cc13cbd6a1d7e0d 100644
--- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H
+++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H
@@ -95,6 +95,17 @@ inline const Foam::List<Foam::label>& Foam::UIndirectList<T>::addressing() const
 }
 
 
+template<class T>
+inline bool Foam::UIndirectList<T>::found
+(
+    const T& val,
+    const label pos
+) const
+{
+    return this->find(val, pos) != -1;
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 template<class T>
diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C
index 5e711c072411100c72b4f301242feaa2fe8accf7..b990952e2d44c9d9501b0f0e53553fea3a2f3031 100644
--- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C
+++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C
@@ -39,14 +39,16 @@ Foam::Ostream& Foam::UIndirectList<T>::writeList
 {
     const UIndirectList<T>& L = *this;
 
+    const label sz = L.size();
+
     // Write list contents depending on data format
     if (os.format() == IOstream::ASCII || !contiguous<T>())
     {
         // Can the contents be considered 'uniform' (ie, identical)?
-        bool uniform = (L.size() > 1 && contiguous<T>());
+        bool uniform = (sz > 1 && contiguous<T>());
         if (uniform)
         {
-            forAll(L, i)
+            for (label i=1; i < sz; ++i)
             {
                 if (L[i] != L[0])
                 {
@@ -58,65 +60,72 @@ Foam::Ostream& Foam::UIndirectList<T>::writeList
 
         if (uniform)
         {
-            // Write size and start delimiter
-            os << L.size() << token::BEGIN_BLOCK;
+            // Size and start delimiter
+            os << sz << token::BEGIN_BLOCK;
 
-            // Write contents
+            // Contents
             os << L[0];
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_BLOCK;
         }
         else if
         (
-            L.size() <= 1 || !shortListLen
-         || (L.size() <= shortListLen && contiguous<T>())
+            sz <= 1 || !shortListLen
+         || (sz <= shortListLen && contiguous<T>())
         )
         {
-            // Write size and start delimiter
-            os << L.size() << token::BEGIN_LIST;
+            // Size and start delimiter
+            os << sz << token::BEGIN_LIST;
 
-            // Write contents
-            forAll(L, i)
+            // Contents
+            for (label i=0; i < sz; ++i)
             {
                 if (i) os << token::SPACE;
                 os << L[i];
             }
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_LIST;
         }
         else
         {
-            // Write size and start delimiter
-            os << nl << L.size() << nl << token::BEGIN_LIST << nl;
+            // Size and start delimiter
+            os << nl << sz << nl << token::BEGIN_LIST << nl;
 
-            // Write contents
-            forAll(L, i)
+            // Contents
+            for (label i=0; i < sz; ++i)
             {
                 os << L[i] << nl;
             }
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_LIST << nl;
         }
     }
     else
     {
         // Contents are binary and contiguous
-        os << nl << L.size() << nl;
+        os << nl << sz << nl;
 
-        if (L.size())
+        if (sz)
         {
-            // This is annoying, and wasteful, but currently no alternative
-            List<T> lst = L();
-
-            // write(...) includes surrounding start/end delimiters
-            os.write
-            (
-                reinterpret_cast<const char*>(lst.cdata()),
-                lst.byteSize()
-            );
+            // The TOTAL number of bytes to be written.
+            // - possibly add start delimiter
+            os.beginRaw(sz*sizeof(T));
+
+            // Contents
+            for (label i=0; i < sz; ++i)
+            {
+                os.writeRaw
+                (
+                    reinterpret_cast<const char*>(&(L[i])),
+                    sizeof(T)
+                );
+            }
+
+            // End delimiter and/or cleanup.
+            os.endRaw();
         }
     }
 
@@ -131,10 +140,10 @@ template<class T>
 Foam::Ostream& Foam::operator<<
 (
     Foam::Ostream& os,
-    const Foam::UIndirectList<T>& L
+    const Foam::UIndirectList<T>& lst
 )
 {
-    return L.writeList(os, 10);
+    return lst.writeList(os, 10);
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C
index f47969874420dee885258c2eaab74473ebc9d146..24cf28a27f95da69f91009f65c3d9b0b49995c04 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.C
+++ b/src/OpenFOAM/containers/Lists/UList/UList.C
@@ -49,18 +49,18 @@ Foam::labelRange Foam::UList<T>::validateRange(const labelRange& range) const
 template<class T>
 Foam::labelRange Foam::UList<T>::validateRange
 (
-    std::initializer_list<label> start_size_pair
+    std::initializer_list<label> start_size
 ) const
 {
-    if (start_size_pair.size() != 2)
+    if (start_size.size() != 2)
     {
         FatalErrorInFunction
-            << "range specified with " << start_size_pair.size()
+            << "range specified with " << start_size.size()
             << " elements instead of 2"
             << abort(FatalError);
     }
 
-    auto iter = start_size_pair.begin();
+    auto iter = start_size.begin();
 
     const label beg = *(iter++);
     const label sz  = *iter;
@@ -71,6 +71,56 @@ Foam::labelRange Foam::UList<T>::validateRange
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
+template<class T>
+void Foam::UList<T>::moveFirst(const label i)
+{
+    checkIndex(i);
+
+    for (label lower = 0; lower < i; ++lower)
+    {
+        Foam::Swap(this->operator[](lower), this->operator[](i));
+    }
+}
+
+
+template<class T>
+void Foam::UList<T>::moveLast(const label i)
+{
+    checkIndex(i);
+
+    for (label upper = size()-1; upper > i; --upper)
+    {
+        Foam::Swap(this->operator[](i), this->operator[](upper));
+    }
+}
+
+
+template<class T>
+void Foam::UList<T>::swapFirst(const label i)
+{
+    checkIndex(i);
+
+    if (i > 0)
+    {
+        Foam::Swap(this->operator[](0), this->operator[](i));
+    }
+}
+
+
+template<class T>
+void Foam::UList<T>::swapLast(const label i)
+{
+    checkIndex(i);
+
+    const label upper = size()-1;
+
+    if (i < upper)
+    {
+        Foam::Swap(this->operator[](i), this->operator[](upper));
+    }
+}
+
+
 template<class T>
 void Foam::UList<T>::deepCopy(const UList<T>& a)
 {
@@ -95,8 +145,9 @@ void Foam::UList<T>::deepCopy(const UList<T>& a)
             List_ACCESS(T, (*this), vp);
             List_CONST_ACCESS(T, a, ap);
             List_FOR_ALL((*this), i)
-                List_ELEM((*this), vp, i) = List_ELEM(a, ap, i);
-            List_END_FOR_ALL
+            {
+                vp[i] = ap[i];
+            }
         }
     }
 }
@@ -125,10 +176,10 @@ const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const
 template<class T>
 Foam::UList<T> Foam::UList<T>::operator[]
 (
-    std::initializer_list<label> start_size_pair
+    std::initializer_list<label> start_size
 )
 {
-    const labelRange slice = validateRange(start_size_pair);
+    const labelRange slice = validateRange(start_size);
 
     return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
 }
@@ -137,23 +188,24 @@ Foam::UList<T> Foam::UList<T>::operator[]
 template<class T>
 const Foam::UList<T> Foam::UList<T>::operator[]
 (
-    std::initializer_list<label> start_size_range
+    std::initializer_list<label> start_size
 ) const
 {
     // Restricted range
-    const labelRange slice = validateRange(start_size_range);
+    const labelRange slice = validateRange(start_size);
 
     return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
 }
 
 
 template<class T>
-void Foam::UList<T>::operator=(const T& t)
+void Foam::UList<T>::operator=(const T& val)
 {
     List_ACCESS(T, (*this), vp);
     List_FOR_ALL((*this), i)
-        List_ELEM((*this), vp, i) = t;
-    List_END_FOR_ALL
+    {
+        vp[i] = val;
+    }
 }
 
 
@@ -162,18 +214,9 @@ void Foam::UList<T>::operator=(const zero)
 {
     List_ACCESS(T, (*this), vp);
     List_FOR_ALL((*this), i)
-        List_ELEM((*this), vp, i) = Zero;
-    List_END_FOR_ALL
-}
-
-
-// * * * * * * * * * * * * * * STL Member Functions  * * * * * * * * * * * * //
-
-template<class T>
-void Foam::UList<T>::swap(UList<T>& a)
-{
-    Swap(size_, a.size_);
-    Swap(v_, a.v_);
+    {
+        vp[i] = Zero;
+    }
 }
 
 
@@ -194,6 +237,48 @@ std::streamsize Foam::UList<T>::byteSize() const
 }
 
 
+template<class T>
+Foam::label Foam::UList<T>::find(const T& val, const label start) const
+{
+    const label len = this->size();
+
+    if (start >= 0 && len)
+    {
+        List_CONST_ACCESS(T, (*this), vp);
+
+        for (label i = start; i < len; ++i)
+        {
+            if (vp[i] == val)
+            {
+                return i;
+            }
+        }
+    }
+
+    return -1;
+}
+
+
+template<class T>
+Foam::label Foam::UList<T>::rfind(const T& val, const label pos) const
+{
+    List_CONST_ACCESS(T, (*this), vp);
+
+    const label len1 = (this->size()-1);
+
+    // pos == -1 has same meaning as std::string::npos - search from end
+    for (label i = ((pos >= 0 && pos < len1) ? pos : len1); i >= 0; --i)
+    {
+        if (vp[i] == val)
+        {
+            return i;
+        }
+    }
+
+    return -1;
+}
+
+
 template<class T>
 void Foam::sort(UList<T>& a)
 {
@@ -201,10 +286,10 @@ void Foam::sort(UList<T>& a)
 }
 
 
-template<class T, class Cmp>
-void Foam::sort(UList<T>& a, const Cmp& cmp)
+template<class T, class Compare>
+void Foam::sort(UList<T>& a, const Compare& comp)
 {
-    std::sort(a.begin(), a.end(), cmp);
+    std::sort(a.begin(), a.end(), comp);
 }
 
 
@@ -215,10 +300,10 @@ void Foam::stableSort(UList<T>& a)
 }
 
 
-template<class T, class Cmp>
-void Foam::stableSort(UList<T>& a, const Cmp& cmp)
+template<class T, class Compare>
+void Foam::stableSort(UList<T>& a, const Compare& comp)
 {
-    std::stable_sort(a.begin(), a.end(), cmp);
+    std::stable_sort(a.begin(), a.end(), comp);
 }
 
 
@@ -244,9 +329,10 @@ bool Foam::UList<T>::operator==(const UList<T>& a) const
     List_CONST_ACCESS(T, (a), ap);
 
     List_FOR_ALL((*this), i)
-        equal = (List_ELEM((*this), vp, i) == List_ELEM((a), ap, i));
+    {
+        equal = (vp[i] == ap[i]);
         if (!equal) break;
-    List_END_FOR_ALL
+    }
 
     return equal;
 }
diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H
index 6b58437b36fa2bd312669c0a265384bf10784d56..e0893960df8975cff4b958d3d94dca77a9b1ccc9 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.H
+++ b/src/OpenFOAM/containers/Lists/UList/UList.H
@@ -48,6 +48,8 @@ SourceFiles
 #include "nullObject.H"
 #include "zero.H"
 #include "stdFoam.H"
+#include "Swap.H"
+
 #include <initializer_list>
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -65,6 +67,7 @@ template<class T> class UList;
 template<class T> Ostream& operator<<(Ostream&, const UList<T>&);
 template<class T> Istream& operator>>(Istream&, UList<T>&);
 
+typedef UList<char> charUList;
 typedef UList<label> labelUList;
 
 /*---------------------------------------------------------------------------*\
@@ -100,15 +103,19 @@ protected:
 
     // Protected Member Functions
 
+        //- Override size to be inconsistent with allocated storage.
+        //  Use with care
+        inline void size(const label n);
+
         //- Write the UList with its compound type
         void writeEntry(Ostream& os) const;
 
         //- Return a validated (start,size) subset range, which means that it
-        //  always addresses a valid section of the list.
+        //- always addresses a valid section of the list.
         labelRange validateRange(const labelRange& range) const;
 
         //- Return a validated (start,size) subset range, which means that it
-        //  always addresses a valid section of the list.
+        //- always addresses a valid section of the list.
         labelRange validateRange
         (
             std::initializer_list<label> start_size_pair
@@ -133,39 +140,35 @@ public:
 
     // Public classes
 
-        //- Less function class that can be used for sorting
-        class less
+        //- A list compare binary predicate for normal sort
+        struct less
         {
-            const UList<T>& values_;
+            const UList<T>& values;
 
-        public:
-
-            less(const UList<T>& values)
+            less(const UList<T>& list)
             :
-                values_(values)
+                values(list)
             {}
 
-            bool operator()(const label a, const label b)
+            bool operator()(const label a, const label b) const
             {
-                return values_[a] < values_[b];
+                return values[a] < values[b];
             }
         };
 
-        //- Greater function class that can be used for sorting
-        class greater
+        //- A list compare binary predicate for reverse sort
+        struct greater
         {
-            const UList<T>& values_;
+            const UList<T>& values;
 
-        public:
-
-            greater(const UList<T>& values)
+            greater(const UList<T>& list)
             :
-                values_(values)
+                values(list)
             {}
 
-            bool operator()(const label a, const label b)
+            bool operator()(const label a, const label b) const
             {
-                return values_[a] > values_[b];
+                return values[a] > values[b];
             }
         };
 
@@ -181,31 +184,42 @@ public:
 
     // Member Functions
 
-
         // Access
 
-            //- Return the forward circular index, i.e. the next index
-            //  which returns to the first at the end of the list
+            //- Return the forward circular index, i.e. next index
+            //- which returns to the first at the end of the list
             inline label fcIndex(const label i) const;
 
-            //- Return the reverse circular index, i.e. the previous index
-            //  which returns to the last at the beginning of the list
+            //- Return forward circular value (ie, next value in the list)
+            inline const T& fcValue(const label i) const;
+
+            //- Return forward circular value (ie, next value in the list)
+            inline T& fcValue(const label i);
+
+            //- Return the reverse circular index, i.e. previous index
+            //- which returns to the last at the beginning of the list
             inline label rcIndex(const label i) const;
 
+            //- Return reverse circular value (ie, previous value in the list)
+            inline const T& rcValue(const label i) const;
+
+            //- Return reverse circular value (ie, previous value in the list)
+            inline T& rcValue(const label i);
+
             //- Return the binary size in number of characters of the UList
-            //  if the element is a primitive type
+            //- if the element is a primitive type
             //  i.e. contiguous<T>() == true.
             //  Note that is of type streamsize since used in stream ops
             std::streamsize byteSize() const;
 
 
-            //- Return a const pointer to the first data element,
-            //  similar to the STL front() method and the string::data() method
+            //- Return a const pointer to the first data element.
+            //  Similar to the STL front() method and the string::data() method
             //  This can be used (with caution) when interfacing with C code
             inline const T* cdata() const;
 
-            //- Return a pointer to the first data element,
-            //  similar to the STL front() method and the string::data() method
+            //- Return a pointer to the first data element.
+            //  Similar to the STL front() method and the string::data() method
             //  This can be used (with caution) when interfacing with C code
             inline T* data();
 
@@ -234,6 +248,44 @@ public:
             inline void checkIndex(const label i) const;
 
 
+      // Search
+
+        //- Find index of the first occurence of the value.
+        //  When start is specified, any occurences before start are ignored.
+        //  Linear search.
+        //  \return position in list or -1 if not found.
+        label find(const T& val, const label start=0) const;
+
+        //- Find index of the last occurence of the value.
+        //  When pos is specified, any occurences after pos are ignored.
+        //  Linear search.
+        //  \return position in list or -1 if not found.
+        label rfind(const T& val, const label pos=-1) const;
+
+        //- True if the value if found in the list.
+        //  When start is specified, any occurences before start are ignored.
+        //  Linear search.
+        //  \return true if found.
+        inline bool found(const T& val, const label start=0) const;
+
+
+      // Edit
+
+        //- Move element to the first position.
+        void moveFirst(const label i);
+
+        //- Move element to the last position.
+        void moveLast(const label i);
+
+        //- Swap element with the first element. Fatal on an empty list.
+        void swapFirst(const label i);
+
+        //- Swap element with the last element. Fatal on an empty list.
+        void swapLast(const label i);
+
+
+      // Copy
+
         //- Copy the pointer held by the given UList
         inline void shallowCopy(const UList<T>& a);
 
@@ -264,21 +316,21 @@ public:
         //- Return (start,size) subset from UList with non-const access.
         //  The range is subsetted with the list size itself to ensure that the
         //  result always addresses a valid section of the list.
-        UList<T> operator[](std::initializer_list<label> start_size_range);
+        UList<T> operator[](std::initializer_list<label> start_size);
 
         //- Return (start,size) subset from UList with const access.
         //  The range is subsetted with the list size itself to ensure that the
         //  result always addresses a valid section of the list.
         const UList<T> operator[]
         (
-            std::initializer_list<label> start_size_range
+            std::initializer_list<label> start_size
         ) const;
 
         //- Allow cast to a const List<T>&
         inline operator const Foam::List<T>&() const;
 
         //- Assignment of all entries to the given value
-        void operator=(const T& t);
+        void operator=(const T& val);
 
         //- Assignment of all entries to zero
         void operator=(const zero);
@@ -296,7 +348,7 @@ public:
         typedef const T& const_reference;
 
         //- The type that can represent the difference between any two
-        //  UList iterator objects
+        //- UList iterator objects
         typedef label difference_type;
 
         //- The type that can represent the size of a UList
@@ -332,11 +384,94 @@ public:
         //- Return const_iterator to end traversing the constant UList
         inline const_iterator end() const;
 
+    // Reverse iterators
+
+        //- Generic const/non-const reverse iterator
+        template<bool Const>
+        class reverse_iterator_base
+        {
+        public:
+            //- The const/non-const type for entries
+            typedef typename std::conditional
+                <Const, const T, T>::type value_type;
+
+            //- A pointer to a const/non-const entry
+            typedef value_type* pointer;
 
-    // STL reverse_iterator
+            //- A reference to a const/non-const entry
+            typedef value_type& reference;
 
-        //- Reverse iterator for reverse traversal of UList
-        typedef T* reverse_iterator;
+
+        private:
+
+            //- The element pointer
+            pointer ptr_;
+
+
+        public:
+
+            //- Construct null or from list element pointer
+            inline reverse_iterator_base(pointer ptr = nullptr)
+            :
+                ptr_(ptr)
+            {}
+
+
+            //- Copy construct
+            inline reverse_iterator_base(const reverse_iterator_base& iter)
+            :
+                ptr_(iter.ptr_)
+            {}
+
+
+            //- Reverse increment
+            inline void operator++()
+            {
+                --ptr_;
+            }
+
+            //- Reverse increment
+            inline reverse_iterator_base operator++(int)
+            {
+                reverse_iterator_base old(*this);
+                --ptr_;
+                return old;
+            }
+
+            //- Reverse increase
+            inline void operator+=(int n)
+            {
+                ptr_ -= n;
+            }
+
+            //- Dereference iterator
+            reference operator*() const
+            {
+                return *ptr_;
+            }
+
+            //- Dereference iterator
+            pointer operator->() const
+            {
+                return ptr_;
+            }
+
+            //- Equality
+            bool operator==(const reverse_iterator_base& iter) const
+            {
+                return ptr_ == iter.ptr_;
+            }
+
+            //- inequality
+            bool operator!=(const reverse_iterator_base& iter) const
+            {
+                return ptr_ != iter.ptr_;
+            }
+        };
+
+
+        //- STL reverse_iterator
+        typedef reverse_iterator_base<false> reverse_iterator;
 
         //- Return reverse_iterator to begin reverse traversing the UList
         inline reverse_iterator rbegin();
@@ -345,10 +480,8 @@ public:
         inline reverse_iterator rend();
 
 
-    // STL const_reverse_iterator
-
-        //- Reverse iterator for reverse traversal of constant UList
-        typedef const T* const_reverse_iterator;
+        //- STL const reverse iterator
+        typedef reverse_iterator_base<true> const_reverse_iterator;
 
         //- Return const_reverse_iterator to begin reverse traversing the UList
         inline const_reverse_iterator crbegin() const;
@@ -374,8 +507,8 @@ public:
         //- Return true if the UList is empty (ie, size() is zero)
         inline bool empty() const;
 
-        //- Swap two ULists of the same type in constant time
-        void swap(UList<T>& a);
+        //- Swap content with another UList of the same type in constant time
+        inline void swap(UList<T>& lst);
 
 
     // STL member operators
@@ -407,7 +540,8 @@ public:
         void writeEntry(const word& keyword, Ostream& os) const;
 
         //- Write the List, with line-breaks in ASCII if the list length
-        //  exceeds shortListLen. Using '0' suppresses line-breaks entirely.
+        //- exceeds shortListLen.
+        //  Using '0' suppresses line-breaks entirely.
         Ostream& writeList(Ostream& os, const label shortListLen=0) const;
 
 
@@ -417,7 +551,7 @@ public:
         friend Ostream& operator<< <T>
         (
             Ostream& os,
-            const UList<T>& L
+            const UList<T>& lst
         );
 
         //- Read List contents from Istream.
@@ -429,28 +563,35 @@ public:
         );
 };
 
+
+// Global Functions
+
 template<class T>
 void sort(UList<T>& a);
 
-template<class T, class Cmp>
-void sort(UList<T>& a, const Cmp& cmp);
+template<class T, class Compare>
+void sort(UList<T>& a, const Compare& comp);
 
 template<class T>
 void stableSort(UList<T>& a);
 
-template<class T, class Cmp>
-void stableSort(UList<T>& a, const Cmp& cmp);
+template<class T, class Compare>
+void stableSort(UList<T>& a, const Compare& comp);
 
 template<class T>
 void shuffle(UList<T>& a);
 
 // Reverse the first n elements of the list
 template<class T>
-inline void reverse(UList<T>& ul, const label n);
+inline void reverse(UList<T>& lst, const label n);
 
 // Reverse all the elements of the list
 template<class T>
-inline void reverse(UList<T>& ul);
+inline void reverse(UList<T>& lst);
+
+// Exchange contents of lists - see UList::swap().
+template<class T>
+inline void Swap(UList<T>& a, UList<T>& b);
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H
index 971fa7faa0530ceadb3964ada7746733a85efa37..20cdaae6de2969b9bf2f27101db8357531e90d1c 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListI.H
+++ b/src/OpenFOAM/containers/Lists/UList/UListI.H
@@ -61,6 +61,20 @@ inline Foam::label Foam::UList<T>::fcIndex(const label i) const
 }
 
 
+template<class T>
+inline const T& Foam::UList<T>::fcValue(const label i) const
+{
+    return this->operator[](this->fcIndex(i));
+}
+
+
+template<class T>
+inline T& Foam::UList<T>::fcValue(const label i)
+{
+    return this->operator[](this->fcIndex(i));
+}
+
+
 template<class T>
 inline Foam::label Foam::UList<T>::rcIndex(const label i) const
 {
@@ -68,6 +82,20 @@ inline Foam::label Foam::UList<T>::rcIndex(const label i) const
 }
 
 
+template<class T>
+inline const T& Foam::UList<T>::rcValue(const label i) const
+{
+    return this->operator[](this->rcIndex(i));
+}
+
+
+template<class T>
+inline T& Foam::UList<T>::rcValue(const label i)
+{
+    return this->operator[](this->rcIndex(i));
+}
+
+
 template<class T>
 inline void Foam::UList<T>::checkStart(const label start) const
 {
@@ -152,6 +180,13 @@ inline T* Foam::UList<T>::data()
 }
 
 
+template<class T>
+inline bool Foam::UList<T>::found(const T& val, const label start) const
+{
+    return (this->find(val, start) >= 0);
+}
+
+
 template<class T>
 inline void Foam::UList<T>::shallowCopy(const UList<T>& a)
 {
@@ -251,47 +286,55 @@ Foam::UList<T>::cend() const
 }
 
 template<class T>
-inline typename Foam::UList<T>::iterator
+inline typename Foam::UList<T>::reverse_iterator
 Foam::UList<T>::rbegin()
 {
-    return &v_[size_-1];
+    return reverse_iterator(&v_[size_-1]);
 }
 
 template<class T>
-inline typename Foam::UList<T>::const_iterator
+inline typename Foam::UList<T>::const_reverse_iterator
 Foam::UList<T>::rbegin() const
 {
-    return &v_[size_-1];
+    return const_reverse_iterator(&v_[size_-1]);
 }
 
 template<class T>
-inline typename Foam::UList<T>::const_iterator
+inline typename Foam::UList<T>::const_reverse_iterator
 Foam::UList<T>::crbegin() const
 {
-    return &v_[size_-1];
+    return const_reverse_iterator(&v_[size_-1]);
 }
 
 template<class T>
-inline typename Foam::UList<T>::iterator
+inline typename Foam::UList<T>::reverse_iterator
 Foam::UList<T>::rend()
 {
-    return &v_[-1];
+    return reverse_iterator(&v_[-1]);
 }
 
 template<class T>
-inline typename Foam::UList<T>::const_iterator
+inline typename Foam::UList<T>::const_reverse_iterator
 Foam::UList<T>::rend() const
 {
-    return &v_[-1];
+    return const_reverse_iterator(&v_[-1]);
 }
 
 template<class T>
-inline typename Foam::UList<T>::const_iterator
+inline typename Foam::UList<T>::const_reverse_iterator
 Foam::UList<T>::crend() const
 {
-    return &v_[-1];
+    return const_reverse_iterator(&v_[-1]);
+}
+
+
+template<class T>
+inline void Foam::UList<T>::size(const label n)
+{
+    size_ = n;
 }
 
+
 template<class T>
 inline Foam::label Foam::UList<T>::size() const
 {
@@ -313,21 +356,37 @@ inline bool Foam::UList<T>::empty() const
 }
 
 
+template<class T>
+inline void Foam::UList<T>::swap(UList<T>& lst)
+{
+    Foam::Swap(size_, lst.size_);
+    Foam::Swap(v_, lst.v_);
+}
+
+
 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
 
 template<class T>
-inline void Foam::reverse(UList<T>& ul, const label n)
+inline void Foam::reverse(UList<T>& lst, const label n)
 {
     for (int i=0; i<n/2; ++i)
     {
-        Swap(ul[i], ul[n-1-i]);
+        Foam::Swap(lst[i], lst[n-1-i]);
     }
 }
 
+
+template<class T>
+inline void Foam::reverse(UList<T>& lst)
+{
+    reverse(lst, lst.size());
+}
+
+
 template<class T>
-inline void Foam::reverse(UList<T>& ul)
+inline void Foam::Swap(UList<T>& a, UList<T>& b)
 {
-    reverse(ul, ul.size());
+    a.swap(b);
 }
 
 
diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C
index efb2ad3ffce3935884d40209ef04f8909eef907e..e6f9a97ad543ec21e1fbcbae244969177cc08bc9 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListIO.C
+++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C
@@ -76,14 +76,16 @@ Foam::Ostream& Foam::UList<T>::writeList
 {
     const UList<T>& L = *this;
 
+    const label sz = L.size();
+
     // Write list contents depending on data format
     if (os.format() == IOstream::ASCII || !contiguous<T>())
     {
         // Can the contents be considered 'uniform' (ie, identical)?
-        bool uniform = (L.size() > 1 && contiguous<T>());
+        bool uniform = (sz > 1 && contiguous<T>());
         if (uniform)
         {
-            forAll(L, i)
+            for (label i=1; i < sz; ++i)
             {
                 if (L[i] != L[0])
                 {
@@ -95,58 +97,62 @@ Foam::Ostream& Foam::UList<T>::writeList
 
         if (uniform)
         {
-            // Write size and start delimiter
-            os << L.size() << token::BEGIN_BLOCK;
+            // Size and start delimiter
+            os << sz << token::BEGIN_BLOCK;
 
-            // Write contents
+            // Contents
             os << L[0];
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_BLOCK;
         }
         else if
         (
-            L.size() <= 1 || !shortListLen
-         || (L.size() <= shortListLen && contiguous<T>())
+            sz <= 1 || !shortListLen
+         || (sz <= shortListLen && contiguous<T>())
         )
         {
-            // Write size and start delimiter
-            os << L.size() << token::BEGIN_LIST;
+            // Size and start delimiter
+            os << sz << token::BEGIN_LIST;
 
-            // Write contents
-            forAll(L, i)
+            // Contents
+            for (label i=0; i < sz; ++i)
             {
                 if (i) os << token::SPACE;
                 os << L[i];
             }
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_LIST;
         }
         else
         {
-            // Write size and start delimiter
-            os << nl << L.size() << nl << token::BEGIN_LIST << nl;
+            // Size and start delimiter
+            os << nl << sz << nl << token::BEGIN_LIST << nl;
 
-            // Write contents
-            forAll(L, i)
+            // Contents
+            for (label i=0; i < sz; ++i)
             {
                 os << L[i] << nl;
             }
 
-            // Write end delimiter
+            // End delimiter
             os << token::END_LIST << nl;
         }
     }
     else
     {
         // Contents are binary and contiguous
-        os << nl << L.size() << nl;
+        os << nl << sz << nl;
 
-        if (L.size())
+        if (sz)
         {
             // write(...) includes surrounding start/end delimiters
-            os.write(reinterpret_cast<const char*>(L.cdata()), L.byteSize());
+            os.write
+            (
+                reinterpret_cast<const char*>(L.cdata()),
+                L.byteSize()
+            );
         }
     }
 
@@ -158,9 +164,9 @@ Foam::Ostream& Foam::UList<T>::writeList
 // * * * * * * * * * * * * * * * Ostream Operator *  * * * * * * * * * * * * //
 
 template<class T>
-Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
+Foam::Ostream& Foam::operator<<(Ostream& os, const UList<T>& lst)
 {
-    return L.writeList(os, 10);
+    return lst.writeList(os, 10);
 }
 
 
@@ -184,29 +190,29 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
             )
         );
         // Check list length
-        const label s = elems.size();
+        const label sz = elems.size();
 
-        if (s != L.size())
+        if (sz != L.size())
         {
             FatalIOErrorInFunction(is)
-                << "incorrect length for UList. Read " << s
+                << "incorrect length for UList. Read " << sz
                 << " expected " << L.size()
                 << exit(FatalIOError);
         }
-        for (label i=0; i<s; ++i)
+        for (label i=0; i<sz; ++i)
         {
             L[i] = elems[i];
         }
     }
     else if (firstToken.isLabel())
     {
-        const label s = firstToken.labelToken();
+        const label sz = firstToken.labelToken();
 
         // Set list length to that read
-        if (s != L.size())
+        if (sz != L.size())
         {
             FatalIOErrorInFunction(is)
-                << "incorrect length for UList. Read " << s
+                << "incorrect length for UList. Read " << sz
                 << " expected " << L.size()
                 << exit(FatalIOError);
         }
@@ -218,11 +224,11 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
             // Read beginning of contents
             const char delimiter = is.readBeginList("List");
 
-            if (s)
+            if (sz)
             {
                 if (delimiter == token::BEGIN_LIST)
                 {
-                    for (label i=0; i<s; ++i)
+                    for (label i=0; i<sz; ++i)
                     {
                         is >> L[i];
 
@@ -245,7 +251,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
                         "reading the single entry"
                     );
 
-                    for (label i=0; i<s; ++i)
+                    for (label i=0; i<sz; ++i)
                     {
                         L[i] = element;
                     }
@@ -259,9 +265,9 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
         {
             // contents are binary and contiguous
 
-            if (s)
+            if (sz)
             {
-                is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T));
+                is.read(reinterpret_cast<char*>(L.data()), sz*sizeof(T));
 
                 is.fatalCheck
                 (
diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C
index 2852654dda0f7bf017089075463441f9e7d0044f..33ff3d9878ec65fe9bb7ea869b2d0298c8761157 100644
--- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C
+++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListIO.C
@@ -31,18 +31,20 @@ License
 template<class T>
 Foam::Ostream& Foam::operator<<(Ostream& os, const UPtrList<T>& L)
 {
-    // Write size and start delimiter
-    os  << nl << indent << L.size() << nl
-        << indent << token::BEGIN_LIST << incrIndent;
+    const label sz = L.size();
 
-    // Write contents
-    forAll(L, i)
+    // Size and start delimiter
+    os  << nl << indent << sz << nl
+        << indent << token::BEGIN_LIST << incrIndent << nl;
+
+    // Contents
+    for (label i=0; i < sz; ++i)
     {
-        os << nl << L[i];
+        os << L[i] << nl;
     }
 
-    // Write end delimiter
-    os << nl << decrIndent << indent << token::END_LIST << nl;
+    // End delimiter
+    os << decrIndent << indent << token::END_LIST << nl;
 
     os.check(FUNCTION_NAME);
     return os;
diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C
index 563eb9c5426514de9ee0288dfc7a2508d77794aa..d97bc75153d78b6478839a5e9257bc4dd52443c7 100644
--- a/src/OpenFOAM/db/IOobject/IOobject.C
+++ b/src/OpenFOAM/db/IOobject/IOobject.C
@@ -374,31 +374,13 @@ const Foam::fileName& Foam::IOobject::caseName() const
 
 Foam::word Foam::IOobject::group() const
 {
-    const auto i = name_.rfind('.');
-
-    if (i == std::string::npos || i == 0)
-    {
-        return word::null;
-    }
-    else
-    {
-        return name_.substr(i+1);
-    }
+    return name_.ext();
 }
 
 
 Foam::word Foam::IOobject::member() const
 {
-    const auto i = name_.rfind('.');
-
-    if (i == std::string::npos || i == 0)
-    {
-        return name_;
-    }
-    else
-    {
-        return name_.substr(0, i);
-    }
+    return name_.lessExt();
 }
 
 
diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C
index 6e460ff9f961d858362c6c27fef80d9c93442e09..3f6d1c5ec9fab17551912ecc09250313fab7b277 100644
--- a/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C
+++ b/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.C
@@ -93,7 +93,7 @@ Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f)
 
     if (readOpt() == MUST_READ_IF_MODIFIED)
     {
-        index = findIndex(files_, f);
+        index = files_.find(f);
 
         if (index == -1)
         {
@@ -117,7 +117,7 @@ void Foam::unwatchedIOdictionary::addWatch()
             f = objectPath();
         }
 
-        if (findIndex(files_, f) != -1)
+        if (files_.found(f))
         {
             FatalErrorInFunction
                 << "Object " << objectPath() << " of type " << type()
diff --git a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C
index d5a93363386f08d71b4b46d651ba290019deddaa..21ad121dfb995e65b0a2515ccf71db812419042a 100644
--- a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C
+++ b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C
@@ -30,8 +30,9 @@ License
 #include "Fstream.H"
 #include "StringStream.H"
 #include "dictionary.H"
-#include <sys/time.h>
 #include "objectRegistry.H"
+#include "foamVersion.H"
+#include <sys/time.h>
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -204,6 +205,20 @@ void Foam::decomposedBlockData::writeHeader
         << "    version     " << version << ";\n"
         << "    format      " << format << ";\n"
         << "    class       " << type << ";\n";
+
+    // This may be useful to have as well
+    /*
+    if (os.format() == IOstream::BINARY)
+    {
+        os  << "    arch        " << Foam::FOAMbuildArch << ";\n";
+    }
+    */
+
+    if (Pstream::parRun())
+    {
+        os  << "    blocks      " << Pstream::nProcs() << ";\n";
+    }
+
     if (note.size())
     {
         os  << "    note        " << note << ";\n";
@@ -938,7 +953,7 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
         return nBlocks;
     }
 
-    // Skip header
+    // FoamFile header
     token firstToken(is);
 
     if
@@ -951,8 +966,15 @@ Foam::label Foam::decomposedBlockData::numBlocks(const fileName& fName)
         dictionary headerDict(is);
         is.version(headerDict.lookup("version"));
         is.format(headerDict.lookup("format"));
+
+        // Obtain number of blocks directly
+        if (headerDict.readIfPresent("blocks", nBlocks))
+        {
+            return nBlocks;
+        }
     }
 
+    // Fallback to brute force read of each data block
     List<char> data;
     while (is.good())
     {
diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C
index fd3889618ea47660ed761cb72e81277653730c61..f1c97306ed5bbde3abdb9dc21521ddc58f469cff 100644
--- a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C
+++ b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.C
@@ -167,7 +167,7 @@ const std::istream& Foam::IFstream::stdStream() const
 }
 
 
-Foam::Istream& Foam::IFstream::rewind()
+void Foam::IFstream::rewind()
 {
     lineNumber_ = 1;      // Reset line number
 
@@ -195,8 +195,6 @@ Foam::Istream& Foam::IFstream::rewind()
     {
         ISstream::rewind();
     }
-
-    return *this;
 }
 
 
diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H
index 72f89873c58a92447f7de8320ceac5609d0ee7d5..34f7c7c94838139b7a9e5662b09221d4aeb6549c 100644
--- a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H
+++ b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H
@@ -130,7 +130,7 @@ public:
         virtual const std::istream& stdStream() const;
 
         //- Rewind the stream so that it may be read again
-        virtual Istream& rewind();
+        virtual void rewind();
 
 
       // Print
diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C
index 25ee28e005574b0cfc9dfa2b531fca4f34c3185b..941b78cfd6e370b3af8740cf1dbc34b14d1fd040 100644
--- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C
+++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.C
@@ -27,7 +27,7 @@ License
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void Foam::Istream::putBack(const token& t)
+void Foam::Istream::putBack(const token& tok)
 {
     if (bad())
     {
@@ -43,13 +43,13 @@ void Foam::Istream::putBack(const token& t)
     }
     else
     {
-        putBackToken_ = t;
+        putBackToken_ = tok;
         putBack_ = true;
     }
 }
 
 
-bool Foam::Istream::getBack(token& t)
+bool Foam::Istream::getBack(token& tok)
 {
     if (bad())
     {
@@ -59,7 +59,7 @@ bool Foam::Istream::getBack(token& t)
     }
     else if (putBack_)
     {
-        t = putBackToken_;
+        tok = putBackToken_;
         putBack_ = false;
         return true;
     }
@@ -68,15 +68,15 @@ bool Foam::Istream::getBack(token& t)
 }
 
 
-bool Foam::Istream::peekBack(token& t)
+bool Foam::Istream::peekBack(token& tok)
 {
     if (putBack_)
     {
-        t = putBackToken_;
+        tok = putBackToken_;
     }
     else
     {
-        t = token::undefinedToken;
+        tok = token::undefinedToken;
     }
 
     return putBack_;
diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H
index 77131761969e0ca866f446bbdf277864f912ae3e..e55211309d8625d6bf81aa8d18542dd00a353593 100644
--- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H
+++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H
@@ -96,16 +96,16 @@ public:
 
             //- Put back token
             //  Only a single put back is permitted
-            void putBack(const token&);
+            void putBack(const token& tok);
 
             //- Get the put back token if there is one and return true.
             //  Return false if no put back token is available.
-            bool getBack(token&);
+            bool getBack(token& tok);
 
             //- Peek at the put back token without removing it.
             //  Returns false if no put back token is available and set the
             //  token to undefined.
-            bool peekBack(token&);
+            bool peekBack(token& tok);
 
             //- Return next token from stream
             virtual Istream& read(token&) = 0;
@@ -116,7 +116,7 @@ public:
             //- Read a word
             virtual Istream& read(word&) = 0;
 
-            // Read a string (including enclosing double-quotes)
+            //- Read a string (including enclosing double-quotes)
             virtual Istream& read(string&) = 0;
 
             //- Read a label
@@ -131,8 +131,8 @@ public:
             //- Read binary block
             virtual Istream& read(char*, std::streamsize) = 0;
 
-            //- Rewind and return the stream so that it may be read again
-            virtual Istream& rewind() = 0;
+            //- Rewind the stream so that it may be read again
+            virtual void rewind() = 0;
 
 
         // Read List punctuation tokens
diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
index 3604a22d0be60e68812e83f64e6b015aeb04cfb2..1c6d2131bc96b8ad95aac1bf1a643ae6a1284b6a 100644
--- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
+++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -96,48 +96,64 @@ public:
 
         // Write functions
 
-            //- Write next token to stream
-            virtual Ostream& write(const token&) = 0;
+            //- Write token to stream or otherwise handle it.
+            //  \return false if the token type was not handled by this method
+            virtual bool write(const token& tok) = 0;
 
             //- Write character
-            virtual Ostream& write(const char) = 0;
+            virtual Ostream& write(const char c) = 0;
 
             //- Write character string
-            virtual Ostream& write(const char*) = 0;
+            virtual Ostream& write(const char* str) = 0;
 
             //- Write word
-            virtual Ostream& write(const word&) = 0;
+            virtual Ostream& write(const word& str) = 0;
 
             //- Write keyType
             //  A plain word is written unquoted.
             //  A regular expression is written as a quoted string.
-            virtual Ostream& write(const keyType&);
+            virtual Ostream& write(const keyType& kw);
 
             //- Write string
-            virtual Ostream& write(const string&) = 0;
+            virtual Ostream& write(const string& str) = 0;
 
             //- Write std::string surrounded by quotes.
             //  Optional write without quotes.
             virtual Ostream& writeQuoted
             (
-                const std::string&,
+                const std::string& str,
                 const bool quoted=true
             ) = 0;
 
             //- Write int32_t
-            virtual Ostream& write(const int32_t) = 0;
+            virtual Ostream& write(const int32_t val) = 0;
 
             //- Write int64_t
-            virtual Ostream& write(const int64_t) = 0;
+            virtual Ostream& write(const int64_t val) = 0;
 
             //- Write floatScalar
-            virtual Ostream& write(const floatScalar) = 0;
+            virtual Ostream& write(const floatScalar val) = 0;
 
             //- Write doubleScalar
-            virtual Ostream& write(const doubleScalar) = 0;
+            virtual Ostream& write(const doubleScalar val) = 0;
 
-            //- Write binary block
-            virtual Ostream& write(const char*, std::streamsize) = 0;
+            //- Write binary block.
+            virtual Ostream& write(const char* data, std::streamsize count) = 0;
+
+            //- Emit begin marker for low-level raw binary output.
+            //  The count should indicate the number of bytes for subsequent
+            //  writeRaw calls.
+            virtual Ostream& beginRaw(std::streamsize count) = 0;
+
+            //- Low-level raw binary output.
+            virtual Ostream& writeRaw
+            (
+                const char* data,
+                std::streamsize count
+            ) = 0;
+
+            //- Emit end marker for low-level raw binary output.
+            virtual Ostream& endRaw() = 0;
 
             //- Add indentation characters
             virtual void indent() = 0;
@@ -164,11 +180,11 @@ public:
             void decrIndent();
 
             //- Write the keyword followed by an appropriate indentation
-            virtual Ostream& writeKeyword(const keyType&);
+            virtual Ostream& writeKeyword(const keyType& kw);
 
             //- Write begin block group with the given name
             //  Increments indentation, adds newline.
-            virtual Ostream& beginBlock(const keyType&);
+            virtual Ostream& beginBlock(const keyType& keyword);
 
             //- Write begin block group without a name
             //  Increments indentation, adds newline.
@@ -195,6 +211,26 @@ public:
                 return endEntry();
             }
 
+            //- Write a keyword/value entry only when the two values differ.
+            //  \param key the name of the entry
+            //  \param value1 the reference value
+            //  \param value2 the value to write if it differs from value1
+            template<class T>
+            Ostream& writeEntryIfDifferent
+            (
+                const word& key,
+                const T& value1,
+                const T& value2
+            )
+            {
+                if (value1 != value2)
+                {
+                    writeEntry(key, value2);
+                }
+
+                return *this;
+            }
+
 
         // Stream state functions
 
@@ -314,8 +350,8 @@ inline Ostream& endEntry(Ostream& os)
 
 
 // Useful aliases for tab and newline characters
-static const char tab = '\t';
-static const char nl = '\n';
+constexpr char tab = '\t';
+constexpr char nl = '\n';
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C
index 333aeca259c72b0a1b8edbc98155725df7aab477..76f9706093821963df3f93e2342cd7979f05ad1c 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -29,6 +29,24 @@ License
 #include "token.H"
 #include <cctype>
 
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+// Adjust stream format based on the flagMask
+inline static void processFlags(Istream& is, int flagMask)
+{
+    if ((flagMask & token::ASCII))
+    {
+        is.format(IOstream::ASCII);
+    }
+    else if ((flagMask & token::BINARY))
+    {
+        is.format(IOstream::BINARY);
+    }
+}
+}
+
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
@@ -42,12 +60,12 @@ inline void Foam::UIPstream::checkEof()
 
 
 template<class T>
-inline void Foam::UIPstream::readFromBuffer(T& t)
+inline void Foam::UIPstream::readFromBuffer(T& val)
 {
     const size_t align = sizeof(T);
     externalBufPosition_ = align + ((externalBufPosition_ - 1) & ~(align - 1));
 
-    t = reinterpret_cast<T&>(externalBuf_[externalBufPosition_]);
+    val = reinterpret_cast<T&>(externalBuf_[externalBufPosition_]);
     externalBufPosition_ += sizeof(T);
     checkEof();
 }
@@ -67,10 +85,14 @@ inline void Foam::UIPstream::readFromBuffer
           + ((externalBufPosition_ - 1) & ~(align - 1));
     }
 
-    const char* bufPtr = &externalBuf_[externalBufPosition_];
-    char* dataPtr = reinterpret_cast<char*>(data);
-    size_t i = count;
-    while (i--) *dataPtr++ = *bufPtr++;
+    const char* const __restrict__ buf = &externalBuf_[externalBufPosition_];
+    char* const __restrict__ output = reinterpret_cast<char*>(data);
+
+    for (size_t i = 0; i < count; ++i)
+    {
+        output[i] = buf[i];
+    }
+
     externalBufPosition_ += count;
     checkEof();
 }
@@ -78,14 +100,15 @@ inline void Foam::UIPstream::readFromBuffer
 
 inline Foam::Istream& Foam::UIPstream::readStringFromBuffer(std::string& str)
 {
+    // Use std::string::assign() to copy content, including '\0'.
+    // Stripping (when desired) is the responsibility of the sending side.
+
     size_t len;
     readFromBuffer(len);
-    // Uses the underlying std::string::operator=()
-    // - no stripInvalid invoked (the sending side should have done that)
-    // - relies on trailing '\0' char (so cannot send anything with an embedded
-    //   nul char)
-    str = &externalBuf_[externalBufPosition_];
-    externalBufPosition_ += len + 1;
+
+    str.assign(&externalBuf_[externalBufPosition_], len);
+
+    externalBufPosition_ += len;
     checkEof();
 
     return *this;
@@ -116,19 +139,48 @@ Foam::UIPstream::~UIPstream()
 Foam::Istream& Foam::UIPstream::read(token& t)
 {
     // Return the put back token if it exists
+    // - with additional handling for special stream flags
     if (Istream::getBack(t))
     {
-        return *this;
+        if (t.isFlag())
+        {
+            processFlags(*this, t.flagToken());
+        }
+        else
+        {
+            return *this;
+        }
     }
 
-    char c;
+    // Read character, return on error
+    // - with additional handling for special stream flags
 
-    // Return on error
-    if (!read(c))
+    char c;
+    do
     {
-        t.setBad();
-        return *this;
+        if (!read(c))
+        {
+            t.setBad();   // Error
+            return *this;
+        }
+
+        if (c == token::FLAG)
+        {
+            char flagVal;
+
+            if (read(flagVal))
+            {
+                processFlags(*this, flagVal);
+            }
+            else
+            {
+                t.setBad();   // Error
+                return *this;
+            }
+        }
     }
+    while (c == token::FLAG);
+
 
     // Set the line number of this token to the current stream line number
     t.lineNumber() = lineNumber();
@@ -159,22 +211,20 @@ Foam::Istream& Foam::UIPstream::read(token& t)
         // Word
         case token::tokenType::WORD :
         {
-            word* pval = new word;
-            if (read(*pval))
+            word val;
+            if (read(val))
             {
-                if (token::compound::isCompound(*pval))
+                if (token::compound::isCompound(val))
                 {
-                    t = token::compound::New(*pval, *this).ptr();
-                    delete pval;
+                    t = token::compound::New(val, *this).ptr();
                 }
                 else
                 {
-                    t = pval;
+                    t = std::move(val);
                 }
             }
             else
             {
-                delete pval;
                 t.setBad();
             }
             return *this;
@@ -185,26 +235,25 @@ Foam::Istream& Foam::UIPstream::read(token& t)
         {
             // Recurse to read actual string
             read(t);
-            t.type() = token::tokenType::VERBATIMSTRING;
+            t.setType(token::tokenType::VERBATIMSTRING);
             return *this;
         }
         case token::tokenType::VARIABLE :
         {
             // Recurse to read actual string
             read(t);
-            t.type() = token::tokenType::VARIABLE;
+            t.setType(token::tokenType::VARIABLE);
             return *this;
         }
         case token::tokenType::STRING :
         {
-            string* pval = new string;
-            if (read(*pval))
+            string val;
+            if (read(val))
             {
-                t = pval;
+                t = std::move(val);
             }
             else
             {
-                delete pval;
                 t.setBad();
             }
             return *this;
@@ -276,7 +325,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
 Foam::Istream& Foam::UIPstream::read(char& c)
 {
     c = externalBuf_[externalBufPosition_];
-    externalBufPosition_++;
+    ++externalBufPosition_;
     checkEof();
     return *this;
 }
@@ -329,10 +378,9 @@ Foam::Istream& Foam::UIPstream::read(char* data, std::streamsize count)
 }
 
 
-Foam::Istream& Foam::UIPstream::rewind()
+void Foam::UIPstream::rewind()
 {
     externalBufPosition_ = 0;
-    return *this;
 }
 
 
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H
index 4913693741f8b24e50f858947f6ec90b5943a3bd..04115646f127b29f9764dc8727529ba8406b3091 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H
@@ -80,7 +80,7 @@ class UIPstream
 
         //- Read a T from the transfer buffer
         template<class T>
-        inline void readFromBuffer(T& t);
+        inline void readFromBuffer(T& val);
 
         //- Read count bytes of data from the transfer buffer
         //  using align byte alignment
@@ -171,8 +171,8 @@ public:
             //- Read binary block with 8-byte alignment.
             Istream& read(char* data, const std::streamsize count);
 
-            //- Rewind and return the stream so that it may be read again
-            Istream& rewind();
+            //- Rewind the stream so that it may be read again
+            void rewind();
 
 
         // Edit
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C
index 6667389b742231d9e691716d6dc487a3503db62a..6b5a46ed6f2d2f6d75167703583f83f0efe5f1bb 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,15 +26,42 @@ License
 #include "UOPstream.H"
 #include "int.H"
 #include "token.H"
-
 #include <cctype>
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+inline void Foam::UOPstream::prepareBuffer
+(
+    const size_t count,
+    const size_t align
+)
+{
+    if (!count)
+    {
+        return;
+    }
+
+    // The current output position
+    label pos = sendBuf_.size();
+
+    if (align > 1)
+    {
+        // Align output position. Pads sendBuf_.size() - oldPos characters.
+        pos = align + ((pos - 1) & ~(align - 1));
+    }
+
+    // Extend buffer (as required)
+    sendBuf_.reserve(max(1000, label(pos + count)));
+
+    // Move to the aligned output position
+    sendBuf_.setSize(pos);
+}
+
+
 template<class T>
-inline void Foam::UOPstream::writeToBuffer(const T& t)
+inline void Foam::UOPstream::writeToBuffer(const T& val)
 {
-    writeToBuffer(&t, sizeof(T), sizeof(T));
+    writeToBuffer(&val, sizeof(T), sizeof(T));
 }
 
 
@@ -55,25 +82,26 @@ inline void Foam::UOPstream::writeToBuffer
     const size_t align
 )
 {
-    if (!sendBuf_.capacity())
+    if (!count)
     {
-        sendBuf_.setCapacity(1000);
+        return;
     }
 
-    label alignedPos = sendBuf_.size();
+    prepareBuffer(count, align);
 
-    if (align > 1)
-    {
-        // Align bufPosition. Pads sendBuf_.size() - oldPos characters.
-        alignedPos = align + ((sendBuf_.size() - 1) & ~(align - 1));
-    }
+    // The aligned output position
+    const label pos = sendBuf_.size();
+
+    // Extend the addressable range for direct pointer access
+    sendBuf_.setSize(pos + count);
 
-    // Extend if necessary
-    sendBuf_.setSize(alignedPos + count);
+    char* const __restrict__ buf = (sendBuf_.begin() + pos);
+    const char* const __restrict__ input = reinterpret_cast<const char*>(data);
 
-    const char* dataPtr = reinterpret_cast<const char*>(data);
-    size_t i = count;
-    while (i--) sendBuf_[alignedPos++] = *dataPtr++;
+    for (size_t i = 0; i < count; ++i)
+    {
+        buf[i] = input[i];
+    }
 }
 
 
@@ -81,7 +109,7 @@ inline void Foam::UOPstream::writeStringToBuffer(const std::string& str)
 {
     const size_t len = str.size();
     writeToBuffer(len);
-    writeToBuffer(str.c_str(), len + 1, 1);
+    writeToBuffer(str.data(), len, 1);
 }
 
 
@@ -135,7 +163,7 @@ Foam::UOPstream::~UOPstream()
     {
         if
         (
-           !UOPstream::write
+            !UOPstream::write
             (
                 commsType_,
                 toProcNo_,
@@ -157,25 +185,41 @@ Foam::UOPstream::~UOPstream()
 
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
-Foam::Ostream& Foam::UOPstream::write(const token& t)
+bool Foam::UOPstream::write(const token& tok)
 {
-    // Raw token output only supported for verbatim strings for now
-    if (t.type() == token::tokenType::VERBATIMSTRING)
-    {
-        writeToBuffer(char(token::tokenType::VERBATIMSTRING));
-        write(t.stringToken());
-    }
-    else if (t.type() == token::tokenType::VARIABLE)
-    {
-        writeToBuffer(char(token::tokenType::VARIABLE));
-        write(t.stringToken());
-    }
-    else
+    // Direct token handling only for some types
+
+    switch (tok.type())
     {
-        NotImplemented;
-        setBad();
+        case token::tokenType::FLAG :
+        {
+            writeToBuffer(char(token::tokenType::FLAG));
+            writeToBuffer(char(tok.flagToken()));
+
+            return true;
+        }
+
+        case token::tokenType::VERBATIMSTRING :
+        {
+            writeToBuffer(char(token::tokenType::VERBATIMSTRING));
+            write(tok.stringToken());
+
+            return true;
+        }
+
+        case token::tokenType::VARIABLE :
+        {
+            writeToBuffer(char(token::tokenType::VARIABLE));
+            write(tok.stringToken());
+
+            return true;
+        }
+
+        default:
+            break;
     }
-    return *this;
+
+    return false;
 }
 
 
@@ -298,6 +342,41 @@ Foam::Ostream& Foam::UOPstream::write
 }
 
 
+Foam::Ostream& Foam::UOPstream::beginRaw
+(
+    const std::streamsize count
+)
+{
+    if (format() != BINARY)
+    {
+        FatalErrorInFunction
+            << "stream format not binary"
+            << Foam::abort(FatalError);
+    }
+
+    // Alignment = 8, as per write(const char*, streamsize)
+    prepareBuffer(count, 8);
+
+    return *this;
+}
+
+
+Foam::Ostream& Foam::UOPstream::writeRaw
+(
+    const char* data,
+    const std::streamsize count
+)
+{
+    // No check for format() == BINARY since this is either done in the
+    // beginRaw() method, or the caller knows what they are doing.
+
+    // Previously aligned and sizes reserved via beginRaw()
+    writeToBuffer(data, count, 1);
+
+    return *this;
+}
+
+
 void Foam::UOPstream::print(Ostream& os) const
 {
     os  << "Writing from processor " << toProcNo_
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H
index 6ee40e03781dc5042ca3b36d08bcaa639d425671..3287c62cd42ebfebd0683cf6de74d186bf5e1eca 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -72,9 +72,12 @@ class UOPstream
 
     // Private Member Functions
 
-        //- Write a T to the transfer buffer
+        //- Prepare buffer for count bytes of output at specified alignment.
+        inline void prepareBuffer(const size_t count, const size_t align);
+
+        //- Write data to the transfer buffer
         template<class T>
-        inline void writeToBuffer(const T& t);
+        inline void writeToBuffer(const T& val);
 
         //- Write a char to the transfer buffer
         inline void writeToBuffer(const char& c);
@@ -124,7 +127,7 @@ public:
         // Inquiry
 
             //- Return flags of output stream
-            ios_base::fmtflags flags() const
+            virtual ios_base::fmtflags flags() const
             {
                 return ios_base::fmtflags(0);
             }
@@ -143,25 +146,26 @@ public:
                 const label communicator = 0
             );
 
-            //- Write next token to stream
-            Ostream& write(const token& t);
+            //- Write token to stream or otherwise handle it.
+            //  \return false if the token type was not handled by this method
+            virtual bool write(const token& tok);
 
             //- Write single character. Whitespace is suppressed.
-            Ostream& write(const char c);
+            virtual Ostream& write(const char c);
 
             //- Write the word-characters of a character string.
             //  Sends as a single char, or as word.
-            Ostream& write(const char* str);
+            virtual Ostream& write(const char* str);
 
             //- Write word
-            Ostream& write(const word& str);
+            virtual Ostream& write(const word& str);
 
             //- Write string
-            Ostream& write(const string& str);
+            virtual Ostream& write(const string& str);
 
             //- Write std::string surrounded by quotes.
             //  Optional write without quotes.
-            Ostream& writeQuoted
+            virtual Ostream& writeQuoted
             (
                 const std::string& str,
                 const bool quoted=true
@@ -171,52 +175,74 @@ public:
             virtual Ostream& write(const int32_t val);
 
             //- Write int64_t as a label
-            Ostream& write(const int64_t val);
+            virtual Ostream& write(const int64_t val);
 
             //- Write floatScalar
-            Ostream& write(const floatScalar val);
+            virtual Ostream& write(const floatScalar val);
 
             //- Write doubleScalar
-            Ostream& write(const doubleScalar val);
+            virtual Ostream& write(const doubleScalar val);
 
             //- Write binary block with 8-byte alignment.
-            Ostream& write(const char* data, const std::streamsize count);
+            virtual Ostream& write
+            (
+                const char* data,
+                const std::streamsize count
+            );
+
+            //- Begin marker for low-level raw binary output.
+            //  The count should indicate the number of bytes for subsequent
+            //  writeRaw calls.
+            virtual Ostream& beginRaw(const std::streamsize count);
+
+            //- Low-level raw binary output.
+            virtual Ostream& writeRaw
+            (
+                const char* data,
+                const std::streamsize count
+            );
+
+            //- End marker for low-level raw binary output.
+            virtual Ostream& endRaw()
+            {
+                return *this;
+            }
 
             //- Add indentation characters
-            void indent()
+            virtual void indent()
             {}
 
 
         // Stream state functions
 
             //- Flush stream
-            void flush()
+            virtual void flush()
             {}
 
             //- Add newline and flush stream
-            void endl()
+            virtual void endl()
             {}
 
             //- Get width of output field
-            int width() const
+            virtual int width() const
             {
                 return 0;
             }
 
             //- Set width of output field (and return old width)
-            int width(const int)
+            virtual int width(const int)
             {
                  return 0;
             }
 
             //- Get precision of output field
-            int precision() const
+            virtual int precision() const
             {
                  return 0;
             }
 
             //- Set precision of output field (and return old precision)
-            int precision(const int)
+            virtual int precision(const int)
             {
                  return 0;
             }
diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C
index 9bd97a134993e2b87430cc2e6e33a257974952eb..4c72c28cc202cf9878992eb9c8ee6d10ffb427dd 100644
--- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C
+++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C
@@ -219,12 +219,12 @@ Foam::label Foam::UPstream::procNo(const label myComm, const int baseProcID)
 
     if (parentComm == -1)
     {
-        return findIndex(parentRanks, baseProcID);
+        return parentRanks.find(baseProcID);
     }
     else
     {
-        label parentRank = procNo(parentComm, baseProcID);
-        return findIndex(parentRanks, parentRank);
+        const label parentRank = procNo(parentComm, baseProcID);
+        return parentRanks.find(parentRank);
     }
 }
 
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C
index 40c2d8e5950f39b6bc7d929944eb8d4a33f92c23..804eb97858c20d8a5d8a9d3d32a5b58ef7ab933e 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -28,6 +28,12 @@ License
 #include "token.H"
 #include <cctype>
 
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+// Truncate error message for readability
+static const unsigned errLen = 80;
+
+
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
 char Foam::ISstream::nextValid()
@@ -43,7 +49,7 @@ char Foam::ISstream::nextValid()
         // Return if stream is bad - ie, previous get() failed
         if (bad() || isspace(c))
         {
-            break;
+            return 0;
         }
 
         // Is this the start of a C/C++ comment?
@@ -51,7 +57,7 @@ char Foam::ISstream::nextValid()
         {
             if (!get(c))
             {
-                // cannot get another character - return this one
+                // Cannot get another character - return this one
                 return '/';
             }
 
@@ -63,10 +69,10 @@ char Foam::ISstream::nextValid()
             }
             else if (c == '*')
             {
-                // within a C-style comment
+                // Within a C-style comment
                 while (true)
                 {
-                    // search for end of C-style comment - '*/'
+                    // Search for end of C-style comment - '*/'
                     if (get(c) && c == '*')
                     {
                         if (get(c))
@@ -99,7 +105,7 @@ char Foam::ISstream::nextValid()
         }
         else
         {
-            // a valid character - return it
+            // A valid character - return it
             return c;
         }
     }
@@ -110,28 +116,25 @@ char Foam::ISstream::nextValid()
 
 void Foam::ISstream::readWordToken(token& t)
 {
-    word* wPtr = new word;
-
-    if (read(*wPtr).bad())
+    word val;
+    if (read(val).bad())
     {
-        delete wPtr;
         t.setBad();
     }
-    else if (token::compound::isCompound(*wPtr))
+    else if (token::compound::isCompound(val))
     {
-        t = token::compound::New(*wPtr, *this).ptr();
-        delete wPtr;
+        t = token::compound::New(val, *this).ptr();
     }
     else
     {
-        t = wPtr;
+        t = std::move(val); // Move contents to token
     }
 }
 
 
 Foam::Istream& Foam::ISstream::read(token& t)
 {
-    static const int maxLen = 128;
+    static const unsigned maxLen = 128;  // When parsing labels or scalars
     static char buf[maxLen];
 
     // Return the put back token if it exists
@@ -151,7 +154,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
     // Set the line number of this token to the current stream line number
     t.lineNumber() = lineNumber();
 
-    // return on error
+    // Return on error
     if (!c)
     {
         t.setBad();
@@ -161,7 +164,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
     // Analyse input starting with this character.
     switch (c)
     {
-        // Check for punctuation first
+        // Check for punctuation first - same as token::isSeparator
 
         case token::END_STATEMENT :
         case token::BEGIN_LIST :
@@ -182,101 +185,96 @@ Foam::Istream& Foam::ISstream::read(token& t)
             return *this;
         }
 
-
         // String: enclosed by double quotes.
         case token::BEGIN_STRING :
         {
             putback(c);
-            string* sPtr = new string;
 
-            if (read(*sPtr).bad())
+            string val;
+            if (read(val).bad())
             {
-                delete sPtr;
                 t.setBad();
             }
             else
             {
-                t = sPtr;
+                t = std::move(val); // Move contents to token
             }
 
             return *this;
         }
+
         // Possible verbatim string or dictionary functionEntry
         case token::HASH :
         {
             char nextC;
             if (read(nextC).bad())
             {
-                // Return hash as word
+                // Return lone '#' as word
                 t = token(word(c));
-                return *this;
             }
             else if (nextC == token::BEGIN_BLOCK)
             {
-                // Verbatim string
-                string* sPtr = new string;
+                // Verbatim string: #{ ... #}
 
-                if (readVerbatim(*sPtr).bad())
+                string val;
+                if (readVerbatim(val).bad())
                 {
-                    delete sPtr;
                     t.setBad();
                 }
                 else
                 {
-                    t = sPtr;
-                    t.type() = token::tokenType::VERBATIMSTRING;
+                    t = std::move(val); // Move contents to token
+                    t.setType(token::tokenType::VERBATIMSTRING);
                 }
-
-                return *this;
             }
             else
             {
-                // Word beginning with #
+                // Word beginning with '#'. Eg, "#include"
                 putback(nextC);
                 putback(c);
 
                 readWordToken(t);
-
-                return *this;
             }
+
+            return *this;
         }
 
+        // Dictionary variable (as rvalue)
         case '$':
         {
-            // Look ahead
             char nextC;
             if (read(nextC).bad())
             {
-                // Return $ as word
+                // Return lone '$' as word
                 t = token(word(c));
-                return *this;
             }
             else if (nextC == token::BEGIN_BLOCK)
             {
+                // Put back so that "${" is included in the variable
                 putback(nextC);
                 putback(c);
 
-                string* sPtr = new string;
-
-                if (readVariable(*sPtr).bad())
+                string val;
+                if (readVariable(val).bad())
                 {
-                    delete sPtr;
                     t.setBad();
                 }
                 else
                 {
-                    t = sPtr;
-                    t.type() = token::tokenType::VARIABLE;
+                    t = std::move(val); // Move contents to token
+                    t.setType(token::tokenType::VARIABLE);
                 }
-                return *this;
             }
             else
             {
+                // Word/variable beginning with '$', but without "{}"
+
                 putback(nextC);
                 putback(c);
                 readWordToken(t);
-                return *this;
             }
+
+            return *this;
         }
 
         // Number: integer or floating point
@@ -290,9 +288,9 @@ Foam::Istream& Foam::ISstream::read(token& t)
         case '0' : case '1' : case '2' : case '3' : case '4' :
         case '5' : case '6' : case '7' : case '8' : case '9' :
         {
-            bool asLabel = (c != '.');
+            label labelVal = (c != '.'); // used as bool here
 
-            int nChar = 0;
+            unsigned nChar = 0;
             buf[nChar++] = c;
 
             // get everything that could resemble a number and let
@@ -310,9 +308,9 @@ Foam::Istream& Foam::ISstream::read(token& t)
                 )
             )
             {
-                if (asLabel)
+                if (labelVal)
                 {
-                    asLabel = isdigit(c);
+                    labelVal = isdigit(c);
                 }
 
                 buf[nChar++] = c;
@@ -343,43 +341,25 @@ Foam::Istream& Foam::ISstream::read(token& t)
 
                 if (nChar == 1 && buf[0] == '-')
                 {
-                    // a single '-' is punctuation
+                    // A single '-' is punctuation
                     t = token::punctuationToken(token::SUBTRACT);
                 }
+                else if (labelVal && Foam::read(buf, labelVal))
+                {
+                    t = labelVal;
+                }
                 else
                 {
-                    if (asLabel)
+                    scalar scalarVal;
+
+                    if (readScalar(buf, scalarVal))
                     {
-                        label labelVal = 0;
-                        if (Foam::read(buf, labelVal))
-                        {
-                            t = labelVal;
-                        }
-                        else
-                        {
-                            // Maybe too big? Try as scalar
-                            scalar scalarVal;
-                            if (readScalar(buf, scalarVal))
-                            {
-                                t = scalarVal;
-                            }
-                            else
-                            {
-                                t.setBad();
-                            }
-                        }
+                        // A scalar or too big to fit as a label
+                        t = scalarVal;
                     }
                     else
                     {
-                        scalar scalarVal;
-                        if (readScalar(buf, scalarVal))
-                        {
-                            t = scalarVal;
-                        }
-                        else
-                        {
-                            t.setBad();
-                        }
+                        t.setBad();
                     }
                 }
             }
@@ -409,28 +389,28 @@ Foam::Istream& Foam::ISstream::read(char& c)
 
 Foam::Istream& Foam::ISstream::read(word& str)
 {
-    static const int maxLen = 1024;
-    static const int errLen = 80; // truncate error message for readability
+    static const unsigned maxLen = 1024;
     static char buf[maxLen];
 
-    int nChar = 0;
-    int listDepth = 0;
+    unsigned nChar = 0;
+    unsigned depth = 0;  // Track depth of "()" nesting
     char c;
 
     while (get(c) && word::valid(c))
     {
         if (c == token::BEGIN_LIST)
         {
-            listDepth++;
+            ++depth;
         }
         else if (c == token::END_LIST)
         {
-            if (listDepth)
+            if (depth)
             {
-                listDepth--;
+                --depth;
             }
             else
             {
+                // Had ')' without a previous '(' ... stop
                 break;
             }
         }
@@ -449,10 +429,13 @@ Foam::Istream& Foam::ISstream::read(word& str)
         }
     }
 
-    // we could probably skip this check
+    // Terminate string with nul char
+    buf[nChar] = '\0';
+
+    // We could probably skip this check
     if (bad())
     {
-        buf[errLen] = buf[nChar] = '\0';
+        buf[errLen] = '\0';
 
         FatalIOErrorInFunction(*this)
             << "problem while reading word '" << buf << "...' after "
@@ -468,9 +451,14 @@ Foam::Istream& Foam::ISstream::read(word& str)
             << "invalid first character found : " << c
             << exit(FatalIOError);
     }
+    else if (depth)
+    {
+        IOWarningInFunction(*this)
+            << "Missing " << depth << " closing ')' while parsing" << nl << nl
+            << buf << nl << endl;
+    }
 
-    // done reading
-    buf[nChar] = '\0';
+    // Finalize
     str = buf;
     putback(c);
 
@@ -480,8 +468,7 @@ Foam::Istream& Foam::ISstream::read(word& str)
 
 Foam::Istream& Foam::ISstream::read(string& str)
 {
-    static const int maxLen = 1024;
-    static const int errLen = 80; // truncate error message for readability
+    static const unsigned maxLen = 1024;
     static char buf[maxLen];
 
     char c;
@@ -505,7 +492,7 @@ Foam::Istream& Foam::ISstream::read(string& str)
         return *this;
     }
 
-    int nChar = 0;
+    unsigned nChar = 0;
     bool escaped = false;
 
     while (get(c))
@@ -515,11 +502,11 @@ Foam::Istream& Foam::ISstream::read(string& str)
             if (escaped)
             {
                 escaped = false;
-                nChar--;    // overwrite backslash
+                --nChar;    // Overwrite backslash
             }
             else
             {
-                // done reading
+                // Done reading
                 buf[nChar] = '\0';
                 str = buf;
                 return *this;
@@ -530,7 +517,7 @@ Foam::Istream& Foam::ISstream::read(string& str)
             if (escaped)
             {
                 escaped = false;
-                nChar--;    // overwrite backslash
+                --nChar;    // Overwrite backslash
             }
             else
             {
@@ -581,12 +568,11 @@ Foam::Istream& Foam::ISstream::read(string& str)
 
 Foam::Istream& Foam::ISstream::readVariable(string& str)
 {
-    static const int maxLen = 1024;
-    static const int errLen = 80; // truncate error message for readability
+    static const unsigned maxLen = 1024;
     static char buf[maxLen];
 
-    int nChar = 0;
-    int blockCount = 0;
+    unsigned nChar = 0;
+    unsigned depth = 0;  // Track depth of "{}" nesting
     char c;
 
     if (!get(c) || c != '$')
@@ -601,8 +587,8 @@ Foam::Istream& Foam::ISstream::readVariable(string& str)
     // Read next character to see if '{'
     if (get(c) && c == token::BEGIN_BLOCK)
     {
-        // Read, counting brackets
         buf[nChar++] = c;
+        ++depth;  // Starts with '{'
 
         // Also allow '/' between ${...} blocks for slash-scoping of entries
         while
@@ -615,34 +601,35 @@ Foam::Istream& Foam::ISstream::readVariable(string& str)
             )
         )
         {
-            buf[nChar++] = c;
-            if (nChar == maxLen)
-            {
-                buf[errLen] = '\0';
-
-                FatalIOErrorInFunction(*this)
-                    << "variable '" << buf << "...'\n"
-                    << "    is too long (max. " << maxLen << " characters)"
-                    << exit(FatalIOError);
-
-                return *this;
-            }
-
             if (c == token::BEGIN_BLOCK)
             {
-                blockCount++;
+                ++depth;
             }
             else if (c == token::END_BLOCK)
             {
-                if (blockCount)
+                if (depth)
                 {
-                    blockCount--;
+                    --depth;
                 }
                 else
                 {
+                    // Had '}' without a previous '{' ... stop
                     break;
                 }
             }
+
+            buf[nChar++] = c;
+            if (nChar == maxLen)
+            {
+                buf[errLen] = '\0';
+
+                FatalIOErrorInFunction(*this)
+                    << "variable '" << buf << "...'\n"
+                    << "    is too long (max. " << maxLen << " characters)"
+                    << exit(FatalIOError);
+
+                return *this;
+            }
         }
     }
     else
@@ -666,10 +653,13 @@ Foam::Istream& Foam::ISstream::readVariable(string& str)
         }
     }
 
+    // Terminate string with nul char
+    buf[nChar] = '\0';
+
     // we could probably skip this check
     if (bad())
     {
-        buf[errLen] = buf[nChar] = '\0';
+        buf[errLen] = '\0';
 
         FatalIOErrorInFunction(*this)
             << "problem while reading string '" << buf << "...' after "
@@ -685,31 +675,29 @@ Foam::Istream& Foam::ISstream::readVariable(string& str)
             << "invalid first character found : " << c
             << exit(FatalIOError);
     }
-
-    // done reading
-    buf[nChar] = '\0';
-    str = buf;
-
-    // Note: check if we exited due to '}' or just !word::valid.
-    if (c != token::END_BLOCK)
+    else if (depth)
     {
-        putback(c);
+        IOWarningInFunction(*this)
+            << "Missing " << depth << " closing '}' while parsing" << nl << nl
+            << buf << nl << endl;
     }
 
+    // Finalize
+    str = buf;
+    putback(c);
+
     return *this;
 }
 
 
 Foam::Istream& Foam::ISstream::readVerbatim(string& str)
 {
-    static const int maxLen = 8000;
-    static const int errLen = 80; // truncate error message for readability
+    static const unsigned maxLen = 8000;
     static char buf[maxLen];
 
+    unsigned nChar = 0;
     char c;
 
-    int nChar = 0;
-
     while (get(c))
     {
         if (c == token::HASH)
@@ -718,6 +706,7 @@ Foam::Istream& Foam::ISstream::readVerbatim(string& str)
             get(nextC);
             if (nextC == token::END_BLOCK)
             {
+                // The closing "#}" found
                 buf[nChar] = '\0';
                 str = buf;
                 return *this;
@@ -798,7 +787,7 @@ Foam::Istream& Foam::ISstream::read(char* buf, std::streamsize count)
 }
 
 
-Foam::Istream& Foam::ISstream::rewind()
+void Foam::ISstream::rewind()
 {
     lineNumber_ = 1;      // Reset line number
 
@@ -807,8 +796,6 @@ Foam::Istream& Foam::ISstream::rewind()
 
     // pubseekpos() rather than seekg() so that it works with gzstream
     stdStream().rdbuf()->pubseekpos(0, std::ios_base::in);
-
-    return *this;
 }
 
 
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H
index 18890e208734385fb266bfb9aec79d5039c8ac6e..e446272f8572e259921120b5b3f03d11c4f67cd6 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -69,9 +69,12 @@ class ISstream
 
 
         //- Read a verbatim string (excluding block delimiters).
+        //  The leading "#{" has been removed prior to calling,
+        //  continues until the closing "#}" has been found.
         Istream& readVerbatim(string& str);
 
-        //- Read a variable name (includes '{')
+        //- Read a variable name starting with '$'.
+        //  Handles both "$var" and "${var}" forms.
         Istream& readVariable(string& str);
 
         //- Disallow default bitwise assignment
@@ -82,7 +85,7 @@ public:
 
     // Constructors
 
-        //- Construct as wrapper around istream
+        //- Construct as wrapper around std::istream
         inline ISstream
         (
             std::istream& is,
@@ -163,8 +166,8 @@ public:
             //- Read binary block
             virtual Istream& read(char* buf, std::streamsize count);
 
-            //- Rewind and return the stream so that it may be read again
-            virtual Istream& rewind();
+            //- Rewind the stream so that it may be read again
+            virtual void rewind();
 
 
         // Stream state functions
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H
index ecad21b4173275827f47a07aecfd5cf779ab5036..6ceeb982c0b037119814d77c07842b21e46d474e 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H
@@ -59,7 +59,7 @@ inline Foam::ISstream& Foam::ISstream::get(char& c)
 
     if (good() && c == '\n')
     {
-        lineNumber_++;
+        ++lineNumber_;
     }
 
     return *this;
@@ -76,7 +76,7 @@ inline Foam::ISstream& Foam::ISstream::getLine(string& str)
 {
     std::getline(is_, str);
     setState(is_.rdstate());
-    lineNumber_++;
+    ++lineNumber_;
 
     return *this;
 }
@@ -86,7 +86,7 @@ inline Foam::ISstream& Foam::ISstream::putback(const char c)
 {
     if (c == '\n')
     {
-        lineNumber_--;
+        --lineNumber_;
     }
 
     if (!is_.putback(c))
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C
index 5dc8a3e6bd9078250ae44ea908c37b79cd015444..2027b2d28a201f0b6c9841ed645e8c59281b5f5a 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -24,26 +24,47 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "error.H"
-#include "OSstream.H"
 #include "token.H"
+#include "OSstream.H"
+#include "stringOps.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-Foam::Ostream& Foam::OSstream::write(const token& t)
+bool Foam::OSstream::write(const token& tok)
 {
-    if (t.type() == token::tokenType::VERBATIMSTRING)
-    {
-        write(char(token::HASH));
-        write(char(token::BEGIN_BLOCK));
-        writeQuoted(t.stringToken(), false);
-        write(char(token::HASH));
-        write(char(token::END_BLOCK));
-    }
-    else if (t.type() == token::tokenType::VARIABLE)
+    // Direct token handling only for some types
+
+    switch (tok.type())
     {
-        writeQuoted(t.stringToken(), false);
+        case token::tokenType::FLAG :
+        {
+            // silently consume the flag
+            return true;
+        }
+
+        case token::tokenType::VERBATIMSTRING :
+        {
+            write(char(token::HASH));
+            write(char(token::BEGIN_BLOCK));
+            writeQuoted(tok.stringToken(), false);
+            write(char(token::HASH));
+            write(char(token::END_BLOCK));
+
+            return true;
+        }
+
+        case token::tokenType::VARIABLE :
+        {
+            writeQuoted(tok.stringToken(), false);
+
+            return true;
+        }
+
+        default:
+            break;
     }
-    return *this;
+
+    return false;
 }
 
 
@@ -52,7 +73,7 @@ Foam::Ostream& Foam::OSstream::write(const char c)
     os_ << c;
     if (c == token::NL)
     {
-        lineNumber_++;
+        ++lineNumber_;
     }
     setState(os_.rdstate());
     return *this;
@@ -61,7 +82,7 @@ Foam::Ostream& Foam::OSstream::write(const char c)
 
 Foam::Ostream& Foam::OSstream::write(const char* str)
 {
-    lineNumber_ += string(str).count(token::NL);
+    lineNumber_ += stringOps::count(str, token::NL);
     os_ << str;
     setState(os_.rdstate());
     return *this;
@@ -76,36 +97,51 @@ Foam::Ostream& Foam::OSstream::write(const word& str)
 }
 
 
-Foam::Ostream& Foam::OSstream::write(const string& str)
+Foam::Ostream& Foam::OSstream::writeQuoted
+(
+    const std::string& str,
+    const bool quoted
+)
 {
+    if (!quoted)
+    {
+        // Output unquoted, only advance line number on newline
+        lineNumber_ += stringOps::count(str, token::NL);
+        os_ << str;
+
+        setState(os_.rdstate());
+        return *this;
+    }
+
+
+    // Output with surrounding quotes and backslash escaping
     os_ << token::BEGIN_STRING;
 
-    int backslash = 0;
+    unsigned backslash = 0;
     for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
     {
         const char c = *iter;
 
         if (c == '\\')
         {
-            backslash++;
-            // suppress output until we know if other characters follow
-            continue;
+            ++backslash;
+            continue; // only output after escaped character is known
         }
         else if (c == token::NL)
         {
-            lineNumber_++;
-            backslash++;    // backslash escape for newline
+            ++lineNumber_;
+            ++backslash;    // backslash escape for newline
         }
         else if (c == token::END_STRING)
         {
-            backslash++;    // backslash escape for quote
+            ++backslash;    // backslash escape for quote
         }
 
-        // output pending backslashes
+        // output all pending backslashes
         while (backslash)
         {
             os_ << '\\';
-            backslash--;
+            --backslash;
         }
 
         os_ << c;
@@ -113,7 +149,6 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
 
     // silently drop any trailing backslashes
     // they would otherwise appear like an escaped end-quote
-
     os_ << token::END_STRING;
 
     setState(os_.rdstate());
@@ -121,60 +156,9 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
 }
 
 
-Foam::Ostream& Foam::OSstream::writeQuoted
-(
-    const std::string& str,
-    const bool quoted
-)
+Foam::Ostream& Foam::OSstream::write(const string& str)
 {
-    if (quoted)
-    {
-        os_ << token::BEGIN_STRING;
-
-        int backslash = 0;
-        for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
-        {
-            const char c = *iter;
-
-            if (c == '\\')
-            {
-                backslash++;
-                // suppress output until we know if other characters follow
-                continue;
-            }
-            else if (c == token::NL)
-            {
-                lineNumber_++;
-                backslash++;    // backslash escape for newline
-            }
-            else if (c == token::END_STRING)
-            {
-                backslash++;    // backslash escape for quote
-            }
-
-            // output pending backslashes
-            while (backslash)
-            {
-                os_ << '\\';
-                backslash--;
-            }
-
-            os_ << c;
-        }
-
-        // silently drop any trailing backslashes
-        // they would otherwise appear like an escaped end-quote
-        os_ << token::END_STRING;
-    }
-    else
-    {
-        // output unquoted string, only advance line number on newline
-        lineNumber_ += string(str).count(token::NL);
-        os_ << str;
-    }
-
-    setState(os_.rdstate());
-    return *this;
+    return writeQuoted(str, true);
 }
 
 
@@ -210,7 +194,24 @@ Foam::Ostream& Foam::OSstream::write(const doubleScalar val)
 }
 
 
-Foam::Ostream& Foam::OSstream::write(const char* buf, std::streamsize count)
+Foam::Ostream& Foam::OSstream::write
+(
+    const char* data,
+    const std::streamsize count
+)
+{
+    beginRaw(count);
+    writeRaw(data, count);
+    endRaw();
+
+    return *this;
+}
+
+
+Foam::Ostream& Foam::OSstream::beginRaw
+(
+    const std::streamsize count
+)
 {
     if (format() != BINARY)
     {
@@ -220,8 +221,6 @@ Foam::Ostream& Foam::OSstream::write(const char* buf, std::streamsize count)
     }
 
     os_ << token::BEGIN_LIST;
-    os_.write(buf, count);
-    os_ << token::END_LIST;
 
     setState(os_.rdstate());
 
@@ -229,9 +228,34 @@ Foam::Ostream& Foam::OSstream::write(const char* buf, std::streamsize count)
 }
 
 
+Foam::Ostream& Foam::OSstream::writeRaw
+(
+    const char* data,
+    std::streamsize count
+)
+{
+    // No check for format() == BINARY since this is either done in the
+    // beginRaw() method, or the caller knows what they are doing.
+
+    os_.write(data, count);
+    setState(os_.rdstate());
+
+    return *this;
+}
+
+
+Foam::Ostream& Foam::OSstream::endRaw()
+{
+    os_ << token::END_LIST;
+    setState(os_.rdstate());
+
+    return *this;
+}
+
+
 void Foam::OSstream::indent()
 {
-    for (unsigned short i = 0; i < indentLevel_*indentSize_; i++)
+    for (unsigned short i = 0; i < indentLevel_*indentSize_; ++i)
     {
         os_ << ' ';
     }
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H
index 4c6e97fd59386ae6c3c599daaf009fb82e25c107..8218a5a3d65ffc3bb51049ad98ed189a4f83106f 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -69,7 +69,7 @@ public:
 
     // Constructors
 
-        //- Construct and set stream status
+        //- Construct as wrapper around std::ostream and set stream status
         OSstream
         (
             std::ostream& os,
@@ -104,8 +104,9 @@ public:
 
         // Write functions
 
-            //- Write next token to stream
-            virtual Ostream& write(const token& t);
+            //- Write token to stream or otherwise handle it.
+            //  \return false if the token type was not handled by this method
+            virtual bool write(const token& tok);
 
             //- Write character
             virtual Ostream& write(const char c);
@@ -116,7 +117,7 @@ public:
             //- Write word
             virtual Ostream& write(const word& str);
 
-            //- Write string
+            //- Write string (quoted)
             //  In the rare case that the string contains a final trailing
             //  backslash, it will be dropped to the appearance of an escaped
             //  double-quote.
@@ -143,7 +144,26 @@ public:
             virtual Ostream& write(const doubleScalar val);
 
             //- Write binary block
-            virtual Ostream& write(const char* buf, std::streamsize count);
+            virtual Ostream& write
+            (
+                const char* data,
+                const std::streamsize count
+            );
+
+            //- Begin marker for low-level raw binary output.
+            //  The count should indicate the number of bytes for subsequent
+            //  writeRaw calls.
+            virtual Ostream& beginRaw(const std::streamsize count);
+
+            //- Low-level raw binary output.
+            virtual Ostream& writeRaw
+            (
+                const char* data,
+                const std::streamsize count
+            );
+
+            //- End marker for low-level raw binary output.
+            virtual Ostream& endRaw();
 
             //- Add indentation characters
             virtual void indent();
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C
index cb28408f7dec651c2e0bbe902bab9e6c9c6f677b..640bc8555d959bf3897a3cffd0e11ca356bf297e 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C
@@ -65,21 +65,41 @@ void Foam::prefixOSstream::print(Ostream& os) const
 }
 
 
-Foam::Ostream& Foam::prefixOSstream::write(const token& t)
+bool Foam::prefixOSstream::write(const token& tok)
 {
-    if (t.type() == token::tokenType::VERBATIMSTRING)
-    {
-        write(char(token::HASH));
-        write(char(token::BEGIN_BLOCK));
-        writeQuoted(t.stringToken(), false);
-        write(char(token::HASH));
-        write(char(token::END_BLOCK));
-    }
-    else if (t.type() == token::tokenType::VARIABLE)
+    // Direct token handling only for some types
+
+    switch (tok.type())
     {
-        writeQuoted(t.stringToken(), false);
+        case token::tokenType::FLAG :
+        {
+            // silently consume the flag
+            return true;
+        }
+
+        case token::tokenType::VERBATIMSTRING :
+        {
+            write(char(token::HASH));
+            write(char(token::BEGIN_BLOCK));
+            writeQuoted(tok.stringToken(), false);
+            write(char(token::HASH));
+            write(char(token::END_BLOCK));
+
+            return true;
+        }
+
+        case token::tokenType::VARIABLE :
+        {
+            writeQuoted(tok.stringToken(), false);
+
+            return true;
+        }
+
+        default:
+            break;
     }
-    return *this;
+
+    return false;
 }
 
 
@@ -102,7 +122,7 @@ Foam::Ostream& Foam::prefixOSstream::write(const char* str)
     checkWritePrefix();
     OSstream::write(str);
 
-    size_t len = strlen(str);
+    const size_t len = strlen(str);
     if (len && str[len-1] == token::NL)
     {
         printPrefix_ = true;
diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H
index 8912793a55220d6e8f3955afd170ddd877ca0be8..d67c6d916ec61c29d0ae396d0c923db9ec4c50da 100644
--- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H
+++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H
@@ -98,8 +98,9 @@ public:
 
         // Write functions
 
-            //- Write next token to stream
-            virtual Ostream& write(const token& t);
+            //- Write token to stream or otherwise handle it.
+            //  \return false if the token type was not handled by this method
+            virtual bool write(const token& tok);
 
             //- Write character
             virtual Ostream& write(const char c);
diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H
index 1bdbad9adb7dbe9c13c4c7ae3258ce7e61ad7bc5..83f75c642a04080e4e5cc905fd332baea9eef6de 100644
--- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H
+++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H
@@ -2,8 +2,8 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -56,8 +56,11 @@ protected:
 
     // Member Data
 
-        //- The allocated stream pointer.
-        StreamType* allocatedPtr_;
+        //- The stream type
+        typedef StreamType stream_type;
+
+        //- The input/output stream.
+        stream_type stream_;
 
 
     // Constructors
@@ -65,56 +68,31 @@ protected:
         //- Construct null
         StringStreamAllocator()
         :
-            allocatedPtr_(new StreamType())
+            stream_()
         {}
 
-        //- Construct from pointer, taking ownership
-        StringStreamAllocator(StreamType* ptr)
-        :
-            allocatedPtr_(ptr)
-        {}
 
-        //- Construct from string
+        //- Copy construct from string
         StringStreamAllocator(const std::string& buffer)
         :
-            allocatedPtr_(new StreamType(buffer))
+            stream_(buffer)
         {}
 
 
-    //- Destructor
-    ~StringStreamAllocator()
-    {
-        deallocate();
-    }
-
-
-    // Protected Member Functions
-
-        //- Delete the stream pointer
-        void deallocate()
-        {
-            if (allocatedPtr_)
-            {
-                delete allocatedPtr_;
-                allocatedPtr_ = nullptr;
-            }
-        }
-
-
 public:
 
     // Public Member Functions
 
-        //- Get the string
+        //- Get the string - as Foam::string rather than std::string
         Foam::string str() const
         {
-            return allocatedPtr_->str();
+            return Foam::string(stream_.str());
         }
 
         //- Set the string
         void str(const std::string& s)
         {
-            allocatedPtr_->str(s);
+            stream_.str(s);
         }
 };
 
@@ -129,6 +107,8 @@ class IStringStream
     public StringStreamAllocator<std::istringstream>,
     public ISstream
 {
+    typedef StringStreamAllocator<std::istringstream> allocator_type;
+
 public:
 
     // Constructors
@@ -142,8 +122,8 @@ public:
             const Foam::string& name="input"
         )
         :
-            StringStreamAllocator<std::istringstream>(buffer),
-            ISstream(*allocatedPtr_, name, format, version)
+            allocator_type(buffer),
+            ISstream(stream_, name, format, version)
         {}
 
 
@@ -156,27 +136,36 @@ public:
             const Foam::string& name="input"
         )
         :
-            StringStreamAllocator<std::istringstream>(buffer),
-            ISstream(*allocatedPtr_, name, format, version)
+            allocator_type(buffer),
+            ISstream(stream_, name, format, version)
         {}
 
 
-    //- Destructor
-    ~IStringStream()
-    {}
+        //- Construct as copy of content
+        IStringStream(const IStringStream& str)
+        :
+            allocator_type(str.str()),
+            ISstream(stream_, str.name(), str.format(), str.version())
+        {}
 
 
     // Member Functions
 
+        //- Reset the input buffer and rewind the stream
+        virtual void reset(const std::string& s)
+        {
+            this->str(s);
+            this->rewind();
+        }
+
         //- Print description to Ostream
-        void print(Ostream& os) const;
+        virtual void print(Ostream& os) const;
 
 
     // Member operators
 
         //- Return a non-const reference to const Istream
-        //  Needed for read-constructors where the stream argument is temporary:
-        //  e.g. thing thisThing(IFstream("thingFileName")());
+        //  Needed for read-constructors where the stream argument is temporary.
         Istream& operator()() const
         {
             return const_cast<IStringStream&>(*this);
@@ -195,6 +184,8 @@ class OStringStream
     public StringStreamAllocator<std::ostringstream>,
     public OSstream
 {
+    typedef StringStreamAllocator<std::ostringstream> allocator_type;
+
 public:
 
     // Constructors
@@ -206,23 +197,19 @@ public:
             versionNumber version=currentVersion
         )
         :
-            StringStreamAllocator<std::ostringstream>(),
-            OSstream(*allocatedPtr_, "output", format, version)
+            allocator_type(),
+            OSstream(stream_, "output", format, version)
         {}
 
-        //- Construct as copy
-        OStringStream(const OStringStream& oss)
+
+        //- Construct as copy of content
+        OStringStream(const OStringStream& str)
         :
-            StringStreamAllocator<std::ostringstream>(oss.str()),
-            OSstream(*allocatedPtr_, oss.name(), oss.format(), oss.version())
+            allocator_type(str.str()),
+            OSstream(stream_, str.name(), str.format(), str.version())
         {}
 
 
-    //- Destructor
-    ~OStringStream()
-    {}
-
-
     // Member Functions
 
         //- Reset the output buffer and rewind the stream
@@ -233,14 +220,14 @@ public:
         }
 
         //- Rewind the output stream
-        void rewind()
+        virtual void rewind()
         {
             // pubseekpos() instead of seekp() for symmetry with other classes
-            allocatedPtr_->rdbuf()->pubseekpos(0, std::ios_base::out);
+            stream_.rdbuf()->pubseekpos(0, std::ios_base::out);
         }
 
         //- Print description to Ostream
-        void print(Ostream& os) const;
+        virtual void print(Ostream& os) const;
 
 };
 
diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C
index c9dae1229471051a350ac5b68b579104bbf4bbdc..499bad8cb240b84bc9b3ad1e4d3c559f32dc7e53 100644
--- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C
+++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,8 +25,140 @@ License
 
 #include "error.H"
 #include "ITstream.H"
+#include "UIListStream.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+Foam::label Foam::ITstream::parseStream(ISstream& is, tokenList& tokens)
+{
+    label nTok = 0;
+
+    tokens.clear();
+    tokens.setSize(64, token::undefinedToken);
+
+    token tok;
+    while (!is.read(tok).bad() && tok.good())
+    {
+        tokens.newElmt(nTok++) = std::move(tok);
+    }
+
+    tokens.setSize(nTok);
+
+    return nTok;
+}
+
+
+Foam::tokenList Foam::ITstream::parse
+(
+    const UList<char>& input,
+    streamFormat format
+)
+{
+    UIListStream is(input, format, IOstream::currentVersion);
+
+    tokenList tokens;
+    parseStream(is, tokens);
+    return tokens;
+}
+
+
+Foam::tokenList Foam::ITstream::parse
+(
+    const std::string& input,
+    streamFormat format
+)
+{
+    UIListStream is
+    (
+        input.data(),
+        input.size(),
+        format,
+        IOstream::currentVersion
+    );
+
+    tokenList tokens;
+    parseStream(is, tokens);
+    return tokens;
+}
+
+
+Foam::tokenList Foam::ITstream::parse
+(
+    const char* input,
+    streamFormat format
+)
+{
+    UIListStream is(input, strlen(input), format, IOstream::currentVersion);
+
+    tokenList tokens;
+    parseStream(is, tokens);
+    return tokens;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::ITstream::ITstream
+(
+    const string& name,
+    const UList<char>& input,
+    streamFormat format,
+    versionNumber version
+)
+:
+    Istream(format, version),
+    tokenList(),
+    name_(name),
+    tokenIndex_(0)
+{
+    UIListStream is(input, format, version);
+
+    parseStream(is, static_cast<tokenList&>(*this));
+    ITstream::rewind();
+}
+
+
+Foam::ITstream::ITstream
+(
+    const string& name,
+    const std::string& input,
+    streamFormat format,
+    versionNumber version
+)
+:
+    Istream(format, version),
+    tokenList(),
+    name_(name),
+    tokenIndex_(0)
+{
+    UIListStream is(input.data(), input.size(), format, version);
+
+    parseStream(is, static_cast<tokenList&>(*this));
+    ITstream::rewind();
+}
+
+
+Foam::ITstream::ITstream
+(
+    const string& name,
+    const char* input,
+    streamFormat format,
+    versionNumber version
+)
+:
+    Istream(format, version),
+    tokenList(),
+    name_(name),
+    tokenIndex_(0)
+{
+    UIListStream is(input, strlen(input), format, version);
+
+    parseStream(is, static_cast<tokenList&>(*this));
+    ITstream::rewind();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 void Foam::ITstream::print(Ostream& os) const
 {
@@ -53,19 +185,19 @@ void Foam::ITstream::print(Ostream& os) const
 }
 
 
-Foam::Istream& Foam::ITstream::read(token& t)
+Foam::Istream& Foam::ITstream::read(token& tok)
 {
     // Return the put back token if it exists
-    if (Istream::getBack(t))
+    if (Istream::getBack(tok))
     {
-        lineNumber_ = t.lineNumber();
+        lineNumber_ = tok.lineNumber();
         return *this;
     }
 
     if (tokenIndex_ < size())
     {
-        t = operator[](tokenIndex_++);
-        lineNumber_ = t.lineNumber();
+        tok = operator[](tokenIndex_++);
+        lineNumber_ = tok.lineNumber();
 
         if (tokenIndex_ == size())
         {
@@ -89,15 +221,15 @@ Foam::Istream& Foam::ITstream::read(token& t)
             setEof();
         }
 
-        t = token::undefinedToken;
+        tok = token::undefinedToken;
 
         if (size())
         {
-            t.lineNumber() = tokenList::last().lineNumber();
+            tok.lineNumber() = tokenList::last().lineNumber();
         }
         else
         {
-            t.lineNumber() = lineNumber();
+            tok.lineNumber() = lineNumber();
         }
     }
 
@@ -154,18 +286,18 @@ Foam::Istream& Foam::ITstream::read(char*, std::streamsize)
 }
 
 
-Foam::Istream& Foam::ITstream::rewind()
+void Foam::ITstream::rewind()
 {
     tokenIndex_ = 0;
+    lineNumber_ = 0;
 
     if (size())
     {
         lineNumber_ = tokenList::first().lineNumber();
     }
 
+    setOpened();
     setGood();
-
-    return *this;
 }
 
 
diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H
index 26617cb37e6f01edddf7a75c738f1311c21331d7..4e13175f0ddc8e8ec737c7b6d8a8638c7479f3ca 100644
--- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H
+++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,7 +25,7 @@ Class
     Foam::ITstream
 
 Description
-    Input token stream.
+    An input stream of tokens.
 
 SourceFiles
     ITstream.C
@@ -43,6 +43,9 @@ SourceFiles
 namespace Foam
 {
 
+// Forward declaration
+class ISstream;
+
 /*---------------------------------------------------------------------------*\
                            Class ITstream Declaration
 \*---------------------------------------------------------------------------*/
@@ -61,6 +64,13 @@ class ITstream
         label tokenIndex_;
 
 
+    // Private Member Functions
+
+        //- Convert input sequence into a list of tokens.
+        //  \return the number of tokens in the resulting list.
+        static label parseStream(ISstream& input, tokenList& tokens);
+
+
 public:
 
     // Constructors
@@ -103,6 +113,39 @@ public:
         }
 
 
+        //- Construct token list by parsing the input character sequence
+        //  Uses UIListStream internally.
+        ITstream
+        (
+            const string& name,
+            const UList<char>& input,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        );
+
+
+        //- Construct token list by parsing the input string
+        //  Uses UIListStream internally.
+        ITstream
+        (
+            const string& name,
+            const std::string& input,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        );
+
+
+        //- Construct token list by parsing the input character sequence
+        //  Uses UIListStream internally.
+        ITstream
+        (
+            const string& name,
+            const char* input,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        );
+
+
         //- Construct as copy
         ITstream(const ITstream& its)
         :
@@ -121,6 +164,33 @@ public:
         {}
 
 
+    // Static Functions
+
+        //- Create token list by parsing the input character sequence until
+        //- no good tokens remain.
+        static tokenList parse
+        (
+            const UList<char>& input,
+            streamFormat format=ASCII
+        );
+
+        //- Create token list by parsing the input string until
+        //- no good tokens remain.
+        static tokenList parse
+        (
+            const std::string& input,
+            streamFormat format=ASCII
+        );
+
+        //- Create token list by parsing the input character sequence until
+        //- no good tokens remain.
+        static tokenList parse
+        (
+            const char* input,
+            streamFormat format=ASCII
+        );
+
+
     // Member functions
 
         // Inquiry
@@ -165,7 +235,7 @@ public:
         // Read functions
 
             //- Return next token from stream
-            virtual Istream& read(token& t);
+            virtual Istream& read(token& tok);
 
             //- Read a character
             virtual Istream& read(char&);
@@ -188,8 +258,8 @@ public:
             //- Read binary block
             virtual Istream& read(char*, std::streamsize);
 
-            //- Rewind and return the stream so that it may be read again
-            virtual Istream& rewind();
+            //- Rewind the stream so that it may be read again
+            virtual void rewind();
 
 
         // Edit
diff --git a/src/OpenFOAM/db/IOstreams/dummyISstream/dummyISstream.H b/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H
similarity index 96%
rename from src/OpenFOAM/db/IOstreams/dummyISstream/dummyISstream.H
rename to src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H
index 9477b087914408dc993a15bb5de59fdda198e995..fa0b441dc2da06f19c48af4b38bfeaaede14cad1 100644
--- a/src/OpenFOAM/db/IOstreams/dummyISstream/dummyISstream.H
+++ b/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H
@@ -126,11 +126,10 @@ public:
                 return *this;
             }
 
-            //- Rewind and return the stream so that it may be read again
-            virtual Istream& rewind()
+            //- Rewind the stream so that it may be read again
+            virtual void rewind()
             {
                 NotImplemented;
-                return *this;
             }
 
             //- Return flags of stream
diff --git a/src/OpenFOAM/db/IOstreams/dummyIstream/dummyIstream.H b/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H
similarity index 97%
rename from src/OpenFOAM/db/IOstreams/dummyIstream/dummyIstream.H
rename to src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H
index 9e8549820db4869fff8b7a11347a90a97614ebd2..b15f892ec21d9955ed41cfc285e26e37d464caa4 100644
--- a/src/OpenFOAM/db/IOstreams/dummyIstream/dummyIstream.H
+++ b/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H
@@ -127,8 +127,8 @@ public:
                 return *this;
             }
 
-            //- Rewind and return the stream so that it may be read again
-            virtual Istream& rewind()
+            //- Rewind the stream so that it may be read again
+            virtual void rewind()
             {
                 NotImplemented;
                 return *this;
diff --git a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H
index 8a43d3d7b1561245f55a7216698173ae56140242..6b9688b73a0c092b6652d23586501eb0211b5b1c 100644
--- a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H
+++ b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H
@@ -47,55 +47,57 @@ class osha1stream;
 class OSHA1stream;
 
 /*---------------------------------------------------------------------------*\
-                        Class sha1streambuf Declaration
+                         Class osha1stream Declaration
 \*---------------------------------------------------------------------------*/
 
-//- A streambuf class for calculating SHA1 digests
-class sha1streambuf
+//- A basic output stream for calculating SHA1 digests
+class osha1stream
 :
-    public std::streambuf
+    virtual public std::ios,
+    public std::ostream
 {
-    // Private data
+    //- A streambuf class for calculating SHA1 digests
+    class sha1buf
+    :
+        public std::streambuf
+    {
+        //- This does all the work and has its own buffering
+        SHA1 sha1_;
 
-    //- This does all the work and has its own buffering
-    SHA1 sha1_;
+    protected:
+        // Protected members
 
-    friend class osha1stream;
+            //- Put sequence of characters
+            virtual std::streamsize xsputn(const char* str, std::streamsize n)
+            {
+                sha1_.append(str, n);
+                return n;
+            }
 
-public:
 
-    // Constructors
+    public:
 
-        //- Construct null
-        sha1streambuf()
-        {}
+        // Constructors
 
-    // Member Functions
+            //- Construct null
+            sha1buf()
+            {}
 
-      // Write
 
-        //- Process unbuffered
-        virtual std::streamsize xsputn(const char* str, std::streamsize n)
-        {
-            sha1_.append(str, n);
-            return n;
-        }
-};
+        // Public member functions
 
+            //- Full access to the sha1
+            inline SHA1& sha1()
+            {
+                return sha1_;
+            }
+    };
 
-/*---------------------------------------------------------------------------*\
-                         Class osha1stream Declaration
-\*---------------------------------------------------------------------------*/
 
-//- A basic output stream for calculating SHA1 digests
-class osha1stream
-:
-    virtual public std::ios,
-    public std::ostream
-{
     // Private data
 
-    sha1streambuf sbuf_;
+        //- Reference to the underlying buffer
+        sha1buf buf_;
 
 public:
 
@@ -104,23 +106,22 @@ public:
         //- Construct null
         osha1stream()
         :
-            std::ostream(&sbuf_)
+            std::ostream(&buf_)
         {}
 
-    // Member Functions
 
-      // Access
+    // Member Functions
 
         //- This hides both signatures of std::basic_ios::rdbuf()
-        sha1streambuf* rdbuf()
+        sha1buf* rdbuf()
         {
-            return &sbuf_;
+            return &buf_;
         }
 
         //- Full access to the sha1
         SHA1& sha1()
         {
-            return sbuf_.sha1_;
+            return buf_.sha1();
         }
 
 };
@@ -135,10 +136,12 @@ class OSHA1streamAllocator
 {
 protected:
 
-    // Member data
+    // Protected data
 
-        //- The allocated stream pointer
-        osha1stream* allocatedPtr_;
+        typedef osha1stream stream_type;
+
+        //- The output stream
+        stream_type stream_;
 
 
     // Constructors
@@ -146,36 +149,32 @@ protected:
         //- Construct null
         OSHA1streamAllocator()
         :
-            allocatedPtr_(new osha1stream())
+            stream_()
         {}
 
 
-    //- Destructor
-    ~OSHA1streamAllocator()
-    {
-        deallocate();
-    }
-
+public:
 
     // Member Functions
 
-        //- Delete the stream pointer
-        void deallocate()
+        //- Full access to the sha1
+        SHA1& sha1()
         {
-            if (allocatedPtr_)
-            {
-                delete allocatedPtr_;
-                allocatedPtr_ = nullptr;
-            }
+            return stream_.sha1();
         }
 
 
-public:
+        //- Return SHA1::Digest for the data processed until now
+        SHA1Digest digest()
+        {
+            return stream_.sha1().digest();
+        }
 
-        //- Full access to the sha1
-        SHA1& sha1()
+
+        //- Clear the SHA1 calculation
+        void reset()
         {
-            return allocatedPtr_->sha1();
+            return stream_.sha1().clear();
         }
 
 };
@@ -191,6 +190,7 @@ class OSHA1stream
     public OSHA1streamAllocator,
     public OSstream
 {
+    typedef OSHA1streamAllocator allocator_type;
 
     // Private Member Functions
 
@@ -211,35 +211,13 @@ public:
             versionNumber version=currentVersion
         )
         :
-            OSHA1streamAllocator(),
-            OSstream(*allocatedPtr_, "OSHA1stream", format, version)
+            allocator_type(),
+            OSstream(stream_, "sha1", format, version)
         {}
 
 
-    //- Destructor
-    ~OSHA1stream()
-    {}
-
-
     // Member functions
 
-      // Access
-
-        //- Return SHA1::Digest for the data processed until now
-        SHA1Digest digest()
-        {
-            return sha1().digest();
-        }
-
-
-      // Edit
-
-        //- Clear the SHA1 calculation
-        void reset()
-        {
-            sha1().clear();
-        }
-
         //- Clear the SHA1 calculation
         //  \deprecated use reset instead (deprecated Jul 2017)
         void rewind()
diff --git a/src/OpenFOAM/db/IOstreams/memory/IListStream.H b/src/OpenFOAM/db/IOstreams/memory/IListStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..553a803bc3c5a19be288582cdea70ac5098fed92
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/IListStream.H
@@ -0,0 +1,245 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::IListStream
+
+Description
+    An input stream that reads from a List and manages the List storage.
+    Similar to IStringStream but with a List for its storage instead of
+    as string to allow reuse of List contents without copying.
+
+See Also
+    Foam::OListStream
+    Foam::UIListStream
+    Foam::UOListStream
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef IListStream_H
+#define IListStream_H
+
+#include "List.H"
+#include "UIListStream.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                    Class IListStreamAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An stream/stream-buffer input allocator for with List storage
+class IListStreamAllocator
+:
+    private List<char>,
+    public UIListStreamAllocator
+{
+protected:
+
+    // Constructors
+
+        //- Construct with an empty list
+        IListStreamAllocator()
+        :
+            List<char>(),
+            UIListStreamAllocator(list_storage())
+        {}
+
+        //- Move construct from an existing List
+        IListStreamAllocator(List<char>&& buffer)
+        :
+            List<char>(std::move(buffer)),
+            UIListStreamAllocator(list_storage())
+        {}
+
+
+        //- Move construct from an existing DynamicList
+        template<int SizeMin>
+        IListStreamAllocator(DynamicList<char,SizeMin>&& buffer)
+        :
+            List<char>(std::move(buffer)),
+            UIListStreamAllocator(list_storage())
+        {}
+
+        //- Transfer (move) construct
+        IListStreamAllocator(const Xfer<List<char>>& buffer)
+        :
+            List<char>(buffer),
+            UIListStreamAllocator(list_storage())
+        {}
+
+
+    // Protected Member Functions
+
+        //- Convenience method to address the underlying List storage
+        inline List<char>& list_storage()
+        {
+            return static_cast<List<char>&>(*this);
+        }
+
+public:
+
+    // Member Functions
+
+        //- The current get position in the buffer
+        using UIListStreamAllocator::size;
+
+        //- Clear storage
+        inline void clearStorage()
+        {
+            list_storage().clear();
+            sync_gbuffer_to_list();
+        }
+
+        //- Transfer contents to the Xfer container as a plain List
+        inline Xfer<List<char>> xfer()
+        {
+            Xfer<List<char>> moved = list_storage().xfer();
+
+            // Update buffer pointers for remaining (zero) size list
+            sync_gbuffer_to_list(); // or rewind
+
+            return moved;
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class IListStream Declaration
+\*----------------------------------------------d-----------------------------*/
+
+//- An ISstream with internal List storage
+class IListStream
+:
+    public IListStreamAllocator,
+    public ISstream
+{
+    typedef IListStreamAllocator allocator_type;
+
+public:
+
+    // Constructors
+
+        //- Construct with an empty list
+        IListStream
+        (
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            allocator_type(),
+            ISstream(stream_, name, format, version)
+        {}
+
+
+        //- Move construct from an existing List
+        IListStream
+        (
+            List<char>&& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            allocator_type(std::move(buffer)),
+            ISstream(stream_, name, format, version)
+        {}
+
+
+        //- Move construct from an existing DynamicList
+        template<int SizeMin>
+        IListStream
+        (
+            DynamicList<char,SizeMin>&& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            allocator_type(std::move(buffer)),
+            ISstream(stream_, name, format, version)
+        {}
+
+
+        //- Transfer (move) construct
+        IListStream
+        (
+            const Xfer<List<char>>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            allocator_type(buffer),
+            ISstream(stream_, name, format, version)
+        {}
+
+
+    // Member functions
+
+        //- The current get position in the buffer
+        using allocator_type::size;
+
+
+        //- Return the current get position in the buffer
+        std::streampos pos() const
+        {
+            return allocator_type::tellg();
+        }
+
+        //- Rewind the stream, clearing any old errors
+        virtual void rewind()
+        {
+            allocator_type::rewind();
+            setGood();  // resynchronize with internal state
+        }
+
+
+        //- Print description to Ostream
+        virtual void print(Ostream& os) const;
+
+
+    // Member operators
+
+        //- A non-const reference to const Istream
+        //  Needed for read-constructors where the stream argument is temporary
+        Istream& operator()() const
+        {
+            return const_cast<Istream&>(static_cast<const Istream&>(*this));
+        }
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/ListStream.C b/src/OpenFOAM/db/IOstreams/memory/ListStream.C
new file mode 100644
index 0000000000000000000000000000000000000000..02750001774a36f717428644af7bff8e75776856
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/ListStream.C
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "UListStream.H"
+#include "ListStream.H"
+#include "OCountStream.H"
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::IListStream::print(Ostream& os) const
+{
+    os  << "IListStream: ";
+    printBufInfo(os);
+    os  << Foam::endl;
+}
+
+
+void Foam::UIListStream::print(Ostream& os) const
+{
+    os  << "UIListStream: ";
+    printBufInfo(os);
+    os  << Foam::endl;
+}
+
+
+void Foam::OListStream::print(Ostream& os) const
+{
+    os  << "OListStream: ";
+    printBufInfo(os);
+    os  << Foam::endl;
+}
+
+
+void Foam::UOListStream::print(Ostream& os) const
+{
+    os  << "UOListStream: ";
+    printBufInfo(os);
+    os  << Foam::endl;
+}
+
+
+void Foam::OCountStream::print(Ostream& os) const
+{
+    os  << "OCountStream: ";
+    printBufInfo(os);
+    os  << Foam::endl;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C b/src/OpenFOAM/db/IOstreams/memory/ListStream.H
similarity index 76%
rename from src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C
rename to src/OpenFOAM/db/IOstreams/memory/ListStream.H
index 055a55b59de65fa61790c626cc5ac8d006d60d68..6ef7518ca07fe880b2be7501e68dbbb3893ecead 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntry.C
+++ b/src/OpenFOAM/db/IOstreams/memory/ListStream.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -21,20 +21,17 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-\*---------------------------------------------------------------------------*/
+Description
+    Input/output streams with managed List storage.
 
-#include "dictionaryListEntry.H"
+\*---------------------------------------------------------------------------*/
 
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+#ifndef ListStream_H
+#define ListStream_H
 
-Foam::dictionaryListEntry::dictionaryListEntry
-(
-    const dictionary& parentDict,
-    const dictionaryListEntry& dictEnt
-)
-:
-    dictionaryEntry(parentDict, dictEnt)
-{}
+#include "IListStream.H"
+#include "OListStream.H"
 
+#endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/OCountStream.H b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..3ae0311667fb9225e5a5f596303dff99b8e5f0eb
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H
@@ -0,0 +1,271 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::OSCountStream
+
+Description
+    An output stream for calculating byte counts.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef OScountStream_H
+#define OScountStream_H
+
+#include "OSstream.H"
+#include <iostream>
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class countstreambuf Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A streambuf class for determining byte counts
+class countstreambuf
+:
+    public std::streambuf
+{
+    // Private data
+
+        //- The number of bytes
+        std::streamsize size_;
+
+protected:
+
+    //- Simply handle output counting via overflow
+    virtual int overflow(int c = EOF)
+    {
+        if (c != EOF)
+        {
+            ++size_;
+        }
+        return c;
+    }
+
+    //- Set position pointer to absolute position
+    //  For the counter, any positioning is ignored and it always acts like
+    //  seekpos(0), which resets the count.
+    virtual std::streampos seekpos
+    (
+        std::streampos,
+        std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
+    )
+    {
+        size_ = 0;
+        return 0;
+    }
+
+
+public:
+
+    // Constructors
+
+        //- Construct null, or with precount size
+        countstreambuf(std::streamsize precount=0)
+        :
+            size_(precount)
+        {}
+
+
+    // Access
+
+        //- Number of bytes counted
+        std::streamsize size() const
+        {
+            return size_;
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                        Class ocountstream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Trivial output stream for calculating byte counts
+//  Since all output values are discarded, it can also be used as a /dev/null
+//  output buffer as well
+class ocountstream
+:
+    virtual public std::ios,
+    public std::ostream
+{
+    // Private data
+
+    countstreambuf buf_;
+
+public:
+
+    // Constructors
+
+        //- Construct null
+        ocountstream()
+        :
+            std::ostream(&buf_)
+        {}
+
+
+    // Member Functions
+
+      // Access
+
+        //- This hides both signatures of std::basic_ios::rdbuf()
+        countstreambuf* rdbuf()
+        {
+            return &buf_;
+        }
+
+
+        //- Get number of bytes counted
+        std::streamsize size() const
+        {
+            return buf_.size();
+        }
+
+
+        //- Rewind the stream, reset the count
+        void rewind()
+        {
+            buf_.pubseekpos(0);
+            clear();    // for safety, clear any old errors
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                    Class OCountStreamAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An stream/stream-buffer allocator for counting
+class OCountStreamAllocator
+{
+protected:
+
+    // Protected data
+
+        typedef std::ostream stream_type;
+
+        //- The stream buffer
+        countstreambuf buf_;
+
+        //- The output stream
+        stream_type stream_;
+
+
+    // Constructors
+
+        //- Construct null, or with precount size
+        OCountStreamAllocator(std::streamsize precount=0)
+        :
+            buf_(precount),
+            stream_(&buf_)
+        {}
+
+
+    // Protected Member Functions
+
+        void printBufInfo(Ostream& os) const
+        {
+            os << "count=" << buf_.size();
+        }
+
+public:
+
+    // Member Functions
+
+        //- The number of bytes counted
+        std::streamsize size() const
+        {
+            return buf_.size();
+        }
+
+        //- Rewind the stream, reset the count
+        void rewind()
+        {
+            buf_.pubseekpos(0);
+            stream_.clear(); // for safety, clear any old errors
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                        Class OCountStream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An output stream for calculating byte counts
+class OCountStream
+:
+    public OCountStreamAllocator,
+    public OSstream
+{
+    typedef OCountStreamAllocator allocator_type;
+
+public:
+
+    // Constructors
+
+        //- Construct and set stream status
+        OCountStream
+        (
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(),
+            OSstream(stream_, "output", format, version)
+        {}
+
+        //- Copy construct
+        OCountStream(const OCountStream& os)
+        :
+            allocator_type(os.size()),
+            OSstream(stream_, os.name(), os.format(), os.version())
+        {}
+
+
+    // Member functions
+
+        //- Rewind the stream, reset the count, clearing any old errors
+        virtual void rewind()
+        {
+            allocator_type::rewind();
+            setGood();  // resynchronize with internal state
+        }
+
+        //- Print description to Ostream
+        virtual void print(Ostream& os) const;
+
+};
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/OListStream.H b/src/OpenFOAM/db/IOstreams/memory/OListStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..78796b338ce63d99723eeafd30b9113d87b77f3b
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/OListStream.H
@@ -0,0 +1,490 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::OListStream
+
+Description
+    An output stream that writes to a List and manages the List storage.
+    Similar to OStringStream but with a List for its storage instead of
+    as string to allow reuse of List contents without copying.
+
+    The default list size is 512 with a 256 byte block increment.
+    These values can be changed on construction of via the
+    reserve() and setBlockSize() methods.
+
+See Also
+    Foam::IListStream
+    Foam::UOListStream
+    Foam::UIListStream
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef OListStream_H
+#define OListStream_H
+
+#include "DynamicList.H"
+#include "OSstream.H"
+#include "memoryStreamBuffer.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration
+class OListStreamAllocator;
+
+/*---------------------------------------------------------------------------*\
+                    Class OListStreamAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An stream/stream-buffer output allocator for lists
+class OListStreamAllocator
+{
+    //- A streambuf adapter to output to a List
+    class listbuf
+    :
+        public memorybuf::out
+    {
+        friend OListStreamAllocator;
+
+        //- Helper for setting the block size.
+        //  Small list minimum of 64 bytes.
+        static int min_size(int n)
+        {
+            return max(64, n);
+        }
+
+        //- Block size when resizing the list
+        int block_ = 256;
+
+        //- Underlying list storage.
+        //  Internally manage like a DynamicList, but the addressable size
+        //  is known through the stream pointers.
+        List<char> storage_;
+
+
+    protected:
+
+        //- Increment capacity directly and
+        //  adjust buffer pointers to agree with list dimensions
+        inline void minCapacity
+        (
+            const std::streamsize n,
+            const std::streamsize cur = 0
+        )
+        {
+            const auto newEnd = n + cur;
+            if (newEnd > storage_.size())
+            {
+                auto newCapacity =
+                (
+                    (storage_.size() + block_)
+                  - (storage_.size() % block_)
+                );
+
+                while (newCapacity < newEnd)
+                {
+                    newCapacity += block_;
+                }
+
+                // Info<<"request:" << newEnd
+                //     << " cur cap:" << storage_.size()
+                //     << " new cap:" << newCapacity
+                //     << " pos:" << cur
+                //     << " incr:" << incr << endl;
+
+                storage_.setSize(newCapacity);
+                sync_pbuffer_to_list();
+                pbump(cur);
+            }
+        }
+
+        //- Define new increment
+        inline void setBlockSize(const int i)
+        {
+            const auto prev = block_;
+            block_ = min_size(i);
+
+            if (block_ > prev)
+            {
+                minCapacity(0, tellp());
+            }
+        }
+
+        //- Handle overflow
+        virtual int overflow(int c = EOF)
+        {
+            if (c != EOF)
+            {
+                // Need another output block
+                minCapacity(block_, tellp());
+
+                *(pptr()) = c;
+                pbump(1);
+            }
+            return c;
+        }
+
+
+        //- Put sequence of characters
+        virtual std::streamsize xsputn(const char* s, std::streamsize n)
+        {
+            // Enough space so that appends work without problem
+            minCapacity(n, tellp());
+
+            std::streamsize count = 0;
+            while (count < n && pptr() < epptr())
+            {
+                *(pptr()) = *(s + count++);
+                pbump(1);
+            }
+
+            return count;
+        }
+
+        //- Initialize put buffer
+        void init_pbuffer(const std::streamsize n)
+        {
+            set_pbuffer(storage_);
+            minCapacity(n);
+        }
+
+
+    public:
+
+      // Constructors
+
+        //- Construct with an empty list, or specified number of reserved bytes
+        listbuf(size_t nbytes = 512)
+        :
+            storage_()
+        {
+            init_pbuffer(min_size(nbytes));
+        }
+
+        //- Move construct content from an existing List
+        listbuf(List<char>&& buffer)
+        :
+            storage_(std::move(buffer))
+        {
+            init_pbuffer(block_);
+        }
+
+        //- Move construct content from an existing DynamicList
+        template<int AnySize>
+        listbuf(DynamicList<char,AnySize>&& buffer)
+        :
+            storage_(std::move(buffer))
+        {
+            init_pbuffer(block_);
+        }
+
+        //- Transfer (move) construct
+        listbuf(const Xfer<List<char>>& buffer)
+        :
+            storage_(buffer)
+        {
+            init_pbuffer(block_);
+        }
+
+
+      // Member Functions
+
+        //- Return the current list output capacity
+        inline label capacity() const
+        {
+            return storage_.size();
+        }
+
+        //- Sync put buffer pointers to agree with list dimensions
+        inline void sync_pbuffer_to_list()
+        {
+            set_pbuffer(storage_);
+        }
+
+        //- Clear storage
+        inline void clearStorage()
+        {
+            storage_.clear();
+            sync_pbuffer_to_list();
+        }
+
+        //- Shrink to addressed storage
+        inline void shrink()
+        {
+            const auto cur = tellp();
+            storage_.setSize(cur);
+            sync_pbuffer_to_list();
+            pbump(cur);
+        }
+    };
+
+protected:
+
+    // Protected data
+
+        typedef std::ostream stream_type;
+
+        //- The stream buffer
+        listbuf buf_;
+
+        //- The stream
+        stream_type stream_;
+
+
+    // Constructors
+
+        //- Construct with an empty list or specified number of reserved bytes
+        OListStreamAllocator(size_t nbytes = 512)
+        :
+            buf_(nbytes),
+            stream_(&buf_)
+        {}
+
+        //- Move construct from an existing List
+        OListStreamAllocator(List<char>&& buffer)
+        :
+            buf_(std::move(buffer)),
+            stream_(&buf_)
+        {}
+
+        //- Move construct from an existing DynamicList
+        template<int SizeMin>
+        OListStreamAllocator(DynamicList<char,SizeMin>&& buffer)
+        :
+            buf_(std::move(buffer)),
+            stream_(&buf_)
+        {}
+
+        //- Transfer (move) construct
+        OListStreamAllocator(const Xfer<List<char>>& buffer)
+        :
+            buf_(buffer),
+            stream_(&buf_)
+        {}
+
+
+    // Protected Member Functions
+
+        void printBufInfo(Ostream& os) const
+        {
+            os  << "pos=" << buf_.tellp()
+                << " capacity=" << buf_.capacity()
+                << " block=" << buf_.block_;
+        }
+
+public:
+
+    // Member Functions
+
+        //- The current list output capacity
+        inline label capacity() const
+        {
+            return buf_.capacity();
+        }
+
+
+        //- Reserve output space for at least this amount.
+        inline void reserve(const std::streamsize n)
+        {
+            // Also maintain current position when resizing
+            const auto cur = buf_.tellp();
+            if (n > cur)
+            {
+                buf_.minCapacity(n - cur, cur);
+            }
+        }
+
+
+        //- Adjust block size for output
+        inline void setBlockSize(int n)
+        {
+            return buf_.setBlockSize(n);
+        }
+
+
+        //- The current output position in the buffer,
+        //  which is also the addressed list size
+        inline label size() const
+        {
+            return buf_.tellp();
+        }
+
+
+        //- Const access to written contents as a list of characters
+        inline const UList<char> list() const
+        {
+            return UList<char>
+            (
+                const_cast<char*>(buf_.storage_.cdata()),
+                buf_.tellp()
+            );
+        }
+
+
+        //- Non-const access to written contents as a list of characters
+        inline UList<char> list()
+        {
+            return UList<char>(buf_.storage_.data(), buf_.tellp());
+        }
+
+
+        //- Transfer contents to the Xfer container as a plain List
+        inline Xfer<List<char>> xfer()
+        {
+            buf_.shrink();  // Shrink to addressed area
+            auto lst = buf_.storage_.xfer();
+            buf_.sync_pbuffer_to_list();
+            return lst;
+        }
+
+
+        //- Move to buffer start, clear errors
+        void rewind()
+        {
+            buf_.pubseekpos(0, std::ios_base::out);
+            stream_.clear(); // for safety, clear any old errors
+        }
+
+        //- Shrink to addressed space, should not affect stream.
+        inline void shrink()
+        {
+            buf_.shrink();
+        }
+
+        //- Clear storage
+        void clearStorage()
+        {
+            buf_.clearStorage();
+            stream_.clear(); // for safety, clear any old errors
+        }
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class OListStream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An OSstream attached to a List
+class OListStream
+:
+    public OListStreamAllocator,
+    public OSstream
+{
+    typedef OListStreamAllocator allocator_type;
+
+public:
+
+    // Constructors
+
+        //- Construct with an empty list
+        OListStream
+        (
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(),
+            OSstream(stream_, "output", format, version)
+        {}
+
+
+        //- Construct with a specified number of reserved bytes
+        OListStream
+        (
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(nbytes),
+            OSstream(stream_, "output", format, version)
+        {}
+
+
+        //- Move construct from an existing List
+        OListStream
+        (
+            List<char>&& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(std::move(buffer)),
+            OSstream(stream_, "output", format, version)
+        {}
+
+
+        //- Move construct from an existing DynamicList
+        template<int SizeMin>
+        OListStream
+        (
+            DynamicList<char,SizeMin>&& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(std::move(buffer)),
+            OSstream(stream_, "output", format, version)
+        {}
+
+        //- Transfer (move) construct
+        OListStream
+        (
+            const Xfer<List<char>>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(buffer),
+            OSstream(stream_, "output", format, version)
+        {}
+
+
+    // Member functions
+
+        //- Rewind the stream, clearing any old errors
+        virtual void rewind()
+        {
+            allocator_type::rewind();
+            setGood();  // resynchronize with internal state
+        }
+
+        //- Print description to Ostream
+        virtual void print(Ostream& os) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..8235b2edd5c523552d85bc54b1ea8fbc48e33e2c
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H
@@ -0,0 +1,314 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::UIListStream
+
+Description
+    Similar to IStringStream but using an externally managed buffer for its
+    input. This allows the input buffer to be filled (and refilled) from
+    various sources.
+
+    Note that this stream will normally be used as a "one-shot" reader.
+    Caution must be exercised that the referenced buffer remains valid and
+    without any intermediate resizing for the duration of the stream's use.
+
+    An example of possible use:
+    \code
+        DynamicList<char> buffer(4096);   // allocate some large buffer
+
+        nread = something.read(buffer.data(),1024); // fill with content
+        buffer.setSize(nread);            // content size
+
+        // construct dictionary, or something else
+        UIListStream is(buffer)
+        dictionary dict1(is);
+
+        // sometime later
+        nread = something.read(buffer.data(),2048); // fill with content
+        buffer.setSize(nread);              // content size
+
+        // without intermediate variable
+        dictionary dict2(UIListStream(buffer)());
+    \endcode
+
+See Also
+    Foam::IListStream
+    Foam::OListStream
+    Foam::UOListStream
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef UIListStream_H
+#define UIListStream_H
+
+#include "FixedList.H"
+#include "UList.H"
+#include "ISstream.H"
+#include "memoryStreamBuffer.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class UIListAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An stream/stream-buffer input allocator for a externally allocated lists
+class UIListStreamAllocator
+{
+    //- A streambuf class for input from UList or equivalent
+    class ulistbuf
+    :
+        public memorybuf::in
+    {
+        friend UIListStreamAllocator;
+
+        //- Underlying list storage
+        UList<char> list_;
+
+    public:
+
+        //- Construct for specified buffer
+        ulistbuf(UList<char>& buffer)
+        :
+            list_(buffer)
+        {
+            set_gbuffer(list_);
+        }
+
+        //- Construct for specified buffer
+        ulistbuf(char* buffer, std::streamsize num)
+        :
+            list_(buffer, num)
+        {
+            set_gbuffer(list_);
+        }
+
+        //- Sync get buffer pointers to agree with list dimensions
+        inline void sync_gbuffer_to_list()
+        {
+            set_gbuffer(list_);
+        }
+    };
+
+protected:
+
+    // Protected data
+
+        typedef std::istream stream_type;
+
+        //- The stream buffer
+        ulistbuf buf_;
+
+        //- The stream
+        stream_type stream_;
+
+
+    // Constructors
+
+        //- Construct with list buffer
+        UIListStreamAllocator(UList<char>& list)
+        :
+            buf_(list),
+            stream_(&buf_)
+        {}
+
+        //- Construct with buffer and number of bytes
+        UIListStreamAllocator(char *buffer, size_t nbytes)
+        :
+            buf_(buffer, nbytes),
+            stream_(&buf_)
+        {}
+
+
+    // Protected Member Functions
+
+        //- Sync get buffer pointers to agree with list dimensions
+        inline void sync_gbuffer_to_list()
+        {
+            buf_.sync_gbuffer_to_list();
+        }
+
+        void printBufInfo(Ostream& os) const
+        {
+            os  << "pos=" << buf_.tellg()
+                << " size=" << buf_.list_.size();
+        }
+
+public:
+
+    // Public Member Functions
+
+        //- Const access to available contents as a list of characters
+        inline const UList<char>& list() const
+        {
+            return buf_.list_;
+        }
+
+
+        //- Non-const access to available contents as a list of characters
+        inline UList<char> list()
+        {
+            return buf_.list_;
+        }
+
+
+        //- The list size
+        inline label size() const
+        {
+            return buf_.list_.size();
+        }
+
+
+        //- Position of the get buffer
+        std::streampos tellg() const
+        {
+            return buf_.tellg();
+        }
+
+
+        //- Move to buffer start, clear errors
+        void rewind()
+        {
+            buf_.pubseekpos(0, std::ios_base::in);
+            stream_.clear(); // for safety, clear any old errors
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class UIListStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class UIListStream
+:
+    public UIListStreamAllocator,
+    public ISstream
+{
+    typedef UIListStreamAllocator allocator_type;
+
+public:
+
+    // Constructors
+
+        //- Construct using specified buffer and number of bytes
+        UIListStream
+        (
+            const char* buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            allocator_type(const_cast<char*>(buffer), nbytes),
+            ISstream(stream_, name, format, version)
+        {}
+
+
+        //- Construct using data area from a FixedList
+        template<unsigned FixedSize>
+        UIListStream
+        (
+            const FixedList<char,FixedSize>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            UIListStream(buffer.cdata(), FixedSize, format, version, name)
+        {}
+
+        //- Construct using data area from a List and number of bytes
+        UIListStream
+        (
+            const UList<char>& buffer,
+            label size,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            UIListStream(buffer.cdata(), size, format, version, name)
+        {}
+
+
+        //- Construct using data area from a List and its inherent storage size
+        //  Uses addressed size, thus no special treatment for a DynamicList
+        UIListStream
+        (
+            const UList<char>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion,
+            const Foam::string& name="input"
+        )
+        :
+            UIListStream(buffer.cdata(), buffer.size(), format, version, name)
+        {}
+
+
+    // Member functions
+
+        //- Return the current get position in the buffer
+        std::streampos pos() const
+        {
+            return allocator_type::tellg();
+        }
+
+
+        //- Rewind the stream, clearing any old errors
+        virtual void rewind()
+        {
+            allocator_type::rewind();
+            setGood();  // resynchronize with internal state
+        }
+
+
+        //- Print description to Ostream
+        virtual void print(Ostream& os) const;
+
+
+    // Member operators
+
+        //- A non-const reference to const Istream
+        //  Needed for read-constructors where the stream argument is temporary
+        Istream& operator()() const
+        {
+            return const_cast<Istream&>(static_cast<const Istream&>(*this));
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/UListStream.H b/src/OpenFOAM/db/IOstreams/memory/UListStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..132dc812128d3eabb4db240f0310c1bed9e1efde
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/UListStream.H
@@ -0,0 +1,37 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+    Input/output streams with externally managed storage.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef UListStream_H
+#define UListStream_H
+
+#include "UIListStream.H"
+#include "UOListStream.H"
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/UOListStream.H b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..df255cd92e355adcc7a7659e9172a4d11a647ac2
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H
@@ -0,0 +1,322 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::UOListStream
+
+Description
+    Similar to OStringStream but using an externally managed buffer for
+    its output.
+
+    This allows the output buffer to be reused and can make it easier when
+    writing out data.  It is the user's responsibility to ensure proper
+    synchronization in the sizes. Provided that the external buffer is large
+    enough that overflow does not occur, the following usage pattern
+    works.
+
+    \code
+        DynamicList<char> buffer(4096);     // allocate some large buffer
+
+        {
+            UOListStream os(buffer);
+            os << "content1" << " and more content";
+            buffer.setSize(os.size());      // synchronize sizes
+        }
+
+        something.write(buffer, buffer.size());
+    \endcode
+
+    Although the UOListStream is quite lightweight, there may be cases
+    where it is preferable to reuse the stream as well.
+    \code
+        DynamicList<char> buffer(4096);     // allocate some large buffer
+
+        UOListStream os(buffer);
+        os << "content1" << " and more content";
+        buffer.setSize(os.size());          // synchronize sizes
+
+        something.write(buffer, buffer.size());
+
+        os.rewind();
+        os << "content2";
+        buffer.setSize(os.size());      // synchronize sizes
+
+        something.write(buffer, buffer.size());
+
+        // or simply using the output size directly (without sync)
+        os.rewind();
+        os << "content3";
+
+        something.write(buffer, os.size());
+    \endcode
+
+See Also
+    Foam::IListStream
+    Foam::OListStream
+    Foam::UIListStream
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef UOListStream_H
+#define UOListStream_H
+
+#include "DynamicList.H"
+#include "FixedList.H"
+#include "OSstream.H"
+#include "memoryStreamBuffer.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                    Class UOListAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An stream/stream-buffer allocator for external buffers
+class UOListAllocator
+{
+    //- A streambuf adapter for output to UList or equivalent
+    class ulistbuf
+    :
+        public memorybuf::out
+    {
+        friend UOListAllocator;
+
+        //- Underlying list storage
+        UList<char> list_;
+
+    public:
+
+      // Constructors
+
+        //- Construct for specified buffer
+        ulistbuf(char* buffer, std::streamsize num)
+        :
+            list_(buffer, num)
+        {
+            set_pbuffer(list_);
+        }
+
+
+      // Member Functions
+
+        //- Return the current list output capacity
+        inline label capacity() const
+        {
+            return list_.size();
+        }
+
+        //- Sync put buffer pointers to agree with list dimensions
+        inline void sync_pbuffer_to_list()
+        {
+            set_pbuffer(list_);
+        }
+    };
+
+
+protected:
+
+    // Protected data
+
+        typedef std::ostream stream_type;
+
+        //- The stream buffer
+        ulistbuf buf_;
+
+        //- The stream
+        stream_type stream_;
+
+
+    // Constructors
+
+        //- Construct with buffer and number of bytes
+        UOListAllocator(char *buffer, size_t nbytes)
+        :
+            buf_(buffer, nbytes),
+            stream_(&buf_)
+        {}
+
+
+    // Protected Member Functions
+
+        void printBufInfo(Ostream& os) const
+        {
+            os  << "pos=" << buf_.tellp()
+                << " capacity=" << buf_.capacity();
+        }
+
+public:
+
+    // Public Member Functions
+
+        //- The current list output capacity
+        inline label capacity() const
+        {
+            return buf_.capacity();
+        }
+
+
+        //- The current output position in the buffer,
+        //  which is also the addressed list size
+        inline label size() const
+        {
+            return buf_.tellp();
+        }
+
+
+        //- Const access to written contents as a list of characters
+        inline const UList<char> list() const
+        {
+            return UList<char>
+            (
+                const_cast<char*>(buf_.list_.cdata()),
+                buf_.tellp()
+            );
+        }
+
+
+        //- Non-const access to written contents as a list of characters
+        inline UList<char> list()
+        {
+            return UList<char>
+            (
+                const_cast<char*>(buf_.list_.cdata()),
+                buf_.tellp()
+            );
+        }
+
+
+        //- Move to buffer start, clear errors
+        void rewind()
+        {
+            buf_.pubseekpos(0, std::ios_base::out);
+            stream_.clear(); // for safety, clear any old errors
+        }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class UOListStream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An OSstream attached to an unallocated external buffer
+class UOListStream
+:
+    public UOListAllocator,
+    public OSstream
+{
+    typedef UOListAllocator allocator_type;
+
+public:
+
+    // Constructors
+
+        //- Construct using specified buffer and number of bytes
+        UOListStream
+        (
+            char* buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            allocator_type(buffer, nbytes),
+            OSstream(stream_, "output", format, version)
+        {}
+
+
+        //- Construct using data area from a List and number of bytes
+        UOListStream
+        (
+            UList<char>& buffer,
+            size_t size,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            UOListStream(buffer.data(), size, format, version)
+        {}
+
+        //- Construct using data area from a FixedList
+        template<unsigned FixedSize>
+        UOListStream
+        (
+            FixedList<char,FixedSize>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            UOListStream(buffer.data(), FixedSize, format, version)
+        {}
+
+        //- Construct using data area from a List and its inherent storage size
+        UOListStream
+        (
+            UList<char>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            UOListStream(buffer.data(), buffer.size(), format, version)
+        {}
+
+
+        //- Construct using data area from a DynamicList and its capacity
+        template<int SizeMin>
+        UOListStream
+        (
+            DynamicList<char,SizeMin>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            UOListStream(buffer.data(), buffer.capacity(), format, version)
+        {}
+
+
+    // Member functions
+
+        //- Rewind the stream, clearing any old errors
+        virtual void rewind()
+        {
+            allocator_type::rewind();
+            setGood();  // resynchronize with internal state
+        }
+
+        //- Print description to Ostream
+        virtual void print(Ostream& os) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H
new file mode 100644
index 0000000000000000000000000000000000000000..48bfd45ddb82d42c9cf54e1cdaece0f663162459
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H
@@ -0,0 +1,224 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::memorybuf
+
+Description
+    A std::streambuf used for memory buffer streams such as
+    UIListStream, UOListStream, etc.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef memoryStreamBuffer_H
+#define memoryStreamBuffer_H
+
+#include "UList.H"
+#include <type_traits>
+#include <sstream>
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                          Class memorybuf Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A streambuf for memory
+class memorybuf
+:
+    public std::streambuf
+{
+protected:
+
+    //- Set position pointer to relative position
+    virtual std::streampos seekoff
+    (
+        std::streamoff off,
+        std::ios_base::seekdir way,
+        std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
+    )
+    {
+        const bool testin  = which & std::ios_base::in;
+        const bool testout = which & std::ios_base::out;
+
+        if (way == std::ios_base::beg)
+        {
+            if (testin)
+            {
+                setg(eback(), eback(), egptr());
+                gbump(off);
+            }
+            if (testout)
+            {
+                setp(pbase(), epptr());
+                pbump(off);
+            }
+        }
+        else if (way == std::ios_base::cur)
+        {
+            if (testin)
+            {
+                gbump(off);
+            }
+            if (testout)
+            {
+                pbump(off);
+            }
+        }
+        else if (way == std::ios_base::end)
+        {
+            if (testin)
+            {
+                setg(eback(), eback(), egptr());
+                gbump(egptr() - eback() - off);
+            }
+            if (testout)
+            {
+                setp(pbase(), epptr());
+                pbump(epptr() - pbase() - off);
+            }
+        }
+
+        if (testin)
+        {
+            return (gptr() - eback()); // tellg()
+        }
+        if (testout)
+        {
+            return (pptr() - pbase()); // tellp()
+        }
+
+        return -1;
+    }
+
+
+    //- Set position pointer to absolute position
+    virtual std::streampos seekpos
+    (
+        std::streampos pos,
+        std::ios_base::openmode which = std::ios_base::in|std::ios_base::out
+    )
+    {
+        return seekoff(pos, std::ios_base::beg, which);
+    }
+
+
+public:
+
+    // Forward declarations
+    class in;
+    class out;
+};
+
+
+/*---------------------------------------------------------------------------*\
+                        Class memorybuf::in Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An input streambuf for memory access
+class memorybuf::in
+:
+    public memorybuf
+{
+protected:
+
+    //- Get sequence of characters
+    virtual std::streamsize xsgetn(char* s, std::streamsize n)
+    {
+        std::streamsize count = 0;
+
+        while (count < n && gptr() < egptr())
+        {
+            *(s + count++) = *(gptr());
+            gbump(1);
+        }
+
+        return count;
+    }
+
+
+    //- The buffer get position
+    inline std::streamsize tellg() const
+    {
+        return (gptr() - eback());
+    }
+
+    //- Sync get buffer pointers to agree with list dimensions
+    inline void set_gbuffer(UList<char>& list)
+    {
+        setg(list.begin(), list.begin(), list.end());
+    }
+};
+
+
+/*---------------------------------------------------------------------------*\
+                       Class memorybuf::out Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An output streambuf for memory access
+class memorybuf::out
+:
+    public memorybuf
+{
+protected:
+
+    //- Put sequence of characters
+    virtual std::streamsize xsputn(const char* s, std::streamsize n)
+    {
+        std::streamsize count = 0;
+        while (count < n && pptr() < epptr())
+        {
+            *(pptr()) = *(s + count++);
+            pbump(1);
+        }
+
+        return count;
+    }
+
+    //- The buffer put position
+    inline std::streamsize tellp() const
+    {
+        return (pptr() - pbase());
+    }
+
+    //- Sync put buffer pointers to agree with list dimensions
+    inline void set_pbuffer(UList<char>& list)
+    {
+        setp(list.begin(), list.end());
+    }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/token/token.C b/src/OpenFOAM/db/IOstreams/token/token.C
index 17019bda99ddeb9c8ab1ac4e37d3a893312e2b5b..c082df43cc9352d22daa616aa202f9fcf3f5a5e5 100644
--- a/src/OpenFOAM/db/IOstreams/token/token.C
+++ b/src/OpenFOAM/db/IOstreams/token/token.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -29,14 +29,14 @@ License
 
 namespace Foam
 {
-    const char* const token::typeName = "token";
-    token token::undefinedToken;
-
     typedef token::compound tokenCompound;
     defineTypeNameAndDebug(tokenCompound, 0);
     defineRunTimeSelectionTable(tokenCompound, Istream);
 }
 
+const char* const Foam::token::typeName = "token";
+const Foam::token Foam::token::undefinedToken;
+
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
@@ -94,24 +94,22 @@ Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is)
 {
     if (type_ == tokenType::COMPOUND)
     {
-        if (compoundTokenPtr_->empty())
+        if (data_.compoundPtr->empty())
         {
             FatalIOErrorInFunction(is)
-                << "compound has already been transfered from token\n    "
+                << "compound has already been transferred from token\n    "
                 << info() << abort(FatalIOError);
         }
         else
         {
-            compoundTokenPtr_->empty() = true;
+            data_.compoundPtr->empty() = true;
         }
 
-        return *compoundTokenPtr_;
-    }
-    else
-    {
-        parseError("compound");
-        return *compoundTokenPtr_;
+        return *data_.compoundPtr;
     }
+
+    parseError("compound");
+    return *data_.compoundPtr;
 }
 
 
diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H
index 1de16e5e13a993e556153f224b01ee3a728c6dcd..868019ba3afc025a3481d42447ddb58db5a297fe 100644
--- a/src/OpenFOAM/db/IOstreams/token/token.H
+++ b/src/OpenFOAM/db/IOstreams/token/token.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,7 +25,7 @@ Class
     Foam::token
 
 Description
-    A token holds items read from Istream.
+    A token holds an item read from Istream.
 
 SourceFiles
     tokenI.H
@@ -64,34 +64,50 @@ Ostream& operator<<(Ostream& os, const token& t);
 
 
 /*---------------------------------------------------------------------------*\
-                           Class token Declaration
+                            Class token Declaration
 \*---------------------------------------------------------------------------*/
 
 class token
 {
-
 public:
 
-    //- Enumeration defining the types of token
+    //- Enumeration defining the types of token.
+    //  Since these values are also used to tag content in Pstream,
+    //  the maximum number of types is limited to 30.
     enum tokenType
     {
-        UNDEFINED,
-
-        PUNCTUATION,
-        WORD,
-        VARIABLE,
-        STRING,
-        VERBATIMSTRING,
-        LABEL,
-        FLOAT_SCALAR,
-        DOUBLE_SCALAR,
-        COMPOUND,
-
-        ERROR
+        UNDEFINED,        //!< An undefined token-type
+
+        // Fundamental types
+        FLAG,             //!< stream flag (1-byte bitmask)
+        PUNCTUATION,      //!< single character punctuation
+        LABEL,            //!< label (integer) type
+        FLOAT_SCALAR,     //!< float (single-precision) type
+        DOUBLE_SCALAR,    //!< double (double-precision) type
+
+        // Pointer types
+        WORD,             //!< Contents represent a Foam::word
+        STRING,           //!< Contents represent a Foam::string
+        VARIABLE,         //!< Contents are a Foam::string representing a
+                          //!< dictionary \c $variable expansion
+        VERBATIMSTRING,   //!< Contents are a Foam::string representing verbatim
+                          //!< content
+        COMPOUND,         //!< Compound type such as List\<label\> etc.
+
+        ERROR             //!< A token error encountered
+    };
+
+
+    //- Stream or output control flags (1-byte width)
+    enum flagType
+    {
+        NO_FLAG = 0,   //!< No flags
+        ASCII   = 1,   //!< ASCII-mode stream
+        BINARY  = 2,   //!< BINARY-mode stream
     };
 
 
-    //- Standard punctuation tokens
+    //- Standard punctuation tokens (a character)
     enum punctuationToken
     {
         NULL_TOKEN     = '\0',
@@ -99,25 +115,26 @@ public:
         TAB            = '\t',
         NL             = '\n',
 
-        END_STATEMENT  = ';',
-        BEGIN_LIST     = '(',
-        END_LIST       = ')',
-        BEGIN_SQR      = '[',
-        END_SQR        = ']',
-        BEGIN_BLOCK    = '{',
-        END_BLOCK      = '}',
-        COLON          = ':',
-        COMMA          = ',',
+        END_STATEMENT  = ';', //!< End entry [#isseparator]
+        BEGIN_LIST     = '(', //!< Begin list [#isseparator]
+        END_LIST       = ')', //!< End list [#isseparator]
+        BEGIN_SQR      = '[', //!< Begin dimensions [#isseparator]
+        END_SQR        = ']', //!< End dimensions [#isseparator]
+        BEGIN_BLOCK    = '{', //!< Begin block [#isseparator]
+        END_BLOCK      = '}', //!< End block [#isseparator]
+        COLON          = ':', //!< Colon [#isseparator]
+        COMMA          = ',', //!< Comma [#isseparator]
         HASH           = '#',
+        ATSYM          = '@',
 
         BEGIN_STRING   = '"',
         END_STRING     = BEGIN_STRING,
 
-        ASSIGN         = '=',
-        ADD            = '+',
-        SUBTRACT       = '-',
-        MULTIPLY       = '*',
-        DIVIDE         = '/'
+        ASSIGN         = '=', //!< Assigment/equals [#isseparator]
+        ADD            = '+', //!< Addition [#isseparator]
+        SUBTRACT       = '-', //!< Substract or start of negative number
+        MULTIPLY       = '*', //!< Multiply [#isseparator]
+        DIVIDE         = '/'  //!< Divide [#isseparator]
     };
 
 
@@ -130,22 +147,11 @@ public:
 
             bool empty_;
 
-
-        // Private Member Functions
-
-            //- Disallow default bitwise copy construct
-            compound(const compound&) = delete;
-
-            //- Disallow default bitwise assignment
-            void operator=(const compound&) = delete;
-
-
     public:
 
         //- Runtime type information
         TypeName("compound");
 
-
         //- Declare run-time constructor selection table
         declareRunTimeSelectionTable
         (
@@ -165,11 +171,14 @@ public:
                 empty_(false)
             {}
 
+            //- No default copy construct
+            compound(const compound&) = delete;
+
 
         // Selectors
 
             //- Select null constructed
-            static autoPtr<compound> New(const word& type, Istream&);
+            static autoPtr<compound> New(const word& type, Istream& is);
 
 
         //- Destructor
@@ -178,31 +187,31 @@ public:
 
         // Member Functions
 
-            // Access
-
-                //- Return true if name is a compound type
-                static bool isCompound(const word& name);
+            //- Return true if name is a known compound type
+            static bool isCompound(const word& name);
 
-                bool empty() const
-                {
-                    return empty_;
-                }
+            bool empty() const
+            {
+                return empty_;
+            }
 
-                bool& empty()
-                {
-                    return empty_;
-                }
+            bool& empty()
+            {
+                return empty_;
+            }
 
-                virtual label size() const = 0;
+            virtual label size() const = 0;
 
-            // Write
+            virtual void write(Ostream& os) const = 0;
 
-                virtual void write(Ostream& os) const = 0;
 
+        // Operators
 
-        // IOstream Operators
+            //- No default assign operator
+            compound& operator=(const compound&) = delete;
 
-            friend Ostream& operator<<(Ostream&, const compound&);
+            //- Output operator
+            friend Ostream& operator<<(Ostream& os, const compound& ct);
     };
 
 
@@ -236,35 +245,50 @@ public:
 
 
     //- Static undefined token
-    static token undefinedToken;
+    static const token undefinedToken;
 
 
 private:
 
+    //- A %union of token types
+    union content
+    {
+        // Fundamental values. Largest first for any {} initialization.
+        int64_t int64Val;
+        int32_t int32Val;
+
+        int flagVal;   // bitmask - stored as int, not enum
+        punctuationToken punctuationVal;
+        label labelVal;
+        floatScalar floatVal;
+        doubleScalar doubleVal;
+
+        // Pointers
+        word* wordPtr;
+        string* stringPtr;
+        mutable compound* compoundPtr;
+    };
+
+
     // Private data
 
+        //- The data content (as a union).
+        //  For memory alignment this should appear as the first member.
+        content data_;
+
         //- The token type
         tokenType type_;
 
-        //- Anonymous Union of token types
-        union
-        {
-            punctuationToken punctuationToken_;
-            word* wordTokenPtr_;
-            string* stringTokenPtr_;
-            label labelToken_;
-            floatScalar floatScalarToken_;
-            doubleScalar doubleScalarToken_;
-            mutable compound* compoundTokenPtr_;
-        };
-
-        //- Line number in the file this token was read from
+        //- Line number in the file the token was read from
         label lineNumber_;
 
 
     // Private Member Functions
 
-        //- Clear any allocated storage (word or string)
+        //- Set as UNDEFINED and zero the union content without any checking
+        inline void setUndefined();
+
+        //- Clear any allocated storage (word or string) and set to UNDEFINED
         inline void clear();
 
         // Parse error, expected 'expected', found ...
@@ -283,18 +307,15 @@ public:
         //- Construct null
         inline token();
 
-        //- Construct as copy
+        //- Copy construct
         inline token(const token& t);
 
+        //- Move construct. The original token is left as UNDEFINED.
+        inline token(token&& t);
+
         //- Construct punctuation character token
         inline explicit token(punctuationToken p);
 
-        //- Construct word token
-        inline explicit token(const word& w);
-
-        //- Construct string token
-        inline explicit token(const string& str);
-
         //- Construct label token
         inline explicit token(const label val);
 
@@ -304,15 +325,15 @@ public:
         //- Construct doubleScalar token
         inline explicit token(const doubleScalar val);
 
+        //- Construct word token by copying word contents
+        inline explicit token(const word& w);
 
-        //- Construct punctuation character token
-        inline token(punctuationToken p, const label lineNumber);
+        //- Construct string token by copying string contents
+        inline explicit token(const string& str);
 
-        //- Construct word token
-        inline token(const word& w, const label lineNumber);
 
-        //- Construct string token
-        inline token(const string& str, const label lineNumber);
+        //- Construct punctuation character token
+        inline token(punctuationToken p, const label lineNumber);
 
         //- Construct label token
         inline token(const label val, const label lineNumber);
@@ -323,6 +344,12 @@ public:
         //- Construct doubleScalar token
         inline token(const doubleScalar val, const label lineNumber);
 
+        //- Construct word token by copying word contents
+        inline token(const word& w, const label lineNumber);
+
+        //- Construct string token by copying string contents
+        inline token(const string& str, const label lineNumber);
+
         //- Construct from Istream
         token(Istream& is);
 
@@ -331,108 +358,228 @@ public:
     inline ~token();
 
 
+    // Static Member Functions
+
+        //- Create a token with stream flags, no sanity check
+        //
+        //  \param bitmask the flags to set
+        inline static token flag(int bitmask);
+
+        //- True if the character is a punctuation separator (eg, in ISstream).
+        //  Since it could also start a number, SUBTRACT is not included as
+        //  a separator.
+        //
+        //  \param c the character to test, passed as int for consistency with
+        //      isdigit, isspace etc.
+        inline static bool isseparator(int c);
+
+
     // Member functions
 
-        // Access
+    // Status
 
-            inline tokenType type() const;
-            inline tokenType& type();
+        //- Return the name of the token type
+        word name() const;
 
-            inline bool good() const;
-            inline bool undefined() const;
-            inline bool error() const;
+        //- Return the token type
+        inline tokenType type() const;
 
-            inline bool isPunctuation() const;
-            inline punctuationToken pToken() const;
+        //- Change the token type, for similar types.
+        //  This can be used to change between string-like variants
+        //  (eg, STRING, VARIABLE, VERBATIMSTRING)
+        //  To change types entirely (eg, STRING to DOUBLE_SCALAR),
+        //  use the corresponding assignment operator.
+        //
+        //  \return true if the change was successful or no change was required
+        inline bool setType(const tokenType variant);
 
-            inline bool isWord() const;
-            inline const word& wordToken() const;
+        //- The line number for the token
+        inline label lineNumber() const;
 
-            inline bool isVariable() const;
+        //- The line number for the token
+        inline label& lineNumber();
 
-            inline bool isString() const;
-            inline const string& stringToken() const;
+        //- True if token is not UNDEFINED or ERROR
+        inline bool good() const;
 
-            inline bool isLabel() const;
-            inline label labelToken() const;
+        //- True if token is UNDEFINED
+        inline bool undefined() const;
 
-            inline bool isFloatScalar() const;
-            inline floatScalar floatScalarToken() const;
+        //- True if token is ERROR
+        inline bool error() const;
 
-            inline bool isDoubleScalar() const;
-            inline doubleScalar doubleScalarToken() const;
+        //- True if token is FLAG
+        inline bool isFlag() const;
 
-            inline bool isScalar() const;
-            inline scalar scalarToken() const;
+        //- True if token is PUNCTUATION
+        inline bool isPunctuation() const;
 
-            inline bool isNumber() const;
-            inline scalar number() const;
+        //- True if token is PUNCTUATION and isseparator
+        inline bool isSeparator() const;
 
-            inline bool isCompound() const;
-            inline const compound& compoundToken() const;
-            compound& transferCompoundToken(const Istream& is);
+        //- True if token is LABEL
+        inline bool isLabel() const;
 
-            inline label lineNumber() const;
-            inline label& lineNumber();
+        //- True if token is FLOAT_SCALAR
+        inline bool isFloatScalar() const;
 
+        //- True if token is DOUBLE_SCALAR
+        inline bool isDoubleScalar() const;
 
-        // Edit
+        //- True if token is FLOAT_SCALAR or DOUBLE_SCALAR
+        inline bool isScalar() const;
 
-            //- Set bad
-            inline void setBad();
+        //- True if token is LABEL, FLOAT_SCALAR or DOUBLE_SCALAR
+        inline bool isNumber() const;
 
+        //- True if token is WORD
+        inline bool isWord() const;
 
-        // Info
+        //- True if token is STRING, VARIABLE or VERBATIMSTRING
+        inline bool isString() const;
 
-            //- Return info proxy.
-            //  Used to print token information to a stream
-            InfoProxy<token> info() const
-            {
-                return *this;
-            }
+        //- True if token is VARIABLE
+        inline bool isVariable() const;
+
+        //- True if token is COMPOUND
+        inline bool isCompound() const;
+
+
+    // Access
+
+        //- Return flag bitmask
+        //  Report FatalIOError and return NO_FLAG if token is not FLAG
+        inline int flagToken() const;
+
+        //- Return punctuation character.
+        //  Report FatalIOError and return \b \\0 if token is not PUNCTUATION
+        inline punctuationToken pToken() const;
+
+        //- Return label value.
+        //  Report FatalIOError and return \b 0 if token is not LABEL
+        inline label labelToken() const;
+
+        //- Return float value.
+        //  Report FatalIOError and return \b 0.0 if token is not FLOAT_SCALAR
+        inline floatScalar floatScalarToken() const;
+
+        //- Return double value.
+        //  Report FatalIOError and return \b 0.0 if token is not DOUBLE_SCALAR
+        inline doubleScalar doubleScalarToken() const;
+
+        //- Return float or double value.
+        //  Report FatalIOError and return \b 0.0 if token is not a
+        //  FLOAT_SCALAR or DOUBLE_SCALAR
+        inline scalar scalarToken() const;
+
+        //- Return label, float or double value.
+        //  Report FatalIOError and return \b 0.0 if token is not a
+        //  LABEL, FLOAT_SCALAR or DOUBLE_SCALAR
+        inline scalar number() const;
+
+        //- Return const reference to the word contents.
+        //  Report FatalIOError and return \b "" if token is not a WORD
+        inline const word& wordToken() const;
+
+        //- Return const reference to the string contents.
+        //  Report FatalIOError and return \b "" if token is not a
+        //  STRING, VARIABLE or VERBATIMSTRING
+        inline const string& stringToken() const;
+
+        //- Read access for compound token
+        inline const compound& compoundToken() const;
+
+        //- Return reference to compound token and decrease its internal
+        //- refCound accordingly.
+        //  The Istream is used for reference error messages only.
+        compound& transferCompoundToken(const Istream& is);
+
+
+    // Edit
+
+        //- Clear token and set to be in an error state.
+        inline void setBad();
+
+        //- Swap token contents: type, data, line-number
+        inline void swap(token& tok);
+
+
+    // Info
+
+        //- Return info proxy for printing token information to a stream
+        InfoProxy<token> info() const
+        {
+            return *this;
+        }
 
 
     // Member operators
 
-        // Assignment
+    // Assignment
+
+        //- Copy assign
+        inline void operator=(const token& tok);
+
+        //- Move assign
+        inline void operator=(token&& tok);
+
+        //- Copy assign from punctuation
+        inline void operator=(const punctuationToken p);
+
+        //- Copy assign from label
+        inline void operator=(const label val);
+
+        //- Copy assign from float
+        inline void operator=(const floatScalar val);
+
+        //- Copy assign from double
+        inline void operator=(const doubleScalar val);
+
+        //- Copy assign from word
+        inline void operator=(const word& w);
+
+        //- Copy assign from string
+        inline void operator=(const string& str);
 
-            inline void operator=(const token& t);
+        //- Move assign from word
+        inline void operator=(word&& w);
 
-            inline void operator=(const punctuationToken p);
+        //- Move assign from string
+        inline void operator=(string&& str);
 
-            inline void operator=(word* wPtr);
-            inline void operator=(const word& w);
+        //- Transfer word pointer to the token
+        //  \deprecated in favour of using move assign from word
+        inline void operator=(word* wordPtr);
 
-            inline void operator=(string* strPtr);
-            inline void operator=(const string& str);
+        //- Transfer string pointer to the token
+        //  \deprecated in favour of using move assign from string
+        inline void operator=(string* stringPtr);
 
-            inline void operator=(const label val);
-            inline void operator=(const floatScalar val);
-            inline void operator=(const doubleScalar val);
+        //- Assign compound with reference counting to token
+        inline void operator=(compound* compoundPtr);
 
-            inline void operator=(compound* compPtr);
 
+    // Equality
 
-        // Equality
+        inline bool operator==(const token& t) const;
 
-            inline bool operator==(const token& t) const;
-            inline bool operator==(const punctuationToken p) const;
-            inline bool operator==(const word& w) const;
-            inline bool operator==(const string& str) const;
-            inline bool operator==(const label val) const;
-            inline bool operator==(const floatScalar val) const;
-            inline bool operator==(const doubleScalar val) const;
+        inline bool operator==(const punctuationToken p) const;
+        inline bool operator==(const label val) const;
+        inline bool operator==(const floatScalar val) const;
+        inline bool operator==(const doubleScalar val) const;
+        inline bool operator==(const word& w) const;
+        inline bool operator==(const string& str) const;
 
 
-        // Inequality
+    // Inequality
 
-            inline bool operator!=(const token& t) const;
-            inline bool operator!=(const punctuationToken p) const;
-            inline bool operator!=(const word& w) const;
-            inline bool operator!=(const string& str) const;
-            inline bool operator!=(const label val) const;
-            inline bool operator!=(const floatScalar val) const;
-            inline bool operator!=(const doubleScalar val) const;
+        inline bool operator!=(const token& t) const;
+        inline bool operator!=(const punctuationToken p) const;
+        inline bool operator!=(const label val) const;
+        inline bool operator!=(const floatScalar val) const;
+        inline bool operator!=(const doubleScalar val) const;
+        inline bool operator!=(const word& w) const;
+        inline bool operator!=(const string& str) const;
 
 
     // IOstream operators
diff --git a/src/OpenFOAM/db/IOstreams/token/tokenI.H b/src/OpenFOAM/db/IOstreams/token/tokenI.H
index 32417b4e7507d7fcb32ae525a34f3e97cf88c163..f6868ec15239a01f9fb25e1d7bbc8cf98ec368b5 100644
--- a/src/OpenFOAM/db/IOstreams/token/tokenI.H
+++ b/src/OpenFOAM/db/IOstreams/token/tokenI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -23,36 +23,96 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+#include <algorithm>
 
-inline void Foam::token::clear()
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+inline Foam::token Foam::token::flag(int bitmask)
 {
-    if (type_ == tokenType::WORD)
-    {
-        delete wordTokenPtr_;
-    }
-    else if
-    (
-        type_ == tokenType::STRING
-     || type_ == tokenType::VARIABLE
-     || type_ == tokenType::VERBATIMSTRING
-    )
+    token tok;
+    tok.type_ = tokenType::FLAG;
+    tok.data_.flagVal = bitmask;
+
+    return tok;
+}
+
+
+inline bool Foam::token::isseparator(int c)
+{
+    switch (c)
     {
-        delete stringTokenPtr_;
+        case token::END_STATEMENT :
+        case token::BEGIN_LIST :
+        case token::END_LIST :
+        case token::BEGIN_SQR :
+        case token::END_SQR :
+        case token::BEGIN_BLOCK :
+        case token::END_BLOCK :
+        case token::COLON :
+        case token::COMMA :
+        case token::ASSIGN :
+        case token::ADD :
+        // Excluded token::SUBTRACT since it could start a number
+        case token::MULTIPLY :
+        case token::DIVIDE :
+        {
+            return true;
+        }
+
+        default:
+            break;
     }
-    else if (type_ == tokenType::COMPOUND)
+
+    return false;
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+inline void Foam::token::setUndefined()
+{
+    type_ = tokenType::UNDEFINED;
+    data_.int64Val = 0; // bit-wise zero for union content
+    // leave lineNumber untouched - may still be needed
+}
+
+
+inline void Foam::token::clear()
+{
+    switch (type_)
     {
-        if (compoundTokenPtr_->unique())
+        case tokenType::WORD:
         {
-            delete compoundTokenPtr_;
+            delete data_.wordPtr;
+            break;
         }
-        else
+
+        case tokenType::STRING:
+        case tokenType::VARIABLE:
+        case tokenType::VERBATIMSTRING:
+        {
+            delete data_.stringPtr;
+            break;
+        }
+
+        case tokenType::COMPOUND:
         {
-            compoundTokenPtr_->refCount::operator--();
+            if (data_.compoundPtr->unique())
+            {
+                delete data_.compoundPtr;
+            }
+            else
+            {
+                data_.compoundPtr->refCount::operator--();
+            }
+            break;
         }
+
+        default:
+            break;
     }
 
-    type_ = tokenType::UNDEFINED;
+    setUndefined();
 }
 
 
@@ -60,58 +120,62 @@ inline void Foam::token::clear()
 
 inline Foam::token::token()
 :
+    data_(), // bit-wise zero for union content
     type_(tokenType::UNDEFINED),
     lineNumber_(0)
 {}
 
 
-inline Foam::token::token(const token& t)
+inline Foam::token::token(const token& tok)
 :
-    type_(t.type_),
-    lineNumber_(t.lineNumber_)
+    data_(tok.data_), // bit-wise copy of union content
+    type_(tok.type_),
+    lineNumber_(tok.lineNumber_)
 {
+    // Fundamental: values already handled by bit-wise copy
+    // Pointer: duplicate content or increase refCount
+
     switch (type_)
     {
-        case tokenType::UNDEFINED:
-        break;
-
-        case tokenType::PUNCTUATION:
-            punctuationToken_ = t.punctuationToken_;
-        break;
-
         case tokenType::WORD:
-            wordTokenPtr_ = new word(*t.wordTokenPtr_);
-        break;
+        {
+            data_.wordPtr = new word(*tok.data_.wordPtr);
+            break;
+        }
 
         case tokenType::STRING:
         case tokenType::VARIABLE:
         case tokenType::VERBATIMSTRING:
-            stringTokenPtr_ = new string(*t.stringTokenPtr_);
-        break;
-
-        case tokenType::LABEL:
-            labelToken_ = t.labelToken_;
-        break;
-
-        case tokenType::FLOAT_SCALAR:
-            floatScalarToken_ = t.floatScalarToken_;
-        break;
-
-        case tokenType::DOUBLE_SCALAR:
-            doubleScalarToken_ = t.doubleScalarToken_;
-        break;
+        {
+            data_.stringPtr = new string(*tok.data_.stringPtr);
+            break;
+        }
 
         case tokenType::COMPOUND:
-            compoundTokenPtr_ = t.compoundTokenPtr_;
-            compoundTokenPtr_->refCount::operator++();
-        break;
+        {
+            // Identical pointers, but increase the refCount
+            data_.compoundPtr = tok.data_.compoundPtr;
+            data_.compoundPtr->refCount::operator++();
+            break;
+        }
 
-        case tokenType::ERROR:
-        break;
+        default:
+            break;
     }
 }
 
 
+inline Foam::token::token(token&& tok)
+:
+    data_(tok.data_), // bit-wise copy of union content
+    type_(tok.type_),
+    lineNumber_(tok.lineNumber_)
+{
+    tok.setUndefined(); // zero the union content without any checking
+    tok.lineNumber_ = 0;
+}
+
+
 inline Foam::token::token(punctuationToken p)
 :
     token(p, 0)
@@ -150,50 +214,62 @@ inline Foam::token::token(const doubleScalar val)
 
 inline Foam::token::token(punctuationToken p, label lineNumber)
 :
+    data_(),
     type_(tokenType::PUNCTUATION),
-    punctuationToken_(p),
     lineNumber_(lineNumber)
-{}
+{
+    data_.punctuationVal = p;
+}
 
 
-inline Foam::token::token(const word& w, label lineNumber)
+inline Foam::token::token(const label val, label lineNumber)
 :
-    type_(tokenType::WORD),
-    wordTokenPtr_(new word(w)),
+    data_(),
+    type_(tokenType::LABEL),
     lineNumber_(lineNumber)
-{}
+{
+    data_.labelVal = val;
+}
 
 
-inline Foam::token::token(const string& str, label lineNumber)
+inline Foam::token::token(const floatScalar val, label lineNumber)
 :
-    type_(tokenType::STRING),
-    stringTokenPtr_(new string(str)),
+    data_(),
+    type_(tokenType::FLOAT_SCALAR),
     lineNumber_(lineNumber)
-{}
+{
+    data_.floatVal = val;
+}
 
 
-inline Foam::token::token(const label val, label lineNumber)
+inline Foam::token::token(const doubleScalar val, label lineNumber)
 :
-    type_(tokenType::LABEL),
-    labelToken_(val),
+    data_(),
+    type_(tokenType::DOUBLE_SCALAR),
     lineNumber_(lineNumber)
-{}
+{
+    data_.doubleVal = val;
+}
 
 
-inline Foam::token::token(const floatScalar val, label lineNumber)
+inline Foam::token::token(const word& w, label lineNumber)
 :
-    type_(tokenType::FLOAT_SCALAR),
-    floatScalarToken_(val),
+    data_(),
+    type_(tokenType::WORD),
     lineNumber_(lineNumber)
-{}
+{
+    data_.wordPtr = new word(w);
+}
 
 
-inline Foam::token::token(const doubleScalar val, label lineNumber)
+inline Foam::token::token(const string& str, label lineNumber)
 :
-    type_(tokenType::DOUBLE_SCALAR),
-    doubleScalarToken_(val),
+    data_(),
+    type_(tokenType::STRING),
     lineNumber_(lineNumber)
-{}
+{
+    data_.stringPtr = new string(str);
+}
 
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
@@ -206,134 +282,167 @@ inline Foam::token::~token()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-inline Foam::token::tokenType  Foam::token::type() const
+inline void Foam::token::swap(token& tok)
 {
-    return type_;
+    std::swap(data_, tok.data_);
+    std::swap(type_, tok.type_);
+    std::swap(lineNumber_, tok.lineNumber_);
 }
 
-inline Foam::token::tokenType&  Foam::token::type()
+
+inline Foam::token::tokenType Foam::token::type() const
 {
     return type_;
 }
 
+
+inline bool Foam::token::setType(token::tokenType variant)
+{
+    if (type_ == variant)
+    {
+        // No change required
+        return true;
+    }
+
+    switch (variant)
+    {
+        case tokenType::STRING:
+        case tokenType::VARIABLE:
+        case tokenType::VERBATIMSTRING:
+        {
+            switch (type_)
+            {
+                // could also go from WORD to STRING etc - to be decided
+                case tokenType::STRING:
+                case tokenType::VARIABLE:
+                case tokenType::VERBATIMSTRING:
+                    type_ = variant;
+                    return true;
+                    break;
+
+                default:
+                    return false;
+                    break;
+            }
+        }
+
+        default:
+            break;
+    }
+
+    return false;
+}
+
+
+inline Foam::label Foam::token::lineNumber() const
+{
+    return lineNumber_;
+}
+
+
+inline Foam::label& Foam::token::lineNumber()
+{
+    return lineNumber_;
+}
+
+
 inline bool Foam::token::good() const
 {
-    return (type_ != tokenType::ERROR && type_ != tokenType::UNDEFINED);
+    return (type_ != tokenType::UNDEFINED && type_ != tokenType::ERROR);
 }
 
+
 inline bool Foam::token::undefined() const
 {
     return (type_ == tokenType::UNDEFINED);
 }
 
+
 inline bool Foam::token::error() const
 {
     return (type_ == tokenType::ERROR);
 }
 
-inline bool Foam::token::isPunctuation() const
+
+inline bool Foam::token::isFlag() const
 {
-    return (type_ == tokenType::PUNCTUATION);
+    return (type_ == tokenType::FLAG);
 }
 
-inline Foam::token::punctuationToken  Foam::token::pToken() const
+
+inline int Foam::token::flagToken() const
 {
-    if (type_ == tokenType::PUNCTUATION)
-    {
-        return punctuationToken_;
-    }
-    else
+    if (type_ == tokenType::FLAG)
     {
-        parseError("punctuation character");
-        return NULL_TOKEN;
+        return data_.flagVal;
     }
+
+    parseError("flag bitmask");
+    return NO_FLAG;
 }
 
-inline bool Foam::token::isWord() const
+
+inline bool Foam::token::isPunctuation() const
 {
-    return (type_ == tokenType::WORD);
+    return (type_ == tokenType::PUNCTUATION);
 }
 
-inline const Foam::word& Foam::token::wordToken() const
+
+inline Foam::token::punctuationToken Foam::token::pToken() const
 {
-    if (type_ == tokenType::WORD)
-    {
-        return *wordTokenPtr_;
-    }
-    else
+    if (type_ == tokenType::PUNCTUATION)
     {
-        parseError(word::typeName);
-        return word::null;
+        return data_.punctuationVal;
     }
-}
 
-inline bool Foam::token::isVariable() const
-{
-    return (type_ == tokenType::VARIABLE);
+    parseError("punctuation character");
+    return punctuationToken::NULL_TOKEN;
 }
 
-inline bool Foam::token::isString() const
+
+inline bool Foam::token::isSeparator() const
 {
     return
     (
-        type_ == tokenType::STRING
-     || type_ == tokenType::VARIABLE
-     || type_ == tokenType::VERBATIMSTRING
+        type_ == tokenType::PUNCTUATION
+     && isseparator(data_.punctuationVal)
     );
 }
 
-inline const Foam::string& Foam::token::stringToken() const
-{
-    if
-    (
-        type_ == tokenType::STRING
-     || type_ == tokenType::VARIABLE
-     || type_ == tokenType::VERBATIMSTRING
-    )
-    {
-        return *stringTokenPtr_;
-    }
-    else
-    {
-        parseError(string::typeName);
-        return string::null;
-    }
-}
 
 inline bool Foam::token::isLabel() const
 {
     return (type_ == tokenType::LABEL);
 }
 
+
 inline Foam::label Foam::token::labelToken() const
 {
     if (type_ == tokenType::LABEL)
     {
-        return labelToken_;
-    }
-    else
-    {
-        parseError(pTraits<label>::typeName);
-        return 0;
+        return data_.labelVal;
     }
+
+    parseError(pTraits<label>::typeName);
+    return 0;
 }
 
+
 inline bool Foam::token::isFloatScalar() const
 {
     return (type_ == tokenType::FLOAT_SCALAR);
 }
 
+
 inline Foam::floatScalar Foam::token::floatScalarToken() const
 {
     if (type_ == tokenType::FLOAT_SCALAR)
     {
-        return floatScalarToken_;
-    }
-    else
-    {
-        parseError("floatScalar");
-        return 0.0;
+        return data_.floatVal;
     }
+
+    parseError("floatScalar");
+    return 0.0;
 }
 
 
@@ -342,17 +451,16 @@ inline bool Foam::token::isDoubleScalar() const
     return (type_ == tokenType::DOUBLE_SCALAR);
 }
 
+
 inline Foam::doubleScalar Foam::token::doubleScalarToken() const
 {
     if (type_ == tokenType::DOUBLE_SCALAR)
     {
-        return doubleScalarToken_;
-    }
-    else
-    {
-        parseError("doubleScalar");
-        return 0.0;
+        return data_.doubleVal;
     }
+
+    parseError("doubleScalar");
+    return 0.0;
 }
 
 
@@ -365,72 +473,112 @@ inline bool Foam::token::isScalar() const
     );
 }
 
+
 inline Foam::scalar Foam::token::scalarToken() const
 {
     if (type_ == tokenType::FLOAT_SCALAR)
     {
-        return floatScalarToken_;
+        return data_.floatVal;
     }
     else if (type_ == tokenType::DOUBLE_SCALAR)
     {
-        return doubleScalarToken_;
-    }
-    else
-    {
-        parseError(pTraits<scalar>::typeName);
-        return 0.0;
+        return data_.doubleVal;
     }
+
+    parseError(pTraits<scalar>::typeName);
+    return 0.0;
 }
 
+
 inline bool Foam::token::isNumber() const
 {
     return (type_ == tokenType::LABEL || isScalar());
 }
 
+
 inline Foam::scalar Foam::token::number() const
 {
-    if (type_ == tokenType::LABEL)
+    if (isLabel())
     {
-        return labelToken_;
+        return labelToken();
     }
-    else if (isScalar())
+    if (isScalar())
     {
         return scalarToken();
     }
-    else
-    {
-        parseError("number (label or scalar)");
-        return 0.0;
-    }
+
+    parseError("number (label or scalar)");
+    return 0.0;
 }
 
-inline bool Foam::token::isCompound() const
+
+inline bool Foam::token::isWord() const
 {
-    return (type_ == tokenType::COMPOUND);
+    return (type_ == tokenType::WORD);
 }
 
-inline const Foam::token::compound& Foam::token::compoundToken() const
+
+inline const Foam::word& Foam::token::wordToken() const
 {
-    if (type_ == tokenType::COMPOUND)
+    if (type_ == tokenType::WORD)
     {
-        return *compoundTokenPtr_;
+        return *data_.wordPtr;
     }
-    else
+
+    parseError(word::typeName);
+    return word::null;
+}
+
+
+inline bool Foam::token::isVariable() const
+{
+    return (type_ == tokenType::VARIABLE);
+}
+
+
+inline bool Foam::token::isString() const
+{
+    return
+    (
+        type_ == tokenType::STRING
+     || type_ == tokenType::VARIABLE
+     || type_ == tokenType::VERBATIMSTRING
+    );
+}
+
+
+inline const Foam::string& Foam::token::stringToken() const
+{
+    if
+    (
+        type_ == tokenType::STRING
+     || type_ == tokenType::VARIABLE
+     || type_ == tokenType::VERBATIMSTRING
+    )
     {
-        parseError("compound");
-        return *compoundTokenPtr_;
+        return *data_.stringPtr;
     }
+
+    parseError(string::typeName);
+    return string::null;
 }
 
 
-inline Foam::label Foam::token::lineNumber() const
+inline bool Foam::token::isCompound() const
 {
-    return lineNumber_;
+    return (type_ == tokenType::COMPOUND);
 }
 
-inline Foam::label& Foam::token::lineNumber()
+
+inline const Foam::token::compound& Foam::token::compoundToken() const
 {
-    return lineNumber_;
+    if (type_ == tokenType::COMPOUND)
+    {
+        return *data_.compoundPtr;
+    }
+
+    parseError("compound");
+    return *data_.compoundPtr;  // This is questionable.
 }
 
 
@@ -443,117 +591,148 @@ inline void Foam::token::setBad()
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-inline void Foam::token::operator=(const token& t)
+inline void Foam::token::operator=(const token& tok)
 {
     clear();
-    type_ = t.type_;
 
-    switch (type_)
-    {
-        case tokenType::UNDEFINED:
-        break;
+    type_ = tok.type_;
+    data_ = tok.data_;  // bit-wise copy of union content
+    lineNumber_ = tok.lineNumber_;
 
-        case tokenType::PUNCTUATION:
-            punctuationToken_ = t.punctuationToken_;
-        break;
+    // Fundamental: values already handled by bit-wise copy
+    // Pointer: duplicate content or increase refCount
 
+    switch (type_)
+    {
         case tokenType::WORD:
-            wordTokenPtr_ = new word(*t.wordTokenPtr_);
+        {
+            data_.wordPtr = new word(*tok.data_.wordPtr);
+        }
         break;
 
         case tokenType::STRING:
         case tokenType::VARIABLE:
         case tokenType::VERBATIMSTRING:
-            stringTokenPtr_ = new string(*t.stringTokenPtr_);
-        break;
-
-        case tokenType::LABEL:
-            labelToken_ = t.labelToken_;
-        break;
-
-        case tokenType::FLOAT_SCALAR:
-            floatScalarToken_ = t.floatScalarToken_;
-        break;
-
-        case tokenType::DOUBLE_SCALAR:
-            doubleScalarToken_ = t.doubleScalarToken_;
+        {
+            data_.stringPtr = new string(*tok.data_.stringPtr);
+        }
         break;
 
         case tokenType::COMPOUND:
-            compoundTokenPtr_ = t.compoundTokenPtr_;
-            compoundTokenPtr_->refCount::operator++();
+        {
+            // Identical pointers, but increase the refCount
+            data_.compoundPtr = tok.data_.compoundPtr;
+            data_.compoundPtr->refCount::operator++();
+        }
         break;
 
-        case tokenType::ERROR:
-        break;
+        default:
+            break;
     }
+}
+
 
-    lineNumber_ = t.lineNumber_;
+inline void Foam::token::operator=(token&& tok)
+{
+    clear();
+    lineNumber_ = 0;
+    swap(tok);
 }
 
+
 inline void Foam::token::operator=(const punctuationToken p)
 {
     clear();
     type_ = tokenType::PUNCTUATION;
-    punctuationToken_ = p;
+    data_.punctuationVal = p;
 }
 
-inline void Foam::token::operator=(word* wPtr)
+
+inline void Foam::token::operator=(const label val)
 {
     clear();
-    type_ = tokenType::WORD;
-    wordTokenPtr_ = wPtr;
+    type_ = tokenType::LABEL;
+    data_.labelVal = val;
 }
 
-inline void Foam::token::operator=(const word& w)
+
+inline void Foam::token::operator=(const floatScalar val)
+{
+    clear();
+    type_ = tokenType::FLOAT_SCALAR;
+    data_.floatVal = val;
+}
+
+
+inline void Foam::token::operator=(const doubleScalar val)
+{
+    clear();
+    type_ = tokenType::DOUBLE_SCALAR;
+    data_.doubleVal = val;
+}
+
+
+inline void Foam::token::operator=(word* wordPtr)
 {
-    operator=(new word(w));
+    clear();
+    type_ = tokenType::WORD;
+    data_.wordPtr = wordPtr;
 }
 
-inline void Foam::token::operator=(string* strPtr)
+
+inline void Foam::token::operator=(string* stringPtr)
 {
     clear();
     type_ = tokenType::STRING;
-    stringTokenPtr_ = strPtr;
+    data_.stringPtr = stringPtr;
 }
 
-inline void Foam::token::operator=(const string& str)
+
+inline void Foam::token::operator=(const word& w)
 {
-    operator=(new string(str));
+    clear();
+    type_ = tokenType::WORD;
+    data_.wordPtr = new word(w);
 }
 
-inline void Foam::token::operator=(const label val)
+
+inline void Foam::token::operator=(const string& str)
 {
     clear();
-    type_ = tokenType::LABEL;
-    labelToken_ = val;
+    type_ = tokenType::STRING;
+    data_.stringPtr = new string(str);
 }
 
-inline void Foam::token::operator=(const floatScalar val)
+
+inline void Foam::token::operator=(word&& w)
 {
     clear();
-    type_ = tokenType::FLOAT_SCALAR;
-    floatScalarToken_ = val;
+    type_ = tokenType::WORD;
+    data_.wordPtr = new word;
+    data_.wordPtr->swap(w);
 }
 
-inline void Foam::token::operator=(const doubleScalar val)
+
+inline void Foam::token::operator=(string&& s)
 {
     clear();
-    type_ = tokenType::DOUBLE_SCALAR;
-    doubleScalarToken_ = val;
+    type_ = tokenType::STRING;
+    data_.stringPtr = new string;
+    data_.stringPtr->swap(s);
 }
 
-inline void Foam::token::operator=(Foam::token::compound* compPtr)
+
+inline void Foam::token::operator=(Foam::token::compound* compoundPtr)
 {
     clear();
     type_ = tokenType::COMPOUND;
-    compoundTokenPtr_ = compPtr;
+    data_.compoundPtr = compoundPtr;
 }
 
 
-inline bool Foam::token::operator==(const token& t) const
+inline bool Foam::token::operator==(const token& tok) const
 {
-    if (type_ != t.type_)
+    if (type_ != tok.type_)
     {
         return false;
     }
@@ -563,28 +742,31 @@ inline bool Foam::token::operator==(const token& t) const
         case tokenType::UNDEFINED:
             return true;
 
-        case tokenType::PUNCTUATION:
-            return punctuationToken_ == t.punctuationToken_;
-
-        case tokenType::WORD:
-            return *wordTokenPtr_ == *t.wordTokenPtr_;
+        case tokenType::FLAG:
+            return data_.flagVal == tok.data_.flagVal;
 
-        case tokenType::STRING:
-        case tokenType::VARIABLE:
-        case tokenType::VERBATIMSTRING:
-            return *stringTokenPtr_ == *t.stringTokenPtr_;
+        case tokenType::PUNCTUATION:
+            return data_.punctuationVal == tok.data_.punctuationVal;
 
         case tokenType::LABEL:
-            return labelToken_ == t.labelToken_;
+            return data_.labelVal == tok.data_.labelVal;
 
         case tokenType::FLOAT_SCALAR:
-            return equal(floatScalarToken_, t.floatScalarToken_);
+            return equal(data_.floatVal, tok.data_.floatVal);
 
         case tokenType::DOUBLE_SCALAR:
-            return equal(doubleScalarToken_, t.doubleScalarToken_);
+            return equal(data_.doubleVal, tok.data_.doubleVal);
+
+        case tokenType::WORD:
+            return *data_.wordPtr == *tok.data_.wordPtr;
+
+        case tokenType::STRING:
+        case tokenType::VARIABLE:
+        case tokenType::VERBATIMSTRING:
+            return *data_.stringPtr == *tok.data_.stringPtr;
 
         case tokenType::COMPOUND:
-            return compoundTokenPtr_ == t.compoundTokenPtr_;
+            return data_.compoundPtr == tok.data_.compoundPtr;
 
         case tokenType::ERROR:
             return true;
@@ -593,16 +775,19 @@ inline bool Foam::token::operator==(const token& t) const
     return false;
 }
 
+
 inline bool Foam::token::operator==(const punctuationToken p) const
 {
-    return (type_ == tokenType::PUNCTUATION && punctuationToken_ == p);
+    return (type_ == tokenType::PUNCTUATION && data_.punctuationVal == p);
 }
 
+
 inline bool Foam::token::operator==(const word& w) const
 {
     return (type_ == tokenType::WORD && wordToken() == w);
 }
 
+
 inline bool Foam::token::operator==(const string& str) const
 {
     return
@@ -616,67 +801,77 @@ inline bool Foam::token::operator==(const string& str) const
     );
 }
 
+
 inline bool Foam::token::operator==(const label val) const
 {
     return
     (
         type_ == tokenType::LABEL
-     && labelToken_ == val
+     && data_.labelVal == val
     );
 }
 
+
 inline bool Foam::token::operator==(const floatScalar val) const
 {
     return
     (
         type_ == tokenType::FLOAT_SCALAR
-     && equal(floatScalarToken_, val)
+     && equal(data_.floatVal, val)
     );
 }
 
+
 inline bool Foam::token::operator==(const doubleScalar val) const
 {
     return
     (
         type_ == tokenType::DOUBLE_SCALAR
-     && equal(doubleScalarToken_, val)
+     && equal(data_.doubleVal, val)
     );
 }
 
+
 inline bool Foam::token::operator!=(const token& t) const
 {
     return !operator==(t);
 }
 
+
 inline bool Foam::token::operator!=(const punctuationToken p) const
 {
     return !operator==(p);
 }
 
-inline bool Foam::token::operator!=(const word& w) const
-{
-    return !operator==(w);
-}
-
-inline bool Foam::token::operator!=(const string& str) const
-{
-    return !operator==(str);
-}
 
 inline bool Foam::token::operator!=(const label val) const
 {
     return !operator==(val);
 }
 
+
 inline bool Foam::token::operator!=(const floatScalar val) const
 {
     return !operator==(val);
 }
 
+
 inline bool Foam::token::operator!=(const doubleScalar val) const
 {
     return !operator==(val);
 }
 
 
+inline bool Foam::token::operator!=(const word& w) const
+{
+    return !operator==(w);
+}
+
+
+inline bool Foam::token::operator!=(const string& str) const
+{
+    return !operator==(str);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/token/tokenIO.C b/src/OpenFOAM/db/IOstreams/token/tokenIO.C
index f451de1796a626335d799b64c3bcbd1df9149a50..cbd4af1ac17276302883d0fbace4e8149ff3d497 100644
--- a/src/OpenFOAM/db/IOstreams/token/tokenIO.C
+++ b/src/OpenFOAM/db/IOstreams/token/tokenIO.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,254 +25,230 @@ License
 
 #include "error.H"
 #include "token.H"
-
-#include "IOstreams.H"
 #include "scalar.H"
+#include "IOstreams.H"
 
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
 
-Foam::token::token(Istream& is)
-:
-    type_(tokenType::UNDEFINED)
+namespace Foam
 {
-    is.read(*this);
-}
-
-
-// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
-
-Foam::Istream& Foam::operator>>(Istream& is, token& t)
+template<class OS>
+static OS& printTokenInfo(OS& os, const token& tok)
 {
-    t.clear();
-    return is.read(t);
-}
-
+    os  << "on line " << tok.lineNumber() << ": ";
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
-{
-    switch (t.type_)
+    switch (tok.type())
     {
         case token::tokenType::UNDEFINED:
-            os << "UNDEFINED";
-            WarningInFunction
-                << "Undefined token" << endl;
+            os  << "undefined token";
+        break;
+
+        case token::tokenType::FLAG:
+            os  << "flag '" << int(tok.flagToken()) << '\'';
         break;
 
         case token::tokenType::PUNCTUATION:
-            os << t.punctuationToken_;
+            os  << "punctuation '" << tok.pToken() << '\'';
         break;
 
-        case token::tokenType::WORD:
-            os << *t.wordTokenPtr_;
+        case token::tokenType::LABEL:
+            os  << "label " << tok.labelToken();
         break;
 
-        case token::tokenType::STRING:
-        case token::tokenType::VERBATIMSTRING:
-            os << *t.stringTokenPtr_;
+        case token::tokenType::FLOAT_SCALAR:
+            os  << "float " << tok.floatScalarToken();
         break;
 
-        case token::tokenType::VARIABLE:
-            // Behaviour differs according to stream type
-            os.write(t);
+        case token::tokenType::DOUBLE_SCALAR:
+            os  << "double " << tok.doubleScalarToken();
         break;
 
-        case token::tokenType::LABEL:
-            os << t.labelToken_;
+        case token::tokenType::WORD:
+            os  << "word '" << tok.wordToken() << '\'';
         break;
 
-        case token::tokenType::FLOAT_SCALAR:
-            os << t.floatScalarToken_;
+        case token::tokenType::STRING:
+            os  << "string " << tok.stringToken();
         break;
 
-        case token::tokenType::DOUBLE_SCALAR:
-            os << t.doubleScalarToken_;
+        case token::tokenType::VARIABLE:
+            os  << "variable " << tok.stringToken();
+        break;
+
+        case token::tokenType::VERBATIMSTRING:
+            os  << "verbatim string " << tok.stringToken();
         break;
 
         case token::tokenType::COMPOUND:
-            os << *t.compoundTokenPtr_;
+        {
+            if (tok.compoundToken().empty())
+            {
+                os  << "empty ";
+            }
+            os  << "compound of type "
+                << tok.compoundToken().type();
+        }
         break;
 
         case token::tokenType::ERROR:
-            os << "ERROR";
-            WarningInFunction
-                << "Error token" << endl;
+            os  << "error";
         break;
 
         default:
-            os << "UNKNOWN";
-            SeriousErrorInFunction
-                << "Unknown token"
-                << endl;
+            os  << "unknown token type '" << int(tok.type()) << '\'';
+            break;
     }
 
-    os.check(FUNCTION_NAME);
     return os;
 }
+} // End namespace Foam
 
 
-ostream& Foam::operator<<(ostream& os, const token::punctuationToken& pt)
-{
-    return os << char(pt);
-}
-
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const token::punctuationToken& pt)
+Foam::token::token(Istream& is)
+:
+    token()
 {
-    return os << char(pt);
+    is.read(*this);
 }
 
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const token::compound& ct)
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+Foam::word Foam::token::name() const
 {
-    os << ct.type() << token::SPACE;
-    ct.write(os);
+    switch (type_)
+    {
+        case token::tokenType::UNDEFINED: return "undefined";
+        case token::tokenType::FLAG: return "flag";
+        case token::tokenType::PUNCTUATION: return "punctuation";
+        case token::tokenType::LABEL: return "label";
+        case token::tokenType::FLOAT_SCALAR: return "float";
+        case token::tokenType::DOUBLE_SCALAR: return "double";
+        case token::tokenType::WORD: return "word";
+        case token::tokenType::STRING: return "string";
+        case token::tokenType::VERBATIMSTRING: return "verbatim";
+        case token::tokenType::VARIABLE: return "variable";
+        case token::tokenType::COMPOUND: return "compound";
+        case token::tokenType::ERROR: return "error";
 
-    return os;
+        default:
+            break;
+    }
+
+    return "unknown(" + std::to_string(int(type_)) + ")";
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
-ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
+Foam::Istream& Foam::operator>>(Istream& is, token& tok)
 {
-    const token& t = ip.t_;
+    tok.clear();
+    return is.read(tok);
+}
 
-    os  << "on line " << t.lineNumber();
 
-    switch (t.type())
+Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok)
+{
+    switch (tok.type_)
     {
         case token::tokenType::UNDEFINED:
-            os  << " an undefined token";
+            os << "UNDEFINED";
+            WarningInFunction
+                << "Undefined token" << endl;
         break;
 
-        case token::tokenType::PUNCTUATION:
-            os  << " the punctuation token " << '\'' << t.pToken() << '\'';
+        case token::tokenType::FLAG:
+            // Swallow the flag
         break;
 
-        case token::tokenType::WORD:
-            os  << " the word " << '\'' << t.wordToken() << '\'';
+        case token::tokenType::PUNCTUATION:
+            os << tok.data_.punctuationVal;
         break;
 
-        case token::tokenType::STRING:
-            os  << " the string " << t.stringToken();
+        case token::tokenType::LABEL:
+            os << tok.data_.labelVal;
         break;
 
-        case token::tokenType::VARIABLE:
-            os  << " the variable " << t.stringToken();
+        case token::tokenType::FLOAT_SCALAR:
+            os << tok.data_.floatVal;
         break;
 
-        case token::tokenType::VERBATIMSTRING:
-            os  << " the verbatim string " << t.stringToken();
+        case token::tokenType::DOUBLE_SCALAR:
+            os << tok.data_.doubleVal;
         break;
 
-        case token::tokenType::LABEL:
-            os  << " the label " << t.labelToken();
+        case token::tokenType::WORD:
+            os << *tok.data_.wordPtr;
         break;
 
-        case token::tokenType::FLOAT_SCALAR:
-            os  << " the floatScalar " << t.floatScalarToken();
+        case token::tokenType::STRING:
+        case token::tokenType::VERBATIMSTRING:
+            os << *tok.data_.stringPtr;
         break;
 
-        case token::tokenType::DOUBLE_SCALAR:
-            os  << " the doubleScalar " << t.doubleScalarToken();
+        case token::tokenType::VARIABLE:
+            // Behaviour differs according to stream type
+            os.write(tok);
         break;
 
         case token::tokenType::COMPOUND:
-        {
-            if (t.compoundToken().empty())
-            {
-                os  << " the empty compound of type "
-                    << t.compoundToken().type();
-            }
-            else
-            {
-                os  << " the compound of type "
-                    << t.compoundToken().type();
-            }
-        }
+            os << *tok.data_.compoundPtr;
         break;
 
         case token::tokenType::ERROR:
-            os  << " an error";
+            os << "ERROR";
+            WarningInFunction
+                << "Error token" << endl;
         break;
 
         default:
-            os  << " an unknown token type " << '\'' << int(t.type()) << '\'';
+            os << "UNKNOWN";
+            SeriousErrorInFunction
+                << "Unknown token"
+                << endl;
     }
 
+    os.check(FUNCTION_NAME);
     return os;
 }
 
 
-template<>
-Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<token>& ip)
+ostream& Foam::operator<<(ostream& os, const token::punctuationToken& pt)
 {
-    const token& t = ip.t_;
-
-    os  << "on line " << t.lineNumber();
-
-    switch (t.type())
-    {
-        case token::tokenType::UNDEFINED:
-            os  << " an undefined token";
-        break;
-
-        case token::tokenType::PUNCTUATION:
-            os  << " the punctuation token " << '\'' << t.pToken() << '\'';
-        break;
+    return os << char(pt);
+}
 
-        case token::tokenType::WORD:
-            os  << " the word " << '\'' << t.wordToken() << '\'';
-        break;
 
-        case token::tokenType::STRING:
-            os  << " the string " << t.stringToken();
-        break;
-
-        case token::tokenType::VARIABLE:
-            os  << " the variable " << t.stringToken();
-        break;
+Foam::Ostream& Foam::operator<<(Ostream& os, const token::punctuationToken& pt)
+{
+    return os << char(pt);
+}
 
-        case token::tokenType::VERBATIMSTRING:
-            os  << " the verbatim string " << t.stringToken();
-        break;
 
-        case token::tokenType::LABEL:
-            os  << " the label " << t.labelToken();
-        break;
+Foam::Ostream& Foam::operator<<(Ostream& os, const token::compound& ct)
+{
+    os << ct.type() << token::SPACE;
+    ct.write(os);
 
-        case token::tokenType::FLOAT_SCALAR:
-            os  << " the floatScalar " << t.floatScalarToken();
-        break;
+    return os;
+}
 
-        case token::tokenType::DOUBLE_SCALAR:
-            os  << " the doubleScalar " << t.doubleScalarToken();
-        break;
 
-        case token::tokenType::COMPOUND:
-        {
-            if (t.compoundToken().empty())
-            {
-                os  << " the empty compound of type "
-                    << t.compoundToken().type();
-            }
-            else
-            {
-                os  << " the compound of type "
-                    << t.compoundToken().type();
-            }
-        }
-        break;
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-        case token::tokenType::ERROR:
-            os  << " an error";
-        break;
+ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
+{
+    return printTokenInfo(os, ip.t_);
+}
 
-        default:
-            os  << " an unknown token type "  << '\'' << int(t.type()) << '\'';
-    }
 
-    return os;
+template<>
+Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<token>& ip)
+{
+    return printTokenInfo(os, ip.t_);
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C
index 33acac0ace16db6be191887197ced5c8fb35133a..d015a464678cf37d9b6dc7630684f6795b7f9059 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.C
+++ b/src/OpenFOAM/db/dictionary/dictionary.C
@@ -28,7 +28,6 @@ License
 #include "dictionaryEntry.H"
 #include "regExp.H"
 #include "OSHA1stream.H"
-#include "DynamicList.H"
 
 /* * * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * */
 
@@ -45,157 +44,6 @@ bool Foam::dictionary::writeOptionalEntries
 );
 
 
-// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
-
-namespace Foam
-{
-    // file-scope
-    //- Walk lists of patterns and regexps for an exact match
-    //  or regular expression match
-    template<class WcIterator, class ReIterator>
-    static bool findInPatterns
-    (
-        const bool patternMatch,
-        const word& keyword,
-        WcIterator& wcIter,
-        ReIterator& reIter
-    )
-    {
-        while (wcIter.found())
-        {
-            if
-            (
-                patternMatch
-              ? reIter()->match(keyword)
-              : wcIter()->keyword() == keyword
-            )
-            {
-                return true;
-            }
-
-            ++reIter;
-            ++wcIter;
-        }
-
-        return false;
-    }
-}
-
-
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
-
-const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
-(
-    const word& keyword,
-    bool recursive,
-    bool patternMatch
-) const
-{
-    string::size_type dotPos = keyword.find('.');
-
-    if (dotPos == string::npos)
-    {
-        // Non-scoped lookup
-        return lookupEntryPtr(keyword, recursive, patternMatch);
-    }
-    else if (dotPos == 0)
-    {
-        // Starting with a '.' -> go up for every further '.' found
-        ++dotPos;
-
-        const dictionary* dictPtr = this;
-        for
-        (
-            string::const_iterator it = keyword.begin()+1;
-            it != keyword.end() && *it == '.';
-            ++dotPos, ++it
-        )
-        {
-            // Go to parent
-            if (&dictPtr->parent_ != &dictionary::null)
-            {
-                dictPtr = &dictPtr->parent_;
-            }
-            else
-            {
-                FatalIOErrorInFunction
-                (
-                    *this
-                )   << "No parent of current dictionary when searching for "
-                    << keyword.substr(1)
-                    << exit(FatalIOError);
-
-                return nullptr;
-            }
-        }
-
-        return dictPtr->lookupScopedSubEntryPtr
-        (
-            keyword.substr(dotPos),
-            false,
-            patternMatch
-        );
-    }
-    else
-    {
-        // The first word
-        const entry* entPtr = lookupScopedSubEntryPtr
-        (
-            keyword.substr(0, dotPos),
-            false,
-            patternMatch
-        );
-
-        if (!entPtr)
-        {
-            // Fall back to finding key with '.' so e.g. if keyword is
-            // a.b.c.d it would try
-            // a.b, a.b.c, a.b.c.d
-
-            while (true)
-            {
-                dotPos = keyword.find('.', dotPos+1);
-
-                entPtr = lookupEntryPtr
-                (
-                    keyword.substr(0, dotPos),
-                    false,
-                    patternMatch
-                );
-
-                if (dotPos == string::npos)
-                {
-                    // Parsed the whole word. Return entry or null.
-                    return entPtr;
-                }
-
-                if (entPtr && entPtr->isDict())
-                {
-                    return entPtr->dict().lookupScopedSubEntryPtr
-                    (
-                        keyword.substr(dotPos),
-                        false,
-                        patternMatch
-                    );
-                }
-            }
-        }
-
-        if (entPtr->isDict())
-        {
-            return entPtr->dict().lookupScopedSubEntryPtr
-            (
-                keyword.substr(dotPos),
-                false,
-                patternMatch
-            );
-        }
-    }
-
-    return nullptr;
-}
-
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::dictionary::dictionary()
@@ -322,10 +170,8 @@ const Foam::dictionary& Foam::dictionary::topDict() const
     {
         return p.topDict();
     }
-    else
-    {
-        return *this;
-    }
+
+    return *this;
 }
 
 
@@ -335,10 +181,8 @@ Foam::label Foam::dictionary::startLineNumber() const
     {
         return first()->startLineNumber();
     }
-    else
-    {
-        return -1;
-    }
+
+    return -1;
 }
 
 
@@ -348,10 +192,8 @@ Foam::label Foam::dictionary::endLineNumber() const
     {
         return last()->endLineNumber();
     }
-    else
-    {
-        return -1;
-    }
+
+    return -1;
 }
 
 
@@ -371,20 +213,17 @@ Foam::SHA1Digest Foam::dictionary::digest() const
 
 Foam::tokenList Foam::dictionary::tokens() const
 {
-    // Serialize dictionary into a string
+    // Serialize dictionary entries into a string
     OStringStream os;
-    write(os, false);
-    IStringStream is(os.str());
 
-    // Parse string as tokens
-    DynamicList<token> tokens;
-    token t;
-    while (is.read(t))
+    // Process entries
+    forAllConstIter(parent_type, *this, iter)
     {
-        tokens.append(t);
+        os << *iter;
     }
 
-    return tokenList(tokens.xfer());
+    // String re-parsed as a list of tokens
+    return ITstream::parse(os.str());
 }
 
 
@@ -395,29 +234,7 @@ bool Foam::dictionary::found
     bool patternMatch
 ) const
 {
-    if (hashedEntries_.found(keyword))
-    {
-        return true;
-    }
-
-    if (patternMatch && patterns_.size())
-    {
-        pattern_const_iterator wcLink = patterns_.begin();
-        regexp_const_iterator  reLink = regexps_.begin();
-
-        // Find in patterns using regular expressions only
-        if (findInPatterns(patternMatch, keyword, wcLink, reLink))
-        {
-            return true;
-        }
-    }
-
-    if (recursive && &parent_ != &dictionary::null)
-    {
-        return parent_.found(keyword, recursive, patternMatch);
-    }
-
-    return false;
+    return csearch(keyword, recursive, patternMatch).found();
 }
 
 
@@ -428,31 +245,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
     bool patternMatch
 ) const
 {
-    auto iter = hashedEntries_.cfind(keyword);
-
-    if (iter.found())
-    {
-        return iter();
-    }
-
-    if (patternMatch && patterns_.size())
-    {
-        pattern_const_iterator wcLink = patterns_.begin();
-        regexp_const_iterator  reLink = regexps_.begin();
-
-        // Find in patterns using regular expressions only
-        if (findInPatterns(patternMatch, keyword, wcLink, reLink))
-        {
-            return wcLink();
-        }
-    }
-
-    if (recursive && &parent_ != &dictionary::null)
-    {
-        return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
-    }
-
-    return nullptr;
+    return csearch(keyword, recursive, patternMatch).ptr();
 }
 
 
@@ -463,36 +256,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
     bool patternMatch
 )
 {
-    auto iter = hashedEntries_.find(keyword);
-
-    if (iter.found())
-    {
-        return iter();
-    }
-
-    if (patternMatch && patterns_.size())
-    {
-        pattern_iterator wcLink = patterns_.begin();
-        regexp_iterator  reLink = regexps_.begin();
-
-        // Find in patterns using regular expressions only
-        if (findInPatterns(patternMatch, keyword, wcLink, reLink))
-        {
-            return wcLink();
-        }
-    }
-
-    if (recursive && &parent_ != &dictionary::null)
-    {
-        return const_cast<dictionary&>(parent_).lookupEntryPtr
-        (
-            keyword,
-            recursive,
-            patternMatch
-        );
-    }
-
-    return nullptr;
+    return search(keyword, recursive, patternMatch).ptr();
 }
 
 
@@ -503,9 +267,9 @@ const Foam::entry& Foam::dictionary::lookupEntry
     bool patternMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
+    const const_searcher finder(csearch(keyword, recursive, patternMatch));
 
-    if (entryPtr == nullptr)
+    if (!finder.found())
     {
         FatalIOErrorInFunction
         (
@@ -515,7 +279,7 @@ const Foam::entry& Foam::dictionary::lookupEntry
             << exit(FatalIOError);
     }
 
-    return *entryPtr;
+    return finder.ref();
 }
 
 
@@ -537,29 +301,37 @@ const Foam::entry* Foam::dictionary::lookupScopedEntryPtr
     bool patternMatch
 ) const
 {
-    if ((keyword[0] == ':' || keyword[0] == '^'))
+    return csearchScoped(keyword, recursive, patternMatch).ptr();
+}
+
+
+bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry)
+{
+    if (keyword.size() < 2)
     {
-        // Go up to top level
-        const dictionary* dictPtr = this;
-        while (&dictPtr->parent_ != &dictionary::null)
+        return false;
+    }
+
+    // Drop leading '$' to get the var-name, already validated as word.
+    const word varName(keyword.substr(1), false);
+
+    // Lookup the variable name in the given dictionary
+    const const_searcher finder(csearch(varName, true, true));
+
+    // If defined insert its entries into this dictionary
+    if (finder.found())
+    {
+        const dictionary& addDict = finder.dict();
+
+        forAllConstIters(addDict, iter)
         {
-            dictPtr = &dictPtr->parent_;
+            add(iter(), mergeEntry);
         }
 
-        return dictPtr->lookupScopedSubEntryPtr
-        (
-            keyword.substr(1),
-            false,
-            patternMatch
-        );
+        return true;
     }
 
-    return lookupScopedSubEntryPtr
-    (
-        keyword,
-        recursive,
-        patternMatch
-    );
+    return false;
 }
 
 
@@ -569,16 +341,21 @@ bool Foam::dictionary::substituteScopedKeyword
     bool mergeEntry
 )
 {
-    // Drop first character of keyword to get the var-name, already validated.
+    if (keyword.size() < 2)
+    {
+        return false;
+    }
+
+    // Drop leading '$' to get the var-name, already validated as word.
     const word varName(keyword.substr(1), false);
 
     // Lookup the variable name in the given dictionary
-    const entry* ePtr = lookupScopedEntryPtr(varName, true, true);
+    const const_searcher finder(csearchScoped(varName, true, true));
 
     // If defined insert its entries into this dictionary
-    if (ePtr != nullptr)
+    if (finder.found())
     {
-        const dictionary& addDict = ePtr->dict();
+        const dictionary& addDict = finder.dict();
 
         forAllConstIter(parent_type, addDict, iter)
         {
@@ -595,54 +372,30 @@ bool Foam::dictionary::substituteScopedKeyword
 bool Foam::dictionary::isDict(const word& keyword) const
 {
     // Find non-recursive with patterns
-    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
-
-    if (entryPtr)
-    {
-        return entryPtr->isDict();
-    }
-    else
-    {
-        return false;
-    }
+    return csearch(keyword, false, true).isDict();
 }
 
 
 const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
-
-    if (entryPtr)
-    {
-        return &entryPtr->dict();
-    }
-    else
-    {
-        return nullptr;
-    }
+    // Find non-recursive with patterns
+    return csearch(keyword, false, true).dictPtr();
 }
 
 
 Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword)
 {
-    entry* entryPtr = lookupEntryPtr(keyword, false, true);
-
-    if (entryPtr)
-    {
-        return &entryPtr->dict();
-    }
-    else
-    {
-        return nullptr;
-    }
+    // Find non-recursive with patterns
+    return search(keyword, false, true).dictPtr();
 }
 
 
 const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
+    // Find non-recursive with patterns
+    const const_searcher finder(csearch(keyword, false, true));
 
-    if (entryPtr == nullptr)
+    if (!finder.found())
     {
         FatalIOErrorInFunction
         (
@@ -651,15 +404,17 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
             << name()
             << exit(FatalIOError);
     }
-    return entryPtr->dict();
+
+    return finder.dict();
 }
 
 
 Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
 {
-    entry* entryPtr = lookupEntryPtr(keyword, false, true);
+    // Find non-recursive with patterns
+    searcher finder = search(keyword, false, true);
 
-    if (entryPtr == nullptr)
+    if (!finder.found())
     {
         FatalIOErrorInFunction
         (
@@ -668,7 +423,8 @@ Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
             << name()
             << exit(FatalIOError);
     }
-    return entryPtr->dict();
+
+    return finder.dict();
 }
 
 
@@ -678,29 +434,35 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
     const bool mustRead
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
+    // Find non-recursive with patterns
+    const const_searcher finder(csearch(keyword, false, true));
 
-    if (entryPtr == nullptr)
+    if (finder.isDict())
     {
-        if (mustRead)
-        {
-            FatalIOErrorInFunction
-            (
-                *this
-            )   << "keyword " << keyword << " is undefined in dictionary "
-                << name()
-                << exit(FatalIOError);
-            return entryPtr->dict();
-        }
-        else
-        {
-            return dictionary(*this, dictionary(name() + '.' + keyword));
-        }
+        // Found and a sub-dictionary
+        return finder.dict();
     }
-    else
+
+    if (mustRead)
     {
-        return entryPtr->dict();
+        FatalIOErrorInFunction
+        (
+            *this
+        )   << "keyword " << keyword
+            << " is not a sub-dictionary in dictionary "
+            << name()
+            << exit(FatalIOError);
     }
+
+    if (finder.found())
+    {
+        IOWarningInFunction((*this))
+            << "keyword " << keyword
+            << " found but not a sub-dictionary in dictionary "
+            << name() << endl;
+    }
+
+    return dictionary(*this, dictionary(name() + '.' + keyword));
 }
 
 
@@ -709,16 +471,23 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
     const word& keyword
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, false, true);
+    const const_searcher finder(csearch(keyword, false, true));
 
-    if (entryPtr)
+    if (finder.isDict())
     {
-        return entryPtr->dict();
+        // Found and a sub-dictionary
+        return finder.dict();
     }
-    else
+
+    if (finder.found())
     {
-        return *this;
+        IOWarningInFunction((*this))
+            << "keyword " << keyword
+            << " found but not a sub-dictionary in dictionary "
+            << name() << endl;
     }
+
+    return *this;
 }
 
 
@@ -726,10 +495,10 @@ Foam::wordList Foam::dictionary::toc() const
 {
     wordList keys(size());
 
-    label nKeys = 0;
-    forAllConstIter(parent_type, *this, iter)
+    label n = 0;
+    forAllConstIters(*this, iter)
     {
-        keys[nKeys++] = iter().keyword();
+        keys[n++] = iter().keyword();
     }
 
     return keys;
@@ -746,22 +515,27 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
 {
     List<keyType> keys(size());
 
-    label nKeys = 0;
-    forAllConstIter(parent_type, *this, iter)
+    label n = 0;
+    forAllConstIters(*this, iter)
     {
         if (iter().keyword().isPattern() ? patterns : !patterns)
         {
-            keys[nKeys++] = iter().keyword();
+            keys[n++] = iter().keyword();
         }
     }
-    keys.setSize(nKeys);
+    keys.setSize(n);
 
     return keys;
 }
 
 
-bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
+Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
 {
+    if (!entryPtr)
+    {
+        return nullptr;
+    }
+
     auto iter = hashedEntries_.find(entryPtr->keyword());
 
     if (mergeEntry && iter.found())
@@ -770,9 +544,9 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
         if (iter()->isDict() && entryPtr->isDict())
         {
             iter()->dict().merge(entryPtr->dict());
-            delete entryPtr;
 
-            return true;
+            delete entryPtr;
+            return iter();   // pointer to existing dictionary
         }
 
 
@@ -794,18 +568,18 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
                 );
             }
 
-            return true;
+            return entryPtr;  // now an entry in the dictionary
         }
-        else
-        {
-            IOWarningInFunction((*this))
-                << "problem replacing entry "<< entryPtr->keyword()
-                << " in dictionary " << name() << endl;
 
-            parent_type::remove(entryPtr);
-            delete entryPtr;
-            return false;
-        }
+
+        IOWarningInFunction((*this))
+            << "problem replacing entry "<< entryPtr->keyword()
+            << " in dictionary " << name() << endl;
+
+        parent_type::remove(entryPtr);
+
+        delete entryPtr;
+        return nullptr;
     }
 
 
@@ -823,215 +597,115 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
             );
         }
 
-        return true;
+        return entryPtr;  // now an entry in the dictionary
     }
-    else
-    {
-        IOWarningInFunction((*this))
-            << "attempt to add entry "<< entryPtr->keyword()
-            << " which already exists in dictionary " << name()
-            << endl;
 
-        delete entryPtr;
-        return false;
-    }
+
+    IOWarningInFunction((*this))
+        << "attempt to add entry " << entryPtr->keyword()
+        << " which already exists in dictionary " << name()
+        << endl;
+
+    delete entryPtr;
+    return nullptr;
 }
 
 
-void Foam::dictionary::add(const entry& e, bool mergeEntry)
+Foam::entry* Foam::dictionary::add(const entry& e, bool mergeEntry)
 {
-    add(e.clone(*this).ptr(), mergeEntry);
+    return add(e.clone(*this).ptr(), mergeEntry);
 }
 
 
-void Foam::dictionary::add(const keyType& k, const word& w, bool overwrite)
+Foam::entry* Foam::dictionary::add
+(
+    const keyType& k,
+    const word& v,
+    bool overwrite
+)
 {
-    add(new primitiveEntry(k, token(w)), overwrite);
+    return add(new primitiveEntry(k, token(v)), overwrite);
 }
 
 
-void Foam::dictionary::add
+Foam::entry* Foam::dictionary::add
 (
     const keyType& k,
-    const Foam::string& s,
+    const Foam::string& v,
     bool overwrite
 )
 {
-    add(new primitiveEntry(k, token(s)), overwrite);
+    return add(new primitiveEntry(k, token(v)), overwrite);
 }
 
 
-void Foam::dictionary::add(const keyType& k, const label l, bool overwrite)
+Foam::entry* Foam::dictionary::add
+(
+    const keyType& k,
+    const label v,
+    bool overwrite
+)
 {
-    add(new primitiveEntry(k, token(l)), overwrite);
+    return add(new primitiveEntry(k, token(v)), overwrite);
 }
 
 
-void Foam::dictionary::add(const keyType& k, const scalar s, bool overwrite)
+Foam::entry* Foam::dictionary::add
+(
+    const keyType& k,
+    const scalar v,
+    bool overwrite
+)
 {
-    add(new primitiveEntry(k, token(s)), overwrite);
+    return add(new primitiveEntry(k, token(v)), overwrite);
 }
 
 
-void Foam::dictionary::add
+Foam::entry* Foam::dictionary::add
 (
     const keyType& k,
-    const dictionary& d,
+    const dictionary& v,
     bool mergeEntry
 )
 {
-    add(new dictionaryEntry(k, *this, d), mergeEntry);
+    return add(new dictionaryEntry(k, *this, v), mergeEntry);
 }
 
 
-void Foam::dictionary::set(entry* entryPtr)
+Foam::entry* Foam::dictionary::set(entry* entryPtr)
 {
+    if (!entryPtr)
+    {
+        return nullptr;
+    }
+
     // Find non-recursive with patterns
-    entry* existingPtr = lookupEntryPtr(entryPtr->keyword(), false, true);
+    searcher finder(search(entryPtr->keyword(), false, true));
 
     // Clear dictionary so merge acts like overwrite
-    if (existingPtr && existingPtr->isDict())
+    if (finder.isDict())
     {
-        existingPtr->dict().clear();
+        finder.dict().clear();
     }
-    add(entryPtr, true);
-}
 
-
-void Foam::dictionary::set(const entry& e)
-{
-    set(e.clone(*this).ptr());
+    return add(entryPtr, true);
 }
 
 
-void Foam::dictionary::set(const keyType& k, const dictionary& d)
+Foam::entry* Foam::dictionary::set(const entry& e)
 {
-    set(new dictionaryEntry(k, *this, d));
+    return set(e.clone(*this).ptr());
 }
 
 
-bool Foam::dictionary::remove(const word& keyword)
+Foam::entry* Foam::dictionary::set(const keyType& k, const dictionary& v)
 {
-    auto iter = hashedEntries_.find(keyword);
-
-    if (iter.found())
-    {
-        // Delete from patterns
-        pattern_iterator wcLink = patterns_.begin();
-        regexp_iterator  reLink = regexps_.begin();
-
-        // Find in pattern using exact match only
-        if (findInPatterns(false, keyword, wcLink, reLink))
-        {
-            patterns_.remove(wcLink);
-            regexps_.remove(reLink);
-        }
-
-        parent_type::remove(iter());
-        delete iter();
-        hashedEntries_.erase(iter);
-
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-
-bool Foam::dictionary::changeKeyword
-(
-    const keyType& oldKeyword,
-    const keyType& newKeyword,
-    bool forceOverwrite
-)
-{
-    // No change
-    if (oldKeyword == newKeyword)
-    {
-        return false;
-    }
-
-    // Check that oldKeyword exists and can be changed
-    auto iter = hashedEntries_.find(oldKeyword);
-
-    if (!iter.found())
-    {
-        return false;
-    }
-
-    if (iter()->keyword().isPattern())
-    {
-        FatalIOErrorInFunction
-        (
-            *this
-        )   << "Old keyword "<< oldKeyword
-            << " is a pattern."
-            << "Pattern replacement not yet implemented."
-            << exit(FatalIOError);
-    }
-
-
-    auto iter2 = hashedEntries_.find(newKeyword);
-
-    // newKeyword already exists
-    if (iter2.found())
-    {
-        if (forceOverwrite)
-        {
-            if (iter2()->keyword().isPattern())
-            {
-                // Delete from patterns
-                pattern_iterator wcLink = patterns_.begin();
-                regexp_iterator  reLink = regexps_.begin();
-
-                // Find in patterns using exact match only
-                if (findInPatterns(false, iter2()->keyword(), wcLink, reLink))
-                {
-                    patterns_.remove(wcLink);
-                    regexps_.remove(reLink);
-                }
-            }
-
-            parent_type::replace(iter2(), iter());
-            delete iter2();
-            hashedEntries_.erase(iter2);
-        }
-        else
-        {
-            IOWarningInFunction
-            (
-                *this
-            )   << "cannot rename keyword "<< oldKeyword
-                << " to existing keyword " << newKeyword
-                << " in dictionary " << name() << endl;
-            return false;
-        }
-    }
-
-    // Change name and HashTable, but leave DL-List untouched
-    iter()->keyword() = newKeyword;
-    iter()->name() = name() + '.' + newKeyword;
-    hashedEntries_.erase(oldKeyword);
-    hashedEntries_.insert(newKeyword, iter());
-
-    if (newKeyword.isPattern())
-    {
-        patterns_.insert(iter());
-        regexps_.insert
-        (
-            autoPtr<regExp>(new regExp(newKeyword))
-        );
-    }
-
-    return true;
+    return set(new dictionaryEntry(k, *this, v));
 }
 
 
 bool Foam::dictionary::merge(const dictionary& dict)
 {
-    // Check for assignment to self
     if (this == &dict)
     {
         FatalIOErrorInFunction(*this)
@@ -1041,7 +715,7 @@ bool Foam::dictionary::merge(const dictionary& dict)
 
     bool changed = false;
 
-    forAllConstIter(parent_type, dict, iter)
+    forAllConstIters(dict, iter)
     {
         auto fnd = hashedEntries_.find(iter().keyword());
 
@@ -1112,7 +786,6 @@ Foam::ITstream& Foam::dictionary::operator[](const word& keyword) const
 
 void Foam::dictionary::operator=(const dictionary& rhs)
 {
-    // Check for assignment to self
     if (this == &rhs)
     {
         FatalIOErrorInFunction(*this)
@@ -1126,7 +799,7 @@ void Foam::dictionary::operator=(const dictionary& rhs)
     // Create clones of the entries in the given dictionary
     // resetting the parentDict to this dictionary
 
-    forAllConstIter(parent_type, rhs, iter)
+    forAllConstIters(rhs, iter)
     {
         add(iter().clone(*this).ptr());
     }
@@ -1135,15 +808,15 @@ void Foam::dictionary::operator=(const dictionary& rhs)
 
 void Foam::dictionary::operator+=(const dictionary& rhs)
 {
-    // Check for assignment to self
     if (this == &rhs)
     {
         FatalIOErrorInFunction(*this)
-            << "attempted addition assignment to self for dictionary " << name()
+            << "attempted addition assignment to self for dictionary "
+            << name()
             << abort(FatalIOError);
     }
 
-    forAllConstIter(parent_type, rhs, iter)
+    forAllConstIters(rhs, iter)
     {
         add(iter().clone(*this).ptr());
     }
@@ -1152,15 +825,15 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
 
 void Foam::dictionary::operator|=(const dictionary& rhs)
 {
-    // Check for assignment to self
     if (this == &rhs)
     {
         FatalIOErrorInFunction(*this)
-            << "attempted assignment to self for dictionary " << name()
+            << "attempted assignment to self for dictionary "
+            << name()
             << abort(FatalIOError);
     }
 
-    forAllConstIter(parent_type, rhs, iter)
+    forAllConstIters(rhs, iter)
     {
         if (!found(iter().keyword()))
         {
@@ -1172,15 +845,15 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
 
 void Foam::dictionary::operator<<=(const dictionary& rhs)
 {
-    // Check for assignment to self
     if (this == &rhs)
     {
         FatalIOErrorInFunction(*this)
-            << "attempted assignment to self for dictionary " << name()
+            << "attempted assignment to self for dictionary "
+            << name()
             << abort(FatalIOError);
     }
 
-    forAllConstIter(parent_type, rhs, iter)
+    forAllConstIters(rhs, iter)
     {
         set(iter().clone(*this).ptr());
     }
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index fc34a32d991c09df2f8dfa6696761b61c9676172..671aba903d3b39d4c48f07d1bb6ac301f85681f8 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -41,10 +41,13 @@ Description
 
 Note
     Within dictionaries, entries can be referenced by using the '$' syntax
-    familiar from shell programming. A '.' separator is used when referencing
-    sub-dictionary entries. Leading '.' prefixes can be used to specify
-    an entry from a parent directory. A leading ':' or '^' prefix specifies
-    starting from the top-level entry. For example,
+    familiar from shell programming.
+    A '.' separator is used when referencing sub-dictionary entries.
+    Leading '.' prefixes can be used to specify an entry from a parent
+    dictionary.
+    An initial '^' anchor (or ':' for backward compatibility) specifies
+    starting from the top-level entry.
+    For example,
 
     \verbatim
     key1        val1;
@@ -70,6 +73,7 @@ Note
 SourceFiles
     dictionary.C
     dictionaryIO.C
+    dictionarySearch.C
 
 SeeAlso
     - Foam::entry
@@ -89,6 +93,7 @@ SeeAlso
 #include "HashTable.H"
 #include "wordList.H"
 #include "className.H"
+#include <type_traits>
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -148,22 +153,20 @@ public:
         const word dictName() const
         {
             const word scopedName = name_.name();
-            const std::string::size_type i = scopedName.rfind('.');
+            const auto i = scopedName.rfind('.');
 
             if (i == std::string::npos)
             {
                 return scopedName;
             }
-            else
-            {
-                return scopedName.substr(i+1);
-            }
+
+            return scopedName.substr(i+1);
         }
 };
 
 
 /*---------------------------------------------------------------------------*\
-                           Class dictionary Declaration
+                         Class dictionary Declaration
 \*---------------------------------------------------------------------------*/
 
 class dictionary
@@ -171,15 +174,158 @@ class dictionary
     public dictionaryName,
     public IDLList<entry>
 {
+public:
+
+    // Searching
+
+        //- Generic const/non-const dictionary entry %searcher.
+        //  A %searcher provides a uniform means of finding and returning
+        //  an entry pointer as well as the dictionary \a context in which
+        //  the entry was located.
+        //
+        //  Note that the constructors and set methods are protected such
+        //  that only friends of the class can set things. This safeguards
+        //  against inconsistencies in context/entry.
+        template<bool Const>
+        class Searcher
+        {
+        public:
+            friend dictionary;
+
+            //- The const/non-const type for the context and sub-dictionaries
+            typedef typename std::conditional
+                <Const, const dictionary, dictionary>::type dict_type;
+
+            //- The const/non-const type for entries
+            typedef typename std::conditional
+                <Const, const entry, entry>::type value_type;
+
+            //- A pointer to a const/non-const dictionary
+            typedef dict_type* dict_pointer;
+
+            //- A reference to a const/non-const dictionary
+            typedef dict_type& dict_reference;
+
+            //- A pointer to a const/non-const entry
+            typedef value_type* pointer;
+
+            //- A reference to a const/non-const entry
+            typedef value_type& reference;
+
+
+        protected:
+
+            //- The dictionary context for the entry
+            dict_pointer dict_;
+
+            //- The entry or nullptr
+            pointer eptr_;
+
+
+            //- Construct for the given dictionary context
+            Searcher(dict_pointer dict)
+            :
+                dict_(dict),
+                eptr_(nullptr)
+            {}
+
+            //- Assign the entry
+            void set(pointer eptr)
+            {
+                eptr_ = eptr;
+            }
+
+
+        public:
+
+            //- Construct null
+            Searcher()
+            :
+                dict_(nullptr),
+                eptr_(nullptr)
+            {}
+
+
+            //- Entry was found.
+            inline bool found() const
+            {
+                return eptr_;
+            }
+
+            //- The containing dictionary context
+            inline dict_reference context() const
+            {
+                return *dict_;
+            }
+
+            //- A pointer to the entry (nullptr if not found)
+            inline pointer ptr() const
+            {
+                return eptr_;
+            }
+
+            //- A reference to the entry (Error if not found)
+            inline reference ref() const
+            {
+                return *eptr_;
+            }
+
+            //- True if found entry is a dictionary.
+            inline bool isDict() const
+            {
+                return eptr_ && eptr_->isDict();
+            }
+
+            //- Pointer to the found entry as a dictionary or nullptr otherwise.
+            inline dict_pointer dictPtr() const
+            {
+                return eptr_ && eptr_->isDict() ? eptr_->dictPtr() : nullptr;
+            }
+
+            //- Reference the found entry as a dictionary.
+            //  (Error if not found, or not a dictionary).
+            inline dict_reference dict() const
+            {
+                return eptr_->dict();
+            }
+
+            //- Permit an explicit cast to the other (const/non-const) searcher
+            inline explicit operator const Searcher<!Const>&() const
+            {
+                return *reinterpret_cast<const Searcher<!Const>*>(this);
+            }
+        };
+
+
+        //- Searcher with const access
+        typedef Searcher<true> const_searcher;
+
+        //- Searcher with non-const access
+        typedef Searcher<false> searcher;
+
+
+    // Friends
+
+        //- Declare friendship with the entry class for IO
+        friend class entry;
+
+        //- Declare friendship with the searcher classes
+        friend const_searcher;
+        friend searcher;
+
+
+private:
+
     // Private data
 
         //- Report optional keywords and values if not present in dictionary
+        //  Set/unset via an InfoSwitch
         static bool writeOptionalEntries;
 
         //- Parent dictionary
         const dictionary& parent_;
 
-        //- HashTable of the entries held on the IDLList for quick lookup
+        //- Quick lookup of the entries held on the IDLList
         HashTable<entry*> hashedEntries_;
 
         //- Entries of matching patterns
@@ -196,27 +342,48 @@ class dictionary
 
         typedef DLList<entry*>::iterator pattern_iterator;
         typedef DLList<entry*>::const_iterator pattern_const_iterator;
+
         typedef DLList<autoPtr<regExp>>::iterator regexp_iterator;
         typedef DLList<autoPtr<regExp>>::const_iterator regexp_const_iterator;
 
 
     // Private Member Functions
 
-        //- Find and return an entry data stream pointer if present
-        //  otherwise return nullptr. Allows scoping using '.'
-        const entry* lookupScopedSubEntryPtr
+        //- Search using a '.' for scoping.
+        //  A leading dot means to use the parent dictionary.
+        //  An intermediate dot separates a sub-dictionary or sub-entry.
+        //  However, the use of dots is unfortunately ambiguous.
+        //  The value "a.b.c.d" could be a first-level entry, a second-level
+        //  entry (eg, "a" with "b.c.d", "a.b" with "c.d" etc),
+        //  or just about any other combination.
+        //  The heuristic tries sucessively longer top-level entries
+        //  until there is a suitable match.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const_searcher csearchDotScoped
         (
             const word& keyword,
             bool recursive,
             bool patternMatch
         ) const;
 
+        //- Search using a '/' for scoping.
+        //  Semantics as per normal files: an intermediate "." is the current
+        //  dictionary level, an intermediate ".." is the parent dictionary.
+        //  Note that since a slash is not a valid word character, there is no
+        //  ambiguity between separator and content.
+        //  No possibility or need for recursion.
+        //
+        //  \param patternMatch use regular expressions
+        const_searcher csearchSlashScoped
+        (
+            const word& keyword,
+            bool patternMatch
+        ) const;
 
-public:
-
-    //- Declare friendship with the entry class for IO
-    friend class entry;
 
+public:
 
     // Declare name of the class and its debug switch
     ClassName("dictionary");
@@ -234,7 +401,7 @@ public:
         explicit dictionary(const fileName& name);
 
         //- Construct given the entry name, parent dictionary and Istream,
-        //  reading entries until lastEntry or EOF
+        //  reading entries until EOF
         dictionary
         (
             const fileName& name,
@@ -248,10 +415,10 @@ public:
 
         //- Construct top-level dictionary from Istream,
         //  reading entries until EOF, optionally keeping the header
-        dictionary(Istream& is, const bool keepHeader);
+        dictionary(Istream& is, bool keepHeader);
 
         //- Construct as copy given the parent dictionary
-        dictionary(const dictionary& parentDict, const dictionary&);
+        dictionary(const dictionary& parentDict, const dictionary& dict);
 
         //- Construct top-level dictionary as copy
         dictionary(const dictionary& dict);
@@ -303,280 +470,575 @@ public:
         tokenList tokens() const;
 
 
-        // Search and lookup
-
-            //- Search dictionary for given keyword
-            //  If recursive, search parent dictionaries
-            //  If patternMatch, use regular expressions
-            bool found
-            (
-                const word& keyword,
-                bool recursive = false,
-                bool patternMatch = true
-            ) const;
-
-            //- Find and return an entry data stream pointer if present
-            //  otherwise return nullptr.
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions
-            const entry* lookupEntryPtr
-            (
-                const word& keyword,
-                bool recursive,
-                bool patternMatch
-            ) const;
-
-            //- Find and return an entry data stream pointer for manipulation
-            //  if present otherwise return nullptr.
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            entry* lookupEntryPtr
-            (
-                const word& keyword,
-                bool recursive,
-                bool patternMatch
-            );
-
-            //- Find and return an entry data stream if present otherwise error.
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            const entry& lookupEntry
-            (
-                const word& keyword,
-                bool recursive,
-                bool patternMatch
-            ) const;
-
-            //- Find and return an entry data stream
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            ITstream& lookup
-            (
-                const word& keyword,
-                bool recursive = false,
-                bool patternMatch = true
-            ) const;
-
-            //- Find and return a T,
-            //  if not found throw a fatal error.
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            template<class T>
-            T lookupType
-            (
-                const word&,
-                bool recursive=false,
-                bool patternMatch=true
-            ) const;
-
-            //- Find and return a T, or return the given default value
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            template<class T>
-            T lookupOrDefault
-            (
-                const word& keyword,
-                const T& deflt,
-                bool recursive = false,
-                bool patternMatch = true
-            ) const;
-
-            //- Find and return a T, if not found return the given
-            //  default value, and add to dictionary.
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            template<class T>
-            T lookupOrAddDefault
-            (
-                const word& keyword,
-                const T& deflt,
-                bool recursive = false,
-                bool patternMatch = true
-            );
-
-            //- Find an entry if present, and assign to T
-            //  Returns true if the entry was found.
-            //  If recursive, search parent dictionaries.
-            //  If patternMatch, use regular expressions.
-            template<class T>
-            bool readIfPresent
-            (
-                const word& keyword,
-                T& val,
-                bool recursive = false,
-                bool patternMatch = true
-            ) const;
-
-            //- Find and return an entry data stream pointer if present
-            //  otherwise return nullptr. Allows scoping using '.'.
-            //  Special handling for ':' at start of keyword and '..'.
-            const entry* lookupScopedEntryPtr
-            (
-                const word& keyword,
-                bool recursive,
-                bool patternMatch
-            ) const;
-
-            //- Check if entry is a sub-dictionary
-            bool isDict(const word& keyword) const;
-
-            //- Find and return a sub-dictionary pointer if present
-            //  otherwise return nullptr.
-            const dictionary* subDictPtr(const word& keyword) const;
-
-            //- Find and return a sub-dictionary pointer if present
-            //  otherwise return nullptr.
-            dictionary* subDictPtr(const word& keyword);
-
-            //- Find and return a sub-dictionary
-            const dictionary& subDict(const word& keyword) const;
-
-            //- Find and return a sub-dictionary for manipulation
-            dictionary& subDict(const word& keyword);
-
-            //- Find and return a sub-dictionary as a copy, or
-            //  return an empty dictionary if the sub-dictionary does not exist
-            dictionary subOrEmptyDict
-            (
-                const word& keyword,
-                const bool mustRead = false
-            ) const;
-
-            //- Find and return a sub-dictionary if found
-            //  otherwise return this dictionary
-            const dictionary& optionalSubDict(const word&) const;
-
-            //- Return the table of contents
-            wordList toc() const;
-
-            //- Return the sorted table of contents
-            wordList sortedToc() const;
-
-            //- Return the list of available keys or patterns
-            List<keyType> keys(bool patterns = false) const;
-
-
-        // Editing
-
-            //- Substitute the given keyword prepended by '$' with the
-            //  corresponding sub-dictionary entries
-            bool substituteKeyword(const word& keyword, bool mergeEntry=false);
-
-            //- Substitute the given scoped keyword prepended by '$' with the
-            //  corresponding sub-dictionary entries
-            bool substituteScopedKeyword
-            (
-                const word& keyword,
-                bool mergeEntry=false
-            );
-
-            //- Add a new entry
-            //  With the merge option, dictionaries are interwoven and
-            //  primitive entries are overwritten
-            bool add(entry* entryPtr, bool mergeEntry=false);
-
-            //- Add an entry
-            //  With the merge option, dictionaries are interwoven and
-            //  primitive entries are overwritten
-            void add(const entry& e, bool mergeEntry=false);
-
-            //- Add a word entry
-            //  optionally overwrite an existing entry
-            void add(const keyType& k, const word& w, bool overwrite=false);
-
-            //- Add a string entry
-            //  optionally overwrite an existing entry
-            void add(const keyType& k, const string& s, bool overwrite=false);
-
-            //- Add a label entry
-            //  optionally overwrite an existing entry
-            void add(const keyType&, const label l, bool overwrite=false);
+      // Search and lookup
 
-            //- Add a scalar entry
-            //  optionally overwrite an existing entry
-            void add(const keyType&, const scalar s, bool overwrite=false);
+        //- Search dictionary for given keyword.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        bool found
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
 
-            //- Add a dictionary entry
-            //  optionally merge with an existing sub-dictionary
-            void add
-            (
-                const keyType& k,
-                const dictionary& d,
-                bool mergeEntry = false
-            );
+        //- Find and return an entry pointer if present, or return a nullptr.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const entry* lookupEntryPtr
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const;
 
-            //- Add a T entry
-            //  optionally overwrite an existing entry
-            template<class T>
-            void add(const keyType& k, const T& t, bool overwrite=false);
+        //- Find and return an entry pointer for manipulation if present,
+        //  or return a nullptr.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        entry* lookupEntryPtr
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        );
 
-            //- Assign a new entry, overwrite any existing entry
-            void set(entry* entryPtr);
+        //- Find and return an entry if present otherwise error.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const entry& lookupEntry
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const;
 
-            //- Assign a new entry, overwrite any existing entry
-            void set(const entry& e);
+        //- Find and return an entry data stream.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        ITstream& lookup
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
 
-            //- Assign a dictionary entry, overwrite any existing entry
-            void set(const keyType& k, const dictionary& d);
+        //- Find and return a T. FatalError if not found.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        template<class T>
+        T lookupType
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
 
-            //- Assign a T entry, overwrite any existing entry
-            template<class T>
-            void set(const keyType& k, const T& t);
+        //- Find and return a T, or return the given default value
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        template<class T>
+        T lookupOrDefault
+        (
+            const word& keyword,
+            const T& deflt,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
 
-            //- Remove an entry specified by keyword
-            bool remove(const word& Keyword);
+        //- Find and return a T, if not found return the default value
+        //  and add it to dictionary.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        template<class T>
+        T lookupOrAddDefault
+        (
+            const word& keyword,
+            const T& deflt,
+            bool recursive = false,
+            bool patternMatch = true
+        );
 
-            //- Change the keyword for an entry,
-            //  optionally forcing overwrite of an existing entry
-            bool changeKeyword
-            (
-                const keyType& oldKeyword,
-                const keyType& newKeyword,
-                bool forceOverwrite=false
-            );
+        //- Find an entry if present, and assign to T val.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param val the value to read
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        //
+        //  \return true if the entry was found.
+        template<class T>
+        bool readIfPresent
+        (
+            const word& keyword,
+            T& val,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
 
-            //- Merge entries from the given dictionary.
-            //  Also merge sub-dictionaries as required.
-            bool merge(const dictionary& dict);
+        //- Find and return an entry pointer if present, or return a nullptr.
+        //  Allows scoping using '.'.
+        //  Special handling for an absolute anchor (^) at start of the keyword
+        //  and for '..' to ascend into the parent dictionaries.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const entry* lookupScopedEntryPtr
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const;
+
+        //- Check if entry exists and is a sub-dictionary.
+        //
+        //  Search type: non-recursive with patterns.
+        bool isDict(const word& keyword) const;
+
+        //- Find and return a sub-dictionary pointer if present
+        //  (and a sub-dictionary) otherwise return nullptr.
+        //
+        //  Search type: non-recursive with patterns.
+        const dictionary* subDictPtr(const word& keyword) const;
+
+        //- Find and return a sub-dictionary pointer if present
+        //  (and a sub-dictionary) otherwise return nullptr.
+        //
+        //  Search type: non-recursive with patterns.
+        dictionary* subDictPtr(const word& keyword);
+
+        //- Find and return a sub-dictionary.
+        //  Fatal if the entry does not exist or is not a sub-dictionary.
+        //
+        //  Search type: non-recursive with patterns.
+        const dictionary& subDict(const word& keyword) const;
+
+        //- Find and return a sub-dictionary for manipulation.
+        //  Fatal if the entry does not exist or is not a sub-dictionary.
+        //
+        //  Search type: non-recursive with patterns.
+        dictionary& subDict(const word& keyword);
+
+        //- Find and return a sub-dictionary as a copy, otherwise return
+        //  an empty dictionary.
+        //  Warn if the entry exists but is not a sub-dictionary.
+        //
+        //  Search type: non-recursive with patterns.
+        dictionary subOrEmptyDict
+        (
+            const word& keyword,
+            const bool mustRead = false
+        ) const;
+
+        //- Find and return a sub-dictionary, otherwise return this dictionary.
+        //  Warn if the entry exists but is not a sub-dictionary.
+        //
+        //  Search type: non-recursive with patterns.
+        const dictionary& optionalSubDict(const word& keyword) const;
+
+        //- Return the table of contents
+        wordList toc() const;
+
+        //- Return the sorted table of contents
+        wordList sortedToc() const;
+
+        //- Return table of contents sorted using the specified comparator
+        template<class Compare>
+        wordList sortedToc(const Compare& comp) const;
+
+        //- Return the list of available keys or patterns
+        List<keyType> keys(bool patterns = false) const;
 
-            //- Clear the dictionary
-            void clear();
 
-            //- Transfer the contents of the argument and annul the argument.
-            void transfer(dictionary& dict);
+      // Editing
 
-            //- Transfer contents to the Xfer container
-            Xfer<dictionary> xfer();
+        //- Substitute the given keyword (which is prefixed by '$')
+        //  with the corresponding sub-dictionary entries
+        bool substituteKeyword
+        (
+            const word& keyword,
+            bool mergeEntry = false
+        );
 
+        //- Substitute the given scoped keyword (which is prefixed by '$')
+        //  with the corresponding sub-dictionary entries
+        bool substituteScopedKeyword
+        (
+            const word& keyword,
+            bool mergeEntry = false
+        );
 
-        // Read
+        //- Add a new entry.
+        //  \param mergeEntry dictionaries are interwoven and primitive
+        //         entries are overwritten
+        //  \return pointer to inserted entry, or place of merging
+        //   or nullptr on failure
+        entry* add(entry* entryPtr, bool mergeEntry=false);
+
+        //- Add an entry.
+        //  \param mergeEntry dictionaries are interwoven and primitive
+        //         entries are overwritten
+        //  \return pointer to inserted entry, or place of merging
+        //   or nullptr on failure
+        entry* add(const entry& e, bool mergeEntry=false);
+
+        //- Add a word entry.
+        //  \param overwrite force overwrite of an existing entry.
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* add(const keyType& k, const word& v, bool overwrite=false);
+
+        //- Add a string entry.
+        //  \param overwrite force overwrite of an existing entry.
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* add(const keyType& k, const string& v, bool overwrite=false);
+
+        //- Add a label entry.
+        //  \param overwrite force overwrite of an existing entry.
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* add(const keyType& k, const label v, bool overwrite=false);
+
+        //- Add a scalar entry.
+        //  \param overwrite force overwrite of an existing entry.
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* add(const keyType& k, const scalar v, bool overwrite=false);
+
+        //- Add a dictionary entry.
+        //  \param mergeEntry merge into an existing sub-dictionary
+        //  \return pointer to inserted entry, or place of merging
+        //   or nullptr on failure
+        entry* add
+        (
+            const keyType& k,
+            const dictionary& d,
+            bool mergeEntry = false
+        );
+
+        //- Add a T entry
+        //  \param overwrite force overwrite of existing entry
+        //  \return pointer to inserted entry or nullptr on failure
+        template<class T>
+        entry* add(const keyType& k, const T& v, bool overwrite=false);
+
+        //- Assign a new entry, overwriting any existing entry.
+        //
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* set(entry* entryPtr);
+
+        //- Assign a new entry, overwriting any existing entry.
+        //
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* set(const entry& e);
+
+        //- Assign a dictionary entry, overwriting any existing entry.
+        //
+        //  \return pointer to inserted entry or nullptr on failure
+        entry* set(const keyType& k, const dictionary& v);
+
+        //- Assign a T entry, overwriting any existing entry.
+        //  \return pointer to inserted entry or nullptr on failure
+        template<class T>
+        entry* set(const keyType& k, const T& v);
+
+        //- Remove an entry specified by keyword
+        bool remove(const word& keyword);
+
+        //- Change the keyword for an entry,
+        //  \param overwrite force overwrite of an existing entry.
+        bool changeKeyword
+        (
+            const keyType& oldKeyword,
+            const keyType& newKeyword,
+            bool overwrite=false
+        );
+
+        //- Merge entries from the given dictionary.
+        //  Also merge sub-dictionaries as required.
+        bool merge(const dictionary& dict);
 
-            //- Read dictionary from Istream
-            bool read(Istream& is);
+        //- Clear the dictionary
+        void clear();
 
-            //- Read dictionary from Istream, optionally keeping the header
-            bool read(Istream& is, const bool keepHeader);
+        //- Transfer the contents of the argument and annul the argument.
+        void transfer(dictionary& dict);
 
+        //- Transfer contents to the Xfer container
+        Xfer<dictionary> xfer();
 
-        // Write
 
-            //- Write sub-dictionary with the keyword as its header
-            void writeEntry(const keyType& keyword, Ostream& os) const;
+      // Read
 
-            //- Write dictionary entries.
-            //  Optionally with extra new line between entries for
-            //  "top-level" dictionaries
-            void writeEntries(Ostream& os, const bool extraNewLine=false) const;
+        //- Read dictionary from Istream
+        bool read(Istream& is);
 
-            //- Write dictionary, normally with sub-dictionary formatting
-            void write(Ostream& os, const bool subDict=true) const;
+        //- Read dictionary from Istream, optionally keeping the header
+        bool read(Istream& is, bool keepHeader);
+
+
+      // Write
+
+        //- Write sub-dictionary with the keyword as its header
+        void writeEntry(const keyType& keyword, Ostream& os) const;
+
+        //- Write dictionary entries.
+        //  \param extraNewLine adds additional newline\n between entries
+        //         for "top-level" dictionaries
+        void writeEntries(Ostream& os, const bool extraNewLine=false) const;
+
+        //- Write dictionary, normally with sub-dictionary formatting
+        void write(Ostream& os, const bool subDict=true) const;
+
+
+      // Searching
+
+        //- Search dictionary for given keyword
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const_searcher csearch
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
+
+        //- Search dictionary for given keyword
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const_searcher search
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
+
+        //- Search dictionary for given keyword
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        searcher search
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        );
+
+        //- Search using scoping.
+        //  There are two types of scoping available:
+        //  -# dot-scoping, where a '.' is used to delineate the scope
+        //  -# slash-scoping, where a '/' is used to delineate the scope
+        //
+        //  For dot-scoping, a leading '^' traverses to the top-level
+        //  dictionary, leading dots mean use the parent dictionary and an
+        //  intermediate dot separates a sub-dictionary or sub-entry.
+        //  However, since the use of dots is ambiguous ("a.b.c" could be
+        //  an entry itself or represent a "bc" entry from dictionary "a" etc),
+        //  the heuristic backtracks and attempts successively longer
+        //  top-level entries until a suitable match is found.
+        //
+        //  For slash-scoping, semantics similar to directory structures are
+        //  used. A leading '/' traverses to the top-level dictionary,
+        //  a single leading or intermediate '.' references the current
+        //  dictionary level. A '..' pair references the parent dictionary.
+        //  Any doubled slashes are silently ignored.
+        //  Since a slash is not a valid keyword character, there is no
+        //  ambiguity between separator and content.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const_searcher csearchScoped
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const;
+
+        //- Search using dot or slash scoping.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const_searcher searchScoped
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const;
+
+        //- Search using dot or slash scoping.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        searcher searchScoped
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        );
+
+        //- Locate a sub-dictionary using slash-scoping
+        //  \return nullptr if the dictionary path does not exist
+        const dictionary* cfindScopedDictPtr(const fileName& dictPath) const;
+
+        //- Locate a sub-dictionary using slash-scoping
+        //  \return nullptr if the dictionary path does not exist
+        const dictionary* findScopedDictPtr(const fileName& dictPath) const;
+
+        //- Locate a sub-dictionary using slash-scoping
+        //  \return nullptr if the dictionary path does not exist
+        dictionary* findScopedDictPtr(const fileName& dictPath);
+
+        //- Locate existing or create sub-dictionary using slash-scoping
+        //  \return nullptr if the dictionary path could not be created
+        dictionary* makeScopedDictPtr(const fileName& dictPath);
+
+
+    // Compatibility helpers
+
+        //- Search dictionary for given keyword and any compatibility names
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //      Old version 1600=OpenFOAM-v3.0, 240=OpenFOAM-2.4.x,
+        //      170=OpenFOAM-1.7.x,...
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const_searcher csearchCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
+
+        //- Search dictionary for given keyword and any compatibility names
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        bool foundCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
+
+        //- Find and return an entry pointer if present, or return a nullptr,
+        //- using any compatibility names it needed.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const entry* lookupEntryPtrCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            bool recursive,
+            bool patternMatch
+        ) const;
+
+        //- Find and return an entry if present otherwise error,
+        //- using any compatibility names it needed.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        const entry& lookupEntryCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            bool recursive,
+            bool patternMatch
+        ) const;
+
+        //- Find and return an entry data stream,
+        //- using any compatibility names it needed.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        ITstream& lookupCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
+
+        //- Find and return a T, or return the given default value
+        //- using any compatibility names it needed.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        template<class T>
+        T lookupOrDefaultCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            const T& deflt,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
+
+        //- Find an entry if present, and assign to T val
+        //- using any compatibility names it needed.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param compat list of old compatibility keywords and the last
+        //      OpenFOAM version for which they were used.
+        //  \param val the value to read
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
+        //
+        //  \return true if the entry was found.
+        template<class T>
+        bool readIfPresentCompat
+        (
+            const word& keyword,
+            std::initializer_list<std::pair<const char*,int>> compat,
+            T& val,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const;
 
 
     // Member Operators
 
-        //- Find and return entry
+        //- Find and return an entry data stream (identical to #lookup method).
+        //  Default search: non-recursive with patterns.
+        //
+        //  \param recursive search parent dictionaries
+        //  \param patternMatch use regular expressions
         ITstream& operator[](const word& keyword) const;
 
+        //- Copy assignment
         void operator=(const dictionary& rhs);
 
         //- Include entries from the given dictionary.
diff --git a/src/OpenFOAM/db/dictionary/dictionaryCompat.C b/src/OpenFOAM/db/dictionary/dictionaryCompat.C
new file mode 100644
index 0000000000000000000000000000000000000000..624231fd14db8f2c000263471b4cf08b3fb12529
--- /dev/null
+++ b/src/OpenFOAM/db/dictionary/dictionaryCompat.C
@@ -0,0 +1,162 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "dictionary.H"
+
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
+
+static void warnAboutAge(const int oldVersion)
+{
+    if (oldVersion < 1000)
+    {
+        // Emit warning
+        std::cerr
+            << "    This keyword is considered to be VERY old!\n"
+            << std::endl;
+    }
+#if (OPENFOAM_PLUS > 1600)
+    else if (OPENFOAM_PLUS > oldVersion)
+    {
+        const int months =
+        (
+            // YYMM -> months
+            (12 * (OPENFOAM_PLUS/100) + (OPENFOAM_PLUS % 100))
+          - (12 * (oldVersion/100) + (oldVersion % 100))
+        );
+
+        std::cerr
+            << "    This keyword is deemed to be " << months
+            << " months old.\n"
+            << std::endl;
+    }
+#endif
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    const_searcher finder(csearch(keyword, recursive,patternMatch));
+
+    if (finder.found())
+    {
+        return finder;
+    }
+
+    for (const std::pair<const char*,int>& iter : compat)
+    {
+        finder = csearch(word::validate(iter.first), recursive,patternMatch);
+
+        if (finder.found())
+        {
+            // Emit warning
+            std::cerr
+                << "--> FOAM IOWarning :" << nl
+                << "    Found [v" << iter.second << "] '"
+                << iter.first << "' instead of '"
+                << keyword.c_str() << "' in dictionary \""
+                << name().c_str() << "\" "
+                << nl
+                << std::endl;
+
+            warnAboutAge(iter.second);
+
+            break;
+        }
+    }
+
+    return finder;
+}
+
+
+bool Foam::dictionary::foundCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    return csearchCompat(keyword, compat, recursive,patternMatch).found();
+}
+
+
+const Foam::entry* Foam::dictionary::lookupEntryPtrCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    return csearchCompat(keyword, compat, recursive,patternMatch).ptr();
+}
+
+
+const Foam::entry& Foam::dictionary::lookupEntryCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    const const_searcher
+        finder(csearchCompat(keyword, compat, recursive,patternMatch));
+
+    if (!finder.found())
+    {
+        FatalIOErrorInFunction
+        (
+            *this
+        )   << "keyword " << keyword << " is undefined in dictionary "
+            << name()
+            << exit(FatalIOError);
+    }
+
+    return finder.ref();
+}
+
+
+Foam::ITstream& Foam::dictionary::lookupCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    return lookupEntryCompat(keyword, compat, recursive,patternMatch).stream();
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C
index 6167956e7096b3167d6a15a26753f2127fbc47ee..262c6b4fb4537f5546b544330139b733c10c7c80 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.C
@@ -58,10 +58,8 @@ Foam::label Foam::dictionaryEntry::startLineNumber() const
     {
         return first()->startLineNumber();
     }
-    else
-    {
-        return -1;
-    }
+
+    return -1;
 }
 
 
@@ -71,10 +69,8 @@ Foam::label Foam::dictionaryEntry::endLineNumber() const
     {
         return last()->endLineNumber();
     }
-    else
-    {
-        return -1;
-    }
+
+    return -1;
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C
index ddc505c661e8df646e8b50f21b98d19973156d97..d608b74e6893bd94ad23b8cba0fd2ae2fa58d9f9 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C
@@ -55,7 +55,7 @@ Foam::dictionary::dictionary(Istream& is)
 }
 
 
-Foam::dictionary::dictionary(Istream& is, const bool keepHeader)
+Foam::dictionary::dictionary(Istream& is, bool keepHeader)
 :
     dictionaryName(is.name()),
     parent_(dictionary::null)
@@ -77,8 +77,14 @@ Foam::autoPtr<Foam::dictionary> Foam::dictionary::New(Istream& is)
 
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
-bool Foam::dictionary::read(Istream& is, const bool keepHeader)
+bool Foam::dictionary::read(Istream& is, bool keepHeader)
 {
+    // Normally remove FoamFile header when read, but avoid this if it already
+    // existed prior to the current read.
+    // We would otherwise lose it with every top-level '#include ...'
+
+    keepHeader = keepHeader || hashedEntries_.found("FoamFile");
+
     // Check for empty dictionary
     if (is.eof())
     {
@@ -103,7 +109,6 @@ bool Foam::dictionary::read(Istream& is, const bool keepHeader)
     while (!is.eof() && entry::New(*this, is))
     {}
 
-    // Normally remove the FoamFile header entry if it exists
     if (!keepHeader)
     {
         remove("FoamFile");
@@ -128,30 +133,6 @@ bool Foam::dictionary::read(Istream& is)
 }
 
 
-bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry)
-{
-    const word varName = keyword.substr(1);
-
-    // Lookup the variable name in the given dictionary
-    const entry* ePtr = lookupEntryPtr(varName, true, true);
-
-    // If defined insert its entries into this dictionary
-    if (ePtr != nullptr)
-    {
-        const dictionary& addDict = ePtr->dict();
-
-        forAllConstIter(parent_type, addDict, iter)
-        {
-            add(iter(), mergeEntry);
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-
 // * * * * * * * * * * * * * * Istream Operator  * * * * * * * * * * * * * * //
 
 Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
diff --git a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C b/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C
index 53399cc5430b76a89d51f64b0396493188cb408d..041c1072585baea3ac840da4fab3442a78980ec1 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryListEntry/dictionaryListEntryIO.C
@@ -44,6 +44,16 @@ static Foam::label realSize(const Foam::dictionary& dict)
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
+Foam::dictionaryListEntry::dictionaryListEntry
+(
+    const dictionary& parentDict,
+    const dictionaryListEntry& dictEnt
+)
+:
+    dictionaryEntry(parentDict, dictEnt)
+{}
+
+
 Foam::dictionaryListEntry::dictionaryListEntry
 (
     const dictionary& parentDict,
diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C
new file mode 100644
index 0000000000000000000000000000000000000000..cea0844cdfcfc377a96cadd2ccd2b73dfba001e0
--- /dev/null
+++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C
@@ -0,0 +1,720 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "dictionary.H"
+#include "dictionaryEntry.H"
+#include "stringOps.H"
+
+/* * * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * */
+
+namespace Foam
+{
+    // file-scope
+    //- Walk lists of patterns and regexps for an exact match
+    //  or regular expression match
+    template<class WcIterator, class ReIterator>
+    static bool findInPatterns
+    (
+        const bool patternMatch,
+        const word& keyword,
+        WcIterator& wcIter,
+        ReIterator& reIter
+    )
+    {
+        while (wcIter.found())
+        {
+            if
+            (
+                patternMatch
+              ? reIter()->match(keyword)
+              : wcIter()->keyword() == keyword
+            )
+            {
+                return true;
+            }
+
+            ++reIter;
+            ++wcIter;
+        }
+
+        return false;
+    }
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    std::string::size_type scopePos = keyword.find('.');
+
+    if (scopePos == string::npos)
+    {
+        // Normal, non-scoped search
+        return csearch(keyword, recursive, patternMatch);
+    }
+
+    if (scopePos == 0)
+    {
+        // Starting with a '.' -> go up for every further '.' found
+        ++scopePos;
+
+        const dictionary* dictPtr = this;
+        for
+        (
+            string::const_iterator it = keyword.begin()+1;
+            it != keyword.end() && *it == '.';
+            ++scopePos, ++it
+        )
+        {
+            // Go to parent
+            if (&dictPtr->parent_ != &dictionary::null)
+            {
+                dictPtr = &dictPtr->parent_;
+            }
+            else
+            {
+                FatalIOErrorInFunction
+                (
+                    *this
+                )   << "No parent of current dictionary when searching for "
+                    << keyword.substr(1)
+                    << exit(FatalIOError);
+
+                return nullptr;
+            }
+        }
+
+        return dictPtr->csearchDotScoped
+        (
+            keyword.substr(scopePos),
+            false,
+            patternMatch
+        );
+    }
+
+    // The first word
+    const_searcher finder = csearchDotScoped
+    (
+        keyword.substr(0, scopePos),
+        false,
+        patternMatch
+    );
+
+    // Fall back to finding key with '.' so e.g. if keyword is
+    // a.b.c.d it would try
+    // a.b, a.b.c, a.b.c.d
+
+    if (!finder.found())
+    {
+        while (!finder.isDict())
+        {
+            scopePos = keyword.find('.', scopePos+1);
+
+            // Local entry:
+            finder = csearch(keyword.substr(0, scopePos), false, patternMatch);
+
+            if (scopePos == string::npos)
+            {
+                // Parsed the whole word. Return entry or null.
+                return finder;
+            }
+        }
+    }
+
+    if (finder.isDict())
+    {
+        return finder.dict().csearchDotScoped
+        (
+            keyword.substr(scopePos),
+            false,
+            patternMatch
+        );
+    }
+
+    return finder;
+}
+
+
+Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
+(
+    const word& keyword,
+    bool patternMatch
+) const
+{
+    const dictionary* dictPtr = this;
+
+    const auto slash = keyword.find('/');
+
+    if (slash == string::npos)
+    {
+        // No slashes:
+        // Can use normal (non-scoped) search at the current dictionary level
+        return csearch(keyword, false, patternMatch);
+    }
+    else if (slash == 0)
+    {
+        // (isAbsolute)
+        // Ascend to top-level
+        while (&dictPtr->parent_ != &dictionary::null)
+        {
+            dictPtr = &dictPtr->parent_;
+        }
+    }
+
+    // Split on '/'
+    auto cmpts = stringOps::split<std::string>(keyword, '/');
+    auto remaining = cmpts.size();
+
+    for (const auto& cmpt : cmpts)
+    {
+        --remaining; // Decrement now so we can check (remaining == 0)
+
+        if (cmpt == ".")
+        {
+            // "." - ignore
+        }
+        else if (cmpt == "..")
+        {
+            // ".." - go to parent
+            if (&dictPtr->parent_ != &dictionary::null)
+            {
+                dictPtr = &dictPtr->parent_;
+            }
+            else
+            {
+                FatalIOErrorInFunction
+                (
+                    *dictPtr
+                )   << "No parent of current dictionary when searching for "
+                    << keyword << " at " << cmpt
+                    << exit(FatalIOError);
+                break;
+            }
+        }
+        else
+        {
+            // Find entry
+            const word key = word::validate(cmpt);
+
+            auto finder = dictPtr->csearch(key, false, patternMatch);
+
+            if (finder.found())
+            {
+                if (remaining)
+                {
+                    // Intermediate must be a dictionary
+                    if (finder.isDict())
+                    {
+                        dictPtr = finder.dictPtr();
+                    }
+                    else
+                    {
+                        return const_searcher(dictPtr);
+                    }
+                }
+                else
+                {
+                    // Last entry - done
+                    return finder;
+                }
+            }
+            else
+            {
+                break;
+            }
+        }
+    }
+
+    // Failed at this dictionary level
+    return const_searcher(dictPtr);
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+Foam::dictionary::const_searcher Foam::dictionary::csearch
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    const_searcher finder(this);
+
+    auto iter = hashedEntries_.cfind(keyword);
+
+    if (iter.found())
+    {
+        finder.set(iter.object());
+        return finder;
+    }
+
+    if (patternMatch && patterns_.size())
+    {
+        pattern_const_iterator wcLink = patterns_.begin();
+        regexp_const_iterator  reLink = regexps_.begin();
+
+        // Find in patterns using regular expressions only
+        if (findInPatterns(patternMatch, keyword, wcLink, reLink))
+        {
+            finder.set(*wcLink);
+            return finder;
+        }
+    }
+
+    if (recursive && &parent_ != &dictionary::null)
+    {
+        return parent_.csearch
+        (
+            keyword,
+            recursive,
+            patternMatch
+        );
+    }
+
+    return finder;
+}
+
+
+Foam::dictionary::const_searcher Foam::dictionary::search
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    return csearch(keyword, recursive, patternMatch);
+}
+
+
+Foam::dictionary::searcher Foam::dictionary::search
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+)
+{
+    const_searcher finder = csearch(keyword, recursive, patternMatch);
+
+    return static_cast<const searcher&>(finder);
+}
+
+
+Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    if (keyword.find('/') != string::npos)
+    {
+        return csearchSlashScoped(keyword, patternMatch);
+    }
+
+    if (keyword[0] == ':' || keyword[0] == '^')
+    {
+        // Ascend to top-level
+        const dictionary* dictPtr = this;
+        while (&dictPtr->parent_ != &dictionary::null)
+        {
+            dictPtr = &dictPtr->parent_;
+        }
+
+        return dictPtr->csearchDotScoped
+        (
+            keyword.substr(1),
+            false,
+            patternMatch
+        );
+    }
+
+    return csearchDotScoped(keyword, recursive, patternMatch);
+}
+
+
+Foam::dictionary::const_searcher Foam::dictionary::searchScoped
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+) const
+{
+    return csearchScoped(keyword, recursive, patternMatch);
+}
+
+
+Foam::dictionary::searcher Foam::dictionary::searchScoped
+(
+    const word& keyword,
+    bool recursive,
+    bool patternMatch
+)
+{
+    const_searcher finder = csearchScoped(keyword, recursive, patternMatch);
+
+    return static_cast<const searcher&>(finder);
+}
+
+
+const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
+(
+    const fileName& dictPath
+) const
+{
+    // Or warning
+    if (dictPath.empty())
+    {
+        return nullptr;
+    }
+
+    const dictionary* dictPtr = this;
+    if (fileName::isAbsolute(dictPath))
+    {
+        // Ascend to top-level
+        while (&dictPtr->parent_ != &dictionary::null)
+        {
+            dictPtr = &dictPtr->parent_;
+        }
+    }
+
+    fileName path = dictPath.clean();
+    const wordList cmpts = path.components();
+
+    for (const word& cmpt : cmpts)
+    {
+        if (cmpt == ".")
+        {
+            // "." - ignore
+        }
+        else if (cmpt == "..")
+        {
+            // ".." - go to parent
+            if (&dictPtr->parent_ != &dictionary::null)
+            {
+                dictPtr = &dictPtr->parent_;
+            }
+            else
+            {
+                FatalIOErrorInFunction
+                (
+                    *dictPtr
+                )   << "No parent for dictionary while searching "
+                    << path
+                    << exit(FatalIOError);
+
+                return nullptr;
+            }
+        }
+        else
+        {
+            // Non-recursive, no patternMatch
+            // -> can do direct lookup, without csearch(cmpt, false, false);
+
+            auto iter = dictPtr->hashedEntries_.cfind(cmpt);
+
+            if (iter.found())
+            {
+                const entry *eptr = iter.object();
+
+                if (eptr->isDict())
+                {
+                    dictPtr = eptr->dictPtr();
+                }
+                else
+                {
+                    FatalIOErrorInFunction
+                    (
+                        *dictPtr
+                    )   << "Found entry '" << cmpt
+                        << "' but not a dictionary, while searching scoped"
+                        << nl
+                        << "    " << path
+                        << exit(FatalIOError);
+
+                    return nullptr;
+                }
+            }
+            else
+            {
+                return nullptr;
+            }
+        }
+    }
+
+    return dictPtr;
+}
+
+
+const Foam::dictionary* Foam::dictionary::findScopedDictPtr
+(
+    const fileName& dictPath
+) const
+{
+    return cfindScopedDictPtr(dictPath);
+}
+
+
+Foam::dictionary* Foam::dictionary::findScopedDictPtr
+(
+    const fileName& dictPath
+)
+{
+    const dictionary* ptr = cfindScopedDictPtr(dictPath);
+    return const_cast<dictionary*>(ptr);
+}
+
+
+Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
+{
+    // Or warning
+    if (dictPath.empty())
+    {
+        return nullptr;
+    }
+
+    dictionary* dictPtr = this;
+    if (fileName::isAbsolute(dictPath))
+    {
+        // Ascend to top-level
+        while (&dictPtr->parent_ != &dictionary::null)
+        {
+            dictPtr = const_cast<dictionary*>(&dictPtr->parent_);
+        }
+    }
+
+    // Work on a copy, without any assumptions
+    std::string path = dictPath;
+    fileName::clean(path);
+
+    // Split on '/'
+    auto cmpts = stringOps::split(path, '/');
+
+    for (const auto& cmpt : cmpts)
+    {
+        if (cmpt == ".")
+        {
+            // "." - ignore
+        }
+        else if (cmpt == "..")
+        {
+            // ".." - go to parent
+            if (&dictPtr->parent_ != &dictionary::null)
+            {
+                dictPtr = const_cast<dictionary*>(&dictPtr->parent_);
+            }
+            else
+            {
+                FatalIOErrorInFunction
+                (
+                    *dictPtr
+                )   << "No parent for dictionary while searching "
+                    << path
+                    << exit(FatalIOError);
+
+                return nullptr;
+            }
+        }
+        else
+        {
+            // Non-recursive, no patternMatch
+            // -> can do direct lookup, without csearch(cmptName, false, false);
+            const word cmptName(cmpt.str(), false);
+
+            auto iter = dictPtr->hashedEntries_.find(cmptName);
+
+            if (iter.found())
+            {
+                entry *eptr = iter.object();
+
+                if (eptr->isDict())
+                {
+                    dictPtr = eptr->dictPtr();
+                }
+                else
+                {
+                    FatalIOErrorInFunction
+                    (
+                        *dictPtr
+                    )   << "Cannot create sub-dictionary entry '" << cmptName
+                        << "' - a non-dictionary entry is in the way"
+                        << nl << "Encountered in scope" << nl
+                        << "    " << path
+                        << exit(FatalIOError);
+
+                    return nullptr;
+                }
+            }
+            else
+            {
+                dictionaryEntry *eptr =
+                    new dictionaryEntry(cmptName, *dictPtr, dictionary());
+
+                // Add *without* merging, since we just checked that the entry
+                // doesn't exist and to ensure that the pointer remains valid.
+
+                if (dictPtr->add(eptr, false))  // NO merge
+                {
+                    dictPtr = eptr;
+                }
+                else
+                {
+                    // Note: a failed add() deletes the eptr passed
+                    return nullptr;
+                }
+            }
+        }
+    }
+
+    return dictPtr;
+}
+
+
+bool Foam::dictionary::remove(const word& keyword)
+{
+    auto iter = hashedEntries_.find(keyword);
+
+    if (iter.found())
+    {
+        // Delete from patterns
+        pattern_iterator wcLink = patterns_.begin();
+        regexp_iterator  reLink = regexps_.begin();
+
+        // Find in pattern using exact match only
+        if (findInPatterns(false, keyword, wcLink, reLink))
+        {
+            patterns_.remove(wcLink);
+            regexps_.remove(reLink);
+        }
+
+        parent_type::remove(iter());
+        delete iter();
+        hashedEntries_.erase(iter);
+
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
+bool Foam::dictionary::changeKeyword
+(
+    const keyType& oldKeyword,
+    const keyType& newKeyword,
+    bool overwrite
+)
+{
+    // No change
+    if (oldKeyword == newKeyword)
+    {
+        return false;
+    }
+
+    // Check that oldKeyword exists and can be changed
+    auto iter = hashedEntries_.find(oldKeyword);
+
+    if (!iter.found())
+    {
+        return false;
+    }
+
+    if (iter()->keyword().isPattern())
+    {
+        FatalIOErrorInFunction
+        (
+            *this
+        )   << "Old keyword "<< oldKeyword
+            << " is a pattern."
+            << "Pattern replacement not yet implemented."
+            << exit(FatalIOError);
+    }
+
+
+    auto iter2 = hashedEntries_.find(newKeyword);
+
+    // newKeyword already exists
+    if (iter2.found())
+    {
+        if (overwrite)
+        {
+            if (iter2()->keyword().isPattern())
+            {
+                // Delete from patterns
+                pattern_iterator wcLink = patterns_.begin();
+                regexp_iterator  reLink = regexps_.begin();
+
+                // Find in patterns using exact match only
+                if (findInPatterns(false, iter2()->keyword(), wcLink, reLink))
+                {
+                    patterns_.remove(wcLink);
+                    regexps_.remove(reLink);
+                }
+            }
+
+            parent_type::replace(iter2(), iter());
+            delete iter2();
+            hashedEntries_.erase(iter2);
+        }
+        else
+        {
+            IOWarningInFunction
+            (
+                *this
+            )   << "cannot rename keyword "<< oldKeyword
+                << " to existing keyword " << newKeyword
+                << " in dictionary " << name() << endl;
+            return false;
+        }
+    }
+
+    // Change name and HashTable, but leave DL-List untouched
+    iter()->keyword() = newKeyword;
+    iter()->name() = name() + '.' + newKeyword;
+    hashedEntries_.erase(oldKeyword);
+    hashedEntries_.insert(newKeyword, iter());
+
+    if (newKeyword.isPattern())
+    {
+        patterns_.insert(iter());
+        regexps_.insert
+        (
+            autoPtr<regExp>(new regExp(newKeyword))
+        );
+    }
+
+    return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
index b247dfe8122647d5ea367c06b24a51d99628705e..833647b951a83315740749d4d5815cd5f9f32da6 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -28,6 +28,27 @@ License
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
+template<class Compare>
+Foam::wordList Foam::dictionary::sortedToc(const Compare& comp) const
+{
+    return hashedEntries_.sortedToc(comp);
+}
+
+
+template<class T>
+Foam::entry* Foam::dictionary::add(const keyType& k, const T& v, bool overwrite)
+{
+    return add(new primitiveEntry(k, v), overwrite);
+}
+
+
+template<class T>
+Foam::entry* Foam::dictionary::set(const keyType& k, const T& v)
+{
+    return set(new primitiveEntry(k, v));
+}
+
+
 template<class T>
 T Foam::dictionary::lookupType
 (
@@ -36,9 +57,9 @@ T Foam::dictionary::lookupType
     bool patternMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
+    const const_searcher finder(csearch(keyword, recursive, patternMatch));
 
-    if (entryPtr == nullptr)
+    if (!finder.found())
     {
         FatalIOErrorInFunction
         (
@@ -48,7 +69,7 @@ T Foam::dictionary::lookupType
             << exit(FatalIOError);
     }
 
-    return pTraits<T>(entryPtr->stream());
+    return pTraits<T>(finder.ptr()->stream());
 }
 
 
@@ -61,24 +82,22 @@ T Foam::dictionary::lookupOrDefault
     bool patternMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
+    const const_searcher finder(csearch(keyword, recursive, patternMatch));
 
-    if (entryPtr)
+    if (finder.found())
     {
-        return pTraits<T>(entryPtr->stream());
+        return pTraits<T>(finder.ptr()->stream());
     }
-    else
+
+    if (writeOptionalEntries)
     {
-        if (writeOptionalEntries)
-        {
-            IOInfoInFunction(*this)
-                << "Optional entry '" << keyword << "' is not present,"
-                << " returning the default value '" << deflt << "'"
-                << endl;
-        }
-
-        return deflt;
+        IOInfoInFunction(*this)
+            << "Optional entry '" << keyword << "' is not present,"
+            << " returning the default value '" << deflt << "'"
+            << endl;
     }
+
+    return deflt;
 }
 
 
@@ -91,25 +110,23 @@ T Foam::dictionary::lookupOrAddDefault
     bool patternMatch
 )
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
+    const const_searcher finder(csearch(keyword, recursive, patternMatch));
 
-    if (entryPtr)
+    if (finder.found())
     {
-        return pTraits<T>(entryPtr->stream());
+        return pTraits<T>(finder.ptr()->stream());
     }
-    else
+
+    if (writeOptionalEntries)
     {
-        if (writeOptionalEntries)
-        {
-            IOInfoInFunction(*this)
-                << "Optional entry '" << keyword << "' is not present,"
-                << " adding and returning the default value '" << deflt << "'"
-                << endl;
-        }
-
-        add(new primitiveEntry(keyword, deflt));
-        return deflt;
+        IOInfoInFunction(*this)
+            << "Optional entry '" << keyword << "' is not present,"
+            << " adding and returning the default value '" << deflt << "'"
+            << endl;
     }
+
+    add(new primitiveEntry(keyword, deflt));
+    return deflt;
 }
 
 
@@ -122,39 +139,84 @@ bool Foam::dictionary::readIfPresent
     bool patternMatch
 ) const
 {
-    const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
+    const const_searcher finder(csearch(keyword, recursive, patternMatch));
 
-    if (entryPtr)
+    if (finder.found())
     {
-        entryPtr->stream() >> val;
+        finder.ptr()->stream() >> val;
         return true;
     }
-    else
+
+    if (writeOptionalEntries)
     {
-        if (writeOptionalEntries)
-        {
-            IOInfoInFunction(*this)
-                << "Optional entry '" << keyword << "' is not present,"
-                << " the default value '" << val << "' will be used."
-                << endl;
-        }
-
-        return false;
+        IOInfoInFunction(*this)
+            << "Optional entry '" << keyword << "' is not present,"
+            << " the default value '" << val << "' will be used."
+            << endl;
     }
+
+    return false;
 }
 
 
 template<class T>
-void Foam::dictionary::add(const keyType& k, const T& t, bool overwrite)
+T Foam::dictionary::lookupOrDefaultCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    const T& deflt,
+    bool recursive,
+    bool patternMatch
+) const
 {
-    add(new primitiveEntry(k, t), overwrite);
+    const const_searcher
+        finder(csearchCompat(keyword, compat, recursive, patternMatch));
+
+    if (finder.found())
+    {
+        return pTraits<T>(finder.ptr()->stream());
+    }
+
+    if (writeOptionalEntries)
+    {
+        IOInfoInFunction(*this)
+            << "Optional entry '" << keyword << "' is not present,"
+            << " returning the default value '" << deflt << "'"
+            << endl;
+    }
+
+    return deflt;
 }
 
 
 template<class T>
-void Foam::dictionary::set(const keyType& k, const T& t)
+bool Foam::dictionary::readIfPresentCompat
+(
+    const word& keyword,
+    std::initializer_list<std::pair<const char*,int>> compat,
+    T& val,
+    bool recursive,
+    bool patternMatch
+) const
 {
-    set(new primitiveEntry(k, t));
+    const const_searcher
+        finder(csearchCompat(keyword, compat, recursive, patternMatch));
+
+    if (finder.found())
+    {
+        finder.ptr()->stream() >> val;
+        return true;
+    }
+
+    if (writeOptionalEntries)
+    {
+        IOInfoInFunction(*this)
+            << "Optional entry '" << keyword << "' is not present,"
+            << " the default value '" << val << "' will be used."
+            << endl;
+    }
+
+    return false;
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C
index b8a75380ab5f36192d7f426e1dfecaa559a553c3..b1fb4b92baad4c17ffa7b9c56cce5da792ce39b8 100644
--- a/src/OpenFOAM/db/dictionary/entry/entryIO.C
+++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C
@@ -56,16 +56,15 @@ bool Foam::entry::getKeyword(keyType& keyword, token& keyToken, Istream& is)
         keyword = keyToken.wordToken();
         return true;
     }
-    else if (keyToken.isString())
+
+    if (keyToken.isString())
     {
         // Enable wildcards
         keyword = keyToken.stringToken();
         return true;
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
@@ -84,20 +83,17 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
     {
         return false;
     }
-    else
-    {
-        // Otherwise the token is invalid
-        cerr<< "--> FOAM Warning :" << nl
-            << "    From function "
-            << FUNCTION_NAME << nl
-            << "    in file " << __FILE__
-            << " at line " << __LINE__ << nl
-            << "    Reading " << is.name().c_str() << nl
-            << "    found " << keyToken << nl
-            << "    expected either " << token::END_BLOCK << " or EOF"
-            << std::endl;
-        return false;
-    }
+
+    // Otherwise the token is invalid
+    std::cerr
+        << "--> FOAM Warning :" << nl
+        << "    From function " << FUNCTION_NAME << nl
+        << "    in file " << __FILE__ << " at line " << __LINE__ << nl
+        << "    Reading " << is.name().c_str() << nl
+        << "    found " << keyToken << nl
+        << "    expected either " << token::END_BLOCK << " or EOF"
+        << std::endl;
+    return false;
 }
 
 
@@ -141,7 +137,8 @@ bool Foam::entry::New
         {
             return false;
         }
-        else if
+
+        if
         (
             keyToken.isLabel()
          || (keyToken.isPunctuation() && keyToken.pToken() == token::BEGIN_LIST)
@@ -154,24 +151,23 @@ bool Foam::entry::New
                 false
             );
         }
-        else
-        {
-            // Otherwise the token is invalid
-            cerr<< "--> FOAM Warning :" << nl
-                << "    From function "
-                << FUNCTION_NAME << nl
-                << "    in file " << __FILE__
-                << " at line " << __LINE__ << nl
-                << "    Reading " << is.name().c_str() << nl
-                << "    found " << keyToken << nl
-                << "    expected either " << token::END_BLOCK << " or EOF"
-                << std::endl;
-            return false;
-        }
+
+        // Otherwise the token is invalid
+        std::cerr
+            << "--> FOAM Warning :" << nl
+            << "    From function " << FUNCTION_NAME << nl
+            << "    in file " << __FILE__ << " at line " << __LINE__ << nl
+            << "    Reading " << is.name().c_str() << nl
+            << "    found " << keyToken << nl
+            << "    expected either " << token::END_BLOCK << " or EOF"
+            << std::endl;
+        return false;
     }
-    else if (keyword[0] == '#')
+
+
+    if (keyword[0] == '#')
     {
-        // Function entry
+        // Function entry - #function
 
         if (disableFunctionEntries)
         {
@@ -186,19 +182,15 @@ bool Foam::entry::New
                 false
             );
         }
-        else
-        {
-            const word functionName(keyword.substr(1), false);
-            return functionEntry::execute(functionName, parentDict, is);
-        }
+
+        const word functionName(keyword.substr(1), false);
+        return functionEntry::execute(functionName, parentDict, is);
     }
-    else if
-    (
-        !disableFunctionEntries
-     && keyword[0] == '$'
-    )
+
+
+    if (!disableFunctionEntries && keyword[0] == '$')
     {
-        // Substitution entry
+        // Substitution entry - $variable
 
         token nextToken(is);
         is.putBack(nextToken);
@@ -224,17 +216,12 @@ bool Foam::entry::New
             const word varName = keyword.substr(1);
 
             // Lookup the variable name in the given dictionary
-            const entry* ePtr = parentDict.lookupScopedEntryPtr
-            (
-                varName,
-                true,
-                true
-            );
+            const auto finder = parentDict.csearchScoped(varName, true, true);
 
-            if (ePtr)
+            if (finder.found())
             {
                 // Read as primitiveEntry
-                const keyType newKeyword(ePtr->stream());
+                const keyType newKeyword(finder.ptr()->stream());
 
                 return parentDict.add
                 (
@@ -242,14 +229,12 @@ bool Foam::entry::New
                     false
                 );
             }
-            else
-            {
-                FatalIOErrorInFunction(is)
-                    << "Attempt to use undefined variable " << varName
-                    << " as keyword"
-                    << exit(FatalIOError);
-                return false;
-            }
+
+            FatalIOErrorInFunction(is)
+                << "Attempt to use undefined variable " << varName
+                << " as keyword"
+                << exit(FatalIOError);
+            return false;
         }
         else
         {
@@ -265,10 +250,10 @@ bool Foam::entry::New
 
         return true;
     }
-    else
-    {
-        // Normal entry
 
+
+    // Normal or scoped entry
+    {
         token nextToken(is);
         is.putBack(nextToken);
 
@@ -281,77 +266,168 @@ bool Foam::entry::New
             return false;
         }
 
-        // How to manage duplicate entries
-        bool mergeEntry = false;
+        const bool scoped =
+        (
+            !disableFunctionEntries
+         && (keyword.find('/') != string::npos)
+        );
 
         // See (using exact match) if entry already present
-        entry* existingPtr = parentDict.lookupEntryPtr
+        auto finder =
         (
-            keyword,
-            false,
-            false
+            scoped
+          ? parentDict.searchScoped(keyword, false, false)
+          : parentDict.search(keyword, false, false)
         );
 
-        if (existingPtr)
+        // How to manage duplicate entries
+        bool mergeEntry = false;
+
+        if (finder.found())
         {
-            if (mode == inputMode::MERGE)
-            {
-                mergeEntry = true;
-            }
-            else if (mode == inputMode::OVERWRITE)
-            {
-                // Clear existing dictionary so merge acts like overwrite
-                if (existingPtr->isDict())
-                {
-                    existingPtr->dict().clear();
-                }
-                mergeEntry = true;
-            }
-            else if (mode == inputMode::PROTECT)
+            // Use keyword from the found entry (ie, eliminate scoping chars)
+            const keyType key = finder.ref().keyword();
+
+            if (mode == inputMode::PROTECT || keyword == "FoamFile")
             {
-                // Read and discard the entry.
+                // Read and discard if existing element should be protected,
+                // or would potentially alter the "FoamFile" header.
+
                 // Disable function/variable expansion to avoid side-effects
                 const int oldFlag = entry::disableFunctionEntries;
                 entry::disableFunctionEntries = 1;
 
                 if (nextToken == token::BEGIN_BLOCK)
                 {
-                    dictionaryEntry dummy("dummy", parentDict, is);
+                    dictionaryEntry dummy("dummy", finder.context(), is);
                 }
                 else
                 {
-                    primitiveEntry  dummy("dummy", parentDict, is);
+                    primitiveEntry  dummy("dummy", finder.context(), is);
                 }
 
                 entry::disableFunctionEntries = oldFlag;
                 return true;
             }
-            else if (mode == inputMode::ERROR)
+
+            if (mode == inputMode::ERROR)
             {
                 FatalIOErrorInFunction(is)
-                    << "duplicate entry: " << keyword
+                    << "duplicate entry: " << key
                     << exit(FatalIOError);
 
                 return false;
             }
-        }
 
+            if (mode == inputMode::MERGE)
+            {
+                mergeEntry = true;
+            }
+            else if (mode == inputMode::OVERWRITE)
+            {
+                // Clear existing dictionary so merge acts like overwrite
+                if (finder.isDict())
+                {
+                    finder.dict().clear();
+                }
+                mergeEntry = true;
+            }
 
-        if (nextToken == token::BEGIN_BLOCK)
+            // Merge/overwrite data entry
+
+            if (nextToken == token::BEGIN_BLOCK)
+            {
+                return finder.context().add
+                (
+                    new dictionaryEntry(key, finder.context(), is),
+                    mergeEntry
+                );
+            }
+            else
+            {
+                return finder.context().add
+                (
+                    new primitiveEntry(key, finder.context(), is),
+                    mergeEntry
+                );
+            }
+        }
+        else if (scoped)
         {
-            return parentDict.add
-            (
-                new dictionaryEntry(keyword, parentDict, is),
-                mergeEntry
-            );
+            // A slash-scoped entry - did not previously exist
+
+            string fullPath(keyword);
+            fileName::clean(fullPath);
+
+            // Get or create the dictionary-path.
+            // fileName::path == dictionary-path
+            dictionary* subDictPtr =
+                parentDict.makeScopedDictPtr
+                (
+                    fileName::path(fullPath)
+                );
+
+            if (subDictPtr)
+            {
+                // fileName::name == keyword-name
+                string keyName = fileName::name(fullPath);
+                keyType key;
+
+                // Patterns allowed for the final element.
+                // - use if key name begins with a (single|double) quote
+
+                if (keyName.find_first_of("\"'") == 0)
+                {
+                    // Begins with a quote - treat as pattern
+                    key = keyType(string::validate<keyType>(keyName), true);
+                }
+                else
+                {
+                    // Treat as a word
+                    key = word::validate(keyName, false);
+                }
+
+                if (nextToken == token::BEGIN_BLOCK)
+                {
+                    return subDictPtr->add
+                    (
+                        new dictionaryEntry(key, *subDictPtr, is),
+                        mergeEntry
+                    );
+                }
+                else
+                {
+                    return subDictPtr->add
+                    (
+                        new primitiveEntry(key, *subDictPtr, is),
+                        mergeEntry
+                    );
+                }
+            }
+
+            // Some error finding/creating intermediate dictionaries
+            return false;
         }
         else
         {
-            return parentDict.add
-            (
-                new primitiveEntry(keyword, parentDict, is),
-                mergeEntry
-            );
+            // A non-scoped entry - did not previously exist
+
+            if (nextToken == token::BEGIN_BLOCK)
+            {
+                return parentDict.add
+                (
+                    new dictionaryEntry(keyword, parentDict, is),
+                    mergeEntry
+                );
+            }
+            else
+            {
+                return parentDict.add
+                (
+                    new primitiveEntry(keyword, parentDict, is),
+                    mergeEntry
+                );
+            }
         }
     }
 }
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/README b/src/OpenFOAM/db/dictionary/functionEntries/README
new file mode 100644
index 0000000000000000000000000000000000000000..c75c21043a3b38715bd88bca8337d31ccd4862bd
--- /dev/null
+++ b/src/OpenFOAM/db/dictionary/functionEntries/README
@@ -0,0 +1,30 @@
+| directive         | context           | content           | line oriented?
+|-------------------|-------------------|-------------------|-----------------
+  #inputMode        | dict              | word
+  #default          | dict              | entry introducer
+  #merge            | dict              | entry introducer
+  #overwrite        | dict              | entry introducer
+  #warn             | dict              | entry introducer
+  #error            | dict              | entry introducer
+                    |                   |
+  #remove           | dict              | readList<keyType>
+                    |                   |
+  #include          | dict/primitive    | string
+  #includeEtc       | dict/primitive    | string
+  #includeIfPresent | dict/primitive    | string
+  #includeFunc      | dict              | word
+                    |                   |
+  #calc             | dict/primitive    | string
+  #codeStream       | dict/primitive    | dictionary
+
+
+Pending future extensions
+
+| directive         | context           | content           | line oriented?
+|-------------------|-------------------|-------------------|-----------------
+  #define           | dict              | entry introducer
+  #local            | dict              | entry introducer
+  #undef            | dict              | readList<word>
+
+
+2017-11-05
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C
index a7e2e2c949299f0492ca77b2474ed1c01fc1169f..4fa4a4a2719df2fdd10af87fcbd14d621d1dffff 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C
@@ -66,7 +66,7 @@ bool Foam::functionEntries::calcEntry::execute
     Istream& is
 )
 {
-    Info<< "Using #calcEntry at line " << is.lineNumber()
+    Info<< "Using #calc at line " << is.lineNumber()
         << " in file " <<  parentDict.name() << endl;
 
     dynamicCode::checkSecurity
@@ -110,7 +110,7 @@ bool Foam::functionEntries::calcEntry::execute
     Istream& is
 )
 {
-    Info<< "Using #calcEntry at line " << is.lineNumber()
+    Info<< "Using #calc at line " << is.lineNumber()
         << " in file " <<  parentDict.name() << endl;
 
     dynamicCode::checkSecurity
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C
index 2798b924e3a77b936f3e876ef4c41682b04228fe..8eba79a926f864c74dec3ab5801c4f3816692797 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C
@@ -160,13 +160,16 @@ bool Foam::functionEntry::execute
 void Foam::functionEntry::write(Ostream& os) const
 {
     // Contents should be single string token
-    const token& t = operator[](0);
-    const string& s = t.stringToken();
+    const token& tok = operator[](0);
+    const string& s = tok.stringToken();
 
-    for (size_t i = 0; i < s.size(); i++)
+    // Write character-wise for literal output
+    for (size_t i = 0; i < s.size(); ++i)
     {
         os.write(s[i]);
     }
+
+    os << nl;
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C
index a9ddde6632d835adda3db4833e719b1d735b5b2b..90fe356885c8486ea37d9277f294bd873a8046cc 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C
@@ -24,11 +24,11 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "includeEntry.H"
-#include "IFstream.H"
 #include "addToMemberFunctionSelectionTable.H"
 #include "stringOps.H"
-#include "Time.H"
+#include "IFstream.H"
 #include "IOstreams.H"
+#include "Time.H"
 #include "fileOperation.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -62,27 +62,6 @@ namespace functionEntries
 
 // * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
-Foam::fileName Foam::functionEntries::includeEntry::resolveFile
-(
-    Istream& is,
-    const dictionary& dict
-)
-{
-    fileName fName(is);
-    // Substitute dictionary and environment variables.
-    // Allow empty substitutions.
-    stringOps::inplaceExpand(fName, dict, true, true);
-
-    if (fName.empty() || fName.isAbsolute())
-    {
-        return fName;
-    }
-
-    // Relative name
-    return fileName(is.name()).path()/fName;
-}
-
-
 Foam::fileName Foam::functionEntries::includeEntry::resolveFile
 (
     const fileName& dir,
@@ -91,6 +70,7 @@ Foam::fileName Foam::functionEntries::includeEntry::resolveFile
 )
 {
     fileName fName(f);
+
     // Substitute dictionary and environment variables.
     // Allow empty substitutions.
     stringOps::inplaceExpand(fName, dict, true, true);
@@ -114,7 +94,8 @@ bool Foam::functionEntries::includeEntry::execute
 )
 {
     const fileName rawName(is);
-    const fileName fName = resolveFile(is.name().path(), rawName, parentDict);
+    const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
+
     autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
     ISstream& ifs = ifsPtr();
 
@@ -133,27 +114,22 @@ bool Foam::functionEntries::includeEntry::execute
             (
                 dynamic_cast<const regIOobject&>(top)
             );
-            //Info<< rio.name() << " : adding dependency on included file "
-            //    << fName << endl;
-
             rio.addWatch(fName);
         }
 
         parentDict.read(ifs);
         return true;
     }
-    else
-    {
-        FatalIOErrorInFunction
-        (
-            is
-        )   << "Cannot open include file "
-            << (ifs.name().size() ? ifs.name() : rawName)
-            << " while reading dictionary " << parentDict.name()
-            << exit(FatalIOError);
-
-        return false;
-    }
+
+    FatalIOErrorInFunction
+    (
+        is
+    )   << "Cannot open include file "
+        << (ifs.name().size() ? ifs.name() : rawName)
+        << " while reading dictionary " << parentDict.name()
+        << exit(FatalIOError);
+
+    return false;
 }
 
 
@@ -165,7 +141,8 @@ bool Foam::functionEntries::includeEntry::execute
 )
 {
     const fileName rawName(is);
-    const fileName fName = resolveFile(is.name().path(), rawName, parentDict);
+    const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
+
     autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
     ISstream& ifs = ifsPtr();
 
@@ -184,27 +161,23 @@ bool Foam::functionEntries::includeEntry::execute
             (
                 dynamic_cast<const regIOobject&>(top)
             );
-            //Info<< rio.name() << " : adding dependency on included file "
-            //    << fName << endl;
-
             rio.addWatch(fName);
         }
 
         entry.read(parentDict, ifs);
         return true;
     }
-    else
-    {
-        FatalIOErrorInFunction
-        (
-            is
-        )   << "Cannot open include file "
-            << (ifs.name().size() ? ifs.name() : rawName)
-            << " while reading dictionary " << parentDict.name()
-            << exit(FatalIOError);
-
-        return false;
-    }
+
+    FatalIOErrorInFunction
+    (
+        is
+    )   << "Cannot open include file "
+        << (ifs.name().size() ? ifs.name() : rawName)
+        << " while reading dictionary " << parentDict.name()
+        << exit(FatalIOError);
+
+    return false;
 }
 
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H
index bbdc122017364e22a7cef829b5e6066cd71a1f6f..a2e7f5c90914f547e802efe8ae9b1823daa194ff 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H
@@ -68,9 +68,6 @@ protected:
 
     // Protected Member Functions
 
-        //- Read the include fileName from Istream, expand and return
-        static fileName resolveFile(Istream& is, const dictionary& dict);
-
         //- Expand include fileName and return
         static fileName resolveFile
         (
@@ -79,6 +76,7 @@ protected:
             const dictionary& dict
         );
 
+
 public:
 
     // Static data members
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C
index c77204a5dd56874c61592a07cb2cdae81c007912..8fd559b7d69fe066acd4236e42936d55a89b03d0 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.C
@@ -24,9 +24,10 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "includeEtcEntry.H"
+#include "addToMemberFunctionSelectionTable.H"
 #include "etcFiles.H"
 #include "stringOps.H"
-#include "addToMemberFunctionSelectionTable.H"
+#include "IFstream.H"
 #include "IOstreams.H"
 #include "fileOperation.H"
 
@@ -61,7 +62,7 @@ namespace functionEntries
 
 // * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
-Foam::fileName Foam::functionEntries::includeEtcEntry::resolveFile
+Foam::fileName Foam::functionEntries::includeEtcEntry::resolveEtcFile
 (
     const fileName& f,
     const dictionary& dict
@@ -78,7 +79,7 @@ Foam::fileName Foam::functionEntries::includeEtcEntry::resolveFile
         return fName;
     }
 
-    // Search the etc directories for the file
+    // Search etc directories for the file
     return Foam::findEtcFile(fName);
 }
 
@@ -92,9 +93,8 @@ bool Foam::functionEntries::includeEtcEntry::execute
 )
 {
     const fileName rawName(is);
-    const fileName fName(resolveFile(rawName, parentDict));
+    const fileName fName(resolveEtcFile(rawName, parentDict));
 
-    //IFstream ifs(fName);
     autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
     ISstream& ifs = ifsPtr();
 
@@ -107,18 +107,16 @@ bool Foam::functionEntries::includeEtcEntry::execute
         parentDict.read(ifs);
         return true;
     }
-    else
-    {
-        FatalIOErrorInFunction
-        (
-            is
-        )   << "Cannot open etc file "
-            << (ifs.name().size() ? ifs.name() : rawName)
-            << " while reading dictionary " << parentDict.name()
-            << exit(FatalIOError);
-
-        return false;
-    }
+
+    FatalIOErrorInFunction
+    (
+        is
+    )   << "Cannot open etc file "
+        << (ifs.name().size() ? ifs.name() : rawName)
+        << " while reading dictionary " << parentDict.name()
+        << exit(FatalIOError);
+
+    return false;
 }
 
 
@@ -130,9 +128,8 @@ bool Foam::functionEntries::includeEtcEntry::execute
 )
 {
     const fileName rawName(is);
-    const fileName fName(resolveFile(rawName, parentDict));
+    const fileName fName(resolveEtcFile(rawName, parentDict));
 
-    //IFstream ifs(fName);
     autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
     ISstream& ifs = ifsPtr();
 
@@ -145,18 +142,16 @@ bool Foam::functionEntries::includeEtcEntry::execute
         entry.read(parentDict, ifs);
         return true;
     }
-    else
-    {
-        FatalIOErrorInFunction
-        (
-            is
-        )   << "Cannot open etc file "
-            << (ifs.name().size() ? ifs.name() : rawName)
-            << " while reading dictionary " << parentDict.name()
-            << exit(FatalIOError);
-
-        return false;
-    }
+
+    FatalIOErrorInFunction
+    (
+        is
+    )   << "Cannot open etc file "
+        << (ifs.name().size() ? ifs.name() : rawName)
+        << " while reading dictionary " << parentDict.name()
+        << exit(FatalIOError);
+
+    return false;
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H
index 4920ff7db01e472d32fde5e6d0d286e0f4b33578..9d6ccae4091b308ada100de03f28f20d8d261ebc 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEtcEntry/includeEtcEntry.H
@@ -79,9 +79,16 @@ class includeEtcEntry
 :
     public functionEntry
 {
-    //- Expand include fileName and return
-    static fileName resolveFile(const fileName& f, const dictionary& dict);
+protected:
 
+    // Protected Member Functions
+
+        //- Expand include fileName and search etc directories for the file
+        static fileName resolveEtcFile
+        (
+            const fileName& f,
+            const dictionary& dict
+        );
 
 public:
 
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C
index 202e1408fe7c1ac7991eaf589f41d5c581874c9a..a110e55cd974e7e9eaf215680c69f7fd6b5d235a 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C
@@ -64,7 +64,9 @@ bool Foam::functionEntries::includeIfPresentEntry::execute
     Istream& is
 )
 {
-    const fileName fName(resolveFile(is, parentDict));
+    const fileName rawName(is);
+    const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
+
     autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
     ISstream& ifs = ifsPtr();
 
@@ -100,7 +102,9 @@ bool Foam::functionEntries::includeIfPresentEntry::execute
     Istream& is
 )
 {
-    const fileName fName(resolveFile(is, parentDict));
+    const fileName rawName(is);
+    const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
+
     autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
     ISstream& ifs = ifsPtr();
 
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C
index bdd92de36e96121d44b74938784d5f3d73010b15..160d5ec87d8e9e1920a116a757be0fe34e0d2535 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.C
@@ -41,6 +41,51 @@ namespace functionEntries
         dictionaryIstream,
         inputMode
     );
+
+    addNamedToMemberFunctionSelectionTable
+    (
+        functionEntry,
+        inputModeDefault,
+        execute,
+        dictionaryIstream,
+        default
+    );
+
+    addNamedToMemberFunctionSelectionTable
+    (
+        functionEntry,
+        inputModeMerge,
+        execute,
+        dictionaryIstream,
+        merge
+    );
+
+    addNamedToMemberFunctionSelectionTable
+    (
+        functionEntry,
+        inputModeOverwrite,
+        execute,
+        dictionaryIstream,
+        overwrite
+    );
+
+    addNamedToMemberFunctionSelectionTable
+    (
+        functionEntry,
+        inputModeWarn,
+        execute,
+        dictionaryIstream,
+        warn
+    );
+
+    addNamedToMemberFunctionSelectionTable
+    (
+        functionEntry,
+        inputModeError,
+        execute,
+        dictionaryIstream,
+        error
+    );
 }
 }
 
@@ -90,4 +135,54 @@ bool Foam::functionEntries::inputMode::execute
 }
 
 
+bool Foam::functionEntries::inputModeDefault::execute
+(
+    dictionary& parentDict,
+    Istream& is
+)
+{
+    return entry::New(parentDict, is, entry::inputMode::PROTECT);
+}
+
+
+bool Foam::functionEntries::inputModeMerge::execute
+(
+    dictionary& parentDict,
+    Istream& is
+)
+{
+    return entry::New(parentDict, is, entry::inputMode::MERGE);
+}
+
+
+bool Foam::functionEntries::inputModeOverwrite::execute
+(
+    dictionary& parentDict,
+    Istream& is
+)
+{
+    return entry::New(parentDict, is, entry::inputMode::OVERWRITE);
+}
+
+
+bool Foam::functionEntries::inputModeWarn::execute
+(
+    dictionary& parentDict,
+    Istream& is
+)
+{
+    return entry::New(parentDict, is, entry::inputMode::WARN);
+}
+
+
+bool Foam::functionEntries::inputModeError::execute
+(
+    dictionary& parentDict,
+    Istream& is
+)
+{
+    return entry::New(parentDict, is, entry::inputMode::ERROR);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H
index c670d9230dcc61218e1521ea60a6d91bf90c2973..91f0d6362bca27da9eeeca2b14cdc0654cc342da 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/inputMode/inputMode.H
@@ -84,6 +84,86 @@ public:
 };
 
 
+/*---------------------------------------------------------------------------*\
+                      Class inputModeDefault Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Temporarily change inputMode to %protect for the following entry
+class inputModeDefault
+:
+    public functionEntry
+{
+public:
+
+    //- Execute in a sub-dict context
+    static bool execute(dictionary& parentDict, Istream& is);
+};
+
+
+/*---------------------------------------------------------------------------*\
+                       Class inputModeMerge Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Temporarily change inputMode to %merge for the following entry
+class inputModeMerge
+:
+    public functionEntry
+{
+public:
+
+    //- Execute in a sub-dict context
+    static bool execute(dictionary& parentDict, Istream& is);
+};
+
+
+/*---------------------------------------------------------------------------*\
+                     Class inputModeOverwrite Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Temporarily change inputMode to %overwrite for the following entry
+class inputModeOverwrite
+:
+    public functionEntry
+{
+public:
+
+    //- Execute in a sub-dict context
+    static bool execute(dictionary& parentDict, Istream& is);
+};
+
+
+/*---------------------------------------------------------------------------*\
+                        Class inputModeWarn Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Temporarily change inputMode to %warn for the following entry
+class inputModeWarn
+:
+    public functionEntry
+{
+public:
+
+    //- Execute in a sub-dict context
+    static bool execute(dictionary& parentDict, Istream& is);
+};
+
+
+/*---------------------------------------------------------------------------*\
+                       Class inputModeError Declaration
+\*---------------------------------------------------------------------------*/
+
+//- Temporarily change inputMode to %error for the following entry
+class inputModeError
+:
+    public functionEntry
+{
+public:
+
+    //- Execute in a sub-dict context
+    static bool execute(dictionary& parentDict, Istream& is);
+};
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace functionEntries
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
index a0c413edd891362966282ce97acb92678c47b394..ebe2baf21642c1817cbef5d0159900b4924be842 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,7 +26,6 @@ License
 #include "removeEntry.H"
 #include "dictionary.H"
 #include "stringListOps.H"
-#include "StringStream.H"
 #include "addToMemberFunctionSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -55,17 +54,36 @@ bool Foam::functionEntries::removeEntry::execute
     Istream& is
 )
 {
-    wordList   dictKeys = parentDict.toc();
-    wordReList patterns = readList<wordRe>(is);
+    const List<keyType> patterns = readList<keyType>(is);
 
-    labelList indices = findStrings(patterns, dictKeys);
-
-    forAll(indices, indexI)
+    for (const keyType& key : patterns)
     {
-        parentDict.remove(dictKeys[indices[indexI]]);
+        if (key.find('/') != string::npos || !key.isPattern())
+        {
+            // Remove scoped keyword, or keyword in the local scope
+            dictionary::searcher finder =
+                parentDict.searchScoped(key, false, false);
+
+            if (finder.found())
+            {
+                finder.context().remove(finder.ptr()->keyword());
+            }
+        }
+        else
+        {
+            // Remove by pattern
+            const wordList dictKeys = parentDict.toc();
+            const labelList indices = findStrings(regExp(key), dictKeys);
+
+            for (const auto idx : indices)
+            {
+                parentDict.remove(dictKeys[idx]);
+            }
+        }
     }
 
     return true;
 }
 
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H
index 5e8fbdd8361f05a16376d88abdf8aba17aaae7ba..6cdb5441a51860f0edc63e15d2baa5313c7173e9 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,17 +27,22 @@ Class
 Description
     Remove a dictionary entry.
 
-    The \c \#remove directive takes a list or a single wordRe.
+    The \c \#remove directive takes a list or a single keyType.
     For example,
     \verbatim
         #remove entry0
         #remove ( entry1 entry2 entry3 otherEntry )
         #remove "entry[1-3]"
         #remove ( "entry[1-3]" otherEntry )
+        #remove ^dict1.subdict2.entry2
+        #remove "/dict1/subdict2/entry1"
     \endverbatim
 
-    The removal only occurs in the current context.
-    Removing sub-entries or parent entries is not supported.
+Note
+    Unless otherwise scoped, the removal occurs in the current context.
+    To remove from other scopes, a dot-scoped or slash-scoped syntax is
+    required. The slash-scoped syntax must be quoted to ensure that it
+    is properly parsed.
 
 SourceFiles
     removeEntry.C
@@ -57,7 +62,7 @@ namespace functionEntries
 {
 
 /*---------------------------------------------------------------------------*\
-                           Class removeEntry Declaration
+                         Class removeEntry Declaration
 \*---------------------------------------------------------------------------*/
 
 class removeEntry
@@ -66,7 +71,7 @@ class removeEntry
 {
 public:
 
-    //- Remove entries from the current sub-dict context
+    //- Remove single or multiple entries. Local or scoped entries.
     static bool execute(dictionary& parentDict, Istream& is);
 };
 
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
index 37cc203083eef07396ab05c0175de11f7a38769c..4730295740b00d9b3b79795be73f4ad4ffafd5b7 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
@@ -30,15 +30,26 @@ License
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-void Foam::primitiveEntry::append(const UList<token>& varTokens)
+void Foam::primitiveEntry::appendTokenList(const UList<token>& toks)
 {
-    for (const token& tok : varTokens)
+    for (const token& tok : toks)
     {
-        newElmt(tokenIndex()++) = tok;
+        newElmt(tokenIndex()++) = tok;  // copy append
     }
 }
 
 
+void Foam::primitiveEntry::appendTokenList(List<token>&& toks)
+{
+    for (token& tok : toks)
+    {
+        newElmt(tokenIndex()++) = std::move(tok);  // move append
+    }
+
+    toks.clear();
+}
+
+
 bool Foam::primitiveEntry::expandVariable
 (
     const string& varName,
@@ -49,7 +60,7 @@ bool Foam::primitiveEntry::expandVariable
     {
         // Recursive substitution mode.
         // Content between {} is replaced with expansion.
-        string expanded = varName.substr(1, varName.size()-2);
+        string expanded(varName.substr(1, varName.size()-2));
 
         // Substitute dictionary and environment variables.
         // Do not allow empty substitutions.
@@ -57,46 +68,52 @@ bool Foam::primitiveEntry::expandVariable
 
         return expandVariable(expanded, dict);
     }
-    else
+
+    // Lookup variable name in the given dictionary WITHOUT pattern matching.
+    // Having a pattern match means that in this example:
+    // {
+    //     internalField XXX;
+    //     boundaryField { ".*" {YYY;} movingWall {value $internalField;}
+    // }
+    // The $internalField would be matched by the ".*" !!!
+
+    // Recursive, non-patterns
+    const entry* eptr = dict.lookupScopedEntryPtr(varName, true, false);
+    if (!eptr)
     {
-        // lookup the variable name in the given dictionary....
-        // Note: allow wildcards to match? For now disabled since following
-        // would expand internalField to wildcard match and not expected
-        // internalField:
-        //      internalField XXX;
-        //      boundaryField { ".*" {YYY;} movingWall {value $internalField;}
-        const entry* ePtr = dict.lookupScopedEntryPtr(varName, true, false);
-
-        // ...if defined append its tokens into this
-        if (ePtr)
-        {
-            if (ePtr->isDict())
-            {
-                append(ePtr->dict().tokens());
-            }
-            else
-            {
-                append(ePtr->stream());
-            }
-        }
-        else
+        // Not found - revert to environment variable
+        const string str(getEnv(varName));
+
+        if (str.empty())
         {
-            // Not in the dictionary - try an environment variable
-            const string envStr = getEnv(varName);
-
-            if (envStr.empty())
-            {
-                FatalIOErrorInFunction
-                (
-                    dict
-                )   << "Illegal dictionary entry or environment variable name "
-                    << varName << endl << "Valid dictionary entries are "
-                    << dict.toc() << exit(FatalIOError);
-
-                return false;
-            }
-            append(tokenList(IStringStream('(' + envStr + ')')()));
+            FatalIOErrorInFunction
+            (
+                dict
+            )   << "Illegal dictionary entry or environment variable name "
+                << varName << endl << "Valid dictionary entries are "
+                << dict.toc() << exit(FatalIOError);
+
+            return false;
         }
+
+        // Parse string into a series of tokens
+
+        tokenList toks(ITstream::parse(str, IOstream::ASCII));
+
+        appendTokenList(std::move(toks));
+    }
+    else if (eptr->isDict())
+    {
+        // Found dictionary entry
+
+        tokenList toks(eptr->dict().tokens().xfer());
+
+        appendTokenList(std::move(toks));
+    }
+    else
+    {
+        // Found primitive entry
+        appendTokenList(eptr->stream());
     }
 
     return true;
@@ -114,10 +131,10 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is)
 }
 
 
-Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& t)
+Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& tok)
 :
     entry(key),
-    ITstream(key, tokenList(1, t))
+    ITstream(key, tokenList(1, tok))
 {}
 
 
@@ -149,14 +166,12 @@ Foam::label Foam::primitiveEntry::startLineNumber() const
 {
     const tokenList& tokens = *this;
 
-    if (tokens.empty())
+    if (tokens.size())
     {
-        return -1;
-    }
-    else
-    {
-        return tokens.first().lineNumber();
+        tokens.first().lineNumber();
     }
+
+    return -1;
 }
 
 
@@ -164,14 +179,12 @@ Foam::label Foam::primitiveEntry::endLineNumber() const
 {
     const tokenList& tokens = *this;
 
-    if (tokens.empty())
-    {
-        return -1;
-    }
-    else
+    if (tokens.size())
     {
         return tokens.last().lineNumber();
     }
+
+    return -1;
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
index 38e9412a8df789c25c8964d751565cdd5d72c01c..c035f4451a9ddae7cfb035c0fc48be327383bce8 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
@@ -64,17 +64,24 @@ class primitiveEntry
 {
     // Private Member Functions
 
-        //- Append the given tokens starting at the current tokenIndex
-        void append(const UList<token>& varTokens);
-
-        //- Append the given token to this entry
-        void append
+        //- Test if token is acceptable after filtering for function entries
+        //- and variable expansions.
+        bool acceptToken
         (
-            const token& currToken,
+            const token& tok,
             const dictionary& dict,
             Istream& is
         );
 
+        //- Copy append the given tokens at the current tokenIndex
+        //  No filtering on the tokens.
+        void appendTokenList(const UList<token>& toks);
+
+        //- Move append the given tokens at the current tokenIndex
+        //  No filtering on the tokens.
+        void appendTokenList(List<token>&& toks);
+
+
         //- Expand the given variable.
         //  The keyword starts with '$', but has been removed by the caller
         //  and thus passed as a varName.
@@ -113,7 +120,7 @@ public:
         primitiveEntry(const keyType& key, const ITstream& is);
 
         //- Construct from keyword and a single token
-        primitiveEntry(const keyType& key, const token& t);
+        primitiveEntry(const keyType& key, const token& tok);
 
         //- Construct from keyword and a list of tokens
         primitiveEntry(const keyType& key, const UList<token>& tokens);
@@ -123,7 +130,7 @@ public:
 
         //- Construct from keyword and a T
         template<class T>
-        primitiveEntry(const keyType& key, const T& t);
+        primitiveEntry(const keyType& key, const T& val);
 
         autoPtr<entry> clone(const dictionary&) const
         {
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
index 6a040941e741c2e2b90fb694203ddc742db6544c..f9a6759030dacae196a955a83fdaaf415002c447 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
@@ -28,18 +28,20 @@ License
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-void Foam::primitiveEntry::append
+bool Foam::primitiveEntry::acceptToken
 (
-    const token& currToken,
+    const token& tok,
     const dictionary& dict,
     Istream& is
 )
 {
-    if (currToken.isWord())
+    bool accept = tok.good();
+
+    if (tok.isWord())
     {
-        const word& key = currToken.wordToken();
+        const word& key = tok.wordToken();
 
-        if
+        accept =
         (
             disableFunctionEntries
          || key.size() == 1
@@ -47,16 +49,13 @@ void Foam::primitiveEntry::append
                 !(key[0] == '$' && expandVariable(key.substr(1), dict))
              && !(key[0] == '#' && expandFunction(key.substr(1), dict, is))
             )
-        )
-        {
-            newElmt(tokenIndex()++) = currToken;
-        }
+        );
     }
-    else if (currToken.isVariable())
+    else if (tok.isVariable())
     {
-        const string& key = currToken.stringToken();
+        const string& key = tok.stringToken();
 
-        if
+        accept =
         (
             disableFunctionEntries
          || key.size() <= 3
@@ -65,15 +64,10 @@ void Foam::primitiveEntry::append
              && key[1] == token::BEGIN_BLOCK
              && expandVariable(key.substr(1), dict)
             )
-        )
-        {
-            newElmt(tokenIndex()++) = currToken;
-        }
-    }
-    else
-    {
-        newElmt(tokenIndex()++) = currToken;
+        );
     }
+
+    return accept;
 }
 
 
@@ -92,65 +86,41 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
 {
     is.fatalCheck(FUNCTION_NAME);
 
-    label blockCount = 0;
-    token currToken;
+    label depth = 0;
+    token tok;
 
-    if
+    while
     (
-        !is.read(currToken).bad()
-     && currToken.good()
-     && currToken != token::END_STATEMENT
+        !is.read(tok).bad() && tok.good()
+     && !(tok == token::END_STATEMENT && depth == 0)
     )
     {
-        append(currToken, dict, is);
-
-        if
-        (
-            currToken == token::BEGIN_BLOCK
-         || currToken == token::BEGIN_LIST
-        )
+        if (tok.isPunctuation())
         {
-            blockCount++;
-        }
-
-        while
-        (
-            !is.read(currToken).bad()
-         && currToken.good()
-         && !(currToken == token::END_STATEMENT && blockCount == 0)
-        )
-        {
-            if
-            (
-                currToken == token::BEGIN_BLOCK
-             || currToken == token::BEGIN_LIST
-            )
+            const char c = tok.pToken();
+            if (c == token::BEGIN_BLOCK || c == token::BEGIN_LIST)
             {
-                blockCount++;
+                ++depth;
             }
-            else if
-            (
-                currToken == token::END_BLOCK
-             || currToken == token::END_LIST
-            )
+            else if (c == token::END_BLOCK || c == token::END_LIST)
             {
-                blockCount--;
+                --depth;
             }
+        }
 
-            append(currToken, dict, is);
+        if (acceptToken(tok, dict, is))
+        {
+            newElmt(tokenIndex()++) = std::move(tok);
         }
-    }
 
-    is.fatalCheck(FUNCTION_NAME);
+        // With/without move: clear any old content and force to have a
+        // known good token so that we can rely on it for the return value.
 
-    if (currToken.good())
-    {
-        return true;
-    }
-    else
-    {
-        return false;
+        tok = token::punctuationToken::NULL_TOKEN;
     }
+
+    is.fatalCheck(FUNCTION_NAME);
+    return tok.good();
 }
 
 
@@ -227,25 +197,19 @@ void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const
         os.writeKeyword(keyword());
     }
 
-    bool space = false;  // Separate from previous tokens with a space
-    for (const token& t : *this)
+    bool addSpace = false;  // Separate from previous tokens with a space
+    for (const token& tok : *this)
     {
-        if (space)
-        {
-            os  << token::SPACE;
-        }
-        space = true;  // Prefix any following tokens
+        if (addSpace) os << token::SPACE;
 
-        if (t.type() == token::tokenType::VERBATIMSTRING)
-        {
-            // Bypass token output operator to avoid losing verbatimness.
-            // Handle in Ostreams themselves
-            os.write(t);
-        }
-        else
+        // Try to output token directly, with special handling in Ostreams.
+
+        if (!os.write(tok))
         {
-            os  << t;
+            os  << tok;   // Revert to normal '<<' output operator
         }
+
+        addSpace = true;  // Separate from following tokens
     }
 
     if (!contentsOnly)
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C
index 29f11a5c80f85d005635c8831971273a5aa0cf8b..ce36746fee8e53bfa0225a7dd4df2e981e012113 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryTemplates.C
@@ -30,13 +30,13 @@ License
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class T>
-Foam::primitiveEntry::primitiveEntry(const keyType& key, const T& t)
+Foam::primitiveEntry::primitiveEntry(const keyType& key, const T& val)
 :
     entry(key),
     ITstream(key, tokenList(10))
 {
     OStringStream os;
-    os  << t << token::END_STATEMENT;
+    os  << val << token::END_STATEMENT;
     readEntry(dictionary::null, IStringStream(os.str())());
 }
 
diff --git a/src/OpenFOAM/db/error/error.C b/src/OpenFOAM/db/error/error.C
index b0c4b3d87714047ece9a1d2b0bffe8afb5dc1951..d72835e175e214a079415cf5fdd69cfb6810a620 100644
--- a/src/OpenFOAM/db/error/error.C
+++ b/src/OpenFOAM/db/error/error.C
@@ -250,21 +250,30 @@ void Foam::error::abort()
 }
 
 
-// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
-
-Foam::Ostream& Foam::operator<<(Ostream& os, const error& err)
+void Foam::error::write(Ostream& os, const bool includeTitle) const
 {
-    os  << nl
-        << err.title().c_str() << endl
-        << err.message().c_str();
+    os  << nl;
+    if (includeTitle)
+    {
+        os  << title().c_str() << endl;
+    }
+    os  << message().c_str();
 
-    if (error::level >= 2 && err.sourceFileLineNumber())
+    if (error::level >= 2 && sourceFileLineNumber())
     {
         os  << nl << nl
-            << "    From function " << err.functionName().c_str() << endl
-            << "    in file " << err.sourceFileName().c_str()
-            << " at line " << err.sourceFileLineNumber() << '.';
+            << "    From function " << functionName().c_str() << endl
+            << "    in file " << sourceFileName().c_str()
+            << " at line " << sourceFileLineNumber() << '.';
     }
+}
+
+
+// * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
+
+Foam::Ostream& Foam::operator<<(Ostream& os, const error& err)
+{
+    err.write(os);
 
     return os;
 }
diff --git a/src/OpenFOAM/db/error/error.H b/src/OpenFOAM/db/error/error.H
index 961bd3cd4dc9ea41eb4765520dd92e776e24c0e3..bf59c5facbe780239d9d121d2506631f3841ddcf 100644
--- a/src/OpenFOAM/db/error/error.H
+++ b/src/OpenFOAM/db/error/error.H
@@ -195,6 +195,9 @@ public:
         //  Prints stack before exiting.
         void abort();
 
+        //- Print error message
+        void write(Ostream& os, const bool includeTitle = true) const;
+
 
     // Ostream operator
 
diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
index 0acd4e17d1cce72443d6dac7393896c00a468b14..56782ea6eefb7473399760a9dfd632f58f6c29f7 100644
--- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
+++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
@@ -579,9 +579,8 @@ bool Foam::functionObjectList::execute()
             }
         }
     }
-
     // Force writing of state dictionary after function object execution
-    if (time_.outputTime())
+    if (time_.writeTime())
     {
         label oldPrecision = IOstream::precision_;
         IOstream::precision_ = 16;
@@ -788,8 +787,9 @@ bool Foam::functionObjectList::read()
                 }
                 catch (Foam::error& err)
                 {
-                    WarningInFunction
-                        << "Caught FatalError " << err << nl << endl;
+                    // Bit of trickery to get the original message
+                    err.write(Warning, false);
+                    InfoInFunction << nl << endl;
                 }
 
                 // Restore previous exception throwing state
diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C
index 3c71b2713d2e51b854038884e1ea6258963554c4..60a2a8b764f7fa6b7d149eef6a4112a7b0de1974 100644
--- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C
+++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C
@@ -150,7 +150,8 @@ Foam::functionObjects::writeFile::writeFile
     fileName_("undefined"),
     filePtr_(),
     writePrecision_(IOstream::defaultPrecision()),
-    writeToFile_(true)
+    writeToFile_(true),
+    writtenHeader_(false)
 {}
 
 
@@ -167,7 +168,8 @@ Foam::functionObjects::writeFile::writeFile
     fileName_(fileName),
     filePtr_(),
     writePrecision_(IOstream::defaultPrecision()),
-    writeToFile_(true)
+    writeToFile_(true),
+    writtenHeader_(false)
 {
     read(dict);
 
@@ -234,8 +236,13 @@ void Foam::functionObjects::writeFile::writeCommented
     const string& str
 ) const
 {
-    os  << setw(1) << "#" << setw(1) << ' '
-        << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str();
+    os  << setw(1) << "#";
+
+    if (str.size())
+    {
+        os  << setw(1) << ' '
+            << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str();
+    }
 }
 
 
@@ -255,8 +262,8 @@ void Foam::functionObjects::writeFile::writeHeader
     const string& str
 ) const
 {
-    os  << setw(1) << "#" << setw(1) << ' '
-        << setf(ios_base::left) << setw(charWidth() - 2) << str.c_str() << nl;
+    writeCommented(os, str);
+    os  << nl;
 }
 
 
@@ -267,4 +274,10 @@ void Foam::functionObjects::writeFile::writeTime(Ostream& os) const
 }
 
 
+void Foam::functionObjects::writeFile::writeBreak(Ostream& os) const
+{
+    writeHeader(os, "===");
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
index 1f7f1edfce343457a18a0445ca3f13fc6b0ac241..918d86a133527c892ff6b01f0ea4169300d89ebe 100644
--- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
+++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
@@ -79,6 +79,9 @@ protected:
         //- Flag to enable/disable writing to file
         bool writeToFile_;
 
+        //- Flag to identify whether the header has been written
+        bool writtenHeader_;
+
 
     // Protected Member Functions
 
@@ -171,6 +174,9 @@ public:
         //- Write the current time to stream
         virtual void writeTime(Ostream& os) const;
 
+        //- Write a break marker to the stream
+        virtual void writeBreak(Ostream& os) const;
+
         //- Write a (commented) header property and value pair
         template<class Type>
         void writeHeaderValue
diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.C b/src/OpenFOAM/dimensionSet/dimensionSet.C
index 269d25282fa15b3e2e5201f737fee4e8f1a545d4..b9c9be7b39de440399747dd378e34668a7fd6131 100644
--- a/src/OpenFOAM/dimensionSet/dimensionSet.C
+++ b/src/OpenFOAM/dimensionSet/dimensionSet.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -59,23 +59,10 @@ Foam::dimensionSet::dimensionSet
 }
 
 
-Foam::dimensionSet::dimensionSet
-(
-    const scalar mass,
-    const scalar length,
-    const scalar time,
-    const scalar temperature,
-    const scalar moles
-)
-{
-    exponents_[MASS] = mass;
-    exponents_[LENGTH] = length;
-    exponents_[TIME] = time;
-    exponents_[TEMPERATURE] = temperature;
-    exponents_[MOLES] = moles;
-    exponents_[CURRENT] = 0;
-    exponents_[LUMINOUS_INTENSITY] = 0;
-}
+Foam::dimensionSet::dimensionSet(const FixedList<scalar,7>& dims)
+:
+    exponents_(dims)
+{}
 
 
 Foam::dimensionSet::dimensionSet(const dimensionSet& ds)
@@ -88,13 +75,13 @@ Foam::dimensionSet::dimensionSet(const dimensionSet& ds)
 
 bool Foam::dimensionSet::dimensionless() const
 {
-    for (int Dimension=0; Dimension<nDimensions; ++Dimension)
+    for (int d=0; d<nDimensions; ++d)
     {
-        // ie, mag(exponents_[Dimension]) > smallExponent
+        // ie, mag(exponents_[d]) > smallExponent
         if
         (
-            exponents_[Dimension] > smallExponent
-         || exponents_[Dimension] < -smallExponent
+            exponents_[d] > smallExponent
+         || exponents_[d] < -smallExponent
         )
         {
             return false;
@@ -105,12 +92,21 @@ bool Foam::dimensionSet::dimensionless() const
 }
 
 
+const Foam::FixedList<Foam::scalar,7>& Foam::dimensionSet::values() const
+{
+    return exponents_;
+}
+
+
+Foam::FixedList<Foam::scalar,7>& Foam::dimensionSet::values()
+{
+    return exponents_;
+}
+
+
 void Foam::dimensionSet::reset(const dimensionSet& ds)
 {
-    for (int Dimension=0; Dimension<nDimensions; ++Dimension)
-    {
-        exponents_[Dimension] = ds.exponents_[Dimension];
-    }
+    exponents_ = ds.exponents_;
 }
 
 
@@ -142,11 +138,11 @@ Foam::scalar& Foam::dimensionSet::operator[](const label type)
 
 bool Foam::dimensionSet::operator==(const dimensionSet& ds) const
 {
-    for (int Dimension=0; Dimension < nDimensions; ++Dimension)
+    for (int d=0; d<nDimensions; ++d)
     {
         if
         (
-            mag(exponents_[Dimension] - ds.exponents_[Dimension])
+            mag(exponents_[d] - ds.exponents_[d])
           > smallExponent
         )
         {
@@ -536,9 +532,9 @@ Foam::dimensionSet Foam::operator*
 {
     dimensionSet dimProduct(ds1);
 
-    for (int Dimension=0; Dimension<dimensionSet::nDimensions; Dimension++)
+    for (int d=0; d<dimensionSet::nDimensions; ++d)
     {
-        dimProduct.exponents_[Dimension] += ds2.exponents_[Dimension];
+        dimProduct.exponents_[d] += ds2.exponents_[d];
     }
 
     return dimProduct;
@@ -553,9 +549,9 @@ Foam::dimensionSet Foam::operator/
 {
     dimensionSet dimQuotient(ds1);
 
-    for (int Dimension=0; Dimension<dimensionSet::nDimensions; Dimension++)
+    for (int d=0; d<dimensionSet::nDimensions; ++d)
     {
-        dimQuotient.exponents_[Dimension] -= ds2.exponents_[Dimension];
+        dimQuotient.exponents_[d] -= ds2.exponents_[d];
     }
 
     return dimQuotient;
diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.H b/src/OpenFOAM/dimensionSet/dimensionSet.H
index 94a1608c9abb23be1e29221ac3f7e3a03ca740b1..ca18178fee6b04e8f1b5bc4e82cac279a675bce0 100644
--- a/src/OpenFOAM/dimensionSet/dimensionSet.H
+++ b/src/OpenFOAM/dimensionSet/dimensionSet.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -120,26 +120,29 @@ Ostream& operator<<(Ostream&, const dimensionSet&);
 
 class dimensionSet
 {
-
 public:
 
+    //- The array of dimension exponents
+    typedef FixedList<scalar,7> list_type;
+
+
     // Member constants
 
         enum
         {
-            nDimensions = 7    // Number of dimensions in SI is 7
+            nDimensions = 7     //!< 7 base dimensions
         };
 
         //- Define an enumeration for the names of the dimension exponents
         enum dimensionType
         {
-            MASS,               // kilogram   kg
-            LENGTH,             // metre      m
-            TIME,               // second     s
-            TEMPERATURE,        // Kelvin     K
-            MOLES,              // mole       mol
-            CURRENT,            // Ampere     A
-            LUMINOUS_INTENSITY  // Candela    Cd
+            MASS,               //!< kilogram   kg
+            LENGTH,             //!< metre      m
+            TIME,               //!< second     s
+            TEMPERATURE,        //!< Kelvin     K
+            MOLES,              //!< mole       mol
+            CURRENT,            //!< Ampere     A
+            LUMINOUS_INTENSITY  //!< Candela    Cd
         };
 
 
@@ -150,6 +153,12 @@ public:
 
 private:
 
+    // Private data
+
+        //- The array of dimension exponents
+        list_type exponents_;
+
+
     // Private classes
 
         class tokeniser
@@ -167,17 +176,17 @@ private:
 
             // Private Member Functions
 
-                void push(const token&);
+                void push(const token& t);
 
                 token pop();
 
-                void unpop(const token&);
+                void unpop(const token& t);
 
         public:
 
             // Constructors
 
-                 tokeniser(Istream&);
+                 tokeniser(Istream& is);
 
 
             // Member Functions
@@ -212,13 +221,6 @@ private:
             const HashTable<dimensionedScalar>&
         ) const;
 
-
-    // private data
-
-        // dimensionSet stored as an array of dimension exponents
-        scalar exponents_[nDimensions];
-
-
 public:
 
     // Declare name of the class and its debug switch
@@ -227,8 +229,7 @@ public:
 
     // Constructors
 
-        //- Construct given individual dimension exponents for all
-        //  seven dimensions
+        //- Construct from exponents for the first five or all seven dimensions
         dimensionSet
         (
             const scalar mass,
@@ -236,20 +237,12 @@ public:
             const scalar time,
             const scalar temperature,
             const scalar moles,
-            const scalar current,
-            const scalar luminousIntensity
+            const scalar current = 0,
+            const scalar luminousIntensity = 0
         );
 
-        //- Construct given individual dimension exponents for first
-        //  five dimensions
-        dimensionSet
-        (
-            const scalar mass,
-            const scalar length,
-            const scalar time,
-            const scalar temperature,
-            const scalar moles
-        );
+        //- Construct from exponents for all seven dimensions
+        dimensionSet(const FixedList<scalar,7>& dimensions);
 
         //- Copy constructor
         dimensionSet(const dimensionSet& ds);
@@ -261,7 +254,7 @@ public:
         }
 
         //- Construct from Istream
-        dimensionSet(Istream&);
+        dimensionSet(Istream& is);
 
 
     // Member functions
@@ -269,7 +262,13 @@ public:
         //- Return true if it is dimensionless
         bool dimensionless() const;
 
-        void reset(const dimensionSet&);
+        //- Return const access to the exponents as a list
+        const FixedList<scalar,7>& values() const;
+
+        //- Return non-const access to the exponents as a list
+        FixedList<scalar,7>& values();
+
+        void reset(const dimensionSet& ds);
 
 
     // I/O
diff --git a/src/OpenFOAM/dimensionSet/dimensionSetIO.C b/src/OpenFOAM/dimensionSet/dimensionSetIO.C
index 9fcfd9ee20bba10295ad601a2f25f1c9691a456a..076c710410777ff050460f1c6badb655641b9521 100644
--- a/src/OpenFOAM/dimensionSet/dimensionSetIO.C
+++ b/src/OpenFOAM/dimensionSet/dimensionSetIO.C
@@ -49,7 +49,7 @@ Foam::dimensionSet::tokeniser::tokeniser(Istream& is)
 
 void Foam::dimensionSet::tokeniser::push(const token& t)
 {
-    label end = (start_+size_)%tokens_.size();
+    const label end = (start_+size_)%tokens_.size();
     tokens_[end] = t;
     if (size_ == tokens_.size())
     {
@@ -444,9 +444,9 @@ Foam::Istream& Foam::dimensionSet::read
     {
         // Read first five dimensions
         exponents_[dimensionSet::MASS] = nextToken.number();
-        for (int Dimension=1; Dimension<dimensionSet::CURRENT; Dimension++)
+        for (int d=1; d<dimensionSet::CURRENT; ++d)
         {
-            is >> exponents_[Dimension];
+            is >> exponents_[d];
         }
 
         // Read next token
@@ -681,11 +681,11 @@ Foam::Ostream& Foam::dimensionSet::write
     }
     else
     {
-        for (int d=0; d<dimensionSet::nDimensions-1; d++)
+        for (int d=0; d<dimensionSet::nDimensions; ++d)
         {
-            os << exponents_[d] << token::SPACE;
+            if (d) os << token::SPACE;
+            os << exponents_[d];
         }
-        os << exponents_[dimensionSet::nDimensions-1];
     }
 
     os  << token::END_SQR;
diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C
index 1626319fc0f94d502991996f65efe2220bf9dde9..a18d76fc9eba32b4f30d61bf43361ceeefcbc1dd 100644
--- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C
+++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,32 +27,32 @@ License
 
 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField(Istream& is)
+template<class T, int SizeMin>
+Foam::DynamicField<T, SizeMin>::DynamicField(Istream& is)
 :
     Field<T>(is),
     capacity_(Field<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-Foam::tmp<Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>>
-Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clone() const
+template<class T, int SizeMin>
+Foam::tmp<Foam::DynamicField<T, SizeMin>>
+Foam::DynamicField<T, SizeMin>::clone() const
 {
-    return tmp<DynamicField<T, SizeInc, SizeMult, SizeDiv>>
+    return tmp<DynamicField<T, SizeMin>>
     (
-        new DynamicField<T, SizeInc, SizeMult, SizeDiv>(*this)
+        new DynamicField<T, SizeMin>(*this)
     );
 }
 
 
 // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Foam::Ostream& Foam::operator<<
 (
     Ostream& os,
-    const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
+    const DynamicField<T, SizeMin>& lst
 )
 {
     os << static_cast<const Field<T>&>(lst);
@@ -60,11 +60,11 @@ Foam::Ostream& Foam::operator<<
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Foam::Istream& Foam::operator>>
 (
     Istream& is,
-    DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
+    DynamicField<T, SizeMin>& lst
 )
 {
     is >> static_cast<Field<T>&>(lst);
diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H
index 178dff7c256f132cd4ff069abbaaf355c20148e0..1d99fcb6b6bfdaa36392a19da9a61c8fb12e45a1 100644
--- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H
+++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H
@@ -46,21 +46,20 @@ namespace Foam
 
 // Forward declaration of friend functions and operators
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-class DynamicField;
+template<class T, int SizeMin> class DynamicField;
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Ostream& operator<<
 (
     Ostream&,
-    const DynamicField<T, SizeInc, SizeMult, SizeDiv>&
+    const DynamicField<T, SizeMin>&
 );
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 Istream& operator>>
 (
     Istream&,
-    DynamicField<T, SizeInc, SizeMult, SizeDiv>&
+    DynamicField<T, SizeMin>&
 );
 
 
@@ -68,16 +67,12 @@ Istream& operator>>
                            Class DynamicField Declaration
 \*---------------------------------------------------------------------------*/
 
-template<class T, unsigned SizeInc=0, unsigned SizeMult=2, unsigned SizeDiv=1>
+template<class T, int SizeMin=64>
 class DynamicField
 :
     public Field<T>
 {
-    static_assert
-    (
-        (SizeInc || SizeMult) && SizeDiv,
-        "Avoid invalid sizing parameters"
-    );
+    static_assert(SizeMin > 0, "Invalid min size parameter");
 
     // Private data
 
@@ -85,17 +80,20 @@ class DynamicField
         label capacity_;
 
 
+    // Private Member Functions
+
+        //- Copy assignment from another list
+        template<class ListType>
+        inline void assignDynField(const ListType& lst);
+
 public:
 
     // Static Member Functions
 
         //- Return a null field
-        inline static const DynamicField<T, SizeInc, SizeMult, SizeDiv>& null()
+        inline static const DynamicField<T, SizeMin>& null()
         {
-            return *reinterpret_cast
-            <
-                DynamicField<T, SizeInc, SizeMult, SizeDiv>*
-            >(0);
+            return *reinterpret_cast<DynamicField<T, SizeMin>*>(0);
         }
 
 
@@ -105,17 +103,17 @@ public:
         inline DynamicField();
 
         //- Construct given size.
-        explicit inline DynamicField(const label);
+        explicit inline DynamicField(const label nElem);
 
         //- Construct from UList. Size set to UList size.
         //  Also constructs from DynamicField with different sizing parameters.
-        explicit inline DynamicField(const UList<T>&);
+        explicit inline DynamicField(const UList<T>& lst);
 
         //- Construct by transferring the parameter contents
-        explicit inline DynamicField(const Xfer<List<T>>&);
+        explicit inline DynamicField(const Xfer<List<T>>& lst);
 
         //- Construct by transferring the parameter contents
-        explicit inline DynamicField(const Xfer<Field<T>>&);
+        explicit inline DynamicField(const Xfer<Field<T>>& lst);
 
         //- Construct by 1 to 1 mapping from the given field
         inline DynamicField
@@ -140,19 +138,19 @@ public:
         );
 
         //- Construct copy
-        inline DynamicField(const DynamicField<T, SizeInc, SizeMult, SizeDiv>&);
+        inline DynamicField(const DynamicField<T, SizeMin>& lst);
 
         //- Construct by transferring the Field contents
         inline DynamicField
         (
-            const Xfer<DynamicField<T, SizeInc, SizeMult, SizeDiv>>&
+            const Xfer<DynamicField<T, SizeMin>>& lst
         );
 
         //- Construct from Istream. Size set to size of list read.
-        explicit DynamicField(Istream&);
+        explicit DynamicField(Istream& is);
 
         //- Clone
-        tmp<DynamicField<T, SizeInc, SizeMult, SizeDiv>> clone() const;
+        tmp<DynamicField<T, SizeMin>> clone() const;
 
 
     // Member Functions
@@ -168,31 +166,31 @@ public:
             //  The addressed size will be truncated if needed to fit, but will
             //  remain otherwise untouched.
             //  Use this or reserve() in combination with append().
-            inline void setCapacity(const label);
+            inline void setCapacity(const label nElem);
 
             //- Alter the addressed list size.
             //  New space will be allocated if required.
             //  Use this to resize the list prior to using the operator[] for
             //  setting values (as per List usage).
-            inline void setSize(const label);
+            inline void setSize(const label nElem);
 
             //- Alter the addressed list size and fill new space with a
             //  constant.
-            inline void setSize(const label, const T&);
+            inline void setSize(const label nElem, const T& val);
 
             //- Alter the addressed list size.
             //  New space will be allocated if required.
             //  Use this to resize the list prior to using the operator[] for
             //  setting values (as per List usage).
-            inline void resize(const label);
+            inline void resize(const label nElem);
 
             //- Alter the addressed list size and fill new space with a
             //  constant.
-            inline void resize(const label, const T&);
+            inline void resize(const label nElem, const T& val);
 
             //- Reserve allocation space for at least this size.
             //  Never shrinks the allocated size, use setCapacity() for that.
-            inline void reserve(const label);
+            inline void reserve(const label nElem);
 
             //- Clear the addressed list, i.e. set the size to zero.
             //  Allocated size does not change
@@ -201,9 +199,13 @@ public:
             //- Clear the list and delete storage.
             inline void clearStorage();
 
+            //- Expand the addressable size to fit the allocated capacity.
+            //  Returns the previous addressable size.
+            inline label expandStorage();
+
             //- Shrink the allocated space to the number of elements used.
             //  Returns a reference to the DynamicField.
-            inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& shrink();
+            inline DynamicField<T, SizeMin>& shrink();
 
             //- Transfer contents to the Xfer container as a plain List
             inline Xfer<List<T>> xfer();
@@ -212,35 +214,31 @@ public:
         // Member Operators
 
             //- Append an element at the end of the list
-            inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& append
-            (
-                const T&
-            );
+            inline DynamicField<T, SizeMin>&
+            append(const T& val);
 
             //- Append a List at the end of this list
-            inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& append
-            (
-                const UList<T>&
-            );
+            inline DynamicField<T, SizeMin>&
+            append(const UList<T>& lst);
 
             //- Remove and return the top element
             inline T remove();
 
             //- Return non-const access to an element, resizing list if
             //  necessary
-            inline T& operator()(const label);
+            inline T& operator()(const label i);
 
             //- Assignment of all addressed entries to the given value
-            inline void operator=(const T&);
+            inline void operator=(const T& val);
 
             //- Assignment to DynamicField
             inline void operator=
             (
-                const DynamicField<T, SizeInc, SizeMult, SizeDiv>&
+                const DynamicField<T, SizeMin>& lst
             );
 
             //- Assignment to UList
-            inline void operator=(const UList<T>&);
+            inline void operator=(const UList<T>& lst);
 };
 
 
diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H
index b29af8958e3357ccb7cc44f69c0c37af8bd9af26..782e2c90eefcf372e1045f57636ce636a37662bb 100644
--- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H
+++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -23,18 +23,46 @@ License
 
 \*---------------------------------------------------------------------------*/
 
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+template<class T, int SizeMin>
+template<class ListType>
+inline void Foam::DynamicField<T, SizeMin>::assignDynField
+(
+    const ListType& lst
+)
+{
+    const label newSize = lst.size();
+
+    if (capacity_ >= newSize)
+    {
+        // Can copy w/o reallocating - adjust addressable size accordingly.
+        Field<T>::size(lst.size());
+        Field<T>::operator=(lst);
+    }
+    else
+    {
+        // Ensure list size consistency prior to copying.
+        Field<T>::size(capacity_);
+
+        Field<T>::operator=(lst);
+        capacity_ = Field<T>::size();
+    }
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField()
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField()
 :
     Field<T>(0),
     capacity_(Field<T>::size())
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const label nElem
 )
@@ -42,13 +70,13 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
     Field<T>(nElem),
     capacity_(Field<T>::size())
 {
-    // we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
+    // We could also enforce sizing granularity
     Field<T>::size(0);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const UList<T>& lst
 )
@@ -58,8 +86,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const Xfer<List<T>>& lst
 )
@@ -69,8 +97,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const Xfer<Field<T>>& lst
 )
@@ -80,8 +108,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const UList<T>& mapF,
     const labelList& mapAddressing
@@ -92,8 +120,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const UList<T>& mapF,
     const labelListList& mapAddressing,
@@ -106,8 +134,8 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 
 
 //- Construct by mapping from the given field
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
     const UList<T>& mapF,
     const FieldMapper& map
@@ -118,10 +146,10 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
-    const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
+    const DynamicField<T, SizeMin>& lst
 )
 :
     Field<T>(lst),
@@ -129,10 +157,10 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 {}
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>::DynamicField
 (
-    const Xfer<DynamicField<T, SizeInc, SizeMult, SizeDiv>>& lst
+    const Xfer<DynamicField<T, SizeMin>>& lst
 )
 :
     Field<T>(lst),
@@ -142,16 +170,16 @@ inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::label Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::capacity()
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicField<T, SizeMin>::capacity()
 const
 {
     return capacity_;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setCapacity
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::setCapacity
 (
     const label nElem
 )
@@ -164,107 +192,90 @@ inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setCapacity
         // truncate addressed sizes too
         nextFree = capacity_;
     }
-    // we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
+
+    // We could also enforce sizing granularity
 
     Field<T>::setSize(capacity_);
     Field<T>::size(nextFree);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::reserve
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::reserve
 (
     const label nElem
 )
 {
-    // allocate more capacity?
+    // Allocate more capacity if necessary
     if (nElem > capacity_)
     {
-// TODO: convince the compiler that division by zero does not occur
-//        if (SizeInc && (!SizeMult || !SizeDiv))
-//        {
-//            // resize with SizeInc as the granularity
-//            capacity_ = nElem;
-//            unsigned pad = SizeInc - (capacity_ % SizeInc);
-//            if (pad != SizeInc)
-//            {
-//                capacity_ += pad;
-//            }
-//        }
-//        else
-        {
-            capacity_ = max
+        capacity_ = max
+        (
+            SizeMin,
+            max
             (
                 nElem,
-                label(SizeInc + capacity_ * SizeMult / SizeDiv)
-            );
-        }
+                // label(SizeInc + capacity_ * SizeMult / SizeDiv)
+                label(2*capacity_)
+            )
+        );
 
-        // adjust allocated size, leave addressed size untouched
-        label nextFree = Field<T>::size();
+        // Adjust allocated size, leave addressed size untouched
+        const label nextFree = Field<T>::size();
         Field<T>::setSize(capacity_);
         Field<T>::size(nextFree);
     }
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setSize
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::setSize
 (
     const label nElem
 )
 {
-    // allocate more capacity?
+    // Allocate more capacity if necessary
     if (nElem > capacity_)
     {
-// TODO: convince the compiler that division by zero does not occur
-//        if (SizeInc && (!SizeMult || !SizeDiv))
-//        {
-//            // resize with SizeInc as the granularity
-//            capacity_ = nElem;
-//            unsigned pad = SizeInc - (capacity_ % SizeInc);
-//            if (pad != SizeInc)
-//            {
-//                capacity_ += pad;
-//            }
-//        }
-//        else
-        {
-            capacity_ = max
+        capacity_ = max
+        (
+            SizeMin,
+            max
             (
                 nElem,
-                label(SizeInc + capacity_ * SizeMult / SizeDiv)
-            );
-        }
+                // label(SizeInc + capacity_ * SizeMult / SizeDiv)
+                label(2*capacity_)
+            )
+        );
 
         Field<T>::setSize(capacity_);
     }
 
-    // adjust addressed size
+    // Adjust addressed size
     Field<T>::size(nElem);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setSize
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::setSize
 (
     const label nElem,
-    const T& t
+    const T& val
 )
 {
     label nextFree = Field<T>::size();
     setSize(nElem);
 
-    // set new elements to constant value
+    // Set new elements to constant value
     while (nextFree < nElem)
     {
-        this->operator[](nextFree++) = t;
+        this->operator[](nextFree++) = val;
     }
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::resize
 (
     const label nElem
 )
@@ -273,43 +284,55 @@ inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::resize
 (
     const label nElem,
-    const T& t
+    const T& val
 )
 {
-    this->setSize(nElem, t);
+    this->setSize(nElem, val);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clear()
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::clear()
 {
     Field<T>::size(0);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clearStorage()
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::clearStorage()
 {
     Field<T>::clear();
     capacity_ = 0;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::shrink()
+template<class T, int SizeMin>
+inline Foam::label Foam::DynamicField<T, SizeMin>::expandStorage()
+{
+    const label nextFree = Field<T>::size();
+
+    // Allow addressing into the entire list
+    Field<T>::size(capacity_);
+
+    return nextFree;
+}
+
+
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>&
+Foam::DynamicField<T, SizeMin>::shrink()
 {
     label nextFree = Field<T>::size();
     if (capacity_ > nextFree)
     {
-        // use the full list when resizing
+        // Use the full list when resizing
         Field<T>::size(capacity_);
 
-        // the new size
+        // The new size
         capacity_ = nextFree;
         Field<T>::setSize(capacity_);
         Field<T>::size(nextFree);
@@ -318,32 +341,32 @@ Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::shrink()
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<class T, int SizeMin>
 inline Foam::Xfer<Foam::List<T>>
-Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::xfer()
+Foam::DynamicField<T, SizeMin>::xfer()
 {
     return xferMoveTo<List<T>>(*this);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>&
+Foam::DynamicField<T, SizeMin>::append
 (
-    const T& t
+    const T& val
 )
 {
-    const label elemI = List<T>::size();
-    setSize(elemI + 1);
+    const label idx = List<T>::size();
+    setSize(idx + 1);
 
-    this->operator[](elemI) = t;
+    this->operator[](idx) = val;
     return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>&
-Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append
+template<class T, int SizeMin>
+inline Foam::DynamicField<T, SizeMin>&
+Foam::DynamicField<T, SizeMin>::append
 (
     const UList<T>& lst
 )
@@ -357,28 +380,29 @@ Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append
     label nextFree = List<T>::size();
     setSize(nextFree + lst.size());
 
-    forAll(lst, elemI)
+    forAll(lst, i)
     {
-        this->operator[](nextFree++) = lst[elemI];
+        this->operator[](nextFree++) = lst[i];
     }
     return *this;
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline T Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::remove()
+template<class T, int SizeMin>
+inline T Foam::DynamicField<T, SizeMin>::remove()
 {
-    const label elemI = List<T>::size() - 1;
+    // Location of last element and simultaneously the new size
+    const label idx = List<T>::size() - 1;
 
-    if (elemI < 0)
+    if (idx < 0)
     {
         FatalErrorInFunction
             << "List is empty" << abort(FatalError);
     }
 
-    const T& val = List<T>::operator[](elemI);
+    const T& val = List<T>::operator[](idx);
 
-    List<T>::size(elemI);
+    List<T>::size(idx);
 
     return val;
 }
@@ -386,80 +410,54 @@ inline T Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::remove()
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline T& Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator()
+template<class T, int SizeMin>
+inline T& Foam::DynamicField<T, SizeMin>::operator()
 (
-    const label elemI
+    const label i
 )
 {
-    if (elemI >= Field<T>::size())
+    if (i >= Field<T>::size())
     {
-        setSize(elemI + 1);
+        setSize(i + 1);
     }
 
-    return this->operator[](elemI);
+    return this->operator[](i);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::operator=
 (
-    const T& t
+    const T& val
 )
 {
-    UList<T>::operator=(t);
+    UList<T>::operator=(val);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::operator=
 (
-    const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
+    const DynamicField<T, SizeMin>& lst
 )
 {
     if (this == &lst)
     {
         FatalErrorInFunction
-            << "attempted assignment to self" << abort(FatalError);
-    }
-
-    if (capacity_ >= lst.size())
-    {
-        // can copy w/o reallocating, match initial size to avoid reallocation
-        Field<T>::size(lst.size());
-        Field<T>::operator=(lst);
+            << "Attempted assignment to self" << abort(FatalError);
     }
-    else
-    {
-        // make everything available for the copy operation
-        Field<T>::size(capacity_);
 
-        Field<T>::operator=(lst);
-        capacity_ = Field<T>::size();
-    }
+    assignDynField(lst);
 }
 
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator=
+template<class T, int SizeMin>
+inline void Foam::DynamicField<T, SizeMin>::operator=
 (
     const UList<T>& lst
 )
 {
-    if (capacity_ >= lst.size())
-    {
-        // can copy w/o reallocating, match initial size to avoid reallocation
-        Field<T>::size(lst.size());
-        Field<T>::operator=(lst);
-    }
-    else
-    {
-        // make everything available for the copy operation
-        Field<T>::size(capacity_);
-
-        Field<T>::operator=(lst);
-        capacity_ = Field<T>::size();
-    }
+    assignDynField(lst);
 }
 
 
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C
index f6ca2a766c6e02a958545682b2fa1bccd38e7b6f..eaaf483064419e29eadf165f9032af90f44d9274 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.C
+++ b/src/OpenFOAM/fields/Fields/Field/Field.C
@@ -744,16 +744,15 @@ void Foam::Field<Type>::writeEntry(const word& keyword, Ostream& os) const
 
     if (uniform)
     {
-        os << "uniform " << this->operator[](0) << token::END_STATEMENT;
+        os << "uniform " << this->operator[](0);
     }
     else
     {
         os << "nonuniform ";
         List<Type>::writeEntry(os);
-        os << token::END_STATEMENT;
     }
 
-    os << endl;
+    os << token::END_STATEMENT << nl;
 }
 
 
diff --git a/src/OpenFOAM/fields/Fields/Field/FieldM.H b/src/OpenFOAM/fields/Fields/Field/FieldM.H
index 28d4788c1764b58ce4aa49545629ce486fe15a54..b1682bf6d7aa6f2b5ca2a03d832ff23009bc03bd 100644
--- a/src/OpenFOAM/fields/Fields/Field/FieldM.H
+++ b/src/OpenFOAM/fields/Fields/Field/FieldM.H
@@ -56,7 +56,8 @@ void checkFields
         FatalErrorInFunction
             << " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')'
             << " and Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')'
-            << endl << " for operation " << op
+            << endl
+            << " for operation " << op
             << abort(FatalError);
     }
 }
@@ -76,7 +77,8 @@ void checkFields
             << " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')'
             << ", Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')'
             << " and Field<"<<pTraits<Type3>::typeName<<"> f3("<<f3.size()<<')'
-            << endl << "    for operation " << op
+            << endl
+            << "    for operation " << op
             << abort(FatalError);
     }
 }
@@ -107,295 +109,306 @@ void checkFields
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-// member function : this f1 OP fUNC f2
+// Member function : f1 OP Func f2
 
 #define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)                 \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP " " #FUNC "(f2)");                           \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP FUNC(f2) */                                                 \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i));                  \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP FUNC(f2P[i]);                                              \
+    }
 
 
 #define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC)                 \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP " f2" #FUNC);                                \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP f2.FUNC() */                                                \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i).FUNC();                 \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP (f2P[i]).FUNC();                                           \
+    }
 
 
-// member function : this field f1 OP fUNC f2, f3
+// Member function : this field f1 OP FUNC(f2, f3)
 
-#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)\
+#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)   \
                                                                                \
-    /* check the three fields have same Field<Type> mesh */                    \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, f3, "f1 " #OP " " #FUNC "(f2, f3)");                   \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
     List_CONST_ACCESS(typeF3, f3, f3P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP FUNC(f2, f3) */                                             \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i)                                                  \
-        OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i));                 \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP FUNC((f2P[i]), (f3P[i]));                                  \
+    }
 
 
-// member function : this field f1 OP fUNC f2, f3
+// Member function : s OP FUNC(f1, f2)
 
 #define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2)     \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "s " #OP " " #FUNC "(f1, f2)");                        \
                                                                                \
-    /* set access to f1 and f2 at end of each field */                         \
+    /* Field access */                                                         \
     List_CONST_ACCESS(typeF1, f1, f1P);                                        \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing s OP FUNC(f1, f2) */                     \
+    /* Loop: s OP FUNC(f1, f2) */                                              \
     List_FOR_ALL(f1, i)                                                        \
-        (s) OP FUNC(List_ELEM(f1, f1P, i), List_ELEM(f2, f2P, i));             \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (s) OP FUNC((f1P[i]), (f2P[i]));                                       \
+    }
 
 
-// member function : this f1 OP fUNC f2, s
+// Member function : this f1 OP FUNC(f2, s)
 
 #define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s)     \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP " " #FUNC "(f2, s)");                        \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP FUNC(f2, s) */                                              \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i), (s));             \
-    List_END_FOR_ALL
+    {                                                                          \
+        (f1P[i]) OP FUNC((f2P[i]), (s));                                       \
+    }
 
 
-// member function : s1 OP fUNC f, s2
+// Member function : s1 OP FUNC(f, s2)
 
 #define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2)     \
                                                                                \
-    /* set access to f at end of field */                                      \
+    /* Field access */                                                         \
     List_CONST_ACCESS(typeF, f, fP);                                           \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: s1 OP FUNC(f, s2) */                                              \
     List_FOR_ALL(f, i)                                                         \
-        (s1) OP FUNC(List_ELEM(f, fP, i), (s2));                               \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (s1) OP FUNC((fP[i]), (s2));                                           \
+    }
 
 
-// member function : this f1 OP fUNC s, f2
+// Member function : this f1 OP FUNC(s, f2)
 
 #define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)     \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP " " #FUNC "(s, f2)");                        \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP1 f2 OP2 f3 */                                               \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP FUNC((s), List_ELEM(f2, f2P, i));             \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP FUNC((s), (f2P[i]));                                       \
+    }
 
 
-// member function : this f1 OP fUNC s, f2
+// Member function : this f1 OP FUNC(s1, s2)
 
-#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)\
+#define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)   \
                                                                                \
-    /* set access to f1 at end of field */                                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
                                                                                \
-    /* loop through fields performing f1 OP1 FUNC(s1, s2) */                   \
+    /* Loop: f1 OP FUNC(s1, s2) */                                             \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP FUNC((s1), (s2));                             \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP FUNC((s1), (s2));                                          \
+    }
 
 
-// member function : this f1 OP1 f2 OP2 FUNC s
+// Member function : this f1 OP f2 FUNC(s)
 
 #define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s)     \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP " f2 " #FUNC "(s)");                         \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP f2 FUNC(s) */                                               \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i) FUNC((s));              \
-    List_END_FOR_ALL                                                           \
-
+    {                                                                          \
+        (f1P[i]) OP (f2P[i]) FUNC((s));                                        \
+    }
 
-// define high performance macro functions for Field<Type> operations
 
-// member operator : this field f1 OP1 f2 OP2 f3
+// Member operator : this field f1 OP1 f2 OP2 f3
 
 #define TFOR_ALL_F_OP_F_OP_F(typeF1, f1, OP1, typeF2, f2, OP2, typeF3, f3)     \
                                                                                \
-    /* check the three fields have same Field<Type> mesh */                    \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, f3, "f1 " #OP1 " f2 " #OP2 " f3");                     \
                                                                                \
-    /* set access to f1, f2 and f3 at end of each field */                     \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
     List_CONST_ACCESS(typeF3, f3, f3P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 f2 OP2 f3 */                      \
+    /* Loop: f1 OP1 f2 OP2 f3 */                                               \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i)                        \
-                              OP2 List_ELEM(f3, f3P, i);                       \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP1 (f2P[i]) OP2 (f3P[i]);                                    \
+    }
 
 
-// member operator : this field f1 OP1 s OP2 f2
+// Member operator : this field f1 OP1 s OP2 f2
 
 #define TFOR_ALL_F_OP_S_OP_F(typeF1, f1, OP1, typeS, s, OP2, typeF2, f2)       \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP1 " s " #OP2 " f2");                          \
                                                                                \
-    /* set access to f1 and f2 at end of each field */                         \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 s OP2 f2 */                       \
+    /* Loop: f1 OP1 s OP2 f2 */                                                \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP1 (s) OP2 List_ELEM(f2, f2P, i);               \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP1 (s) OP2 (f2P[i]);                                         \
+    }
 
 
-// member operator : this field f1 OP1 f2 OP2 s
+// Member operator : this field f1 OP1 f2 OP2 s
 
 #define TFOR_ALL_F_OP_F_OP_S(typeF1, f1, OP1, typeF2, f2, OP2, typeS, s)       \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP1 " f2 " #OP2 " s");                          \
                                                                                \
-    /* set access to f1 and f2 at end of each field */                         \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 s OP2 f2 */                       \
+    /* Loop f1 OP1 s OP2 f2 */                                                 \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) OP2 (s);               \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP1 (f2P[i]) OP2 (s);                                         \
+    }
 
 
-// member operator : this field f1 OP f2
+// Member operator : this field f1 OP f2
 
 #define TFOR_ALL_F_OP_F(typeF1, f1, OP, typeF2, f2)                            \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, "f1 " #OP " f2");                                      \
                                                                                \
-    /* set pointer to f1P at end of f1 and */                                  \
-    /* f2.p at end of f2 */                                                    \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP f2 */                              \
+    /* Loop: f1 OP f2 */                                                       \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i);                        \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP (f2P[i]);                                                  \
+    }
 
-// member operator : this field f1 OP1 OP2 f2
+// Member operator : this field f1 OP1 OP2 f2
 
 #define TFOR_ALL_F_OP_OP_F(typeF1, f1, OP1, OP2, typeF2, f2)                   \
                                                                                \
-    /* check the two fields have same Field<Type> mesh */                      \
+    /* Check fields have same size */                                          \
     checkFields(f1, f2, #OP1 " " #OP2 " f2");                                  \
                                                                                \
-    /* set pointer to f1P at end of f1 and */                                  \
-    /* f2.p at end of f2 */                                                    \
+    /* Field access */                                                         \
     List_ACCESS(typeF1, f1, f1P);                                              \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through fields performing f1 OP1 OP2 f2 */                         \
+    /* Loop: f1 OP1 OP2 f2 */                                                  \
     List_FOR_ALL(f1, i)                                                        \
-        List_ELEM(f1, f1P, i) OP1 OP2 List_ELEM(f2, f2P, i);                   \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (f1P[i]) OP1 OP2 (f2P[i]);                                             \
+    }
 
 
-// member operator : this field f OP s
+// Member operator : this field f OP s
 
 #define TFOR_ALL_F_OP_S(typeF, f, OP, typeS, s)                                \
                                                                                \
-    /* set access to f at end of field */                                      \
+    /* Field access */                                                         \
     List_ACCESS(typeF, f, fP);                                                 \
                                                                                \
-    /* loop through field performing f OP s */                                 \
+    /* Loop: f OP s */                                                         \
     List_FOR_ALL(f, i)                                                         \
-        List_ELEM(f, fP, i) OP (s);                                            \
-    List_END_FOR_ALL                                                           \
+    {                                                                          \
+        (fP[i]) OP (s);                                                        \
+    }
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-// define high performance macro functions for Field<Type> friend functions
 
-// friend operator function : s OP f, allocates storage for s
+// Friend operator function : s OP f, allocates storage for s
 
 #define TFOR_ALL_S_OP_F(typeS, s, OP, typeF, f)                                \
                                                                                \
-    /* set access to f at end of field */                                      \
+    /* Field access */                                                         \
     List_CONST_ACCESS(typeF, f, fP);                                           \
                                                                                \
-    /* loop through field performing s OP f */                                 \
+    /* Loop: s OP f */                                                         \
     List_FOR_ALL(f, i)                                                         \
-        (s) OP List_ELEM(f, fP, i);                                            \
-    List_END_FOR_ALL
+    {                                                                          \
+        (s) OP (fP[i]);                                                        \
+    }
 
 
-// friend operator function : s OP1 f1 OP2 f2, allocates storage for s
+// Friend operator function : s OP1 f1 OP2 f2, allocates storage for s
 
 #define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2)       \
                                                                                \
-    /* set access to f1 and f2 at end of each field */                         \
+    /* Field access */                                                         \
     List_CONST_ACCESS(typeF1, f1, f1P);                                        \
     List_CONST_ACCESS(typeF2, f2, f2P);                                        \
                                                                                \
-    /* loop through field performing s OP f */                                 \
+    /* Loop: s OP f */                                                         \
     List_FOR_ALL(f1, i)                                                        \
-        (s) OP1 List_ELEM(f1, f1P, i) OP2 List_ELEM(f2, f2P, i);               \
-    List_END_FOR_ALL
+    {                                                                          \
+        (s) OP1 (f1P[i]) OP2 (f2P[i]);                                         \
+    }
 
 
-// friend operator function : s OP FUNC(f), allocates storage for s
+// Friend operator function : s OP FUNC(f), allocates storage for s
 
 #define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f)                     \
                                                                                \
-    /* set access to f at end of field */                                      \
+    /* Field access */                                                         \
     List_CONST_ACCESS(typeF, f, fP);                                           \
                                                                                \
-    /* loop through field performing s OP f */                                 \
+    /* Loop: s OP FUNC(f) */                                                   \
     List_FOR_ALL(f, i)                                                         \
-        (s) OP FUNC(List_ELEM(f, fP, i));                                      \
-    List_END_FOR_ALL
+    {                                                                          \
+        (s) OP FUNC(fP[i]);                                                    \
+    }
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C b/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C
index 94bf0ca6c887dcf1c7b95a2106576bde262e6368..9e722c6569a7806114fe3e9d11a15cf38c5e635b 100644
--- a/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C
+++ b/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.C
@@ -97,10 +97,8 @@ bool Foam::UniformDimensionedField<Type>::writeData(Ostream& os) const
 {
     scalar multiplier;
     os.writeKeyword("dimensions");
-    this->dimensions().write(os, multiplier) << token::END_STATEMENT
-        << nl;
-    os.writeKeyword("value") << this->value()/multiplier << token::END_STATEMENT
-        << nl << nl;
+    this->dimensions().write(os, multiplier) << token::END_STATEMENT << nl;
+    os.writeEntry("value", this->value()/multiplier) << nl;
 
     return os.good();
 }
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C
index 6f32877f6262703ab529ca3830571e2be7a4ef91..16969e8dc9b5a3579f1ef7809b96807ae1e08dc3 100644
--- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C
@@ -270,8 +270,7 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
         // Make sure to construct the patchfield with up-to-date value
 
         OStringStream os;
-        os.writeKeyword("type") << name_ << token::END_STATEMENT
-            << nl;
+        os.writeEntry("type", name_);
         static_cast<const Field<Type>&>(*this).writeEntry("value", os);
         IStringStream is(os.str());
         dictionary dict(is);
@@ -333,8 +332,7 @@ template<class Type>
 void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
 {
     fixedValuePointPatchField<Type>::write(os);
-    os.writeKeyword("name") << name_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("name", name_);
 
     codedBase::writeCodeDict(os, dict_);
 }
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C
index cd99728ca504c604ed3e8f34293362c4429c8b4d..c5941fade46ec4693e6fed7156ba55526f5c8092 100644
--- a/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/fixedNormalSlip/fixedNormalSlipPointPatchField.C
@@ -100,8 +100,7 @@ template<class Type>
 void Foam::fixedNormalSlipPointPatchField<Type>::write(Ostream& os) const
 {
     slipPointPatchField<Type>::write(os);
-    os.writeKeyword("n")
-        << n_ << token::END_STATEMENT << nl;
+    os.writeEntry("n", n_);
 }
 
 
diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C
index 2c98caa0e5cc105e311e4099b8a81eabc27ed4a2..b2016d79a3a7a8916a4ecce4926b634ca47ece8f 100644
--- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C
+++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.C
@@ -113,29 +113,11 @@ const Foam::objectRegistry& Foam::pointPatchField<Type>::db() const
 template<class Type>
 void Foam::pointPatchField<Type>::write(Ostream& os) const
 {
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
 
     if (patchType_.size())
     {
-        os.writeKeyword("patchType") << patchType_
-            << token::END_STATEMENT << nl;
-    }
-}
-
-
-template<class Type>
-template<class EntryType>
-void Foam::pointPatchField<Type>::writeEntryIfDifferent
-(
-    Ostream& os,
-    const word& entryName,
-    const EntryType& value1,
-    const EntryType& value2
-) const
-{
-    if (value1 != value2)
-    {
-        os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
+        os.writeEntry("patchType", patchType_);
     }
 }
 
diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H
index b4ac7f2dc8d425778cbbcfa24875c3dd82d98f7a..40129b82ec793accd28d993f28ba57b9de52bf5d 100644
--- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H
+++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H
@@ -436,17 +436,6 @@ public:
             //- Write
             virtual void write(Ostream&) const;
 
-            //- Helper function to write the keyword and entry only if the
-            //  values are not equal. The value is then output as value2
-            template<class EntryType>
-            void writeEntryIfDifferent
-            (
-                Ostream& os,
-                const word& entryName,
-                const EntryType& value1,
-                const EntryType& value2
-            ) const;
-
 
     // Member operators
 
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C
index 20d4bffbc7174611340fdd006ee6444d47f4923a..648138a14772d18551e0fddf09a3f036106654ec 100644
--- a/src/OpenFOAM/global/argList/argList.C
+++ b/src/OpenFOAM/global/argList/argList.C
@@ -102,6 +102,52 @@ Foam::argList::initValidTables::initValidTables()
 
 Foam::argList::initValidTables dummyInitValidTables;
 
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Counted per machine name
+// Does not include any sorting since we wish to know the ordering according to
+// mpi rank.
+//
+// Always include the master too.
+// This provides a better overview of the subscription
+static void printHostsSubscription(const UList<string>& slaveProcs)
+{
+    Info<< "Hosts  :" << nl << "(" << nl;
+
+    std::string prev = hostName();
+    int count = 1;
+
+    for (const auto& str : slaveProcs)
+    {
+        std::string curr(str.substr(0, str.rfind('.')));
+
+        if (prev != curr)
+        {
+            if (count)
+            {
+                // Finish previous
+                Info<<"    (" << prev.c_str() << " " << count << ")" << nl;
+                count = 0;
+            }
+
+            prev = std::move(curr);
+        }
+        ++count;
+    }
+
+    if (count)
+    {
+        // Finished last one
+        Info<<"    (" << prev.c_str() << " " << count << ")" << nl;
+    }
+
+    Info<< ")" << nl;
+}
+
+}
 
 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
 
@@ -931,6 +977,7 @@ void Foam::argList::parse
     }
 
     stringList slaveProcs;
+    const int writeHostsSwitch = debug::infoSwitch("writeHosts", 1);
 
     // Collect slave machine/pid, and check that the build is identical
     if (parRunControl_.parRun())
@@ -981,8 +1028,9 @@ void Foam::argList::parse
     // Keep or discard slave and root information for reporting:
     if (Pstream::master() && parRunControl_.parRun())
     {
-        if (!debug::infoSwitch("writeSlaves", 1))
+        if (!writeHostsSwitch)
         {
+            // Clear here to ensures it doesn't show in the jobInfo
             slaveProcs.clear();
         }
         if (!debug::infoSwitch("writeRoots", 1))
@@ -1000,7 +1048,16 @@ void Foam::argList::parse
         {
             if (slaveProcs.size())
             {
-                Info<< "Slaves : " << slaveProcs << nl;
+                if (writeHostsSwitch == 1)
+                {
+                    // Compact output (see etc/controlDict)
+                    printHostsSubscription(slaveProcs);
+                }
+                else
+                {
+                    // Full output of "slave.pid"
+                    Info<< "Slaves : " << slaveProcs << nl;
+                }
             }
             if (roots.size())
             {
diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H
index cba9bb009fa4903a2e0c6c5b2622be6e98416750..171bdb7ffb63bde94222055ded8090dd46d47ede 100644
--- a/src/OpenFOAM/global/argList/argList.H
+++ b/src/OpenFOAM/global/argList/argList.H
@@ -126,7 +126,10 @@ class argList
         //  so destructor is done last.
         ParRunControl parRunControl_;
 
+        //- The arguments after removing known options
         stringList args_;
+
+        //- The extracted options
         HashTable<string> options_;
 
         word executable_;
@@ -202,7 +205,7 @@ public:
     // Constructors
 
         //- Construct from argc and argv
-        //  checking the arguments and options as requested
+        //- checking the arguments and options as requested.
         argList
         (
             int& argc,
@@ -246,8 +249,8 @@ public:
             //- Return root path
             inline const fileName& rootPath() const;
 
-            //- Return distributed flag (i.e. are rootPaths different on
-            //  different machines)
+            //- Return distributed flag
+            //- (i.e. are rootPaths different on different machines)
             inline bool distributed() const;
 
             //- Return case name (parallel run) or global case (serial run)
@@ -338,20 +341,19 @@ public:
             inline const string& operator[](const label index) const;
 
             //- Return the argument string associated with the named option
-            //  \sa option()
             inline const string& operator[](const word& opt) const;
 
 
         // Edit
 
-            //- Add to a bool option to validOptions with usage information
+            //- Add a bool option to validOptions with usage information
             static void addBoolOption
             (
                 const word& opt,
                 const string& usage = ""
             );
 
-            //- Add to an option to validOptions with usage information
+            //- Add an option to validOptions with usage information
             //  An option with an empty param is a bool option
             static void addOption
             (
diff --git a/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H b/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H
index c7faae1bd273a4ab30a5703f0c17699e646e7611..a71217514791c512f83b185b6a06c6dbed914f88 100644
--- a/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H
+++ b/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H
@@ -45,7 +45,7 @@ namespace mathematical
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-    static const char* const group = "mathematical";
+    constexpr const char* const group = "mathematical";
 
     constexpr scalar e(M_E);
     constexpr scalar pi(M_PI);
diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C b/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C
index b5dbb13517b9d583e279cf65abf343d026194206..dd105496a4ee5460e21cf49271dc59800d3ed415 100644
--- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C
+++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/collatedFileOperation.C
@@ -200,7 +200,7 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
                 << "         may \"hang\".  If thread support cannot be "
                    "enabled, deactivate threading" << nl
                 << "         by setting maxThreadFileBufferSize to 0 in "
-                   "$FOAM_ETC/controlDict"
+                   "the OpenFOAM etc/controlDict"
                 << endl;
         }
 
diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H
index 6e776320d0ae0bfc3407dfb59089ac27dc8415ea..f7044aa08e5415d92b91025b710b06db4313eafe 100644
--- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H
+++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.H
@@ -247,7 +247,12 @@ public:
             virtual bool rm(const fileName&) const = 0;
 
             //- Remove a dirctory and its contents
-            virtual bool rmDir(const fileName&) const = 0;
+            //  \param silent do not report missing directory
+            virtual bool rmDir
+            (
+                const fileName& dir,
+                const bool silent = false
+            ) const = 0;
 
 //            //- Open a shared library. Return handle to library. Print error
 //            //  message if library cannot be loaded (check = true)
diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C
index f436b45776ea412b69724d4f03c1f20bc097662a..41c949fe5012c2780414921860b520292b1fe58c 100644
--- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C
+++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C
@@ -630,10 +630,11 @@ bool Foam::fileOperations::masterUncollatedFileOperation::rm
 
 bool Foam::fileOperations::masterUncollatedFileOperation::rmDir
 (
-    const fileName& dir
+    const fileName& dir,
+    const bool silent
 ) const
 {
-    return masterOp<bool, rmDirOp>(dir, rmDirOp());
+    return masterOp<bool, rmDirOp>(dir, rmDirOp(silent));
 }
 
 
diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H
index 5061b1e5cf839552f8a32e40aa408a1dd7fc8f00..b57ced6153a56415d35c9390919d9492b6edc310 100644
--- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H
+++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H
@@ -249,10 +249,19 @@ protected:
 
         class rmDirOp
         {
+            bool silent_;
         public:
+            rmDirOp()
+            :
+                silent_(false)
+            {}
+            rmDirOp(const bool silent)
+            :
+                silent_(silent)
+            {}
             bool operator()(const fileName& fName) const
             {
-                return Foam::rmDir(fName);
+                return Foam::rmDir(fName, silent_);
             }
         };
 
@@ -533,7 +542,12 @@ public:
             virtual bool rm(const fileName&) const;
 
             //- Remove a dirctory and its contents
-            virtual bool rmDir(const fileName&) const;
+            //  \param silent do not report missing directory
+            virtual bool rmDir
+            (
+                const fileName& dir,
+                const bool silent = false
+            ) const;
 
 //            //- Open a shared library. Return handle to library. Print error
 //            //  message if library cannot be loaded (check = true)
diff --git a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C
index e6a509e74c2f19c83868ca8272683baf1a77245d..9c4788b3f54d5ef94493dbf00b85a27e86874046 100644
--- a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C
+++ b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C
@@ -292,10 +292,11 @@ bool Foam::fileOperations::uncollatedFileOperation::rm
 
 bool Foam::fileOperations::uncollatedFileOperation::rmDir
 (
-    const fileName& dir
+    const fileName& dir,
+    const bool silent
 ) const
 {
-    return Foam::rmDir(dir);
+    return Foam::rmDir(dir, silent);
 }
 
 
@@ -600,7 +601,7 @@ bool Foam::fileOperations::uncollatedFileOperation::read
     if (masterOnly && Pstream::parRun())
     {
         // Master reads headerclassname from file. Make sure this gets
-        // transfered as well as contents.
+        // transferred as well as contents.
         Pstream::scatter(io.headerClassName());
         Pstream::scatter(io.note());
 
diff --git a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H
index f2d624a9c9db575147eb4d4bc62fc09a8a4fb3cd..8e750214e3289bef5746aee6f1da923c04bfa752 100644
--- a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H
+++ b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.H
@@ -192,7 +192,11 @@ public:
             virtual bool rm(const fileName&) const;
 
             //- Remove a dirctory and its contents
-            virtual bool rmDir(const fileName&) const;
+            virtual bool rmDir
+            (
+                const fileName& dir,
+                const bool silent = false
+            ) const;
 
 //            //- Open a shared library. Return handle to library. Print error
 //            //  message if library cannot be loaded (check = true)
diff --git a/src/OpenFOAM/global/profiling/profiling.C b/src/OpenFOAM/global/profiling/profiling.C
index 2c212044182d05fac09c88cbc579a8c20eb26aad..e6a85fbefe6af0a58631f7218ac6a0b8cacabf20 100644
--- a/src/OpenFOAM/global/profiling/profiling.C
+++ b/src/OpenFOAM/global/profiling/profiling.C
@@ -48,8 +48,7 @@ Foam::profilingInformation* Foam::profiling::find
     const label parentId
 )
 {
-    StorageContainer::iterator iter = hash_.find(Key(descr, parentId));
-    return (iter.found() ? iter() : 0);
+    return hash_.lookup(Key(descr, parentId), nullptr);
 }
 
 
@@ -313,6 +312,7 @@ const Foam::Time& Foam::profiling::owner() const
     return owner_;
 }
 
+
 Foam::label Foam::profiling::size() const
 {
     return stack_.size();
diff --git a/src/OpenFOAM/global/profiling/profiling.H b/src/OpenFOAM/global/profiling/profiling.H
index 4b6fc498206164056ca9ce4ae62fe07d55e91a23..0059dfb2aa50b154c79ee90c48130ad5034dc1b3 100644
--- a/src/OpenFOAM/global/profiling/profiling.H
+++ b/src/OpenFOAM/global/profiling/profiling.H
@@ -33,9 +33,9 @@ Description
         profiling
         {
             active      true;
-            cpuInfo     true;
+            cpuInfo     false;
             memInfo     false;
-            sysInfo     true;
+            sysInfo     false;
         }
     \endcode
     or simply using all defaults:
diff --git a/src/OpenFOAM/global/profiling/profilingInformation.C b/src/OpenFOAM/global/profiling/profilingInformation.C
index bc73478e51886b7bac062825933808c17e27753b..24957284e1d6a98de0f96b2ec0a00e18460abb44 100644
--- a/src/OpenFOAM/global/profiling/profilingInformation.C
+++ b/src/OpenFOAM/global/profiling/profilingInformation.C
@@ -128,18 +128,12 @@ Foam::Ostream& Foam::profilingInformation::write
     os.beginBlock(word("trigger" + Foam::name(id_)));
 
     os.writeEntry("id",             id_);
-    if (id_ != parent().id())
-    {
-        os.writeEntry("parentId",   parent().id());
-    }
+    os.writeEntryIfDifferent("parentId", id_, parent().id());
     os.writeEntry("description",    description());
     os.writeEntry("calls",          calls()     + (offset ? 1 : 0));
     os.writeEntry("totalTime",      totalTime() + elapsedTime);
     os.writeEntry("childTime",      childTime() + childTimes);
-    if (maxMem_)
-    {
-        os.writeEntry("maxMem",     maxMem_);
-    }
+    os.writeEntryIfDifferent<int>("maxMem", 0, maxMem_);
     os.writeEntry("onStack",        Switch(onStack()));
 
     os.endBlock();
diff --git a/src/OpenFOAM/graph/curve/curveTools.H b/src/OpenFOAM/graph/curve/curveTools.H
index 04787e4e800599e10eca7b0e260349686b559ce2..4963c23bb3853f0f2458889c64b132862cc29fea 100644
--- a/src/OpenFOAM/graph/curve/curveTools.H
+++ b/src/OpenFOAM/graph/curve/curveTools.H
@@ -15,10 +15,6 @@ namespace Foam
 #define curveSmall 1.0e-8
 #define curveGreat 1.0e8
 
-typedef List<char> charList;
-typedef List<charList> charListList;
-
-
 scalar distance(const vector&, const vector&);
 
 
diff --git a/src/OpenFOAM/include/addFunctionObjectOptions.H b/src/OpenFOAM/include/addFunctionObjectOptions.H
index 7747c16d4f8b3e6dc1c39b35b7f24593c8d6e1dd..35f8503e7d84cfa8549704f8548d82782d4342cf 100644
--- a/src/OpenFOAM/include/addFunctionObjectOptions.H
+++ b/src/OpenFOAM/include/addFunctionObjectOptions.H
@@ -9,8 +9,7 @@ Foam::argList::addOption
 (
     "fields",
     "list",
-    "Specify a list of fields to be processed, e.g. '(U T p)' - "
-    "regular expressions not currently supported"
+    "Specify a list of fields to be processed, e.g. '(U T p)'"
 );
 Foam::argList::addOption
 (
diff --git a/src/OpenFOAM/include/stdFoam.H b/src/OpenFOAM/include/stdFoam.H
index 59b0d9f704a8463605ead378ed254d83868f04dd..ac6bd6c34227e1ae7284ab7e01777dd402765f16 100644
--- a/src/OpenFOAM/include/stdFoam.H
+++ b/src/OpenFOAM/include/stdFoam.H
@@ -25,23 +25,27 @@ Namespace
     stdFoam
 
 Description
-    Includes some global templates and macros used by OpenFOAM.
+    Some global templates and macros used by OpenFOAM and some standard
+    C++ headers.
 
-    Some of the templates are defined here correspond to useful
+    Some of the templates defined here correspond to useful
     std templates that are part of future C++ standards, or that
     are in a state of change. Defining them here provides some additional
-    control over which definition are used within the OpenFOAM code-base.
+    control over which definitions are used within the OpenFOAM code-base.
 
 SeeAlso
-    - http://en.cppreference.com/w/cpp/iterator/end
     - http://en.cppreference.com/w/cpp/iterator/begin
+    - http://en.cppreference.com/w/cpp/iterator/end
+    - http://en.cppreference.com/w/cpp/iterator/rbegin
+    - http://en.cppreference.com/w/cpp/iterator/rend
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef StdFoam_H
-#define StdFoam_H
+#ifndef stdFoam_H
+#define stdFoam_H
 
 #include <initializer_list>
+#include <utility>
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -50,7 +54,9 @@ namespace stdFoam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-//- Return iterator to the beginning of the container \a c or array.
+// Forward iteration
+
+//- Return iterator to the beginning of the container \a c.
 //  Definition as per std::begin C++17
 template<class C>
 constexpr auto begin(C& c) -> decltype(c.begin())
@@ -58,7 +64,7 @@ constexpr auto begin(C& c) -> decltype(c.begin())
     return c.begin();
 }
 
-//- Return const_iterator to the beginning of the container \a c or array.
+//- Return const_iterator to the beginning of the container \a c.
 //  Definition as per std::begin C++17
 template<class C>
 constexpr auto begin(const C& c) -> decltype(c.begin())
@@ -66,7 +72,7 @@ constexpr auto begin(const C& c) -> decltype(c.begin())
     return c.begin();
 }
 
-//- Return const_iterator to the beginning of the container \a c or array.
+//- Return const_iterator to the beginning of the container \a c.
 //  Definition as per std::cbegin C++17
 template<class C>
 constexpr auto cbegin(const C& c) -> decltype(c.begin())
@@ -74,7 +80,7 @@ constexpr auto cbegin(const C& c) -> decltype(c.begin())
     return c.begin();
 }
 
-//- Return iterator to the end of the container \a c or array.
+//- Return iterator to the end of the container \a c array.
 //  Definition as per std::end C++17
 template<class C>
 constexpr auto end(C& c) -> decltype(c.end())
@@ -82,7 +88,7 @@ constexpr auto end(C& c) -> decltype(c.end())
     return c.end();
 }
 
-//- Return const_iterator to the end of the container \a c or array.
+//- Return const_iterator to the end of the container \a c array.
 //  Definition as per std::end C++17
 template<class C>
 constexpr auto end(const C& c) -> decltype(c.end())
@@ -90,7 +96,7 @@ constexpr auto end(const C& c) -> decltype(c.end())
     return c.end();
 }
 
-//- Return const_iterator to the end of the container \a c or array.
+//- Return const_iterator to the end of the container \a c.
 //  Definition as per std::cend C++17
 template<class C>
 constexpr auto cend(const C& c) -> decltype(c.end())
@@ -99,6 +105,57 @@ constexpr auto cend(const C& c) -> decltype(c.end())
 }
 
 
+// Reverse iteration
+
+//- Return reverse_iterator to the reverse-begin of container \a c.
+//  Definition as per std::rbegin C++17
+template<class C>
+constexpr auto rbegin(C& c) -> decltype(c.rbegin())
+{
+    return c.rbegin();
+}
+
+//- Return const_reverse_iterator to the reverse-begin of container \a c.
+//  Definition as per std::rbegin C++17
+template<class C>
+constexpr auto rbegin(const C& c) -> decltype(c.rbegin())
+{
+    return c.rbegin();
+}
+
+//- Return const_reverse_iterator to the reverse-begin of container \a c.
+//  Definition as per std::crbegin C++17
+template<class C>
+constexpr auto crbegin(const C& c) -> decltype(c.rbegin())
+{
+    return c.rbegin();
+}
+
+//- Return reverse_iterator to reverse-end of container \a c.
+//  Definition as per std::rend C++17
+template<class C>
+constexpr auto rend(C& c) -> decltype(c.rend())
+{
+    return c.rend();
+}
+
+//- Return const_reverse_iterator to reverse-end of container \a c.
+//  Definition as per std::rend C++17
+template<class C>
+constexpr auto rend(const C& c) -> decltype(c.rend())
+{
+    return c.rend();
+}
+
+//- Return const_reverse_iterator to reverse-end of container \a c.
+//  Definition as per std::crend C++17
+template<class C>
+constexpr auto crend(const C& c) -> decltype(c.rend())
+{
+    return c.rend();
+}
+
+
 } // End namespace stdFoam
 
 
@@ -114,12 +171,12 @@ constexpr auto cend(const C& c) -> decltype(c.end())
 //  }
 //  \endcode
 //  \sa forAllConstIters, forAllIter, forAllConstIters
-#define forAllIters(container,it)                                              \
+#define forAllIters(container,iter)                                            \
     for                                                                        \
     (                                                                          \
-        auto it = stdFoam::begin(container);                                   \
-        it != stdFoam::end(container);                                         \
-        ++it                                                                   \
+        auto iter = stdFoam::begin(container);                                 \
+        iter != stdFoam::end(container);                                       \
+        ++iter                                                                 \
     )
 
 
@@ -132,12 +189,49 @@ constexpr auto cend(const C& c) -> decltype(c.end())
 //  }
 //  \endcode
 //  \sa forAllIters, forAllIter, forAllConstIter
-#define forAllConstIters(container,cit)                                        \
+#define forAllConstIters(container,iter)                                       \
+    for                                                                        \
+    (                                                                          \
+        auto iter = stdFoam::cbegin(container);                                \
+        iter != stdFoam::cend(container);                                      \
+        ++iter                                                                 \
+    )
+
+
+//- Rverse iterate across elements in the \a container object of type
+//  \a Container.
+//  \par Usage
+//  \code
+//  forAllReverseIters(container, iter)
+//  {
+//      statements;
+//  }
+//  \endcode
+//  \sa forAllConstReverseIters
+#define forAllReverseIters(container,iter)                                     \
     for                                                                        \
     (                                                                          \
-        auto cit = stdFoam::cbegin(container);                                 \
-        cit != stdFoam::cend(container);                                       \
-        ++cit                                                                  \
+        auto iter = stdFoam::rbegin(container);                                \
+        iter != stdFoam::rend(container);                                      \
+        ++iter                                                                 \
+    )
+
+
+//- Reverse iterate across elements of \a container object with const access.
+//  \par Usage
+//  \code
+//  forAllReverseConstIters(container, iter)
+//  {
+//      statements;
+//  }
+//  \endcode
+//  \sa forAllReverseIters
+#define forAllConstReverseIters(container,iter)                                \
+    for                                                                        \
+    (                                                                          \
+        auto iter = stdFoam::crbegin(container);                               \
+        iter != stdFoam::crend(container);                                     \
+        ++iter                                                                 \
     )
 
 
@@ -167,6 +261,8 @@ constexpr auto cend(const C& c) -> decltype(c.end())
     for (Foam::label i=(list).size()-1; i>=0; --i)
 
 
+// Compatibility macros for pre C++11
+
 //- Iterate across all elements in the \a container object
 //  of type \a Container.
 //  \par Usage
diff --git a/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C b/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C
index 32e76884b6180eb70ff11ab52afe8bc20805c84f..f317ae5f708c980ffa6cfa7d81cc98c6f9f8315d 100644
--- a/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C
+++ b/src/OpenFOAM/interpolations/interpolationLookUpTable/interpolationLookUpTable.C
@@ -354,19 +354,15 @@ void Foam::interpolationLookUpTable<Type>::write
 
     control.writeHeader(os);
 
-    os.writeKeyword("fields")
-        << entries_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("output")
-        << output_ << token::END_STATEMENT << nl;
+    os.writeEntry("fields", entries_);
+    os.writeEntry("output", output_);
 
     if (this->size() == 0)
     {
         FatalErrorInFunction
             << "table is empty" << nl << exit(FatalError);
     }
-    os.writeKeyword("values")
-        << *this << token::END_STATEMENT << nl;
+    os.writeEntry("values", *this);
 }
 
 
diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
index 51adcb3381cab245be0b65761ed35bff86b6de65..bf972fda0a194104560d4263a19671480c76ead8 100644
--- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
+++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C
@@ -173,10 +173,8 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const
 {
     tableReader<Type>::write(os);
 
-    os.writeKeyword("hasHeaderLine")
-        << headerLine_ << token::END_STATEMENT << nl;
-    os.writeKeyword("timeColumn")
-        << timeColumn_ << token::END_STATEMENT << nl;
+    os.writeEntry("hasHeaderLine", headerLine_);
+    os.writeEntry("timeColumn", timeColumn_);
 
     // Force writing labelList in ascii
     os.writeKeyword("valueColumns");
@@ -186,10 +184,13 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const
         os  << componentColumns_;
         os.format(IOstream::BINARY);
     }
+    else
+    {
+        os << componentColumns_;
+    }
     os  << token::END_STATEMENT << nl;
 
-    os.writeKeyword("separator")
-        << string(separator_) << token::END_STATEMENT << nl;
+    os.writeEntry("separator", string(separator_));
 }
 
 
diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
index b3d96d50b0b7864dd4ce2b10b30356b4dfbb1a00..b32b3bfdc1605838625d1b776ae823c8225beede 100644
--- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
+++ b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReader.C
@@ -74,10 +74,7 @@ Foam::tableReader<Type>::~tableReader()
 template<class Type>
 void Foam::tableReader<Type>::write(Ostream& os) const
 {
-    if (this->type() != "openFoam")
-    {
-        os.writeEntry("readerType", this->type());
-    }
+    os.writeEntryIfDifferent<word>("readerType", "openFoam", this->type());
 }
 
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C
index 321e8f3d3df2edb4d1124047baa47f1b6190538d..4e402464c31c9025301f6316c91068b108fda45d 100644
--- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C
+++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C
@@ -704,11 +704,9 @@ void Foam::GAMGAgglomeration::calculateRegionMaster
     // processor
     agglomProcIDs = findIndices(procAgglomMap, myAgglom);
     // Make sure the master is the first element.
-    label index = findIndex
-    (
-        agglomProcIDs,
-        agglomToMaster[myAgglom]
-    );
+    const label index =
+        agglomProcIDs.find(agglomToMaster[myAgglom]);
+
     Swap(agglomProcIDs[0], agglomProcIDs[index]);
 }
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C
index 5095e2be6f8fcd53dc707373d3e2c2dd6d3d2209..ee20d9b461ba4e1397c45232e9517e3904641b3e 100644
--- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C
+++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C
@@ -634,7 +634,7 @@ bool Foam::GAMGAgglomeration::checkRestriction
     {
         labelList& masters = coarseToMasters[restrict[celli]];
 
-        if (findIndex(masters, master[celli]) == -1)
+        if (!masters.found(master[celli]))
         {
             masters.append(master[celli]);
             nNewCoarse++;
@@ -672,7 +672,7 @@ bool Foam::GAMGAgglomeration::checkRestriction
         {
             label coarseI = restrict[celli];
 
-            label index = findIndex(coarseToMasters[coarseI], master[celli]);
+            label index = coarseToMasters[coarseI].find(master[celli]);
             newRestrict[celli] = coarseToNewCoarse[coarseI][index];
         }
 
diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C
index 4c64f2dbfae3ba307ad4959a63c0ab742953cfcf..21cb8365d548344dfce660ae75c4ec726307c4dc 100644
--- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C
+++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/manualGAMGProcAgglomeration/manualGAMGProcAgglomeration.C
@@ -133,11 +133,8 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate()
                             procAgglomMap[cluster[i]] = coarseI;
                         }
 
-                        label masterIndex = findIndex
-                        (
-                            cluster,
-                            coarseToMaster[coarseI]
-                        );
+                        const label masterIndex =
+                            cluster.find(coarseToMaster[coarseI]);
 
                         if (masterIndex == -1)
                         {
@@ -150,7 +147,7 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate()
                                 << exit(FatalError);
                         }
 
-                        if (findIndex(cluster, myProcID) != -1)
+                        if (cluster.found(myProcID))
                         {
                             // This is my cluster. Make sure master index is
                             // first
@@ -161,12 +158,12 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate()
 
 
                     // Check that we've done all processors
-                    if (findIndex(procAgglomMap, -1) != -1)
+                    if (procAgglomMap.found(-1))
                     {
                         FatalErrorInFunction
                             << "At level " << fineLevelIndex
                             << " processor "
-                            << findIndex(procAgglomMap, -1)
+                            << procAgglomMap.find(-1)
                             << " is not in any cluster"
                             << exit(FatalError);
                     }
diff --git a/src/OpenFOAM/memory/refCount/refCount.H b/src/OpenFOAM/memory/refCount/refCount.H
index a4a208b3c05c6d2488836677f4b1897cdd072de8..1f90ba73a490b1b0e0337ec6cd4559f817095daf 100644
--- a/src/OpenFOAM/memory/refCount/refCount.H
+++ b/src/OpenFOAM/memory/refCount/refCount.H
@@ -36,8 +36,6 @@ See also
 #ifndef refCount_H
 #define refCount_H
 
-#include "bool.H"
-
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
@@ -50,20 +48,10 @@ namespace Foam
 class refCount
 {
     // Private data
+    int count_;
 
-        int count_;
-
-
-    // Private Member Functions
-
-        //- Dissallow copy
-        refCount(const refCount&);
-
-        //- Dissallow bitwise assignment
-        void operator=(const refCount&);
 
-
-protected:
+public:
 
     // Constructors
 
@@ -74,8 +62,6 @@ protected:
         {}
 
 
-public:
-
     // Member Functions
 
         //- Return the current reference count
@@ -87,7 +73,7 @@ public:
         //- Return true if the reference count is zero
         bool unique() const
         {
-            return count_ == 0;
+            return !count_;
         }
 
 
@@ -96,25 +82,25 @@ public:
         //- Increment the reference count
         void operator++()
         {
-            count_++;
+            ++count_;
         }
 
         //- Increment the reference count
         void operator++(int)
         {
-            count_++;
+            ++count_;
         }
 
         //- Decrement the reference count
         void operator--()
         {
-            count_--;
+            --count_;
         }
 
         //- Decrement the reference count
         void operator--(int)
         {
-            count_--;
+            --count_;
         }
 };
 
diff --git a/src/OpenFOAM/memory/tmp/tmp.H b/src/OpenFOAM/memory/tmp/tmp.H
index 0da141b95a0748c0337de26aa9f91043ceb9e82c..de9d05befda48893823ff77deac28c14d18d5ebf 100644
--- a/src/OpenFOAM/memory/tmp/tmp.H
+++ b/src/OpenFOAM/memory/tmp/tmp.H
@@ -161,7 +161,7 @@ public:
         //- Assignment to pointer changing this tmp to a temporary T
         inline void operator=(T* tPtr);
 
-        //- Assignment transfering the temporary T to this tmp
+        //- Assignment transferring the temporary T to this tmp
         inline void operator=(const tmp<T>& t);
 };
 
diff --git a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C
index e68137a628f921d8de72d62a7107ec960ef50bf4..0f9a8c111432261a6bfa4ec5a8860a77915f96eb 100644
--- a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C
+++ b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C
@@ -82,7 +82,7 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
             return -1;
         }
 
-        label index = findIndex(patchIDs, thisPatch.index());
+        label index = patchIDs.find(thisPatch.index());
 
         if (index == -1)
         {
diff --git a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C
index c535e5b0bf6c9ad6d5f03a2d51013e4972d7ae54..274549fb3c7bb325a1cfba4c28cc5ff1281075c7 100644
--- a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C
+++ b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C
@@ -82,7 +82,7 @@ Foam::patchIdentifier::~patchIdentifier()
 
 bool Foam::patchIdentifier::inGroup(const word& name) const
 {
-    return findIndex(inGroups_, name) != -1;
+    return inGroups_.found(name);
 }
 
 
diff --git a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C
index bdd63ab03564a56243527259b5252122d77e14f7..3475700bc921259dce88bd77e9d4e81f972777d9 100644
--- a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C
+++ b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C
@@ -426,11 +426,8 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
                                 << endl;
                         }
 
-                        label nbrProcMeshI = findIndex
-                        (
-                            procIDs,
-                            pldui.neighbProcNo()
-                        );
+                        const label nbrProcMeshI =
+                            procIDs.find(pldui.neighbProcNo());
 
                         if (procMeshI < nbrProcMeshI)
                         {
@@ -625,7 +622,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
                     // Look up corresponding interfaces
                     label myP = pldui.myProcNo();
                     label nbrP = pldui.neighbProcNo();
-                    label nbrProcMeshI = findIndex(procIDs, nbrP);
+                    label nbrProcMeshI = procIDs.find(nbrP);
 
                     if (procMeshI < nbrProcMeshI)
                     {
@@ -1052,7 +1049,7 @@ void Foam::lduPrimitiveMesh::gather
             );
        }
     }
-    else if (findIndex(procIDs, Pstream::myProcNo(comm)) != -1)
+    else if (procIDs.found(Pstream::myProcNo(comm)))
     {
         // Send to master
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/indirectPointList.H b/src/OpenFOAM/meshes/meshShapes/cell/cellIndList.H
similarity index 77%
rename from src/OpenFOAM/meshes/polyMesh/zones/pointZone/indirectPointList.H
rename to src/OpenFOAM/meshes/meshShapes/cell/cellIndList.H
index 87f963d7408b833e66c4016d0a2e929cd530e44e..26a5b634ca7f8687bc37f6d254006f925fb4a920 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/indirectPointList.H
+++ b/src/OpenFOAM/meshes/meshShapes/cell/cellIndList.H
@@ -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) 2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -22,23 +22,33 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Typedef
-    Foam::indirectPointList
+    Foam::cellIndList
 
 Description
+    An IndirectList of cells.
+
+Typedef
+    Foam::cellUIndList
+
+Description
+    A UIndirectList of cells.
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef indirectPointList_H
-#define indirectPointList_H
+#ifndef cellIndList_H
+#define cellIndList_H
 
-#include "point.H"
+// Include all normal list typedefs as well
+#include "cellList.H"
 #include "IndirectList.H"
+#include "UIndirectList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    typedef IndirectList<point> indirectPointList;
+    typedef IndirectList<cell>  cellIndList;
+    typedef UIndirectList<cell> cellUIndList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cellList.H b/src/OpenFOAM/meshes/meshShapes/cell/cellList.H
index 5f776bb7aedf17ef1d75dd8ac85ef7343e46fbf7..e878ce05958d725a37b78f9a7a1c8d8281052964 100644
--- a/src/OpenFOAM/meshes/meshShapes/cell/cellList.H
+++ b/src/OpenFOAM/meshes/meshShapes/cell/cellList.H
@@ -25,7 +25,25 @@ Typedef
     Foam::cellList
 
 Description
-    list of cells
+    A List of cells.
+
+Typedef
+    Foam::cellUList
+
+Description
+    A UList of cells.
+
+Typedef
+    Foam::cellSubList
+
+Description
+    A SubList of cells.
+
+Typedef
+    Foam::cellListList
+
+Description
+    A List of cellList.
 
 \*---------------------------------------------------------------------------*/
 
@@ -34,15 +52,8 @@ Description
 
 #include "cell.H"
 #include "List.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-    typedef List<cell> cellList;
-}
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+#include "SubList.H"
+#include "cellListFwd.H"
 
 #endif
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/indirectCellList.H b/src/OpenFOAM/meshes/meshShapes/cell/cellListFwd.H
similarity index 78%
rename from src/OpenFOAM/meshes/polyMesh/zones/cellZone/indirectCellList.H
rename to src/OpenFOAM/meshes/meshShapes/cell/cellListFwd.H
index 0ac8c1c38e54174c5582223ec75ec15271eedd86..c616384a7aaffd40ea8ce84bf14ebdf41dcdc2b1 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/indirectCellList.H
+++ b/src/OpenFOAM/meshes/meshShapes/cell/cellListFwd.H
@@ -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) 2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -21,24 +21,30 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-Typedef
-    Foam::indirectCellList
+Header
+    cellListFwd.H
 
 Description
+    Forwards for various types of cell lists
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef indirectCellList_H
-#define indirectCellList_H
+#ifndef cellListFwd_H
+#define cellListFwd_H
 
-#include "cell.H"
-#include "IndirectList.H"
+#include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    typedef IndirectList<cell> indirectCellList;
+    class cell;
+
+    typedef UList<cell> cellUList;
+    typedef List<cell> cellList;
+    typedef SubList<cell> cellSubList;
+    typedef List<cellList> cellListList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H
index aecb9a9c2e416c1acc4b055fcf1c4ff12e162b17..dabdc197efa866c56d3c5818af7682019c346e42 100644
--- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H
+++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H
@@ -28,7 +28,7 @@ Description
     An edge is a list of two point labels. The functionality it provides
     supports the discretisation on a 2-D flat mesh.
 
-    The edge is implemented as a FixedList of labels.
+    The edge is implemented as a Pair/FixedList of labels.
     As well as geometrically relevant methods, it also provides methods
     similar to HashSet for additional convenience.
     Valid point labels are always non-negative (since they correspond to
@@ -37,6 +37,7 @@ Description
     can be filled with a HashSet-like functionality.
 
 SourceFiles
+    edge.C
     edgeI.H
 
 \*---------------------------------------------------------------------------*/
@@ -44,10 +45,9 @@ SourceFiles
 #ifndef edge_H
 #define edge_H
 
-#include "FixedList.H"
 #include "labelPair.H"
-#include "pointField.H"
 #include "linePointRef.H"
+#include "pointField.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -60,7 +60,7 @@ namespace Foam
 
 class edge
 :
-    public FixedList<label, 2>
+    public labelPair
 {
     // Private Member Functions
 
@@ -93,19 +93,19 @@ public:
         //- Construct null with invalid point labels (-1)
         inline edge();
 
-        //- Construct from components
+        //- Construct from two point labels
         inline edge(const label from, const label to);
 
-        //- Construct, optionally sorted with start less-than end
-        inline edge(const label from, const label to, const bool doSort);
-
-        //- Construct from two labels
+        //- Construct from pair of labels
         inline edge(const labelPair& pair);
 
-        //- Construct from FixedList
+        //- Construct from list
         inline edge(const FixedList<label, 2>& lst);
 
-        //- Construct, optionally sorted with start less-than end
+        //- Construct from two point labels, sorted with first less-than second
+        inline edge(const label from, const label to, const bool doSort);
+
+        //- Construct from list, sorted with first less-than second
         inline edge(const FixedList<label, 2>& lst, const bool doSort);
 
         //- Construct from Istream
@@ -116,16 +116,26 @@ public:
 
       // Access
 
-        //- Return start vertex label
+        //- Return first vertex label
+        using labelPair::first;
+
+        //- Return last (second) vertex label
+        using labelPair::last;
+
+        //- Return second (last) vertex label
+        using labelPair::second;
+
+
+        //- Return start (first) vertex label
         inline label start() const;
 
-        //- Return start vertex label
+        //- Return start (first) vertex label
         inline label& start();
 
-        //- Return end vertex label
+        //- Return end (last/second) vertex label
         inline label end() const;
 
-        //- Return end vertex label
+        //- Return end (last/second) vertex label
         inline label& end();
 
         //- Return reverse edge as copy.
@@ -143,10 +153,6 @@ public:
         //  No special handling of negative point labels.
         inline label maxVertex() const;
 
-        //- True if start() is less-than end()
-        //  No special handling of negative point labels.
-        inline bool sorted() const;
-
         //- Return true if point label is found in edge.
         //  Always false for a negative label.
         inline bool found(const label pointLabel) const;
@@ -175,14 +181,6 @@ public:
         //  Return the effective size after collapsing.
         inline label collapse();
 
-        //- Flip the edge in-place.
-        //  No special handling of negative point labels.
-        inline void flip();
-
-        //- Sort so that start() is less-than end()
-        //  No special handling of negative point labels.
-        inline void sort();
-
 
      // Hash-like functions
 
@@ -211,8 +209,8 @@ public:
         //  Returns true on success. Negative labels never insert.
         //  Return the number of slots filled.
         //  Similar to a HashTable::insert().
-        template<unsigned AnySize>
-        inline label insert(const FixedList<label, AnySize>& lst);
+        template<unsigned Size>
+        inline label insert(const FixedList<label, Size>& lst);
 
         //- Fill open slots with the indices if they did not previously exist.
         //  Returns true on success. Negative labels never insert.
@@ -231,8 +229,8 @@ public:
 
         //- Remove existing indices from the edge and set locations to '-1'.
         //  Returns the number of changes.
-        template<unsigned AnySize>
-        inline label erase(const FixedList<label, AnySize>& lst);
+        template<unsigned Size>
+        inline label erase(const FixedList<label, Size>& lst);
 
         //- Remove existing indices from the edge and set locations to '-1'.
         //  Returns the number of changes.
@@ -265,7 +263,7 @@ public:
      // Comparison
 
         //- Compare edges
-        //  Returns:
+        //  \return
         //  -  0: different
         //  - +1: identical values and order used
         //  - -1: identical values, but in different order
@@ -274,7 +272,14 @@ public:
 };
 
 
-// Global Operators
+// * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * * //
+
+//- Return reverse of an edge
+inline edge reverse(const edge& e)
+{
+    return edge(e.second(), e.first());
+}
+
 
 //- Compare edges for equal content, ignoring orientation
 inline bool operator==(const edge& a, const edge& b);
@@ -290,15 +295,15 @@ inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const
 {
     unsigned val = seed;
 
-    if (e[0] < e[1])
+    if (e.first() < e.second())
     {
-        val = Hash<label>()(e[0], val);
-        val = Hash<label>()(e[1], val);
+        val = Hash<label>()(e.first(), val);
+        val = Hash<label>()(e.second(), val);
     }
     else
     {
-        val = Hash<label>()(e[1], val);
-        val = Hash<label>()(e[0], val);
+        val = Hash<label>()(e.second(), val);
+        val = Hash<label>()(e.first(), val);
     }
 
     return val;
@@ -313,7 +318,7 @@ inline unsigned Hash<edge>::operator()(const edge& e) const
     return Hash<edge>()(e, 0);
 }
 
-
+// Edges are a pair of labels - thus contiguous
 template<>
 inline bool contiguous<edge>()  {return true;}
 
diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
index e4ca81e9386f6abb51f0abc14ba2035222656268..db939da2aac5c7670af599319bf2c63d453f64e6 100644
--- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
+++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
@@ -24,24 +24,12 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "IOstreams.H"
-#include "Swap.H"
 
 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
 
 inline int Foam::edge::compare(const edge& a, const edge& b)
 {
-    if (a[0] == b[0] && a[1] == b[1])
-    {
-        return 1;
-    }
-    else if (a[0] == b[1] && a[1] == b[0])
-    {
-        return -1;
-    }
-    else
-    {
-        return 0;
-    }
+    return labelPair::compare(a, b);
 }
 
 
@@ -56,7 +44,7 @@ inline Foam::label Foam::edge::insertMultiple
 {
     // Available slots.
     // Don't use count() since it has special treatment for duplicates
-    const int maxChange = (start() < 0 ? 1 : 0) + (end() < 0 ? 1 : 0);
+    const int maxChange = (first() < 0 ? 1 : 0) + (second() < 0 ? 1 : 0);
 
     int changed = 0;
     if (maxChange)
@@ -86,7 +74,7 @@ inline Foam::label Foam::edge::eraseMultiple
 {
     // Occupied slots.
     // Don't use count() since it has special treatment for duplicates
-    const int maxChange = (start() >= 0 ? 1 : 0) + (end() >= 0 ? 1 : 0);
+    const int maxChange = (first() >= 0 ? 1 : 0) + (second() >= 0 ? 1 : 0);
 
     int changed = 0;
     if (maxChange)
@@ -109,64 +97,43 @@ inline Foam::label Foam::edge::eraseMultiple
 
 inline Foam::edge::edge()
 :
-    FixedList<label, 2>(-1)
+    labelPair(-1, -1)
 {}
 
 
 inline Foam::edge::edge(const label from, const label to)
-{
-    start() = from;
-    end()   = to;
-}
-
-
-inline Foam::edge::edge(const label from, const label to, const bool doSort)
-{
-    if (doSort && from > to)
-    {
-        start() = to;
-        end()   = from;
-    }
-    else
-    {
-        start() = from;
-        end()   = to;
-    }
-}
+:
+    labelPair(from, to)
+{}
 
 
 inline Foam::edge::edge(const labelPair& pair)
-{
-    start() = pair.first();
-    end()   = pair.second();
-}
+:
+    labelPair(pair.first(), pair.second())
+{}
 
 
 inline Foam::edge::edge(const FixedList<label, 2>& lst)
-{
-    start() = lst[0];
-    end()   = lst[1];
-}
+:
+    labelPair(lst.first(), lst.last())
+{}
+
+
+inline Foam::edge::edge(const label from, const label to, const bool doSort)
+:
+    labelPair(from, to, doSort)
+{}
 
 
 inline Foam::edge::edge(const FixedList<label, 2>& lst, const bool doSort)
-{
-    if (doSort && lst[0] > lst[1])
-    {
-        start() = lst[1];
-        end()   = lst[0];
-    }
-    else
-    {
-        start() = lst[0];
-        end()   = lst[1];
-    }
-}
+:
+    labelPair(lst, doSort)
+{}
 
 
 inline Foam::edge::edge(Istream& is)
 :
-    FixedList<label, 2>(is)
+    labelPair(is)
 {}
 
 
@@ -174,42 +141,47 @@ inline Foam::edge::edge(Istream& is)
 
 inline Foam::label Foam::edge::start() const
 {
-    return operator[](0);
+    return first();
 }
 
 inline Foam::label& Foam::edge::start()
 {
-    return operator[](0);
+    return first();
 }
 
 
 inline Foam::label Foam::edge::end() const
 {
-    return operator[](1);
+    return second();
 }
 
+
 inline Foam::label& Foam::edge::end()
 {
-    return operator[](1);
+    return second();
 }
 
 
 inline Foam::label Foam::edge::minVertex() const
 {
-    return (start() < end() ? start() : end());
+    return (first() < second() ? first() : second());
 }
 
 
 inline Foam::label Foam::edge::maxVertex() const
 {
-    return (start() > end() ? start() : end());
+    return (first() > second() ? first() : second());
 }
 
 
 inline bool Foam::edge::found(const label pointLabel) const
 {
     // -1: always false
-    return (pointLabel >= 0 && (pointLabel == start() || pointLabel == end()));
+    return
+    (
+        pointLabel >= 0
+     && (pointLabel == first() || pointLabel == second())
+    );
 }
 
 
@@ -218,11 +190,11 @@ inline Foam::label Foam::edge::which(const label pointLabel) const
     // -1: always false
     if (pointLabel >= 0)
     {
-        if (pointLabel == start())
+        if (pointLabel == first())
         {
             return 0;
         }
-        if (pointLabel == end())
+        if (pointLabel == second())
         {
             return 1;
         }
@@ -233,43 +205,39 @@ inline Foam::label Foam::edge::which(const label pointLabel) const
 
 inline bool Foam::edge::connects(const edge& other) const
 {
-    return (other.found(start()) || other.found(end()));
+    return (other.found(first()) || other.found(second()));
 }
 
 
 inline Foam::label Foam::edge::commonVertex(const edge& other) const
 {
-    if (other.found(start()))
-    {
-        return start();
-    }
-    else if (other.found(end()))
+    if (other.found(first()))
     {
-        return end();
+        return first();
     }
-    else
+    if (other.found(second()))
     {
-        // No shared vertex.
-        return -1;
+        return second();
     }
+
+    // No shared vertex.
+    return -1;
 }
 
 
 inline Foam::label Foam::edge::otherVertex(const label index) const
 {
-    if (index == start())
-    {
-        return end();
-    }
-    else if (index == end())
+    if (index == first())
     {
-        return start();
+        return second();
     }
-    else
+    if (index == second())
     {
-        // The given vertex is not on the edge in the first place.
-        return -1;
+        return first();
     }
+
+    // The given vertex is not on the edge in the first place.
+    return -1;
 }
 
 
@@ -280,12 +248,12 @@ inline Foam::label Foam::edge::collapse()
     // catch any '-1' (eg, if called multiple times)
 
     label n = 2;
-    if (start() == end() || end() < 0)
+    if (first() == second() || second() < 0)
     {
-        end() = -1;
+        second() = -1;
         --n;
     }
-    if (start() < 0)
+    if (first() < 0)
     {
         --n;
     }
@@ -294,48 +262,27 @@ inline Foam::label Foam::edge::collapse()
 }
 
 
-inline bool Foam::edge::sorted() const
-{
-    return (start() < end());
-}
-
-
-inline void Foam::edge::sort()
-{
-    if (start() > end())
-    {
-        flip();
-    }
-}
-
-
-inline void Foam::edge::flip()
-{
-    Swap(operator[](0), operator[](1));
-}
-
-
 inline Foam::edge Foam::edge::reverseEdge() const
 {
-    return edge(end(), start());
+    return edge(second(), first());
 }
 
 
 inline void Foam::edge::clear()
 {
-    start() = -1;
-    end()   = -1;
+    first()  = -1;
+    second() = -1;
 }
 
 
 inline Foam::label Foam::edge::count() const
 {
     label n = 2;
-    if (start() == end() || end() < 0)
+    if (first() == second() || second() < 0)
     {
         --n;
     }
-    if (start() < 0)
+    if (first() < 0)
     {
         --n;
     }
@@ -346,7 +293,7 @@ inline Foam::label Foam::edge::count() const
 
 inline bool Foam::edge::empty() const
 {
-    return (start() < 0 && end() < 0);
+    return (first() < 0 && second() < 0);
 }
 
 
@@ -358,21 +305,21 @@ inline bool Foam::edge::insert(const label index)
         return false;
     }
 
-    if (start() < 0)
+    if (first() < 0)
     {
-        // Store at [0], if not duplicate of [1]
-        if (index != end())
+        // Store at first, if not duplicate of second
+        if (index != second())
         {
-            start() = index;
+            first() = index;
             return true;
         }
     }
-    else if (end() < 0)
+    else if (second() < 0)
     {
-        // Store at [1], if not duplicate of [0]
-        if (index != start())
+        // Store at second, if not duplicate of first
+        if (index != first())
         {
-            end() = index;
+            second() = index;
             return true;
         }
     }
@@ -387,8 +334,8 @@ inline Foam::label Foam::edge::insert(const UList<label>& lst)
 }
 
 
-template<unsigned AnySize>
-inline Foam::label Foam::edge::insert(const FixedList<label, AnySize>& lst)
+template<unsigned Size>
+inline Foam::label Foam::edge::insert(const FixedList<label, Size>& lst)
 {
     return insertMultiple(lst.begin(), lst.end());
 }
@@ -409,16 +356,16 @@ inline Foam::label Foam::edge::erase(const label index)
     }
 
     label n = 0;
-    if (index == start())
+    if (index == first())
     {
-        start() = -1;
+        first() = -1;
         ++n;
     }
 
     // Automatically handle duplicates, which should not have been there anyhow
-    if (index == end())
+    if (index == second())
     {
-        end() = -1;
+        second() = -1;
         ++n;
     }
 
@@ -432,8 +379,8 @@ inline Foam::label Foam::edge::erase(const UList<label>& lst)
 }
 
 
-template<unsigned AnySize>
-inline Foam::label Foam::edge::erase(const FixedList<label, AnySize>& lst)
+template<unsigned Size>
+inline Foam::label Foam::edge::erase(const FixedList<label, Size>& lst)
 {
     return eraseMultiple(lst.begin(), lst.end());
 }
@@ -450,7 +397,7 @@ inline Foam::label Foam::edge::erase(std::initializer_list<label> lst)
 inline Foam::point Foam::edge::centre(const UList<point>& pts) const
 {
     #ifdef FULLDEBUG
-    if (start() < 0 || end() < 0)
+    if (first() < 0 || second() < 0)
     {
         FatalErrorInFunction
             << "negative point index on edge " << *this
@@ -458,14 +405,14 @@ inline Foam::point Foam::edge::centre(const UList<point>& pts) const
     }
     #endif
 
-    return 0.5*(pts[start()] + pts[end()]);
+    return 0.5*(pts[first()] + pts[second()]);
 }
 
 
 inline Foam::vector Foam::edge::vec(const UList<point>& pts) const
 {
     #ifdef FULLDEBUG
-    if (start() < 0 || end() < 0)
+    if (first() < 0 || second() < 0)
     {
         FatalErrorInFunction
             << "negative point index on edge " << *this
@@ -473,14 +420,14 @@ inline Foam::vector Foam::edge::vec(const UList<point>& pts) const
     }
     #endif
 
-    return pts[end()] - pts[start()];
+    return pts[second()] - pts[first()];
 }
 
 
 inline Foam::vector Foam::edge::unitVec(const UList<point>& pts) const
 {
     #ifdef FULLDEBUG
-    if (start() < 0 || end() < 0)
+    if (first() < 0 || second() < 0)
     {
         FatalErrorInFunction
             << "negative point index on edge " << *this
@@ -488,7 +435,7 @@ inline Foam::vector Foam::edge::unitVec(const UList<point>& pts) const
     }
     #endif
 
-    Foam::vector v = pts[end()] - pts[start()];
+    Foam::vector v = pts[second()] - pts[first()];
     v /= ::Foam::mag(v) + VSMALL;
 
     return v;
@@ -504,7 +451,7 @@ inline Foam::scalar Foam::edge::mag(const UList<point>& pts) const
 inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const
 {
     #ifdef FULLDEBUG
-    if (start() < 0 || end() < 0)
+    if (first() < 0 || second() < 0)
     {
         FatalErrorInFunction
             << "negative point index on edge " << *this
@@ -512,7 +459,7 @@ inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const
     }
     #endif
 
-    return linePointRef(pts[start()], pts[end()]);
+    return linePointRef(pts[first()], pts[second()]);
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/indirectFaceList.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeIndList.H
similarity index 77%
rename from src/OpenFOAM/meshes/polyMesh/zones/faceZone/indirectFaceList.H
rename to src/OpenFOAM/meshes/meshShapes/edge/edgeIndList.H
index 81a125cfe66d4b641b296ce8be7fc1068795cbfd..2cd77b797eaaea877ae163e300378d4571e88796 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/indirectFaceList.H
+++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeIndList.H
@@ -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) 2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -22,23 +22,33 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Typedef
-    Foam::indirectFaceList
+    Foam::edgeIndList
 
 Description
+    An IndirectList of edges.
+
+Typedef
+    Foam::edgeUIndList
+
+Description
+    A UIndirectList of edges.
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef indirectFaceList_H
-#define indirectFaceList_H
+#ifndef edgeIndList_H
+#define edgeIndList_H
 
-#include "face.H"
+// Include all normal list typedefs as well
+#include "edgeList.H"
 #include "IndirectList.H"
+#include "UIndirectList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    typedef IndirectList<face> indirectFaceList;
+    typedef IndirectList<edge>  edgeIndList;
+    typedef UIndirectList<edge> edgeUIndList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H
index 177a36aeb485b09935637ae5271f082d8aaa5a6a..17f0ab96e28117dbab04b25ce99733187cbb2809 100644
--- a/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H
+++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeList.H
@@ -24,18 +24,42 @@ License
 Typedef
     Foam::edgeList
 
+Description
+    A List of edges.
+
+Typedef
+    Foam::edgeUList
+
+Description
+    A UList of edges.
+
+Typedef
+    Foam::edgeSubList
+
+Description
+    A SubList of edges.
+
+Typedef
+    Foam::edgeListList
+
+Description
+    A List of edgeList.
+
 \*---------------------------------------------------------------------------*/
 
 #ifndef edgeList_H
 #define edgeList_H
 
 #include "edge.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
+    typedef UList<edge> edgeUList;
     typedef List<edge> edgeList;
+    typedef SubList<edge> edgeSubList;
     typedef List<edgeList> edgeListList;
 }
 
diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C
index 9900b4e6f3a926dca1f453fc26c718612664a17a..6f44cb0314a258fa76ac943622f80a31e4195cf8 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/face.C
+++ b/src/OpenFOAM/meshes/meshShapes/face/face.C
@@ -773,14 +773,14 @@ int Foam::face::edgeDirection(const edge& e) const
 {
     forAll(*this, i)
     {
-        if (operator[](i) == e.start())
+        if (operator[](i) == e.first())
         {
-            if (operator[](rcIndex(i)) == e.end())
+            if (operator[](rcIndex(i)) == e.second())
             {
                 // Reverse direction
                 return -1;
             }
-            else if (operator[](fcIndex(i)) == e.end())
+            else if (operator[](fcIndex(i)) == e.second())
             {
                 // Forward direction
                 return 1;
@@ -789,14 +789,14 @@ int Foam::face::edgeDirection(const edge& e) const
             // No match
             return 0;
         }
-        else if (operator[](i) == e.end())
+        else if (operator[](i) == e.second())
         {
-            if (operator[](rcIndex(i)) == e.start())
+            if (operator[](rcIndex(i)) == e.first())
             {
                 // Forward direction
                 return 1;
             }
-            else if (operator[](fcIndex(i)) == e.start())
+            else if (operator[](fcIndex(i)) == e.first())
             {
                 // Reverse direction
                 return -1;
diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H
index 822e3c4f9a6fc3f146480ee1ada390afb311497f..0866a7eead9e80ce723a10b370b90b17a9885bca 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/face.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/face.H
@@ -50,6 +50,7 @@ SourceFiles
 #include "faceListFwd.H"
 #include "intersection.H"
 #include "pointHit.H"
+#include "FixedList.H"
 #include "ListListOps.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -62,8 +63,7 @@ namespace Foam
 class face;
 class triFace;
 
-template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
-class DynamicList;
+template<class T, int SizeMin> class DynamicList;
 
 inline Istream& operator>>(Istream& is, face& f);
 
@@ -107,15 +107,15 @@ class face
         //- Enumeration listing the modes for split()
         enum splitMode
         {
-            COUNTTRIANGLE,  // count if split into triangles
-            COUNTQUAD,      // count if split into triangles&quads
-            SPLITTRIANGLE,  // split into triangles
-            SPLITQUAD       // split into triangles&quads
+            COUNTTRIANGLE,  //!< count if split into triangles
+            COUNTQUAD,      //!< count if split into triangles and quads
+            SPLITTRIANGLE,  //!< split into triangles
+            SPLITQUAD       //!< split into  triangles and quads
         };
 
-        //- Split face into triangles or triangles&quads.
+        //- Split face into triangles or triangles and quads.
         //  Stores results quadFaces[quadI], triFaces[triI]
-        //  Returns number of new faces created
+        //  \return number of new faces created
         label split
         (
             const splitMode mode,
@@ -153,12 +153,19 @@ public:
         //- Construct from list of labels
         explicit inline face(const labelUList& lst);
 
+        //- Construct from list of labels
+        template<unsigned Size>
+        explicit inline face(const FixedList<label, Size>& lst);
+
         //- Construct from an initializer list of labels
         explicit inline face(std::initializer_list<label> lst);
 
-        //- Construct by transferring the parameter contents
+        //- Transfer (move) construct
         explicit inline face(const Xfer<labelList>& lst);
 
+        //- Move construct
+        explicit inline face(labelList&& lst);
+
         //- Copy construct from triFace
         face(const triFace& f);
 
@@ -312,8 +319,8 @@ public:
         //- Return n-th face edge
         inline edge faceEdge(const label n) const;
 
-        //- Return the edge direction on the face
-        //  Returns:
+        //- The edge direction on the face
+        //  \return
         //  -  0: edge not found on the face
         //  - +1: forward (counter-clockwise) on the face
         //  - -1: reverse (clockwise) on the face
@@ -344,11 +351,11 @@ public:
             //- Split into triangles using existing points.
             //  Append to DynamicList.
             //  Returns number of faces created.
-            template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+            template<int SizeMin>
             label triangles
             (
                 const UList<point>& points,
-                DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces
+                DynamicList<face, SizeMin>& triFaces
             ) const;
 
             //- Number of triangles and quads after splitting
@@ -374,9 +381,10 @@ public:
             ) const;
 
         //- Compare faces
-        //   0: different
-        //  +1: identical
-        //  -1: same face, but different orientation
+        //  \return
+        //  -  0: different
+        //  - +1: identical
+        //  - -1: same face, but different orientation
         static int compare(const face& a, const face& b);
 
         //- Return true if the faces have the same vertices
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
index d312560843c35033a0246ebfae1255704dda80b7..0ec413433d5916517114ef130aa9cefc878a6a96 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
@@ -57,6 +57,13 @@ inline Foam::face::face(const labelUList& lst)
 {}
 
 
+template<unsigned Size>
+inline Foam::face::face(const FixedList<label, Size>& lst)
+:
+    labelList(lst)
+{}
+
+
 inline Foam::face::face(std::initializer_list<label> lst)
 :
     labelList(lst)
@@ -69,6 +76,12 @@ inline Foam::face::face(const Xfer<labelList>& lst)
 {}
 
 
+inline Foam::face::face(labelList&& lst)
+:
+    labelList(std::move(lst))
+{}
+
+
 inline Foam::face::face(Istream& is)
 {
     is >> *this;
@@ -87,9 +100,10 @@ inline Foam::pointField Foam::face::points
 
     // For each point in list, set it to the point in 'pnts' addressed
     // by 'labs'
-    forAll(p, i)
+    label i = 0;
+    for (const label pointi : *this)
     {
-        p[i] = meshPoints[operator[](i)];
+        p[i++] = meshPoints[pointi];
     }
 
     // Return list
@@ -124,13 +138,13 @@ inline bool Foam::face::found(const label globalIndex) const
 
 inline Foam::label Foam::face::nextLabel(const label i) const
 {
-    return operator[](fcIndex(i));
+    return this->fcValue(i);
 }
 
 
 inline Foam::label Foam::face::prevLabel(const label i) const
 {
-    return operator[](rcIndex(i));
+    return this->rcValue(i);
 }
 
 
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceIndList.H b/src/OpenFOAM/meshes/meshShapes/face/faceIndList.H
new file mode 100644
index 0000000000000000000000000000000000000000..b7a89ee7374a139791cdea03efa4a3e9fccbe83c
--- /dev/null
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceIndList.H
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Typedef
+    Foam::faceIndList
+
+Description
+    An IndirectList of faces.
+
+Typedef
+    Foam::faceUIndList
+
+Description
+    A UIndirectList of faces.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef faceIndList_H
+#define faceIndList_H
+
+// Include all normal list typedefs as well
+#include "faceList.H"
+#include "IndirectList.H"
+#include "UIndirectList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef IndirectList<face>  faceIndList;
+    typedef UIndirectList<face> faceUIndList;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceList.H b/src/OpenFOAM/meshes/meshShapes/face/faceList.H
index 19684fff19088710e3adf27428380f52a6538de4..337b3f24029d7e1624e43e9bd5c01e461d0d160f 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceList.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceList.H
@@ -25,6 +25,25 @@ Typedef
     Foam::faceList
 
 Description
+    A List of faces.
+
+Typedef
+    Foam::faceUList
+
+Description
+    A UList of faces.
+
+Typedef
+    Foam::faceSubList
+
+Description
+    A SubList of faces.
+
+Typedef
+    Foam::faceListList
+
+Description
+    A List of faceList.
 
 \*---------------------------------------------------------------------------*/
 
@@ -36,8 +55,6 @@ Description
 #include "SubList.H"
 #include "faceListFwd.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H b/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H
index 0caf8a454a2d93c03ad9e66ada975b8d86d20ab9..fadad20bebd30d5c134db414f0178078765b5034 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H
@@ -21,10 +21,11 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-Typedef
-    Foam::faceListFwd
+Header
+    faceListFwd.H
 
 Description
+    Forwards for various types of face lists
 
 \*---------------------------------------------------------------------------*/
 
@@ -39,6 +40,7 @@ Description
 namespace Foam
 {
     class face;
+
     typedef UList<face> faceUList;
     typedef List<face> faceList;
     typedef SubList<face> faceSubList;
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C b/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C
index 112a5703fbe6b7803dd133252aa9190974698f9f..9f9bb58844ea96b96fc5483a3c32bf51e61f3407 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C
@@ -28,11 +28,11 @@ License
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
+template<int SizeMin>
 Foam::label Foam::face::triangles
 (
     const UList<point>& points,
-    DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces
+    DynamicList<face, SizeMin>& triFaces
 ) const
 {
     label triI = triFaces.size();
diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
index 301b845d112a82499420b4de2eeddd3daf6f4477..ea18b760194a8d3708a028dd8eeaacd1c40e7e6c 100644
--- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
+++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
@@ -86,7 +86,7 @@ public:
             const label c
         );
 
-        //- Construct from a list of 3 labels.
+        //- Copy construct from a list of 3 labels.
         explicit inline triFace(const labelUList& lst);
 
         //- Construct from an initializer list of 3 labels
@@ -223,14 +223,14 @@ public:
         inline edge faceEdge(const label n) const;
 
         //- Return the edge direction on the face
-        //  Returns:
+        //  \return
         //  - +1: forward (counter-clockwise) on the face
         //  - -1: reverse (clockwise) on the face
         //  -  0: edge not found on the face
         inline int edgeDirection(const edge& e) const;
 
         //- Compare triFaces
-        //  Returns:
+        //  \return:
         //  -  0: different
         //  - +1: identical
         //  - -1: same face, but different orientation
diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
index ae2545a7aa233e8542a9e4e644e1f098bd6b3c09..bc99e45518cd599c81015c72f062e54ca3b4bf56 100644
--- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
@@ -147,13 +147,7 @@ inline Foam::pointField Foam::triFace::points(const UList<point>& points) const
 
 inline Foam::face Foam::triFace::triFaceFace() const
 {
-    Foam::face f(3);
-
-    f[0] = operator[](0);
-    f[1] = operator[](1);
-    f[2] = operator[](2);
-
-    return f;
+    return Foam::face(*this);
 }
 
 
@@ -342,14 +336,14 @@ inline Foam::edgeList Foam::triFace::edges() const
 {
     edgeList e(3);
 
-    e[0].start() = operator[](0);
-    e[0].end()   = operator[](1);
+    e[0].first()  = operator[](0);
+    e[0].second() = operator[](1);
 
-    e[1].start() = operator[](1);
-    e[1].end()   = operator[](2);
+    e[1].first()  = operator[](1);
+    e[1].second() = operator[](2);
 
-    e[2].start() = operator[](2);
-    e[2].end()   = operator[](0);
+    e[2].first()  = operator[](2);
+    e[2].second() = operator[](0);
 
     return e;
 }
@@ -369,18 +363,18 @@ inline int Foam::triFace::edgeDirection(const edge& e) const
 {
     if
     (
-        (operator[](0) == e.start() && operator[](1) == e.end())
-     || (operator[](1) == e.start() && operator[](2) == e.end())
-     || (operator[](2) == e.start() && operator[](0) == e.end())
+        (operator[](0) == e.first() && operator[](1) == e.second())
+     || (operator[](1) == e.first() && operator[](2) == e.second())
+     || (operator[](2) == e.first() && operator[](0) == e.second())
     )
     {
         return 1;
     }
     else if
     (
-        (operator[](0) == e.end() && operator[](1) == e.start())
-     || (operator[](1) == e.end() && operator[](2) == e.start())
-     || (operator[](2) == e.end() && operator[](0) == e.start())
+        (operator[](0) == e.second() && operator[](1) == e.first())
+     || (operator[](1) == e.second() && operator[](2) == e.first())
+     || (operator[](2) == e.second() && operator[](0) == e.first())
     )
     {
         return -1;
diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
index 81dbaf798d8e96f33f89aacead1876bbe72c34ff..8a693b037ac407a38e159876a41c6c5afa79ddd5 100644
--- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
+++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
@@ -1395,10 +1395,9 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
                 // Add all slaveBFaces. Note that need to check for
                 // uniqueness only in case of cyclics.
 
-                forAll(slaveBFaces, j)
+                for (const label slave : slaveBFaces)
                 {
-                    label slave = slaveBFaces[j];
-                    if (findIndex(SubList<label>(myBFaces, sz), slave) == -1)
+                    if (!SubList<label>(myBFaces, sz).found(slave))
                     {
                         myBFaces[n++] = slave;
                     }
@@ -1434,11 +1433,10 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
                 const labelList& slaveBFaces =
                     globalPointBoundaryFaces[transformedSlaves[i]];
 
-                forAll(slaveBFaces, j)
+                for (const label slave : slaveBFaces)
                 {
-                    label slave = slaveBFaces[j];
                     // Check that same face not already present untransformed
-                    if (findIndex(untrafoFaces, slave)== -1)
+                    if (!untrafoFaces.found(slave))
                     {
                         label proci = globalIndices.whichProcID(slave);
                         label facei = globalIndices.toLocal(proci, slave);
@@ -1624,10 +1622,9 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
                 // Add all slaveBCells. Note that need to check for
                 // uniqueness only in case of cyclics.
 
-                forAll(slaveBCells, j)
+                for (const label slave : slaveBCells)
                 {
-                    label slave = slaveBCells[j];
-                    if (findIndex(SubList<label>(myBCells, sz), slave) == -1)
+                    if (!SubList<label>(myBCells, sz).found(slave))
                     {
                         myBCells[n++] = slave;
                     }
@@ -1663,12 +1660,10 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
                 const labelList& slaveBCells =
                     globalPointBoundaryCells[transformedSlaves[i]];
 
-                forAll(slaveBCells, j)
+                for (const label slave : slaveBCells)
                 {
-                    label slave = slaveBCells[j];
-
                     // Check that same cell not already present untransformed
-                    if (findIndex(untrafoCells, slave)== -1)
+                    if (!untrafoCells.found(slave))
                     {
                         label proci = globalIndices.whichProcID(slave);
                         label celli = globalIndices.toLocal(proci, slave);
diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C
index 2cace80f4b5cb73f23f374b155301ccc857928f4..9ddd3502634742193dd10c9fd2f2821b0bfc85da 100644
--- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C
+++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C
@@ -138,20 +138,18 @@ void Foam::globalPoints::addToSend
     // information is the patch faces using the point and the relative position
     // of the point in the face)
 
-    label meshPointi = pp.meshPoints()[patchPointi];
+    const label meshPointi = pp.meshPoints()[patchPointi];
 
     // Add all faces using the point so we are sure we find it on the
     // other side.
     const labelList& pFaces = pp.pointFaces()[patchPointi];
 
-    forAll(pFaces, i)
+    for (const label patchFacei : pFaces)
     {
-        label patchFacei = pFaces[i];
-
         const face& f = pp[patchFacei];
 
         patchFaces.append(patchFacei);
-        indexInFace.append(findIndex(f, meshPointi));
+        indexInFace.append(f.find(meshPointi));
 
         // Add patch transformation
         allInfo.append(addSendTransform(pp.index(), knownInfo));
diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C
index fce5b416c3c438b0163d9e05ef41a8f92823eeff..67c436c4b89a0c704c9eba26453d9794923430ab 100644
--- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C
+++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C
@@ -89,7 +89,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
 
             forAll(nbrData, i)
             {
-                if (findIndex(allComms, nbrData[i]) == -1)
+                if (!allComms.found(nbrData[i]))
                 {
                     label sz = allComms.size();
                     allComms.setSize(sz+1);
diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H
index 32ad8ee634440b9bc86d74183ee85d25819688c1..b0bfc8d58571d94fedfc4af53ca2ef102f13e2d3 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H
@@ -163,12 +163,12 @@ public:
         //- Return patch indices for all matches. Optionally matches patchGroups
         labelList findIndices
         (
-            const keyType&,
+            const keyType& key,
             const bool usePatchGroups = true
         ) const;
 
         //- Return patch index for the first match, return -1 if not found
-        label findIndex(const keyType&) const;
+        label findIndex(const keyType& key) const;
 
         //- Find patch index given a name
         label findPatchID
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
index ee160048be8d0b8c34f8c21f4e85cfc340f27081..65eeb613a44cd80130c78983384dff1b2670a00f 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
@@ -38,8 +38,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells
     const cellShapeList& c
 ) const
 {
-    List<DynamicList<label, primitiveMesh::cellsPerPoint_>>
-        pc(points().size());
+    List<DynamicList<label>> pc(points().size());
 
     // For each cell
     forAll(c, i)
@@ -51,8 +50,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells
         {
             // Set working point label
             label curPoint = labels[j];
-            DynamicList<label, primitiveMesh::cellsPerPoint_>& curPointCells =
-                pc[curPoint];
+            DynamicList<label>& curPointCells = pc[curPoint];
 
             // Enter the cell label in the point's cell list
             curPointCells.append(i);
@@ -595,7 +593,7 @@ Foam::polyMesh::polyMesh
 
         // Check if there already exists a defaultFaces patch as last patch
         // and reuse it.
-        label patchi = findIndex(boundaryPatchNames, defaultBoundaryPatchName);
+        label patchi = boundaryPatchNames.find(defaultBoundaryPatchName);
 
         if (patchi != -1)
         {
@@ -868,7 +866,7 @@ Foam::polyMesh::polyMesh
 
         // Check if there already exists a defaultFaces patch as last patch
         // and reuse it.
-        label patchi = findIndex(boundaryPatchNames, defaultBoundaryPatchName);
+        label patchi = boundaryPatchNames.find(defaultBoundaryPatchName);
 
         if (patchi != -1)
         {
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C
index 22a1e1b0f78eac1631b19d8594f39c8f513635cf..6421a4ee53eef0e3874deb510fe156ce62fd74e1 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/generic/genericPolyPatch.C
@@ -126,10 +126,10 @@ const Foam::word& Foam::genericPolyPatch::actualType() const
 
 void Foam::genericPolyPatch::write(Ostream& os) const
 {
-    os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl;
+    os.writeEntry("type", actualTypeName_);
     patchIdentifier::write(os);
-    os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
-    os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
+    os.writeEntry("nFaces", size());
+    os.writeEntry("startFace", start());
 
     forAllConstIter(dictionary, dict_, iter)
     {
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
index d83efd4fed7df88b83a4e5e363630a505745e1b7..6544881f4a2f01e49a581af998b70f93bae0a1ab 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
@@ -1447,24 +1447,20 @@ void Foam::cyclicPolyPatch::write(Ostream& os) const
     coupledPolyPatch::write(os);
     if (!neighbPatchName_.empty())
     {
-        os.writeKeyword("neighbourPatch") << neighbPatchName_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("neighbourPatch", neighbPatchName_);
     }
     coupleGroup_.write(os);
     switch (transform())
     {
         case ROTATIONAL:
         {
-            os.writeKeyword("rotationAxis") << rotationAxis_
-                << token::END_STATEMENT << nl;
-            os.writeKeyword("rotationCentre") << rotationCentre_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("rotationAxis", rotationAxis_);
+            os.writeEntry("rotationCentre", rotationCentre_);
             break;
         }
         case TRANSLATIONAL:
         {
-            os.writeKeyword("separationVector") << separationVector_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("separationVector", separationVector_);
             break;
         }
         case NOORDERING:
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C
index 7fdf0634754ceb3c1556e2f82ccad5217e122a32..5001f6e238febd9068df60cc54fe7398769eaf8c 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/oldCyclic/oldCyclicPolyPatch.C
@@ -1221,28 +1221,24 @@ bool Foam::oldCyclicPolyPatch::order
 void Foam::oldCyclicPolyPatch::write(Ostream& os) const
 {
     // Replacement of polyPatch::write to write 'cyclic' instead of type():
-    os.writeKeyword("type") << cyclicPolyPatch::typeName
-        << token::END_STATEMENT << nl;
+    os.writeEntry("type", cyclicPolyPatch::typeName);
     patchIdentifier::write(os);
-    os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
-    os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
+    os.writeEntry("nFaces", size());
+    os.writeEntry("startFace", start());
 
 
-    os.writeKeyword("featureCos") << featureCos_ << token::END_STATEMENT << nl;
+    os.writeEntry("featureCos", featureCos_);
     switch (transform())
     {
         case ROTATIONAL:
         {
-            os.writeKeyword("rotationAxis") << rotationAxis_
-                << token::END_STATEMENT << nl;
-            os.writeKeyword("rotationCentre") << rotationCentre_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("rotationAxis", rotationAxis_);
+            os.writeEntry("rotationCentre", rotationCentre_);
             break;
         }
         case TRANSLATIONAL:
         {
-            os.writeKeyword("separationVector") << separationVector_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("separationVector", separationVector_);
             break;
         }
         default:
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C
index bf58d1a407490ee0cc29f8a93efa73e2a57b82cc..9c27fada85100eb122c5e1955f55ce165dffab91 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C
@@ -362,7 +362,7 @@ void Foam::processorPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
 
             const face& f = localFaces()[facei];
 
-            pointIndex[patchPointi] = findIndex(f, patchPointi);
+            pointIndex[patchPointi] = f.find(patchPointi);
         }
 
         // Express all edges as patch face and index in face.
@@ -377,7 +377,7 @@ void Foam::processorPolyPatch::initUpdateMesh(PstreamBuffers& pBufs)
 
             const labelList& fEdges = faceEdges()[facei];
 
-            edgeIndex[patchEdgeI] = findIndex(fEdges, patchEdgeI);
+            edgeIndex[patchEdgeI] = fEdges.find(patchEdgeI);
         }
 
         UOPstream toNeighbProc(neighbProcNo(), pBufs);
@@ -1112,10 +1112,8 @@ bool Foam::processorPolyPatch::order
 void Foam::processorPolyPatch::write(Ostream& os) const
 {
     coupledPolyPatch::write(os);
-    os.writeKeyword("myProcNo") << myProcNo_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("neighbProcNo") << neighbProcNo_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("myProcNo", myProcNo_);
+    os.writeEntry("neighbProcNo", neighbProcNo_);
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
index 02dcc6294add023ea3715877236fab29a8fb7527..9163b5c19c353d736f6864b170ce2051e363087c 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
@@ -337,13 +337,8 @@ bool Foam::processorCyclicPolyPatch::order
 void Foam::processorCyclicPolyPatch::write(Ostream& os) const
 {
     processorPolyPatch::write(os);
-    os.writeKeyword("referPatch") << referPatchName_
-        << token::END_STATEMENT << nl;
-    if (tag_ != -1)
-    {
-        os.writeKeyword("tag") << tag_
-            << token::END_STATEMENT << nl;
-    }
+    os.writeEntry("referPatch", referPatchName_);
+    os.writeEntryIfDifferent<label>("tag", -1, tag_);
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C
index 9263609ee5cfa6a53a7d2093189fe82268f8dc4f..d4ddce3424e4f78a0b461b87d5f7b962a7775b83 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/derived/wall/wallPolyPatch.C
@@ -51,7 +51,7 @@ Foam::wallPolyPatch::wallPolyPatch
     polyPatch(name, size, start, index, bm, patchType)
 {
     //  wall is not constraint type so add wall group explicitly
-    if (findIndex(inGroups(), typeName) == -1)
+    if (!inGroups().found(typeName))
     {
         inGroups().append(typeName);
     }
@@ -70,7 +70,7 @@ Foam::wallPolyPatch::wallPolyPatch
     polyPatch(name, dict, index, bm, patchType)
 {
     //  wall is not constraint type so add wall group explicitly
-    if (findIndex(inGroups(), typeName) == -1)
+    if (!inGroups().found(typeName))
     {
         inGroups().append(typeName);
     }
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C
index bd14deffc6b8269934234dc334a42f4483806e19..d48d7e30caa155e175ce6991c8fac798e2cb2a23 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C
@@ -99,7 +99,7 @@ Foam::polyPatch::polyPatch
     (
         patchType != word::null
      && constraintType(patchType)
-     && findIndex(inGroups(), patchType) == -1
+     && !inGroups().found(patchType)
     )
     {
         inGroups().append(patchType);
@@ -160,7 +160,7 @@ Foam::polyPatch::polyPatch
     (
         patchType != word::null
      && constraintType(patchType)
-     && findIndex(inGroups(), patchType) == -1
+     && !inGroups().found(patchType)
     )
     {
         inGroups().append(patchType);
@@ -374,10 +374,10 @@ void Foam::polyPatch::clearAddressing()
 
 void Foam::polyPatch::write(Ostream& os) const
 {
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
     patchIdentifier::write(os);
-    os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
-    os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
+    os.writeEntry("nFaces", size());
+    os.writeEntry("startFace", start());
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C
index 066c9c268f86493bfb163225a4be24629b5870c3..9c67afde9b436e25ce933f9fe876a10438bb27c5 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C
@@ -247,17 +247,7 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::whichZone
     const label objectIndex
 ) const
 {
-    const Map<label>& zm = zoneMap();
-    Map<label>::const_iterator zmIter = zm.find(objectIndex);
-
-    if (zmIter == zm.end())
-    {
-        return -1;
-    }
-    else
-    {
-        return zmIter();
-    }
+    return zoneMap().lookup(objectIndex, -1);
 }
 
 
@@ -579,13 +569,13 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::checkParallelSync
 
 
 template<class ZoneType, class MeshType>
-void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& p)
+void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& pts)
 {
     PtrList<ZoneType>& zones = *this;
 
     forAll(zones, zonei)
     {
-        zones[zonei].movePoints(p);
+        zones[zonei].movePoints(pts);
     }
 }
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H
index d76823b85222ea5bd57b5abb494a40bbc75e6f11..9c83890d7676447315685ac74111ec18f9681f1c 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H
@@ -176,7 +176,7 @@ public:
         //- Return zone index for the first match, return -1 if not found
         label findIndex(const keyType& key) const;
 
-        //- Find zone index given a name
+        //- Find zone index given a name, return -1 if not found
         label findZoneID(const word& zoneName) const;
 
         //- Mark cells that match the zone specification
@@ -191,12 +191,12 @@ public:
         //- Check zone definition. Return true if in error.
         bool checkDefinition(const bool report = false) const;
 
-        //- Check whether all procs have all zones and in same order. Return
-        //  true if in error.
+        //- Check whether all procs have all zones and in same order.
+        //  \return True if any errors.
         bool checkParallelSync(const bool report = false) const;
 
         //- Correct zone mesh after moving points
-        void movePoints(const pointField& p);
+        void movePoints(const pointField& pts);
 
         //- writeData member function required by regIOobject
         bool writeData(Ostream& os) const;
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H
index bd760cbcced42fbfb19f7b02ec680c2efe05befc..fdb46615524b1834da1ba3907ef75e9f92e7f2c2 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H
@@ -33,8 +33,6 @@ Description
 #include "cellZone.H"
 #include "cellZoneMeshFwd.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H
index 2ddd1eda9e55654426a307ca124ee266e15530ee..9d3eca8b9fffc1c457e28b4e89b349b75ee96f6e 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H
@@ -36,10 +36,10 @@ Description
 
 namespace Foam
 {
-    template<class Zone, class MeshType> class ZoneMesh;
     class cellZone;
     class polyMesh;
 
+    template<class Zone, class MeshType> class ZoneMesh;
     typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh;
 }
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H
index 3f9a51c2b749cdf3a7f4f0c98976841cdb76a024..d0a41ea5ef35c3e978366035db3b09c09863ead9 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H
@@ -33,8 +33,6 @@ Description
 #include "faceZone.H"
 #include "faceZoneMeshFwd.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H
index 9642d2e55308d19b2dddda24b5a713fb897cf85a..89d66b6baf48d28fe890547afbc165fe246d3d1b 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H
@@ -36,10 +36,10 @@ Description
 
 namespace Foam
 {
-    template<class Zone, class MeshType> class ZoneMesh;
     class faceZone;
     class polyMesh;
 
+    template<class Zone, class MeshType> class ZoneMesh;
     typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh;
 }
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H
index 13bdddd5f9567353971bdc849e2b821fceedf356..c2547c19e02134e3d579d4c85f19c4c92d17fe6d 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H
@@ -33,8 +33,6 @@ Description
 #include "pointZone.H"
 #include "pointZoneMeshFwd.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H
index 24974a68b13abaf73b1f29e1bd5e0df48a24a3df..6cc67017bc4ba86cbef2b4e7f143c7481bd44513 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H
@@ -36,10 +36,10 @@ Description
 
 namespace Foam
 {
-    template<class Zone, class MeshType> class ZoneMesh;
     class pointZone;
     class polyMesh;
 
+    template<class Zone, class MeshType> class ZoneMesh;
     typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh;
 }
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C
index c59ec220911ca966e40cc645db8504a42aae7658..4940529e11509d233098083f1de79368c1b7ee00 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C
@@ -42,6 +42,7 @@ namespace Foam
 
 const char * const Foam::cellZone::labelsName = "cellLabels";
 
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::cellZone::cellZone
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H
index c5027f3eaae4cc2ceb62c1f18ac7ab1c69188bfa..3d3658b207e4da52691ff3e89994f980635f9e6a 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H
@@ -52,7 +52,7 @@ namespace Foam
 // Forward declaration of friend functions and operators
 
 class cellZone;
-Ostream& operator<<(Ostream&, const cellZone&);
+Ostream& operator<<(Ostream& os, const cellZone& zn);
 
 
 /*---------------------------------------------------------------------------*\
@@ -64,6 +64,12 @@ class cellZone
     public zone
 {
 
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        cellZone(const cellZone&) = delete;
+
+
 protected:
 
     // Protected data
@@ -72,14 +78,6 @@ protected:
         const cellZoneMesh& zoneMesh_;
 
 
-private:
-
-    // Private Member Functions
-
-        //- Disallow default bitwise copy construct
-        cellZone(const cellZone&);
-
-
 public:
 
     // Static data members
@@ -117,7 +115,7 @@ public:
             const word& name,
             const labelUList& addr,
             const label index,
-            const cellZoneMesh&
+            const cellZoneMesh& zm
         );
 
         //- Construct from components, transferring contents
@@ -126,36 +124,36 @@ public:
             const word& name,
             const Xfer<labelList>& addr,
             const label index,
-            const cellZoneMesh&
+            const cellZoneMesh& zm
         );
 
         //- Construct from dictionary
         cellZone
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const label index,
-            const cellZoneMesh&
+            const cellZoneMesh& zm
         );
 
-        //- Construct given the original zone and resetting the
-        //  cell list and zone mesh information
+        //- Construct given the original zone,
+        //  resetting the cell list and zone mesh information
         cellZone
         (
-            const cellZone&,
+            const cellZone& cz,
             const labelUList& addr,
             const label index,
-            const cellZoneMesh&
+            const cellZoneMesh& zm
         );
 
-        //- Construct given the original zone, resetting the
-        //  cell list and zone mesh information
+        //- Construct given the original zone,
+        //  resetting the cell list and zone mesh information
         cellZone
         (
-            const cellZone&,
+            const cellZone& cz,
             const Xfer<labelList>& addr,
             const label index,
-            const cellZoneMesh&
+            const cellZoneMesh& zm
         );
 
         //- Construct and return a clone, resetting the zone mesh
@@ -190,9 +188,9 @@ public:
         static autoPtr<cellZone> New
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const label index,
-            const cellZoneMesh&
+            const cellZoneMesh& zm
         );
 
 
@@ -211,33 +209,33 @@ public:
         //- Check zone definition. Return true if in error.
         virtual bool checkDefinition(const bool report = false) const;
 
-        //- Check whether zone is synchronised across coupled boundaries. Return
-        //  true if in error.
+        //- Check whether zone is synchronised across coupled boundaries.
+        //  \return True if any errors.
         virtual bool checkParallelSync(const bool report = false) const
         {
             return false;
         }
 
         //- Write dictionary
-        virtual void writeDict(Ostream&) const;
+        virtual void writeDict(Ostream& os) const;
 
 
     // Member Operators
 
         //- Assign to zone, clearing demand-driven data
-        void operator=(const cellZone&);
+        void operator=(const cellZone& zn);
 
         //- Assign addressing, clearing demand-driven data
-        void operator=(const labelUList&);
+        void operator=(const labelUList& addr);
 
         //- Assign addressing, clearing demand-driven data
-        void operator=(const Xfer<labelList>&);
+        void operator=(const Xfer<labelList>& addr);
 
 
     // I-O
 
         //- Ostream Operator
-        friend Ostream& operator<<(Ostream&, const cellZone&);
+        friend Ostream& operator<<(Ostream& os, const cellZone& zn);
 };
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
index 459e8002d7e2372baa89ab58e073de6e1bcb3f4f..f91a48b9e33272255e8bd9c422e36af60c0be074 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
@@ -43,6 +43,23 @@ namespace Foam
 
 const char* const Foam::faceZone::labelsName = "faceLabels";
 
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::faceZone::setFlipMap(const bool flipValue)
+{
+    // Match size for flipMap
+    if (flipMap_.size() == this->size())
+    {
+        flipMap_ = flipValue;
+    }
+    else
+    {
+        // Avoid copying old values on resize
+        flipMap_.clear();
+        flipMap_.setSize(this->size(), flipValue);
+    }
+}
+
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
@@ -128,8 +145,8 @@ void Foam::faceZone::calcCellLayers() const
 
         forAll(mf, facei)
         {
-            label ownCelli = own[mf[facei]];
-            label neiCelli =
+            const label ownCelli = own[mf[facei]];
+            const label neiCelli =
             (
                 zoneMesh().mesh().isInternalFace(mf[facei])
               ? nei[mf[facei]]
@@ -386,6 +403,30 @@ void Foam::faceZone::resetAddressing
 }
 
 
+void Foam::faceZone::resetAddressing
+(
+    const labelUList& addr,
+    const bool flipValue
+)
+{
+    clearAddressing();
+    labelList::operator=(addr);
+    setFlipMap(flipValue);
+}
+
+
+void Foam::faceZone::resetAddressing
+(
+    const Xfer<labelList>& addr,
+    const bool flipValue
+)
+{
+    clearAddressing();
+    labelList::operator=(addr);
+    setFlipMap(flipValue);
+}
+
+
 void Foam::faceZone::updateMesh(const mapPolyMesh& mpm)
 {
     clearAddressing();
@@ -511,11 +552,11 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
 }
 
 
-void Foam::faceZone::movePoints(const pointField& p)
+void Foam::faceZone::movePoints(const pointField& pts)
 {
     if (patchPtr_)
     {
-        patchPtr_->movePoints(p);
+        patchPtr_->movePoints(pts);
     }
 }
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H
index 253c78e1da51048ae001101adefb4db6065051f8..5a6896db7c1205b647f48e896585bea2fceddebb 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H
@@ -55,7 +55,7 @@ class mapPolyMesh;
 // Forward declaration of friend functions and operators
 
 class faceZone;
-Ostream& operator<<(Ostream&, const faceZone&);
+Ostream& operator<<(Ostream& os, const faceZone& zn);
 
 
 /*---------------------------------------------------------------------------*\
@@ -66,46 +66,43 @@ class faceZone
 :
     public zone
 {
-    // Private data
-
-        //- The name associated with the zone-labels dictionary entry
-        static const word labelsName_;
-
-
     // Private Member Functions
 
+        //- Set flip-map to constant value
+        void setFlipMap(const bool flipValue);
+
         //- Disallow default bitwise copy construct
-        faceZone(const faceZone&);
+        faceZone(const faceZone&) = delete;
 
         //- Disallow default bitwise assignment
-        void operator=(const faceZone&);
+        void operator=(const faceZone&) = delete;
 
 
 protected:
 
     // Protected data
 
-        //- Flip map for all faces in the zone.  Set to true if the
-        //  face needs to be flipped to achieve the correct orientation.
+        //- Flip map for all faces in the zone.
+        //  Use true if the face needs flipping for the correct orientation.
         boolList flipMap_;
 
         //- Reference to zone list
         const faceZoneMesh& zoneMesh_;
 
 
-        // Demand-driven private data
+      // Demand-driven data
 
-            //- Primitive patch made out of correctly flipped faces
-            mutable primitiveFacePatch* patchPtr_;
+        //- Primitive patch made out of correctly flipped faces
+        mutable primitiveFacePatch* patchPtr_;
 
-            //- Master cell layer
-            mutable labelList* masterCellsPtr_;
+        //- Master cell layer
+        mutable labelList* masterCellsPtr_;
 
-            //- Slave cell layer
-            mutable labelList* slaveCellsPtr_;
+        //- Slave cell layer
+        mutable labelList* slaveCellsPtr_;
 
-            //- Global edge addressing
-            mutable labelList* mePtr_;
+        //- Global edge addressing
+        mutable labelList* mePtr_;
 
 
     // Protected Member Functions
@@ -168,38 +165,38 @@ public:
             const Xfer<labelList>& addr,
             const Xfer<boolList>& fm,
             const label index,
-            const faceZoneMesh&
+            const faceZoneMesh& zm
         );
 
         //- Construct from dictionary
         faceZone
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const label index,
-            const faceZoneMesh&
+            const faceZoneMesh& zm
         );
 
         //- Construct given the original zone and resetting the
         //  face list and zone mesh information
         faceZone
         (
-            const faceZone&,
+            const faceZone& fz,
             const labelUList& addr,
             const boolList& fm,
             const label index,
-            const faceZoneMesh&
+            const faceZoneMesh& zm
         );
 
-        //- Construct given the original zone, resetting the
-        //  face list and zone mesh information
+        //- Construct given the original zone,
+        //  resetting the face list and zone mesh information
         faceZone
         (
-            const faceZone&,
+            const faceZone& fz,
             const Xfer<labelList>& addr,
             const Xfer<boolList>& fm,
             const label index,
-            const faceZoneMesh&
+            const faceZoneMesh& zm
         );
 
         //- Construct and return a clone, resetting the zone mesh
@@ -235,9 +232,9 @@ public:
         static autoPtr<faceZone> New
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const label index,
-            const faceZoneMesh&
+            const faceZoneMesh& zm
         );
 
 
@@ -247,6 +244,9 @@ public:
 
     // Member Functions
 
+        //- Return zoneMesh reference
+        const faceZoneMesh& zoneMesh() const;
+
         //- Return face flip map
         const boolList& flipMap() const
         {
@@ -259,52 +259,71 @@ public:
         //- Return reference to primitive patch
         const primitiveFacePatch& operator()() const;
 
-        //- Return zoneMesh reference
-        const faceZoneMesh& zoneMesh() const;
-
 
-        // Addressing into mesh
+      // Addressing into mesh
 
-            //- Return labels of master cells (cells next to the master face
-            //  zone in the prescribed direction)
-            const labelList& masterCells() const;
+        //- Return labels of master cells (cells next to the master face
+        //  zone in the prescribed direction)
+        const labelList& masterCells() const;
 
-            //- Return labels of slave cells
-            const labelList& slaveCells() const;
+        //- Return labels of slave cells
+        const labelList& slaveCells() const;
 
-            //- Return global edge index for local edges
-            const labelList& meshEdges() const;
+        //- Return global edge index for local edges
+        const labelList& meshEdges() const;
 
 
         //- Clear addressing
         virtual void clearAddressing();
 
-        //- Reset addressing and flip map (clearing demand-driven data)
-        virtual void resetAddressing(const labelUList&, const boolList&);
+        //- Reset addressing and flip map.
+        //  Clears demand-driven data.
+        virtual void resetAddressing
+        (
+            const labelUList& addr,
+            const boolList& flipMap
+        );
+
+        //- Reset addressing - use constant flip map
+        //  Clears demand-driven data.
+        virtual void resetAddressing
+        (
+            const labelUList& addr,
+            const bool flipValue
+        );
+
+        //- Reset addressing - use constant flip map
+        //  Clears demand-driven data.
+        virtual void resetAddressing
+        (
+            const Xfer<labelList>& addr,
+            const bool flipValue
+        );
 
         //- Check zone definition. Return true if in error.
         virtual bool checkDefinition(const bool report = false) const;
 
-        //- Check whether all procs have faces synchronised. Return
-        //  true if in error.
+        //- Check whether all procs have faces synchronised.
+        //  \return True if any errors.
         virtual bool checkParallelSync(const bool report = false) const;
 
         //- Correct patch after moving points
-        virtual void movePoints(const pointField&);
+        virtual void movePoints(const pointField& pts);
 
         //- Update for changes in topology
-        virtual void updateMesh(const mapPolyMesh&);
+        virtual void updateMesh(const mapPolyMesh& mpm);
 
         //- Write
-        virtual void write(Ostream&) const;
+        virtual void write(Ostream& os) const;
 
         //- Write dictionary
-        virtual void writeDict(Ostream&) const;
+        virtual void writeDict(Ostream& os) const;
+
 
     // I-O
 
         //- Ostream Operator
-        friend Ostream& operator<<(Ostream&, const faceZone&);
+        friend Ostream& operator<<(Ostream& os, const faceZone& zn);
 };
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H
index 18f1147ac0e0bcd8cb7c57c97221c1ad92926052..aa887135152335828dadeba7378e425931e23cda 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/primitiveFaceZone.H
@@ -33,7 +33,7 @@ Description
 
 #include "face.H"
 #include "PrimitivePatch.H"
-#include "indirectFaceList.H"
+#include "IndirectList.H"
 #include "pointField.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C
index 31680ccf1a0310b12077ce86c2f62af83c449d73..7a197bef349c044d269e2b2e2127f7055e534f58 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C
@@ -42,6 +42,7 @@ namespace Foam
 
 const char* const Foam::pointZone::labelsName = "pointLabels";
 
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::pointZone::pointZone
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H
index 9bc911153adee519877b5015dafe434f55857aaf..d8e71270b0c6901313928b9f220fd2d234ca9972 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H
@@ -53,7 +53,7 @@ namespace Foam
 // Forward declaration of friend functions and operators
 
 class pointZone;
-Ostream& operator<<(Ostream&, const pointZone&);
+Ostream& operator<<(Ostream& os, const pointZone& zn);
 
 
 /*---------------------------------------------------------------------------*\
@@ -64,6 +64,11 @@ class pointZone
 :
     public zone
 {
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        pointZone(const pointZone&) = delete;
+
 
 protected:
 
@@ -72,10 +77,6 @@ protected:
         //- Reference to zone list
         const pointZoneMesh& zoneMesh_;
 
-    // Private Member Functions
-
-        //- Disallow default bitwise copy construct
-        pointZone(const pointZone&);
 
 public:
 
@@ -114,7 +115,7 @@ public:
             const word& name,
             const labelUList& addr,
             const label index,
-            const pointZoneMesh&
+            const pointZoneMesh& zm
         );
 
         //- Construct from components, transferring contents
@@ -123,36 +124,36 @@ public:
             const word& name,
             const Xfer<labelList>& addr,
             const label index,
-            const pointZoneMesh&
+            const pointZoneMesh& zm
         );
 
         //- Construct from dictionary
         pointZone
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const label index,
-            const pointZoneMesh&
+            const pointZoneMesh& zm
         );
 
         //- Construct given the original zone and resetting the
         //  point list and zone mesh information
         pointZone
         (
-            const pointZone&,
+            const pointZone& pz,
             const labelUList& addr,
             const label index,
-            const pointZoneMesh&
+            const pointZoneMesh& zm
         );
 
-        //- Construct given the original zone, resetting the
-        //  face list and zone mesh information
+        //- Construct given the original zone,
+        //  resetting the point list and zone mesh information
         pointZone
         (
-            const pointZone&,
+            const pointZone& pz,
             const Xfer<labelList>& addr,
             const label index,
-            const pointZoneMesh&
+            const pointZoneMesh& zm
         );
 
         //- Construct and return a clone, resetting the zone mesh
@@ -187,9 +188,9 @@ public:
         static autoPtr<pointZone> New
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const label index,
-            const pointZoneMesh&
+            const pointZoneMesh& zm
         );
 
 
@@ -208,8 +209,8 @@ public:
         //- Check zone definition. Return true if in error.
         virtual bool checkDefinition(const bool report = false) const;
 
-        //- Check whether zone is synchronised across coupled boundaries. Return
-        //  true if in error.
+        //- Check whether zone is synchronised across coupled boundaries.
+        //  \return True if any errors.
         virtual bool checkParallelSync(const bool report = false) const;
 
         //- Correct patch after moving points
@@ -217,25 +218,25 @@ public:
         {}
 
         //- Write dictionary
-        virtual void writeDict(Ostream&) const;
+        virtual void writeDict(Ostream& os) const;
 
 
     // Member Operators
 
         //- Assign to zone, clearing demand-driven data
-        void operator=(const pointZone&);
+        void operator=(const pointZone& zn);
 
         //- Assign addressing, clearing demand-driven data
-        void operator=(const labelUList&);
+        void operator=(const labelUList& addr);
 
         //- Assign addressing, clearing demand-driven data
-        void operator=(const Xfer<labelList>&);
+        void operator=(const Xfer<labelList>& addr);
 
 
     // I-O
 
         //- Ostream Operator
-        friend Ostream& operator<<(Ostream&, const pointZone&);
+        friend Ostream& operator<<(Ostream& os, const pointZone& zn);
 };
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C
index 5ff0eebb7b49ed8985b29722c416e513dbd1d84a..8e11bc24a71ea0af955401ff6799798b245acf6e 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C
@@ -127,13 +127,13 @@ Foam::zone::zone
 
 Foam::zone::zone
 (
-    const zone& z,
+    const zone& zn,
     const labelUList& addr,
     const label index
 )
 :
     labelList(addr),
-    name_(z.name()),
+    name_(zn.name()),
     index_(index),
     lookupMapPtr_(nullptr)
 {}
@@ -141,13 +141,13 @@ Foam::zone::zone
 
 Foam::zone::zone
 (
-    const zone& z,
+    const zone& zn,
     const Xfer<labelList>& addr,
     const label index
 )
 :
     labelList(addr),
-    name_(z.name()),
+    name_(zn.name()),
     index_(index),
     lookupMapPtr_(nullptr)
 {}
@@ -165,18 +165,7 @@ Foam::zone::~zone()
 
 Foam::label Foam::zone::localID(const label globalCellID) const
 {
-    const Map<label>& lm = lookupMap();
-
-    Map<label>::const_iterator lmIter = lm.find(globalCellID);
-
-    if (lmIter == lm.end())
-    {
-        return -1;
-    }
-    else
-    {
-        return lmIter();
-    }
+    return lookupMap().lookup(globalCellID, -1);
 }
 
 
@@ -197,7 +186,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
 
     forAll(addr, i)
     {
-        if (addr[i] < 0 || addr[i] >= maxSize)
+        const label idx = addr[i];
+        if (idx < 0 || idx >= maxSize)
         {
             hasError = true;
 
@@ -205,7 +195,7 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
             {
                 SeriousErrorInFunction
                     << "Zone " << name_
-                    << " contains invalid index label " << addr[i] << nl
+                    << " contains invalid index label " << idx << nl
                     << "Valid index labels are 0.."
                     << maxSize-1 << endl;
             }
@@ -215,13 +205,13 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
                 break;
             }
         }
-        else if (!elems.insert(addr[i]))
+        else if (!elems.insert(idx))
         {
             if (report)
             {
                 WarningInFunction
                     << "Zone " << name_
-                    << " contains duplicate index label " << addr[i] << endl;
+                    << " contains duplicate index label " << idx << endl;
             }
         }
     }
@@ -239,9 +229,9 @@ void Foam::zone::write(Ostream& os) const
 
 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
 
-Foam::Ostream& Foam::operator<<(Ostream& os, const zone& z)
+Foam::Ostream& Foam::operator<<(Ostream& os, const zone& zn)
 {
-    z.write(os);
+    zn.write(os);
     os.check(FUNCTION_NAME);
     return os;
 }
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H
index 924a97db55d8c5a75d341a35bb55b25ab7a6090c..db769812957130b9b200f6be292af6a5ea15a29c 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H
+++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H
@@ -49,7 +49,7 @@ namespace Foam
 // Forward declaration of friend functions and operators
 
 class zone;
-Ostream& operator<<(Ostream&, const zone&);
+Ostream& operator<<(Ostream& os, const zone& zn);
 
 /*---------------------------------------------------------------------------*\
                            Class zone Declaration
@@ -59,6 +59,11 @@ class zone
 :
     public labelList
 {
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        zone(const zone&) = delete;
+
 
 protected:
 
@@ -71,10 +76,10 @@ protected:
         label index_;
 
 
-        // Demand-driven private data
+      // Demand-driven private data
 
-            //- Map of labels in zone for fast location lookup
-            mutable Map<label>* lookupMapPtr_;
+        //- Map of labels in zone for fast location lookup
+        mutable Map<label>* lookupMapPtr_;
 
 
     // Protected Member Functions
@@ -82,9 +87,6 @@ protected:
         //- Construct the look-up map
         void calcLookupMap() const;
 
-        //- Disallow default bitwise copy construct
-        zone(const zone&);
-
 
 public:
 
@@ -114,7 +116,7 @@ public:
         zone
         (
             const word& name,
-            const dictionary&,
+            const dictionary& dict,
             const word& labelsName,
             const label index
         );
@@ -123,7 +125,7 @@ public:
         //  cell list and zone mesh information
         zone
         (
-            const zone&,
+            const zone& zn,
             const labelUList& addr,
             const label index
         );
@@ -132,7 +134,7 @@ public:
         //  cell list and zone mesh information
         zone
         (
-            const zone&,
+            const zone& zn,
             const Xfer<labelList>& addr,
             const label index
         );
@@ -178,20 +180,20 @@ public:
         ) const;
 
         //- Correct patch after moving points
-        virtual void movePoints(const pointField&)
+        virtual void movePoints(const pointField& pts)
         {}
 
         //- Write
-        virtual void write(Ostream&) const;
+        virtual void write(Ostream& os) const;
 
         //- Write dictionary
-        virtual void writeDict(Ostream&) const = 0;
+        virtual void writeDict(Ostream& os) const = 0;
 
 
     // I-O
 
         //- Ostream Operator
-        friend Ostream& operator<<(Ostream&, const zone&);
+        friend Ostream& operator<<(Ostream& os, const zone& zn);
 };
 
 
diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C
index 784b78bb44f343a1022cab200dda23c068a86959..2c6d4041717a2f9188bd8ce6e38f12cce5a6aa0a 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSortPoints.C
@@ -128,7 +128,7 @@ Foam::PatchTools::sortedPointEdges
         {
             forAll(pEdges, eI)
             {
-                if (findIndex(newEdgeList, pEdges[eI]) == -1)
+                if (!newEdgeList.found(pEdges[eI]))
                 {
                     WarningInFunction
                         << "Cannot find all original edges in the new list"
diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C
index 80cc44a3708968244cb7cd9ecb46e194f937394c..5780089ca309a1c5eb5cf92175d00ed516959134 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchCheck.C
@@ -50,7 +50,7 @@ visitPointRegion
     boolList& pFacesHad
 ) const
 {
-    label index = findIndex(pFaces, startFacei);
+    label index = pFaces.find(startFacei);
 
     if (!pFacesHad[index])
     {
@@ -267,7 +267,7 @@ checkPointManifold
         // After this all faces using pointi should have been visited and
         // marked off in pFacesHad.
 
-        label unset = findIndex(pFacesHad, false);
+        label unset = pFacesHad.find(false);
 
         if (unset != -1)
         {
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C
index 1b56bd5268ca01d3b74768cd3e82cd90927aff15..ed6589ac3a231c64b7dffdacd2d07da78b7e9592 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C
@@ -60,7 +60,7 @@ void Foam::primitiveMesh::calcCellEdges() const
     else
     {
         // Set up temporary storage
-        List<DynamicList<label, edgesPerCell_>> ce(nCells());
+        List<DynamicList<label>> ce(nCells());
 
 
         // Get reference to faceCells and faceEdges
@@ -71,13 +71,13 @@ void Foam::primitiveMesh::calcCellEdges() const
         // loop through the list again and add edges; checking for duplicates
         forAll(own, facei)
         {
-            DynamicList<label, edgesPerCell_>& curCellEdges = ce[own[facei]];
+            DynamicList<label>& curCellEdges = ce[own[facei]];
 
             const labelList& curEdges = fe[facei];
 
             forAll(curEdges, edgeI)
             {
-                if (findIndex(curCellEdges, curEdges[edgeI]) == -1)
+                if (!curCellEdges.found(curEdges[edgeI]))
                 {
                     // Add the edge
                     curCellEdges.append(curEdges[edgeI]);
@@ -87,13 +87,13 @@ void Foam::primitiveMesh::calcCellEdges() const
 
         forAll(nei, facei)
         {
-            DynamicList<label, edgesPerCell_>& curCellEdges = ce[nei[facei]];
+            DynamicList<label>& curCellEdges = ce[nei[facei]];
 
             const labelList& curEdges = fe[facei];
 
             forAll(curEdges, edgeI)
             {
-                if (findIndex(curCellEdges, curEdges[edgeI]) == -1)
+                if (!curCellEdges.found(curEdges[edgeI]))
                 {
                     // add the edge
                     curCellEdges.append(curEdges[edgeI]);
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C
index 681024b48c84ccc4e855ca35fa3acd99027b939d..57a7be528b1896af2fe50ed0481c30b942cda3b2 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C
@@ -1436,7 +1436,7 @@ bool Foam::primitiveMesh::checkCommonOrder
             forAll(curFace, fp)
             {
                 // Get the index in the neighbouring face shared with curFace
-                label nb = findIndex(nbFace, curFace[fp]);
+                label nb = nbFace.find(curFace[fp]);
 
                 if (nb != -1)
                 {
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
index 01c7ec471c682bebb2b24bd646f46e13773bcbc6..3cf689595ab870c71bd8f006206347c99894497b 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshEdges.C
@@ -404,7 +404,7 @@ void Foam::primitiveMesh::calcEdges(const bool doFaceEdges) const
 
         if (debug)
         {
-            label edgeI = findIndex(oldToNew, -1);
+            label edgeI = oldToNew.find(-1);
 
             if (edgeI != -1)
             {
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H
index 2899d00149af13ad61d1869d1717d84217d3afe3..3d7733deba0496993ddc3728d37367eb09e1dd07 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/indirectPrimitivePatch.H
@@ -25,7 +25,7 @@ Typedef
     Foam::indirectPrimitivePatch
 
 Description
-    Foam::indirectPrimitivePatch
+    A PrimitivePatch using an IndirectList for the faces.
 
 \*---------------------------------------------------------------------------*/
 
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H
index 0bb30e55fbfdce3c6c7f4502eb207a070fdb57a7..630e9e5be0830da6cc7b554191ff1c49f31650b3 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H
@@ -25,7 +25,7 @@ Typedef
     Foam::uindirectPrimitivePatch
 
 Description
-    Foam::uindirectPrimitivePatch
+    A PrimitivePatch using a UIndirectList for the faces.
 
 \*---------------------------------------------------------------------------*/
 
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C
index f2551cfcd834d4708da3653dafa2e5d02c5408e9..ade123369567eebb0eec923b838f7682f9cbb172 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/walkPatch.C
@@ -149,7 +149,7 @@ void Foam::walkPatch::faceToFace
 
             const face& f = pp_.localFaces()[facei];
 
-            label fp = findIndex(f, enterVertI);
+            label fp = f.find(enterVertI);
 
             indexInFace_.append(fp);
 
diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/line.H b/src/OpenFOAM/meshes/primitiveShapes/line/line.H
index 778a843ba75740616ef5922d017b94747f6a839a..a3ccc2319f24d7254408f18d1ed083dcf747432a 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/line/line.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/line/line.H
@@ -57,10 +57,10 @@ class Ostream;
 template<class Point, class PointRef> class line;
 
 template<class Point, class PointRef>
-inline Istream& operator>>(Istream&, line<Point, PointRef>&);
+inline Istream& operator>>(Istream& is, line<Point, PointRef>& l);
 
 template<class Point, class PointRef>
-inline Ostream& operator<<(Ostream&, const line<Point, PointRef>&);
+inline Ostream& operator<<(Ostream& os, const line<Point, PointRef>& l);
 
 
 /*---------------------------------------------------------------------------*\
@@ -72,7 +72,11 @@ class line
 {
     // Private data
 
-        PointRef a_, b_;
+        //- First point
+        PointRef a_;
+
+        //- Second point
+        PointRef b_;
 
 
 public:
@@ -86,7 +90,7 @@ public:
         //  The indices could be from edge etc.
         inline line
         (
-            const UList<Point>&,
+            const UList<Point>& points,
             const FixedList<label, 2>& indices
         );
 
@@ -96,56 +100,62 @@ public:
 
     // Member functions
 
-        // Access
+      // Access
+
+        //- Return first point
+        inline PointRef first() const;
 
-            //- Return first point
-            inline PointRef start() const;
+        //- Return second point
+        inline PointRef second() const;
 
-            //- Return second point
-            inline PointRef end() const;
+        //- Return first point
+        inline PointRef start() const;
 
+        //- Return second point
+        inline PointRef end() const;
 
-        // Properties
 
-            //- Return centre (centroid)
-            inline Point centre() const;
+      // Properties
 
-            //- Return scalar magnitude
-            inline scalar mag() const;
+        //- Return centre (centroid)
+        inline Point centre() const;
 
-            //- Return start-to-end vector
-            inline Point vec() const;
+        //- Return scalar magnitude
+        inline scalar mag() const;
 
-            //- Return the unit vector (start-to-end)
-            inline Point unitVec() const;
+        //- Return start-to-end vector
+        inline Point vec() const;
 
-            //- Return nearest distance to line from a given point
-            //  If the nearest point is on the line, return a hit
-            PointHit<Point> nearestDist(const Point& p) const;
+        //- Return the unit vector (start-to-end)
+        inline Point unitVec() const;
 
-            //- Return nearest distance from line to line. Returns distance
-            //  and sets both points (one on *this, one on the provided
-            //  linePointRef.
-            scalar nearestDist
-            (
-                const line<Point, const Point&>& edge,
-                Point& thisPoint,
-                Point& edgePoint
-            ) const;
+        //- Return nearest distance to line from a given point
+        //  If the nearest point is on the line, return a hit
+        PointHit<Point> nearestDist(const Point& p) const;
+
+        //- Return nearest distance from line to line. Returns distance
+        //  and sets both points (one on *this, one on the provided
+        //  linePointRef.
+        scalar nearestDist
+        (
+            const line<Point, const Point&>& edge,
+            Point& thisPoint,
+            Point& edgePoint
+        ) const;
 
 
     // Ostream operator
 
         friend Istream& operator>> <Point, PointRef>
         (
-            Istream&,
-            line&
+            Istream& is,
+            line& l
         );
 
         friend Ostream& operator<< <Point, PointRef>
         (
-            Ostream&,
-            const line&
+            Ostream& os,
+            const line& l
         );
 };
 
diff --git a/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H b/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H
index 034f86878034c75a7e60b95cf812206f05b6ebd9..b2ee4d40ea132bfc26517b1b77617546e237aa19 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/line/lineI.H
@@ -57,18 +57,32 @@ inline Foam::line<Point, PointRef>::line(Istream& is)
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Point, class PointRef>
-inline PointRef Foam::line<Point, PointRef>::start() const
+inline PointRef Foam::line<Point, PointRef>::first() const
 {
     return a_;
 }
 
+
 template<class Point, class PointRef>
-inline PointRef Foam::line<Point, PointRef>::end() const
+inline PointRef Foam::line<Point, PointRef>::second() const
 {
     return b_;
 }
 
 
+template<class Point, class PointRef>
+inline PointRef Foam::line<Point, PointRef>::start() const
+{
+    return first();
+}
+
+template<class Point, class PointRef>
+inline PointRef Foam::line<Point, PointRef>::end() const
+{
+    return second();
+}
+
+
 template<class Point, class PointRef>
 inline Point Foam::line<Point, PointRef>::centre() const
 {
@@ -110,21 +124,21 @@ Foam::PointHit<Point> Foam::line<Point, PointRef>::nearestDist
 
     Point w(p - a_);
 
-    scalar c1 = v & w;
+    const scalar c1 = v & w;
 
     if (c1 <= 0)
     {
         return PointHit<Point>(false, a_, Foam::mag(p - a_), true);
     }
 
-    scalar c2 = v & v;
+    const scalar c2 = v & v;
 
     if (c2 <= c1)
     {
         return PointHit<Point>(false, b_, Foam::mag(p - b_), true);
     }
 
-    scalar b = c1/c2;
+    const scalar b = c1/c2;
 
     Point pb(a_ + b*v);
 
diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H
index 1c55ad2d05c5c620730aa1a292c0931c38fc00ae..7664b3cc863d290162731e6f598dda1c0b7acfce 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/PointHit.H
@@ -117,6 +117,8 @@ public:
 
     // Member Functions
 
+      // Access
+
         //- Is there a hit
         bool hit() const
         {
@@ -167,6 +169,8 @@ public:
             return eligibleMiss_;
         }
 
+      // Edit
+
         void setHit()
         {
             hit_ = true;
diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H
index dd8a081b6dfa49907d0691be857d30affe042919..e4637ecde19be2c49a87da49e28dacde35d96546 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -83,6 +83,8 @@ public:
 
     // Member Functions
 
+      // Access
+
         //- Is there a hit
         inline bool hit() const
         {
@@ -96,6 +98,19 @@ public:
         }
 
 
+      // Edit
+
+        void setHit()
+        {
+            hit_ = true;
+        }
+
+        void setMiss()
+        {
+            hit_ = false;
+        }
+
+
     // Ostream operator
 
         inline friend Ostream& operator<<(Ostream& os, const objectHit& obj)
diff --git a/src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H b/src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H
new file mode 100644
index 0000000000000000000000000000000000000000..e27e72a629a4bf0ee88eb99c2ffa84c93a15d62d
--- /dev/null
+++ b/src/OpenFOAM/meshes/primitiveShapes/point/pointIndList.H
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Typedef
+    Foam::pointIndList
+
+Description
+    An IndirectList of points.
+
+Typedef
+    Foam::pointUIndList
+
+Description
+    A UIndirectList of points.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef pointIndList_H
+#define pointIndList_H
+
+// Include all normal list typedefs as well
+#include "pointList.H"
+#include "IndirectList.H"
+#include "UIndirectList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef IndirectList<point>  pointIndList;
+    typedef UIndirectList<point> pointUIndList;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H
index 8eab5ae007f2901361b01fa4ba6c97eadfc1df41..aa3d96e8c9f8e37215de4860334c7a62d712b785 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H
@@ -25,13 +25,25 @@ Typedef
     Foam::pointList
 
 Description
-    A List of points
+    A List of points.
+
+Typedef
+    Foam::pointUList
+
+Description
+    A UList of points.
+
+Typedef
+    Foam::pointSubList
+
+Description
+    A SubList of points.
 
 Typedef
     Foam::pointListList
 
 Description
-    A List of labelList
+    A List of pointList.
 
 \*---------------------------------------------------------------------------*/
 
@@ -40,14 +52,15 @@ Description
 
 #include "point.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    // Note: frequently used UList version is located in container itself
-
+    typedef UList<point> pointUList;
     typedef List<point> pointList;
+    typedef SubList<point> pointSubList;
     typedef List<pointList> pointListList;
 }
 
diff --git a/src/OpenFOAM/primitives/Pair/Pair.H b/src/OpenFOAM/primitives/Pair/Pair.H
index 73b99e5c15d9bc1063b9c77ec1941d6bfa9eae46..3209f4d9421b844872c18447af9666c6fe161272 100644
--- a/src/OpenFOAM/primitives/Pair/Pair.H
+++ b/src/OpenFOAM/primitives/Pair/Pair.H
@@ -28,6 +28,9 @@ Description
     An ordered pair of two objects of type \<T\> with first() and second()
     elements.
 
+SourceFiles
+    PairI.H
+
 See also
     Foam::Tuple2 for storing two objects of dissimilar types.
 
@@ -48,10 +51,10 @@ namespace Foam
                             Class Pair Declaration
 \*---------------------------------------------------------------------------*/
 
-template<class Type>
+template<class T>
 class Pair
 :
-    public FixedList<Type, 2>
+    public FixedList<T, 2>
 {
 
 public:
@@ -59,131 +62,96 @@ public:
     // Constructors
 
         //- Null constructor
-        inline Pair()
-        {}
+        inline Pair();
 
         //- Construct from components
-        inline Pair(const Type& f, const Type& s)
-        {
-            first() = f;
-            second() = s;
-        }
+        inline Pair(const T& f, const T& s);
 
         //- Construct from FixedList
-        inline Pair(const FixedList<Type, 2>& lst)
-        :
-            FixedList<Type, 2>(lst)
-        {}
+        inline Pair(const FixedList<T, 2>& lst);
+
+        //- Construct, optionally sorted with first less-than second
+        inline Pair(const T& f, const T& s, const bool doSort);
+
+        //- Construct, optionally sorted with first less-than second
+        inline Pair(const FixedList<T, 2>& lst, const bool doSort);
 
         //- Construct from Istream
-        inline Pair(Istream& is)
-        :
-            FixedList<Type, 2>(is)
-        {}
+        inline Pair(Istream& is);
 
 
     // Member Functions
 
-        //- Return first
-        inline const Type& first() const
-        {
-            return this->operator[](0);
-        }
-
-        //- Return first
-        inline Type& first()
-        {
-            return this->operator[](0);
-        }
-
-        //- Return second
-        inline const Type& second() const
-        {
-            return this->operator[](1);
-        }
-
-        //- Return second
-        inline Type& second()
-        {
-            return this->operator[](1);
-        }
-
-        //- Return other
-        inline const Type& other(const Type& a) const
-        {
-            if (first() == second())
-            {
-                FatalErrorInFunction
-                    << "Call to other only valid for Pair with differing"
-                    << " elements:" << *this << abort(FatalError);
-            }
-            else if (first() == a)
-            {
-                return second();
-            }
-            else
-            {
-                if (second() != a)
-                {
-                    FatalErrorInFunction
-                        << "Pair " << *this
-                        << " does not contain " << a << abort(FatalError);
-                }
-                return first();
-            }
-        }
+      // Access
+
+        //- Return first element
+        using FixedList<T, 2>::first;
+
+        //- Return last element
+        using FixedList<T, 2>::last;
+
+        //- Return second element, which is also the last element
+        inline const T& second() const;
+
+        //- Return second element, which is also the last element
+        inline T& second();
+
+        //- Return other element
+        inline const T& other(const T& a) const;
+
+
+     // Queries
+
+        //- True if first() is less-than second()
+        inline bool sorted() const;
+
+
+     // Editing
+
+        //- Flip the Pair in-place.
+        inline void flip();
+
+        //- Sort so that first() is less-than second()
+        inline void sort();
 
 
      // Comparison
 
         //- Compare Pairs
-        //  Returns:
+        //  \return
         //  -  0: different
         //  - +1: identical values and order used
         //  - -1: identical values, but in reversed order
-        static inline int compare(const Pair<Type>& a, const Pair<Type>& b)
-        {
-            if (a[0] == b[0] && a[1] == b[1])
-            {
-                return 1;
-            }
-            else if (a[0] == b[1] && a[1] == b[0])
-            {
-                return -1;
-            }
-            else
-            {
-                return 0;
-            }
-        }
+        static inline int compare(const Pair<T>& a, const Pair<T>& b);
 };
 
 
 // * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * * //
 
-template<class Type>
-Pair<Type> reverse(const Pair<Type>& p)
+//- Return reverse of a Pair
+template<class T>
+Pair<T> reverse(const Pair<T>& p)
 {
-    return Pair<Type>(p.second(), p.first());
+    return Pair<T>(p.second(), p.first());
 }
 
 
-template<class Type>
-bool operator==(const Pair<Type>& a, const Pair<Type>& b)
+template<class T>
+bool operator==(const Pair<T>& a, const Pair<T>& b)
 {
     return (a.first() == b.first() && a.second() == b.second());
 }
 
 
-template<class Type>
-bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
+template<class T>
+bool operator!=(const Pair<T>& a, const Pair<T>& b)
 {
     return !(a == b);
 }
 
 
-template<class Type>
-bool operator<(const Pair<Type>& a, const Pair<Type>& b)
+template<class T>
+bool operator<(const Pair<T>& a, const Pair<T>& b)
 {
     return
     (
@@ -197,22 +165,22 @@ bool operator<(const Pair<Type>& a, const Pair<Type>& b)
 }
 
 
-template<class Type>
-bool operator<=(const Pair<Type>& a, const Pair<Type>& b)
+template<class T>
+bool operator<=(const Pair<T>& a, const Pair<T>& b)
 {
     return !(b < a);
 }
 
 
-template<class Type>
-bool operator>(const Pair<Type>& a, const Pair<Type>& b)
+template<class T>
+bool operator>(const Pair<T>& a, const Pair<T>& b)
 {
     return (b < a);
 }
 
 
-template<class Type>
-bool operator>=(const Pair<Type>& a, const Pair<Type>& b)
+template<class T>
+bool operator>=(const Pair<T>& a, const Pair<T>& b)
 {
     return !(a < b);
 }
@@ -224,6 +192,10 @@ bool operator>=(const Pair<Type>& a, const Pair<Type>& b)
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "PairI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Pair/PairI.H b/src/OpenFOAM/primitives/Pair/PairI.H
new file mode 100644
index 0000000000000000000000000000000000000000..2f489a03804ee19f403ecf845d9ca2ce5718dd6d
--- /dev/null
+++ b/src/OpenFOAM/primitives/Pair/PairI.H
@@ -0,0 +1,165 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "Swap.H"
+
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+template<class T>
+inline int Foam::Pair<T>::compare(const Pair<T>& a, const Pair<T>& b)
+{
+    if (a.first() == b.first() && a.second() == b.second())
+    {
+        return 1;
+    }
+    if (a.first() == b.second() && a.second() == b.first())
+    {
+        return -1;
+    }
+
+    return 0;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class T>
+inline Foam::Pair<T>::Pair()
+{}
+
+
+template<class T>
+inline Foam::Pair<T>::Pair(const T& f, const T& s)
+{
+    first()  = f;
+    second() = s;
+}
+
+
+template<class T>
+inline Foam::Pair<T>::Pair(const FixedList<T, 2>& lst)
+:
+    FixedList<T, 2>(lst)
+{}
+
+
+template<class T>
+inline Foam::Pair<T>::Pair(const T& f, const T& s, const bool doSort)
+{
+    if (doSort && f < s)
+    {
+        first()  = s;
+        second() = f;
+    }
+    else
+    {
+        first()  = f;
+        second() = s;
+    }
+}
+
+
+template<class T>
+inline Foam::Pair<T>::Pair(const FixedList<T, 2>& lst, const bool doSort)
+:
+    Pair<T>(lst.first(), lst.last(), doSort)
+{}
+
+
+
+template<class T>
+inline Foam::Pair<T>::Pair(Istream& is)
+:
+    FixedList<T, 2>(is)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class T>
+inline const T& Foam::Pair<T>::second() const
+{
+    return last();
+}
+
+
+template<class T>
+inline T& Foam::Pair<T>::second()
+{
+    return last();
+}
+
+
+template<class T>
+inline const T& Foam::Pair<T>::other(const T& a) const
+{
+    if (first() == second())
+    {
+        FatalErrorInFunction
+            << "Call to other only valid for Pair with differing"
+            << " elements:" << *this << abort(FatalError);
+    }
+    else if (a == first())
+    {
+        return second();
+    }
+    else
+    {
+        if (a != second())
+        {
+            FatalErrorInFunction
+                << "Pair " << *this
+                << " does not contain " << a << abort(FatalError);
+        }
+        return first();
+    }
+}
+
+
+template<class T>
+inline bool Foam::Pair<T>::sorted() const
+{
+    return (first() < second());
+}
+
+
+template<class T>
+inline void Foam::Pair<T>::flip()
+{
+    Foam::Swap(first(), second());
+}
+
+
+template<class T>
+inline void Foam::Pair<T>::sort()
+{
+    if (second() < first())
+    {
+        flip();
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Pair/labelPair.H b/src/OpenFOAM/primitives/Pair/labelPair.H
index 0e798e7b1519da4f21ed1c4b427722b85f6f1354..a2fa0f1168d4338e56b8fff570c5a665826e64ad 100644
--- a/src/OpenFOAM/primitives/Pair/labelPair.H
+++ b/src/OpenFOAM/primitives/Pair/labelPair.H
@@ -37,13 +37,19 @@ Typedef
     Foam::labelPairList
 
 Description
-    List of labelPairs
+    List of labelPairs.
 
 Typedef
     Foam::labelPairUList
 
 Description
-    UList of labelPairs
+    UList of labelPairs.
+
+Typedef
+    Foam::labelPairSubList
+
+Description
+    A SubList of labelPairs.
 
 \*---------------------------------------------------------------------------*/
 
@@ -51,6 +57,7 @@ Description
 #define labelPair_H
 
 #include "List.H"
+#include "SubList.H"
 #include "Pair.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -61,6 +68,7 @@ namespace Foam
     typedef Pair<labelPair> labelPairPair;
     typedef List<labelPair> labelPairList;
     typedef UList<labelPair> labelPairUList;
+    typedef SubList<labelPair> labelPairSubList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.C b/src/OpenFOAM/primitives/Scalar/Scalar.C
index d8eb7e06fc96c902396d0901d8c60dca7eadb28b..99e1b1c7c97960c1d4c609b15ed4c94753578436 100644
--- a/src/OpenFOAM/primitives/Scalar/Scalar.C
+++ b/src/OpenFOAM/primitives/Scalar/Scalar.C
@@ -80,10 +80,15 @@ Scalar ScalarRead(const char* buf)
 {
     char* endptr = nullptr;
     errno = 0;
+    const auto parsed = ScalarConvert(buf, &endptr);
 
-    const Scalar val = ScalarConvert(buf, &endptr);
+    const parsing::errorType err =
+    (
+        (parsed < -ScalarVGREAT || parsed > ScalarVGREAT)
+      ? parsing::errorType::RANGE
+      : parsing::checkConversion(buf, endptr)
+    );
 
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
     if (err != parsing::errorType::NONE)
     {
         FatalIOErrorInFunction("unknown")
@@ -91,7 +96,13 @@ Scalar ScalarRead(const char* buf)
             << exit(FatalIOError);
     }
 
-    return val;
+    // Round underflow to zero
+    return
+    (
+        (parsed > -ScalarVSMALL && parsed < ScalarVSMALL)
+      ? 0
+      : Scalar(parsed)
+    );
 }
 
 
@@ -99,21 +110,22 @@ bool readScalar(const char* buf, Scalar& val)
 {
     char* endptr = nullptr;
     errno = 0;
-
-    val = ScalarConvert(buf, &endptr);
-
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
-    if (err != parsing::errorType::NONE)
-    {
-        #ifdef FULLDEBUG
-        IOWarningInFunction("unknown")
-            << parsing::errorNames[err] << " '" << buf << "'"
-            << endl;
-        #endif
-        return false;
-    }
-
-    return true;
+    const auto parsed = ScalarConvert(buf, &endptr);
+
+    // Round underflow to zero
+    val =
+    (
+        (parsed >= -ScalarVSMALL && parsed <= ScalarVSMALL)
+      ? 0
+      : Scalar(parsed)
+    );
+
+    return
+    (
+        (parsed < -ScalarVGREAT || parsed > ScalarVGREAT)
+      ? false
+      : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE)
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C
index da73874c63374ed49a357ae4f86e8103053ae66f..41069b3555aa1a9e642d3173080db2bad84fa937 100644
--- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C
+++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.C
@@ -28,6 +28,7 @@ License
 #include "parsing.H"
 #include "IOstreams.H"
 
+#include <cstdlib>
 #include <sstream>
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -40,7 +41,8 @@ License
 #define ScalarROOTVGREAT doubleScalarROOTVGREAT
 #define ScalarROOTVSMALL doubleScalarROOTVSMALL
 #define ScalarRead readDouble
-#define ScalarConvert ::strtod
+// Convert using larger representation to properly capture underflow
+#define ScalarConvert ::strtold
 
 #include "Scalar.C"
 
diff --git a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H
index b7a0b8fd562ea94a08add0af9add7dc4b5ba8255..143245890e4cbff4c1150716066af72151dca10e 100644
--- a/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H
+++ b/src/OpenFOAM/primitives/Scalar/doubleScalar/doubleScalar.H
@@ -51,13 +51,13 @@ typedef double doubleScalar;
 // Largest and smallest scalar values allowed in certain parts of the code.
 // (15 is the number of significant figures in an
 //  IEEE double precision number.  See limits.h or float.h)
-static const doubleScalar doubleScalarGREAT = 1.0e+15;
-static const doubleScalar doubleScalarVGREAT = 1.0e+300;
-static const doubleScalar doubleScalarROOTVGREAT = 1.0e+150;
-static const doubleScalar doubleScalarSMALL = 1.0e-15;
-static const doubleScalar doubleScalarROOTSMALL = 3.0e-8;
-static const doubleScalar doubleScalarVSMALL = 1.0e-300;
-static const doubleScalar doubleScalarROOTVSMALL = 1.0e-150;
+constexpr doubleScalar doubleScalarGREAT = 1.0e+15;
+constexpr doubleScalar doubleScalarVGREAT = 1.0e+300;
+constexpr doubleScalar doubleScalarROOTVGREAT = 1.0e+150;
+constexpr doubleScalar doubleScalarSMALL = 1.0e-15;
+constexpr doubleScalar doubleScalarROOTSMALL = 3.0e-8;
+constexpr doubleScalar doubleScalarVSMALL = 1.0e-300;
+constexpr doubleScalar doubleScalarROOTVSMALL = 1.0e-150;
 
 
 #define Scalar doubleScalar
diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C
index 94d40441f7a59b47dd4fe5e3ea1f61d99b12ea26..5a8e071556113ea3f6fbfe5b02dca6eeb27054bd 100644
--- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C
+++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.C
@@ -40,7 +40,8 @@ License
 #define ScalarROOTVGREAT floatScalarROOTVGREAT
 #define ScalarROOTVSMALL floatScalarROOTVSMALL
 #define ScalarRead readFloat
-#define ScalarConvert ::strtof
+// Convert using larger representation to properly capture underflow
+#define ScalarConvert ::strtod
 
 #include "Scalar.C"
 
diff --git a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H
index 07c8a4aa66052323750a685ec29e68210b7c899e..951de0f84fb6859a3d7e4bef7abba17a19f7626c 100644
--- a/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H
+++ b/src/OpenFOAM/primitives/Scalar/floatScalar/floatScalar.H
@@ -51,13 +51,13 @@ typedef float floatScalar;
 // Largest and smallest scalar values allowed in certain parts of the code.
 // (6 is the number of significant figures in an
 //  IEEE single precision number.  See limits.h or float.h)
-static const floatScalar floatScalarGREAT = 1.0e+6;
-static const floatScalar floatScalarVGREAT = 1.0e+37;
-static const floatScalar floatScalarROOTVGREAT = 1.0e+18;
-static const floatScalar floatScalarSMALL = 1.0e-6;
-static const floatScalar floatScalarROOTSMALL = 1.0e-3;
-static const floatScalar floatScalarVSMALL = 1.0e-37;
-static const floatScalar floatScalarROOTVSMALL = 1.0e-18;
+constexpr floatScalar floatScalarGREAT = 1.0e+6;
+constexpr floatScalar floatScalarVGREAT = 1.0e+37;
+constexpr floatScalar floatScalarROOTVGREAT = 1.0e+18;
+constexpr floatScalar floatScalarSMALL = 1.0e-6;
+constexpr floatScalar floatScalarROOTSMALL = 1.0e-3;
+constexpr floatScalar floatScalarVSMALL = 1.0e-37;
+constexpr floatScalar floatScalarROOTVSMALL = 1.0e-18;
 
 
 #define Scalar floatScalar
diff --git a/src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H b/src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H
new file mode 100644
index 0000000000000000000000000000000000000000..00a2a37050fdc8e59e8ff0b8258b7d0003f8056f
--- /dev/null
+++ b/src/OpenFOAM/primitives/Scalar/lists/scalarIndList.H
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Typedef
+    Foam::scalarIndList
+
+Description
+    An IndirectList of scalars.
+
+Typedef
+    Foam::scalarUIndList
+
+Description
+    A UIndirectList of scalars.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef scalarIndList_H
+#define scalarIndList_H
+
+// Include all normal list typedefs as well
+#include "scalarList.H"
+#include "IndirectList.H"
+#include "UIndirectList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef IndirectList<scalar>  scalarIndList;
+    typedef UIndirectList<scalar> scalarUIndList;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Scalar/lists/scalarList.C b/src/OpenFOAM/primitives/Scalar/lists/scalarList.C
index 8b81dba98498b11115289e2b5ddc3623422b9dbd..24a5f392cf47fe0d6475432d38327e44f4eb6117 100644
--- a/src/OpenFOAM/primitives/Scalar/lists/scalarList.C
+++ b/src/OpenFOAM/primitives/Scalar/lists/scalarList.C
@@ -21,9 +21,6 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-Description
-    Specialisation of List\<T\> for scalar.
-
 \*---------------------------------------------------------------------------*/
 
 #include "scalarList.H"
diff --git a/src/OpenFOAM/primitives/Scalar/lists/scalarList.H b/src/OpenFOAM/primitives/Scalar/lists/scalarList.H
index eaad958adba65d3261248528ce903233c01d1e89..ef366eafde4c91710c4b8e168b8b54e3323248e0 100644
--- a/src/OpenFOAM/primitives/Scalar/lists/scalarList.H
+++ b/src/OpenFOAM/primitives/Scalar/lists/scalarList.H
@@ -33,6 +33,18 @@ Typedef
 Description
     A List of scalars.
 
+Typedef
+    Foam::scalarSubList
+
+Description
+    A SubList of scalars.
+
+Typedef
+    Foam::scalarListList
+
+Description
+    A List of scalarList.
+
 \*---------------------------------------------------------------------------*/
 
 #ifndef scalarList_H
@@ -40,14 +52,15 @@ Description
 
 #include "scalar.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
     typedef UList<scalar> scalarUList;
-
     typedef List<scalar> scalarList;
+    typedef SubList<scalar> scalarSubList;
     typedef List<scalarList> scalarListList;
 }
 
diff --git a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H
index e705dc8550a53094a2645acc79e2321bbf972520..33b7a61c18b1c07fb1ee8731294e4726dbb99e4b 100644
--- a/src/OpenFOAM/primitives/Scalar/scalar/scalar.H
+++ b/src/OpenFOAM/primitives/Scalar/scalar/scalar.H
@@ -49,13 +49,13 @@ namespace Foam
 {
     typedef floatScalar scalar;
 
-    static const scalar GREAT = floatScalarGREAT;
-    static const scalar VGREAT = floatScalarVGREAT;
-    static const scalar ROOTVGREAT = floatScalarROOTVGREAT;
-    static const scalar SMALL = floatScalarSMALL;
-    static const scalar ROOTSMALL = floatScalarROOTSMALL;
-    static const scalar VSMALL = floatScalarVSMALL;
-    static const scalar ROOTVSMALL = floatScalarROOTVSMALL;
+    constexpr scalar GREAT = floatScalarGREAT;
+    constexpr scalar VGREAT = floatScalarVGREAT;
+    constexpr scalar ROOTVGREAT = floatScalarROOTVGREAT;
+    constexpr scalar SMALL = floatScalarSMALL;
+    constexpr scalar ROOTSMALL = floatScalarROOTSMALL;
+    constexpr scalar VSMALL = floatScalarVSMALL;
+    constexpr scalar ROOTVSMALL = floatScalarROOTVSMALL;
 
     scalar readScalar(Istream& is);
 
@@ -73,13 +73,13 @@ namespace Foam
 {
     typedef doubleScalar scalar;
 
-    static const scalar GREAT = doubleScalarGREAT;
-    static const scalar VGREAT = doubleScalarVGREAT;
-    static const scalar ROOTVGREAT = doubleScalarROOTVGREAT;
-    static const scalar SMALL = doubleScalarSMALL;
-    static const scalar ROOTSMALL = doubleScalarROOTSMALL;
-    static const scalar VSMALL = doubleScalarVSMALL;
-    static const scalar ROOTVSMALL = doubleScalarROOTVSMALL;
+    constexpr scalar GREAT = doubleScalarGREAT;
+    constexpr scalar VGREAT = doubleScalarVGREAT;
+    constexpr scalar ROOTVGREAT = doubleScalarROOTVGREAT;
+    constexpr scalar SMALL = doubleScalarSMALL;
+    constexpr scalar ROOTSMALL = doubleScalarROOTSMALL;
+    constexpr scalar VSMALL = doubleScalarVSMALL;
+    constexpr scalar ROOTVSMALL = doubleScalarROOTVSMALL;
 
     scalar readScalar(Istream& is);
 
diff --git a/src/OpenFOAM/primitives/Swap/Swap.H b/src/OpenFOAM/primitives/Swap/Swap.H
index 85b0c7316da4cf3e85fae59e92e456e269feb66c..0c2b20b1d4d282ff61e59c5a702fc6bdfe164622 100644
--- a/src/OpenFOAM/primitives/Swap/Swap.H
+++ b/src/OpenFOAM/primitives/Swap/Swap.H
@@ -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) 2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -25,28 +25,56 @@ InNamespace
     Foam
 
 Description
-    Swap its arguments
+    Swap arguments as per std::swap, but in Foam namespace.
 
 \*---------------------------------------------------------------------------*/
 
 #ifndef Swap_H
 #define Swap_H
 
+#include <type_traits>
+#include <utility>
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
+//- Swap non-array types as per std::swap example, but in Foam namespace.
+//  \sa http://www.cplusplus.com/reference/utility/swap/
 template<class T>
-inline void Swap(T& a, T& b)
+void Swap(T& a, T& b)
+{
+    // compile-time resolution with std::enable_if not yet working
+    if (std::is_fundamental<T>::value || std::is_pointer<T>::value)
+    {
+        // Use copy/assign for simple types
+        const T tmp = a;
+        a = b;
+        b = tmp;
+    }
+    else
+    {
+        // Use move/assignment
+        T tmp(std::move(a));
+        a = std::move(b);
+        b = std::move(tmp);
+    }
+}
+
+
+//- Swap array types as per std::swap example, but in Foam namespace.
+//  \sa http://www.cplusplus.com/reference/utility/swap/
+template<class T, size_t N>
+void Swap(T (&a)[N], T (&b)[N])
 {
-    T tmp = a;
-    a = b;
-    b = tmp;
+    for (size_t i = 0; i < N; ++i)
+    {
+        Foam::Swap(a[i], b[i]);
+    }
 }
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/primitives/Tuple2/Tuple2.H b/src/OpenFOAM/primitives/Tuple2/Tuple2.H
index bf911ebc56bfc42ca40e2fdc66e558a7d9fee582..195f74044ce0ec9e1d21e40f26590a514b68e060 100644
--- a/src/OpenFOAM/primitives/Tuple2/Tuple2.H
+++ b/src/OpenFOAM/primitives/Tuple2/Tuple2.H
@@ -144,7 +144,7 @@ public:
 };
 
 
-//- Return reverse of a tuple2
+//- Return reverse of a Tuple2
 template<class Type1, class Type2>
 inline Tuple2<Type2, Type1> reverse(const Tuple2<Type1, Type2>& t)
 {
diff --git a/src/OpenFOAM/primitives/Vector/lists/vectorIndList.H b/src/OpenFOAM/primitives/Vector/lists/vectorIndList.H
new file mode 100644
index 0000000000000000000000000000000000000000..b035cb45657917f977128e7962155ca3f5362cf8
--- /dev/null
+++ b/src/OpenFOAM/primitives/Vector/lists/vectorIndList.H
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Typedef
+    Foam::vectorIndList
+
+Description
+    An IndirectList of vectors.
+
+Typedef
+    Foam::vectorUIndList
+
+Description
+    A UIndirectList of vectors.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef vectorIndList_H
+#define vectorIndList_H
+
+// Include all normal list typedefs as well
+#include "vectorList.H"
+#include "IndirectList.H"
+#include "UIndirectList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef IndirectList<vector>  vectorIndList;
+    typedef UIndirectList<vector> vectorUIndList;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Vector/lists/vectorList.H b/src/OpenFOAM/primitives/Vector/lists/vectorList.H
index ba921ced145113e0add9162572a120c31a954f95..a582586c4e6ab13d381b7c6abc962aab87732dcf 100644
--- a/src/OpenFOAM/primitives/Vector/lists/vectorList.H
+++ b/src/OpenFOAM/primitives/Vector/lists/vectorList.H
@@ -33,6 +33,18 @@ Typedef
 Description
     A List of vectors.
 
+Typedef
+    Foam::vectorSubList
+
+Description
+    A SubList of vectors.
+
+Typedef
+    Foam::vectorListList
+
+Description
+    A List of vectorList.
+
 \*---------------------------------------------------------------------------*/
 
 #ifndef vectorList_H
@@ -40,14 +52,16 @@ Description
 
 #include "vector.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
     typedef UList<vector> vectorUList;
-
     typedef List<vector> vectorList;
+    typedef SubList<vector> vectorSubList;
+    typedef List<vectorList> vectorListList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/enums/Enum.H b/src/OpenFOAM/primitives/enums/Enum.H
index b57fc9891ac1c73fe6a883f04fd404e0480e4acf..85b96f314f53faa50144dc6ca033732b21fa2a18 100644
--- a/src/OpenFOAM/primitives/enums/Enum.H
+++ b/src/OpenFOAM/primitives/enums/Enum.H
@@ -105,7 +105,7 @@ public:
         explicit Enum(std::initializer_list<std::pair<EnumType, word>> lst);
 
         //- Construct from a list of names with values incremented from the
-        //  specified start value.
+        //- specified start value.
         Enum(const EnumType start, std::initializer_list<word> lst);
 
 
@@ -141,7 +141,7 @@ public:
       // Lookup
 
         //- Lookup the key in the dictionary and return the corresponding
-        //  enumeration element based on its name.
+        //- enumeration element based on its name.
         //  Fatal if anything is incorrect.
         EnumType lookup
         (
@@ -150,7 +150,7 @@ public:
         ) const;
 
         //- Find the key in the dictionary and return the corresponding
-        //  enumeration element based on its name.
+        //- enumeration element based on its name.
         //  Return the default value if the key was not found in the dictionary.
         //  Fatal if the enumerated name was incorrect.
         EnumType lookupOrDefault
@@ -162,7 +162,7 @@ public:
 
 
         //- Find the key in the dictionary and return the corresponding
-        //  enumeration element based on its name.
+        //- enumeration element based on its name.
         //  Return the default value if the key was not found in the dictionary
         //  or if the enumerated name was incorrect (emit warning)
         EnumType lookupOrFailsafe
diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H
index 6e3b14ba0c064a97134e82fe2841bee31f494f8a..ad78b17f5531cedf84320f1f66505678b61b01a1 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H
+++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H
@@ -23,8 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef Function1Fws_H
-#define Function1Fws_H
+#ifndef Function1Fwd_H
+#define Function1Fwd_H
 
 #include "Function1.H"
 #include "vector.H"
diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C
index db5779edda3a237f4971385e70fb3b6da068cc33..c952a6f6c84f46d2af4ed074439cb4b8ee066d20 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C
@@ -71,11 +71,13 @@ void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const
 {
     Function1<Type>::writeData(os);
     os  << token::END_STATEMENT << nl;
-    os  << indent << word(this->name() + "Coeffs") << nl;
-    os  << indent << token::BEGIN_BLOCK << incrIndent << nl;
+
+    os.beginBlock(word(this->name() + "Coeffs"));
+
     scale_->writeData(os);
     value_->writeData(os);
-    os  << decrIndent << indent << token::END_BLOCK << endl;
+
+    os.endBlock();
 }
 
 
diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C
index 0efcbcf146328978284a7c6d0fb466b8a40debe5..5a6e5104114f3b7fd61eca3672d2ab9f170172cc 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C
@@ -345,18 +345,19 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
 template<class Type>
 void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const
 {
-    if (bounding_ != bounds::repeatableBounding::CLAMP)
-    {
-        os.writeEntry
-        (
-            "outOfBounds",
-            bounds::repeatableBoundingNames[bounding_]
-        );
-    }
-    if (interpolationScheme_ != "linear")
-    {
-        os.writeEntry("interpolationScheme", interpolationScheme_);
-    }
+    os.writeEntryIfDifferent<word>
+    (
+        "outOfBounds",
+        bounds::repeatableBoundingNames[bounds::repeatableBounding::CLAMP],
+        bounds::repeatableBoundingNames[bounding_]
+    );
+
+    os.writeEntryIfDifferent<word>
+    (
+        "interpolationScheme",
+        "linear",
+        interpolationScheme_
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C
index 40645aa1910708f1fdc6e363d793b5f631ae22ee..773a072f2ef794b5a6889a3fb6dd6f6ab3f660ea 100644
--- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C
+++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C
@@ -58,11 +58,13 @@ void Foam::Function1Types::ramp::writeData(Ostream& os) const
 {
     Function1<scalar>::writeData(os);
     os  << token::END_STATEMENT << nl;
-    os  << indent << word(this->name() + "Coeffs") << nl;
-    os  << indent << token::BEGIN_BLOCK << incrIndent << nl;
-    os.writeKeyword("start") << start_ << token::END_STATEMENT << nl;
-    os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl;
-    os  << decrIndent << indent << token::END_BLOCK << endl;
+
+    os.beginBlock(word(this->name() + "Coeffs"));
+
+    os.writeEntry("start", start_);
+    os.writeEntry("duration", duration_);
+
+    os.endBlock();
 }
 
 
diff --git a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C
index b6ca5a26efedc6ab7e1025710ad3b160ff3812b6..bebceaeeca4d4913c3bb84dfccfb614d7ca76547 100644
--- a/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C
+++ b/src/OpenFOAM/primitives/globalIndexAndTransform/globalIndexAndTransform.C
@@ -404,7 +404,7 @@ bool Foam::globalIndexAndTransform::uniqueTransform
     const labelPair& patchTrafo
 ) const
 {
-    if (findIndex(trafos, patchTrafo) == -1)
+    if (!trafos.found(patchTrafo))
     {
         // New transform. Check if already have 3
         if (trafos.size() == 3)
diff --git a/src/OpenFOAM/primitives/ints/int/intIO.C b/src/OpenFOAM/primitives/ints/int/intIO.C
index 6a2901aefb04eba927a1e822cbbde69e57e57372..f9a8e2a58b91865a78d1ef8cd7863b22a4a6ef6d 100644
--- a/src/OpenFOAM/primitives/ints/int/intIO.C
+++ b/src/OpenFOAM/primitives/ints/int/intIO.C
@@ -39,13 +39,13 @@ int Foam::readInt(const char* buf)
 
     const int val = int(parsed);
 
-    if (parsed < INT_MIN || parsed > INT_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
+    const parsing::errorType err =
+    (
+        (parsed < INT_MIN || parsed > INT_MAX)
+      ? parsing::errorType::RANGE
+      : parsing::checkConversion(buf, endptr)
+    );
 
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
     if (err != parsing::errorType::NONE)
     {
         FatalIOErrorInFunction("unknown")
@@ -65,24 +65,12 @@ bool Foam::readInt(const char* buf, int& val)
 
     val = int(parsed);
 
-    if (parsed < INT_MIN || parsed > INT_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
-
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
-    if (err != parsing::errorType::NONE)
-    {
-        #ifdef FULLDEBUG
-        IOWarningInFunction("unknown")
-            << parsing::errorNames[err] << " '" << buf << "'"
-            << endl;
-        #endif
-        return false;
-    }
-
-    return true;
+    return
+    (
+        (parsed < INT_MIN || parsed > INT_MAX)
+      ? false
+      : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE)
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/ints/int32/int32IO.C b/src/OpenFOAM/primitives/ints/int32/int32IO.C
index f1b4f23fb05a214e3fea27789bc425fe68cb6f95..926421ff2b32ce1b18ef3480b1d1f32db9f7be32 100644
--- a/src/OpenFOAM/primitives/ints/int32/int32IO.C
+++ b/src/OpenFOAM/primitives/ints/int32/int32IO.C
@@ -39,13 +39,13 @@ int32_t Foam::readInt32(const char* buf)
 
     const int32_t val = int32_t(parsed);
 
-    if (parsed < INT32_MIN || parsed > INT32_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
+    const parsing::errorType err =
+    (
+        (parsed < INT32_MIN || parsed > INT32_MAX)
+      ? parsing::errorType::RANGE
+      : parsing::checkConversion(buf, endptr)
+    );
 
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
     if (err != parsing::errorType::NONE)
     {
         FatalIOErrorInFunction("unknown")
@@ -65,24 +65,12 @@ bool Foam::readInt32(const char* buf, int32_t& val)
 
     val = int32_t(parsed);
 
-    if (parsed < INT32_MIN || parsed > INT32_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
-
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
-    if (err != parsing::errorType::NONE)
-    {
-        #ifdef FULLDEBUG
-        IOWarningInFunction("unknown")
-            << parsing::errorNames[err] << " '" << buf << "'"
-            << endl;
-        #endif
-        return false;
-    }
-
-    return true;
+    return
+    (
+        (parsed < INT32_MIN || parsed > INT32_MAX)
+      ? false
+      : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE)
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/ints/int64/int64IO.C b/src/OpenFOAM/primitives/ints/int64/int64IO.C
index d16d979d6f21a1ebec28ede6a1376b7e65c82615..1a2ad639e3f0d01ac795066564eece5846b5fb8a 100644
--- a/src/OpenFOAM/primitives/ints/int64/int64IO.C
+++ b/src/OpenFOAM/primitives/ints/int64/int64IO.C
@@ -39,13 +39,13 @@ int64_t Foam::readInt64(const char* buf)
 
     const int64_t val = int64_t(parsed);
 
-    if (parsed < INT64_MIN || parsed > INT64_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
+    const parsing::errorType err =
+    (
+        (parsed < INT64_MIN || parsed > INT64_MAX)
+      ? parsing::errorType::RANGE
+      : parsing::checkConversion(buf, endptr)
+    );
 
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
     if (err != parsing::errorType::NONE)
     {
         FatalIOErrorInFunction("unknown")
@@ -65,24 +65,12 @@ bool Foam::readInt64(const char* buf, int64_t& val)
 
     val = int64_t(parsed);
 
-    if (parsed < INT64_MIN || parsed > INT64_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
-
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
-    if (err != parsing::errorType::NONE)
-    {
-        #ifdef FULLDEBUG
-        IOWarningInFunction("unknown")
-            << parsing::errorNames[err] << " '" << buf << "'"
-            << endl;
-        #endif
-        return false;
-    }
-
-    return true;
+    return
+    (
+        (parsed < INT64_MIN || parsed > INT64_MAX)
+      ? false
+      : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE)
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/ints/label/label.H b/src/OpenFOAM/primitives/ints/label/label.H
index 08b4d1ff39cfbb1e47b29f4b2c31cd603957e41c..11a862fd7cb4aa3f03569417f085b0c18f7199d1 100644
--- a/src/OpenFOAM/primitives/ints/label/label.H
+++ b/src/OpenFOAM/primitives/ints/label/label.H
@@ -58,8 +58,8 @@ namespace Foam
 
 typedef INT_SIZE(int, _t) label;
 
-static const label labelMin = INT_SIZE(INT, _MIN);
-static const label labelMax = INT_SIZE(INT, _MAX);
+constexpr label labelMin = INT_SIZE(INT, _MIN);
+constexpr label labelMax = INT_SIZE(INT, _MAX);
 
 //- Read label from stream.
 //  Uses readInt32 or readInt64 according to WM_LABEL_SIZE
diff --git a/src/OpenFOAM/primitives/ints/lists/labelIndList.H b/src/OpenFOAM/primitives/ints/lists/labelIndList.H
new file mode 100644
index 0000000000000000000000000000000000000000..3a20c2469cc06cdcee6eb75dffbd62e7f1d59fa3
--- /dev/null
+++ b/src/OpenFOAM/primitives/ints/lists/labelIndList.H
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Typedef
+    Foam::labelIndList
+
+Description
+    A IndirectList of labels.
+
+Typedef
+    Foam::labelUIndList
+
+Description
+    An UIndirectList of labels.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef labelIndList_H
+#define labelIndList_H
+
+// Include all normal list typedefs as well
+#include "labelList.H"
+#include "IndirectList.H"
+#include "UIndirectList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    typedef IndirectList<label>  labelIndList;
+    typedef UIndirectList<label> labelUIndList;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/ints/lists/labelList.H b/src/OpenFOAM/primitives/ints/lists/labelList.H
index b64aead443910bcf382b1610202ef065d0f6ed3d..30536a59a91fc4ff02fb63f0db37ef98d91810fe 100644
--- a/src/OpenFOAM/primitives/ints/lists/labelList.H
+++ b/src/OpenFOAM/primitives/ints/lists/labelList.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,19 +25,25 @@ Typedef
     Foam::labelList
 
 Description
-    A List of labels
+    A List of labels.
+
+Typedef
+    Foam::labelSubList
+
+Description
+    A SubList of labels.
 
 Typedef
     Foam::labelListList
 
 Description
-    A List of labelList
+    A List of labelList.
 
 Typedef
     Foam::labelListListList
 
 Description
-    A List of labelListList
+    A List of labelListList.
 
 \*---------------------------------------------------------------------------*/
 
@@ -46,14 +52,16 @@ Description
 
 #include "label.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-    // Note: frequently used UList version is located in container itself
+    // Note: frequently used labelUList is defined in UList itself
 
     typedef List<label> labelList;
+    typedef SubList<label> labelSubList;
     typedef List<labelList> labelListList;
     typedef List<labelListList> labelListListList;
 }
diff --git a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H
index 9a8713f7338f338337b63b11a3964872f791442f..afdf9f39e6cb2d27dacda0116009a8353732cd71 100644
--- a/src/OpenFOAM/primitives/ints/uLabel/uLabel.H
+++ b/src/OpenFOAM/primitives/ints/uLabel/uLabel.H
@@ -58,7 +58,7 @@ namespace Foam
 
 typedef UINT_SIZE(uint, _t) uLabel;
 
-static const uLabel uLabelMax = UINT_SIZE(UINT, _MAX);
+constexpr uLabel uLabelMax = UINT_SIZE(UINT, _MAX);
 
 //- Read uLabel from stream.
 //  Uses readUint32 or readUint64 according to WM_LABEL_SIZE
diff --git a/src/OpenFOAM/primitives/ints/uint32/uint32IO.C b/src/OpenFOAM/primitives/ints/uint32/uint32IO.C
index bf4e6fb8a02c2a2a53bd2a698a07fe65fbb429f5..96fdc8c85bcbef4de3e9e6dea05bd3c29ba7496d 100644
--- a/src/OpenFOAM/primitives/ints/uint32/uint32IO.C
+++ b/src/OpenFOAM/primitives/ints/uint32/uint32IO.C
@@ -38,13 +38,13 @@ uint32_t Foam::readUint32(const char* buf)
 
     const uint32_t val = uint32_t(parsed);
 
-    if (parsed > UINT32_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
+    const parsing::errorType err =
+    (
+        (parsed > UINT32_MAX)
+      ? parsing::errorType::RANGE
+      : parsing::checkConversion(buf, endptr)
+    );
 
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
     if (err != parsing::errorType::NONE)
     {
         FatalIOErrorInFunction("unknown")
@@ -64,24 +64,12 @@ bool Foam::readUint32(const char* buf, uint32_t& val)
 
     val = uint32_t(parsed);
 
-    if (parsed > UINT32_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
-
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
-    if (err != parsing::errorType::NONE)
-    {
-        #ifdef FULLDEBUG
-        IOWarningInFunction("unknown")
-            << parsing::errorNames[err] << " '" << buf << "'"
-            << endl;
-        #endif
-        return false;
-    }
-
-    return true;
+    return
+    (
+        (parsed > UINT32_MAX)
+      ? false
+      : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE)
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64IO.C b/src/OpenFOAM/primitives/ints/uint64/uint64IO.C
index 2f23b89dddefab74e8e05814e34efd563818b7de..b73e90e7714c47a777909ddc6214155ecf56f8f2 100644
--- a/src/OpenFOAM/primitives/ints/uint64/uint64IO.C
+++ b/src/OpenFOAM/primitives/ints/uint64/uint64IO.C
@@ -38,13 +38,13 @@ uint64_t Foam::readUint64(const char* buf)
 
     const uint64_t val = uint64_t(parsed);
 
-    if (parsed > UINT64_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
+    const parsing::errorType err =
+    (
+        (parsed > UINT64_MAX)
+      ? parsing::errorType::RANGE
+      : parsing::checkConversion(buf, endptr)
+    );
 
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
     if (err != parsing::errorType::NONE)
     {
         FatalIOErrorInFunction("unknown")
@@ -64,24 +64,12 @@ bool Foam::readUint64(const char* buf, uint64_t& val)
 
     val = uint64_t(parsed);
 
-    if (parsed > UINT64_MAX)
-    {
-        // Range error
-        errno = ERANGE;
-    }
-
-    const parsing::errorType err = parsing::checkConversion(buf, endptr);
-    if (err != parsing::errorType::NONE)
-    {
-        #ifdef FULLDEBUG
-        IOWarningInFunction("unknown")
-            << parsing::errorNames[err] << " '" << buf << "'"
-            << endl;
-        #endif
-        return false;
-    }
-
-    return true;
+    return
+    (
+        (parsed > UINT64_MAX)
+      ? false
+      : (parsing::checkConversion(buf, endptr) == parsing::errorType::NONE)
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/nullObject/nullObject.H b/src/OpenFOAM/primitives/nullObject/nullObject.H
index e0ab12029ef88fa979be5a3b955362ff93e6443c..d2316fa5d3774473c036daee264a353988b66c46 100644
--- a/src/OpenFOAM/primitives/nullObject/nullObject.H
+++ b/src/OpenFOAM/primitives/nullObject/nullObject.H
@@ -22,12 +22,13 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Class
-    Foam::nullObject
+    Foam::NullObject
 
 Description
     Singleton null-object class and instance.
-    It occupies enough space to reinterpret its content as a class with
-    a null pointer for its content.
+    Its contents occupy just enough space to also be reinterpreted
+    as another class with a null pointer or zero long for its first
+    member.
 
 SourceFiles
     nullObjectI.H
@@ -43,8 +44,14 @@ SourceFiles
 namespace Foam
 {
 
+// Forward declarations
+class Istream;
+class Ostream;
+
+class NullObject;
+
 /*---------------------------------------------------------------------------*\
-                         Class nullObject Declaration
+                         Class NullObject Declaration
 \*---------------------------------------------------------------------------*/
 
 class NullObject
@@ -55,12 +62,12 @@ class NullObject
     {
         void* ptr;
         unsigned long val;
-    } null;
+    } content;
 
-    //- Private constructor
+    //- Private constructor for singleton only
     NullObject()
     :
-        null{nullptr}
+        content{nullptr}
     {}
 
     //- Disallow default bitwise copy construct
@@ -70,23 +77,44 @@ class NullObject
     void operator=(const NullObject&) = delete;
 
 public:
-    //- The unique null object
-    static const NullObject nullObject;
 
-    //- A nullptr pointer content
-    inline const void* pointer() const
-    {
-        return null.ptr;
-    }
+    // Static Data
 
-    //- A zero value content
-    inline unsigned long value() const
-    {
-        return null.val;
-    }
+        //- A unique null object
+        static const NullObject nullObject;
+
+
+    // Member Functions
+
+        //- A nullptr pointer content
+        inline const void* pointer() const
+        {
+            return content.ptr;
+        }
+
+        //- Zero valued integer content
+        inline unsigned long value() const
+        {
+            return content.val;
+        }
 };
 
 
+// IOstream Operators
+
+//- Read from Istream consumes no content.
+inline Istream& operator>>(Istream& is, NullObject&)
+{
+    return is;
+}
+
+//- Write to Ostream emits no content.
+inline Ostream& operator<<(Ostream& os, const NullObject&)
+{
+    return os;
+}
+
+
 //- Pointer to the unique nullObject
 extern const NullObject* nullObjectPtr;
 
diff --git a/src/OpenFOAM/primitives/one/one.H b/src/OpenFOAM/primitives/one/one.H
index a184af000dfc401a333b83e4adb2ac095e069e58..350db36483db35f7f83dc194967807e29bbac6c1 100644
--- a/src/OpenFOAM/primitives/one/one.H
+++ b/src/OpenFOAM/primitives/one/one.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,9 +25,8 @@ Class
     Foam::one
 
 Description
-    A class representing the concept of 1 (scalar(1.0)) used to avoid
-    unnecessary manipulations for objects which are known to be one at
-    compile-time.
+    A class representing the concept of 1 (or 1.0) used to avoid unnecessary
+    manipulations for objects that are known to be one at compile-time.
 
 SourceFiles
     oneI.H
@@ -44,6 +43,11 @@ SourceFiles
 namespace Foam
 {
 
+// Forward declaration of classes, friend functions and operators
+class Istream;
+class Ostream;
+class one;
+
 /*---------------------------------------------------------------------------*\
                            Class one Declaration
 \*---------------------------------------------------------------------------*/
@@ -51,15 +55,22 @@ namespace Foam
 class one
 {
 public:
-
     typedef one value_type;
 
+    // Forward declaration
+    class null;
+
+
     // Constructors
 
-        //- Construct null
+        //- Null constructible
         one()
         {}
 
+        //- Construct null from Istream. Consumes no content.
+        explicit one(Istream&)
+        {}
+
 
     // Member operators
 
@@ -83,6 +94,43 @@ public:
 };
 
 
+/*---------------------------------------------------------------------------*\
+                          Class one::null Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A one class with a null output adapter.
+class one::null
+:
+    public one
+{
+public:
+    typedef null value_type;
+
+    //- Null constructible
+    null()
+    {}
+
+    //- Construct null from Istream without consuming any content.
+    explicit null(Istream&)
+    {}
+};
+
+
+// IOstream Operators
+
+//- Read from Istream consumes no content.
+inline Istream& operator>>(Istream& is, one&)
+{
+    return is;
+}
+
+//- Write to Ostream emits no content.
+inline Ostream& operator<<(Ostream& os, const one::null&)
+{
+    return os;
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/primitives/predicates/predicates.H b/src/OpenFOAM/primitives/predicates/predicates.H
index 0d7d8539fa24394ddb2e743888df4ace222ad59c..a44b4eec7e2749ab83e1b396e0489aa967977b5c 100644
--- a/src/OpenFOAM/primitives/predicates/predicates.H
+++ b/src/OpenFOAM/primitives/predicates/predicates.H
@@ -49,37 +49,40 @@ namespace predicates
                            Class always Declaration
 \*---------------------------------------------------------------------------*/
 
-//- Unary and binary predicates returning true, useful for templating.
-class always
+//- Unary and binary predicates that always return true, useful for templating.
+struct always
 {
-public:
     typedef always value_type;
 
-    //- Construct null
+    //- Null constructible
     inline always()
     {}
 
-    //- Evaluated as a bool - return true
+    //- Evaluated as a bool
+    //  \return true
     inline operator bool() const
     {
         return true;
     }
 
-    //- Unary predicate returning true
+    //- Unary predicate
+    //  \return true
     template<class T>
     inline bool operator()(const T&) const
     {
         return true;
     }
 
-    //- Binary predicate returning true
+    //- Binary predicate
+    //  \return true
     template<class T1, class T2>
     inline bool operator()(const T1&, const T2&) const
     {
         return true;
     }
 
-    //- String match returning true
+    //- String match
+    //  \return true
     inline bool match(const std::string&, bool literal=false) const
     {
         return true;
@@ -91,37 +94,40 @@ public:
                             Class never Declaration
 \*---------------------------------------------------------------------------*/
 
-//- Unary and binary predicates returning false, useful for templating.
-class never
+//- Unary and binary predicates that never return true, useful for templating.
+struct never
 {
-public:
     typedef never value_type;
 
-    //- Construct null
+    //- Null constructible
     inline never()
     {}
 
-    //- Evaluated as a bool - return false
+    //- Evaluated as a bool
+    //  \return false
     inline operator bool() const
     {
         return false;
     }
 
-    //- Unary predicate returning false
+    //- Unary predicate
+    //  \return false
     template<class T>
     inline bool operator()(const T&) const
     {
         return false;
     }
 
-    //- Binary predicate returning false
+    //- Binary predicate
+    //  \return false
     template<class T1, class T2>
     inline bool operator()(const T1&, const T2&) const
     {
         return false;
     }
 
-    //- String match returning false
+    //- String match
+    //  \return false
     inline bool match(const std::string&, bool literal=false) const
     {
         return false;
diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C
index d191c46d5e4e6d27614f29863474d89cbc4a0e00..ceba5881162d2103a20ddb94dffd50ecc8709ba4 100644
--- a/src/OpenFOAM/primitives/strings/fileName/fileName.C
+++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C
@@ -37,20 +37,105 @@ int Foam::fileName::debug(debug::debugSwitch(fileName::typeName, 0));
 const Foam::fileName Foam::fileName::null;
 
 
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+Foam::fileName Foam::fileName::validate
+(
+    const std::string& s,
+    const bool doClean
+)
+{
+    fileName out;
+    out.resize(s.size());
+
+    char prev = 0;
+    std::string::size_type count = 0;
+
+    // Largely as per stripInvalid
+    for (auto iter = s.cbegin(); iter != s.cend(); ++iter)
+    {
+        const char c = *iter;
+
+        if (fileName::valid(c))
+        {
+            if (doClean && prev == '/' && c == '/')
+            {
+                // Avoid repeated '/';
+                continue;
+            }
+
+            // Only track valid chars
+            out[count++] = prev = c;
+        }
+    }
+
+    if (doClean && prev == '/' && count > 1)
+    {
+        // Avoid trailing '/'
+        --count;
+    }
+
+    out.resize(count);
+
+    return out;
+}
+
+
+bool Foam::fileName::equals(const std::string& s1, const std::string& s2)
+{
+    // Do not use (s1 == s2) or s1.compare(s2) first since this would
+    // potentially be doing the comparison twice.
+
+    std::string::size_type i1 = 0;
+    std::string::size_type i2 = 0;
+
+    const auto n1 = s1.size();
+    const auto n2 = s2.size();
+
+    //Info<< "compare " << s1 << " == " << s2 << endl;
+    while (i1 < n1 && i2 < n2)
+    {
+        //Info<< "check '" << s1[i1] << "' vs '" << s2[i2] << "'" << endl;
+
+        if (s1[i1] != s2[i2])
+        {
+            return false;
+        }
+
+        // Increment to next positions and also skip repeated slashes
+        do
+        {
+            ++i1;
+        }
+        while (s1[i1] == '/');
+
+        do
+        {
+            ++i2;
+        }
+        while (s2[i2] == '/');
+    }
+    //Info<< "return: " << Switch(i1 == n1 && i2 == n2) << endl;
+
+    // Equal if it made it all the way through both strings
+    return (i1 == n1 && i2 == n2);
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::fileName::fileName(const UList<word>& lst)
 {
     // Estimate overall size
     size_type sz = lst.size();  // Approx number of '/' needed
-    for (const auto& item : lst)
+    for (const word& item : lst)
     {
         sz += item.size();
     }
     reserve(sz);
 
     sz = 0;
-    for (const auto& item : lst)
+    for (const word& item : lst)
     {
         if (item.size())
         {
@@ -65,14 +150,14 @@ Foam::fileName::fileName(std::initializer_list<word> lst)
 {
     // Estimate overall size
     size_type sz = lst.size();  // Approx number of '/' needed
-    for (const auto& item : lst)
+    for (const word& item : lst)
     {
         sz += item.size();
     }
     reserve(sz);
 
     sz = 0;
-    for (const auto& item : lst)
+    for (const word& item : lst)
     {
         if (item.size())
         {
@@ -217,10 +302,8 @@ std::string Foam::fileName::name(const std::string& str)
     {
         return str;
     }
-    else
-    {
-        return str.substr(beg+1);
-    }
+
+    return str.substr(beg+1);
 }
 
 
@@ -253,10 +336,8 @@ std::string Foam::fileName::nameLessExt(const std::string& str)
     {
         return str.substr(beg);
     }
-    else
-    {
-        return str.substr(beg, dot - beg);
-    }
+
+    return str.substr(beg, dot - beg);
 }
 
 
@@ -278,10 +359,8 @@ std::string Foam::fileName::path(const std::string& str)
     {
         return str.substr(0, i);
     }
-    else
-    {
-        return "/";
-    }
+
+    return "/";
 }
 
 
@@ -299,10 +378,8 @@ Foam::fileName Foam::fileName::lessExt() const
     {
         return *this;
     }
-    else
-    {
-        return substr(0, i);
-    }
+
+    return substr(0, i);
 }
 
 
@@ -407,28 +484,26 @@ void Foam::fileName::operator=(const char* str)
 
 Foam::fileName Foam::operator/(const string& a, const string& b)
 {
-    if (a.size())           // First string non-null
+    if (a.size())
     {
-        if (b.size())       // Second string non-null
+        if (b.size())
         {
+            // Two non-empty strings: can concatenate
             return fileName(a + '/' + b);
         }
-        else                // Second string null
-        {
-            return a;
-        }
+
+        return a;
     }
-    else                    // First string null
+
+    // Or, if the first string is empty
+
+    if (b.size())
     {
-        if (b.size())       // Second string non-null
-        {
-            return b;
-        }
-        else                // Second string null
-        {
-            return fileName();
-        }
+        return b;
     }
+
+    // Both strings are empty
+    return fileName();
 }
 
 
@@ -438,19 +513,19 @@ Foam::fileName Foam::search(const word& file, const fileName& directory)
 {
     // Search the current directory for the file
     fileNameList files(fileHandler().readDir(directory));
-    forAll(files, i)
+    for (const fileName& item : files)
     {
-        if (files[i] == file)
+        if (item == file)
         {
-            return directory/file;
+            return directory/item;
         }
     }
 
     // If not found search each of the sub-directories
     fileNameList dirs(fileHandler().readDir(directory, fileName::DIRECTORY));
-    forAll(dirs, i)
+    for (const fileName& item : dirs)
     {
-        fileName path = search(file, directory/dirs[i]);
+        fileName path = search(file, directory/item);
         if (path != fileName::null)
         {
             return path;
diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H
index a0a3ece3ce8db34de9b568c5285af945e5a53e0f..8d8d7999b97f90d8c488a24332b3fbde3d7c91bc 100644
--- a/src/OpenFOAM/primitives/strings/fileName/fileName.H
+++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H
@@ -135,6 +135,20 @@ public:
         //- Is this character valid for a fileName?
         inline static bool valid(char c);
 
+        //- Construct validated fileName (no invalid characters).
+        //  Optionally perform some additional cleanup such as removing
+        //  duplicate or trailing slashes.
+        static fileName validate
+        (
+            const std::string& s,
+            const bool doClean=false
+        );
+
+        //- This is a specialized (possibly slower) version of compare()
+        //  that ignores duplicate or trailing slashes.
+        static bool equals(const std::string& s1, const std::string& s2);
+
+
         //- Cleanup filename
         //
         // Removes trailing \c /
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H
index 0f9d6139433c5f29b57e5439ee8db8d218a516f3..14770a9ce9c2ed2ed34948e44cf9af6b216fee78 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyType.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -72,7 +72,7 @@ class keyType
 
     // Private Member Functions
 
-        //- Disallow assignments where we cannot determine string/word type
+        //- No assignment where we cannot determine string/word type
         void operator=(const std::string&) = delete;
 
 public:
@@ -88,22 +88,34 @@ public:
         //- Construct null
         inline keyType();
 
-        //- Construct as copy, retaining type (literal or regex)
+        //- Copy construct, retaining type (literal or regex)
         inline keyType(const keyType& s);
 
-        //- Construct as copy of word. Not treated as a regular expression
+        //- Copy construct from word. Not treated as a regular expression
         inline keyType(const word& s);
 
-        //- Construct as copy of string. Treat as regular expression.
+        //- Copy construct from string. Treat as regular expression.
         inline keyType(const string& s);
 
         //- Construct as copy of character array.
         //  Not treated as a regular expression
         inline keyType(const char* s);
 
-        //- Construct as copy of std::string with specified treatment
+        //- Copy construct from std::string with specified treatment
         inline keyType(const std::string& s, const bool isPattern);
 
+        //- Move construct, retaining type (literal or regex)
+        inline keyType(keyType&& s);
+
+        //- Move construct from word. Not treated as a regular expression
+        inline keyType(word&& s);
+
+        //- Move construct from string. Treat as regular expression.
+        inline keyType(string&& s);
+
+        //- Move construct from std::string with specified treatment
+        inline keyType(std::string&& s, const bool isPattern);
+
         //- Construct from Istream
         //  Treat as regular expression if surrounded by quotation marks.
         keyType(Istream& is);
@@ -119,6 +131,9 @@ public:
         //- Treat as a pattern rather than a literal string?
         inline bool isPattern() const;
 
+        //- Swap contents
+        inline void swap(keyType& s);
+
         //- Smart match as regular expression or as a string.
         //  Optionally force a literal match only
         bool match(const std::string& text, bool literal = false) const;
@@ -126,27 +141,25 @@ public:
 
     // Member operators
 
-        //- Avoid masking the normal operator()
-        using word::operator();
-
         //- Perform smart match on text
         inline bool operator()(const std::string& text) const;
 
 
-      // Assignment
-
-        //- Assignment operator, retaining type (literal or regex)
+        //- Copy assignment, retaining type (literal or regex)
         inline void operator=(const keyType& s);
 
         //- Assign as word, not treated as a regular expression.
         inline void operator=(const word& s);
 
-        //- Assign as regular expression
+        //- Assign from Foam::string as regular expression
         inline void operator=(const string& s);
 
         //- Assign as word, not treated as a regular expression.
         inline void operator=(const char* s);
 
+        //- Move assignment, retaining type (literal or regex)
+        inline void operator=(keyType&& s);
+
 
     // IOstream operators
 
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
index 575bb834b1634c9a19e735a6571d36f67fc36744..95fa78496ad4cef889a4097f9652a27664b9a2b1 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -23,6 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
+#include <algorithm>
+
 // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
 
 inline bool Foam::keyType::valid(char c)
@@ -75,17 +77,44 @@ inline Foam::keyType::keyType(const char* s)
 {}
 
 
-inline Foam::keyType::keyType
-(
-    const std::string& s,
-    const bool isPattern
-)
+inline Foam::keyType::keyType(const std::string& s, const bool isPattern)
 :
     word(s, false),
     isPattern_(isPattern)
 {}
 
 
+
+inline Foam::keyType::keyType(keyType&& s)
+:
+    word(std::move(static_cast<word&>(s)), false),
+    isPattern_(s.isPattern())
+{
+    s.isPattern_ = false;
+}
+
+
+inline Foam::keyType::keyType(word&& s)
+:
+    word(std::move(s), false),
+    isPattern_(false)
+{}
+
+
+inline Foam::keyType::keyType(string&& s)
+:
+    word(std::move(s), false),
+    isPattern_(true)
+{}
+
+
+inline Foam::keyType::keyType(std::string&& s, const bool isPattern)
+:
+    word(std::move(s), false),
+    isPattern_(isPattern)
+{}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 inline bool Foam::keyType::isPattern() const
@@ -94,6 +123,13 @@ inline bool Foam::keyType::isPattern() const
 }
 
 
+inline void Foam::keyType::swap(keyType& s)
+{
+    word::swap(static_cast<word&>(s));
+    std::swap(isPattern_, s.isPattern_);
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 inline bool Foam::keyType::operator()(const std::string& text) const
@@ -104,30 +140,37 @@ inline bool Foam::keyType::operator()(const std::string& text) const
 
 inline void Foam::keyType::operator=(const keyType& s)
 {
-    string::operator=(s); // Bypass checking
+    string::operator=(s); // Bypass char checking
     isPattern_ = s.isPattern_;
 }
 
 
 inline void Foam::keyType::operator=(const word& s)
 {
-    string::operator=(s); // Bypass checking
+    string::operator=(s); // Bypass char checking
     isPattern_ = false;
 }
 
 
 inline void Foam::keyType::operator=(const string& s)
 {
-    string::operator=(s); // Bypass checking
+    string::operator=(s); // Bypass char checking
     isPattern_ = true;
 }
 
 
 inline void Foam::keyType::operator=(const char* s)
 {
-    string::operator=(s); // Bypass checking
+    string::operator=(s); // Bypass char checking
     isPattern_ = false;
 }
 
 
+inline void Foam::keyType::operator=(keyType&& s)
+{
+    clear();
+    swap(s);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/lists/fileNameList.H b/src/OpenFOAM/primitives/strings/lists/fileNameList.H
index c4e65aed79a5ecbdc79c3c8062afa59534fad945..ee059804526dd110f4854b52f7e406f411760021 100644
--- a/src/OpenFOAM/primitives/strings/lists/fileNameList.H
+++ b/src/OpenFOAM/primitives/strings/lists/fileNameList.H
@@ -33,6 +33,12 @@ Typedef
 Description
     A List of fileNames.
 
+Typedef
+    Foam::fileNameSubList
+
+Description
+    A SubList of fileNames.
+
 \*---------------------------------------------------------------------------*/
 
 #ifndef fileNameList_H
@@ -40,14 +46,15 @@ Description
 
 #include "fileName.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
     typedef UList<fileName> fileNameUList;
-
     typedef List<fileName> fileNameList;
+    typedef SubList<fileName> fileNameSubList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/strings/lists/stringList.H b/src/OpenFOAM/primitives/strings/lists/stringList.H
index af53c186ca88581b2aca5c66a22a33c2419fe71f..8c69b339c79e73122bbb45d6feb9be60d4a1fcb6 100644
--- a/src/OpenFOAM/primitives/strings/lists/stringList.H
+++ b/src/OpenFOAM/primitives/strings/lists/stringList.H
@@ -33,6 +33,12 @@ Typedef
 Description
     A List of strings.
 
+Typedef
+    Foam::stringSubList
+
+Description
+    A SubList of strings.
+
 \*---------------------------------------------------------------------------*/
 
 #ifndef stringList_H
@@ -40,14 +46,15 @@ Description
 
 #include "string.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
     typedef UList<string> stringUList;
-
     typedef List<string> stringList;
+    typedef SubList<string> stringSubList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/strings/lists/stringListOps.H b/src/OpenFOAM/primitives/strings/lists/stringListOps.H
index 0ea3266d3ea204820b2bdad78243ed04de3044b9..b87f1bd59c2e9dad649db17bb702f3f534a229d0 100644
--- a/src/OpenFOAM/primitives/strings/lists/stringListOps.H
+++ b/src/OpenFOAM/primitives/strings/lists/stringListOps.H
@@ -44,19 +44,14 @@ SourceFiles
 
 namespace Foam
 {
-  // Single-string matches:
-
-    //- Return true if text matches one of the regular expressions
-    //  The primary purpose of this function is to automatically convert
-    //  a wordReList to a wordRes for matching.
+    //- Single-string match for one of the regular expressions
+    //  \deprecated use stringOps::match instead (deprecated NOV-2017)
     inline bool findStrings(const wordRes& matcher, const std::string& text)
     {
         return matcher(text);
     }
 
 
-  // Multi-string matches:
-
     //- Extract list indices
     //  The unary match predicate has the following signature:
     //  \code
diff --git a/src/OpenFOAM/primitives/strings/lists/wordList.H b/src/OpenFOAM/primitives/strings/lists/wordList.H
index ca0830414030a0129f4dd4e60f4f4b62abba31b3..a12d2afcb164e252fdea1cde0e4fdb96203b07b5 100644
--- a/src/OpenFOAM/primitives/strings/lists/wordList.H
+++ b/src/OpenFOAM/primitives/strings/lists/wordList.H
@@ -33,6 +33,12 @@ Typedef
 Description
     A List of words.
 
+Typedef
+    Foam::wordSubList
+
+Description
+    A SubList of words.
+
 \*---------------------------------------------------------------------------*/
 
 #ifndef wordList_H
@@ -40,14 +46,15 @@ Description
 
 #include "word.H"
 #include "List.H"
+#include "SubList.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
     typedef UList<word> wordUList;
-
     typedef List<word> wordList;
+    typedef SubList<word> wordSubList;
 }
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/strings/parsing/parsing.C b/src/OpenFOAM/primitives/strings/parsing/parsing.C
index 2b818295284d70567d8e50d4c6a69aebdd1a528c..bb3a38564b3dbaa797d9c952fafac4aee5d519c7 100644
--- a/src/OpenFOAM/primitives/strings/parsing/parsing.C
+++ b/src/OpenFOAM/primitives/strings/parsing/parsing.C
@@ -30,7 +30,8 @@ License
 const Foam::Enum<Foam::parsing::errorType>
 Foam::parsing::errorNames
 {
-    { errorType::GENERAL,  "General error parsing" },
+    { errorType::GENERAL, "General error parsing" },
+    { errorType::RANGE, "Range error while parsing" },
     { errorType::TRAILING, "Trailing content found parsing" },
 };
 
diff --git a/src/OpenFOAM/primitives/strings/parsing/parsing.H b/src/OpenFOAM/primitives/strings/parsing/parsing.H
index bef3d34f9c0c92b55ff33b87e2a6c0daa2d678fd..925de3ccdbac58539fbd8d4897109c11e4b5e5c2 100644
--- a/src/OpenFOAM/primitives/strings/parsing/parsing.H
+++ b/src/OpenFOAM/primitives/strings/parsing/parsing.H
@@ -56,7 +56,8 @@ namespace parsing
     {
         NONE = 0,         //!< No error encountered
         GENERAL = 1,      //!< General parsing error
-        TRAILING = 2,     //!< Trailing content detected
+        RANGE = 2,        //!< Range error
+        TRAILING = 3,     //!< Trailing content detected
     };
 
 
diff --git a/src/OpenFOAM/primitives/strings/parsing/parsingI.H b/src/OpenFOAM/primitives/strings/parsing/parsingI.H
index 7f6a4087a1715170feb10b2e7cbfd6ebd056a8bb..63e4209ba11afff10bc17d9849a75082a0253ff7 100644
--- a/src/OpenFOAM/primitives/strings/parsing/parsingI.H
+++ b/src/OpenFOAM/primitives/strings/parsing/parsingI.H
@@ -32,7 +32,7 @@ inline Foam::parsing::errorType Foam::parsing::checkConversion
     if (errno || endptr == buf)
     {
         // Some type of error OR no conversion
-        return errorType::GENERAL;
+        return (errno == ERANGE ? errorType::RANGE : errorType::GENERAL);
     }
 
     // Trailing spaces are permitted
diff --git a/src/OpenFOAM/primitives/strings/string/string.C b/src/OpenFOAM/primitives/strings/string/string.C
index b16b30f66defb2d22491a8507338b5a03f3a03ef..ac8beb6f187b66a62d5989400bfadce900fa435e 100644
--- a/src/OpenFOAM/primitives/strings/string/string.C
+++ b/src/OpenFOAM/primitives/strings/string/string.C
@@ -101,17 +101,7 @@ bool Foam::string::hasExt(const wordRe& ending) const
 
 Foam::string::size_type Foam::string::count(const char c) const
 {
-    size_type nChar = 0;
-
-    for (auto iter = cbegin(); iter != cend(); ++iter)
-    {
-        if (*iter == c)
-        {
-            ++nChar;
-        }
-    }
-
-    return nChar;
+    return stringOps::count(*this, c);
 }
 
 
diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H
index 78a25c00f2a930a6e698f7bcd73d1ed700473f43..ee5aee9b9c6e7434702a497c74345c549393d308 100644
--- a/src/OpenFOAM/primitives/strings/string/string.H
+++ b/src/OpenFOAM/primitives/strings/string/string.H
@@ -151,7 +151,10 @@ public:
         inline string(const char c);
 
         //- Construct from copies of a single character
-        inline string(const size_type, const char);
+        inline string(const size_type len, const char c);
+
+        //- Move construct from std::string
+        inline string(std::string&& str);
 
         //- Construct from Istream
         string(Istream& is);
@@ -159,7 +162,9 @@ public:
 
     // Member Functions
 
-        //- Count and return the number of a given character in the string
+        //- Count the number of occurences of the specified character
+        //- in the string
+        //  Partially deprecated (NOV-2017) in favour of stringOps::count
         size_type count(const char c) const;
 
         //- Does the string contain valid characters only?
@@ -194,7 +199,7 @@ public:
         using std::string::replace;
 
         //- Replace first occurence of sub-string oldStr with newStr,
-        //  beginning at start
+        //- beginning at start
         string& replace
         (
             const string& oldStr,
@@ -203,7 +208,7 @@ public:
         );
 
         //- Replace all occurences of sub-string oldStr with newStr,
-        //  beginning at start. This is a no-op if oldStr is empty.
+        //- beginning at start. This is a no-op if oldStr is empty.
         string& replaceAll
         (
             const string& oldStr,
@@ -267,19 +272,6 @@ public:
         //  \return True when strings match literally.
         inline bool operator()(const std::string& text) const;
 
-        //- Return sub-string from the i-th character for \a n characters
-        inline string operator()
-        (
-            const size_type i,
-            const size_type n
-        ) const;
-
-        //- Return sub-string from the first character for \a n characters
-        inline string operator()
-        (
-            const size_type n
-        ) const;
-
 
     // IOstream Operators
 
diff --git a/src/OpenFOAM/primitives/strings/string/stringI.H b/src/OpenFOAM/primitives/strings/string/stringI.H
index 9c485deda3d82ed95f9045b534956dd620c2d4ee..7d584d2244aa2e23eca49c8c4703cf6085abf7c7 100644
--- a/src/OpenFOAM/primitives/strings/string/stringI.H
+++ b/src/OpenFOAM/primitives/strings/string/stringI.H
@@ -99,6 +99,12 @@ inline Foam::string::string(const size_type len, const char c)
 {}
 
 
+inline Foam::string::string(std::string&& str)
+:
+    std::string(std::move(str))
+{}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class String>
@@ -243,22 +249,6 @@ inline bool Foam::string::operator()(const std::string& text) const
 }
 
 
-inline Foam::string Foam::string::operator()
-(
-    const size_type i,
-    const size_type n
-) const
-{
-    return substr(i, n);
-}
-
-
-inline Foam::string Foam::string::operator()(const size_type n) const
-{
-    return substr(0, n);
-}
-
-
 inline unsigned Foam::string::hash::operator()
 (
     const string& str,
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
index b3c35d95413387a2eb112ca2c51b6b91c8005c6c..8646523b6830daa16946aad0eccbb19f294c9463 100644
--- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
@@ -29,11 +29,71 @@ License
 #include "etcFiles.H"
 #include "StringStream.H"
 
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+// Standard handling of "~/", "./" etc.
+static void standardExpansions(Foam::string& s)
+{
+    if (s.empty())
+    {
+        return;
+    }
+
+    if (s[0] == '.')
+    {
+        // Expand a lone '.' and an initial './' into cwd
+        if (s.size() == 1)
+        {
+            s = cwd();
+        }
+        else if (s[1] == '/')
+        {
+            s.std::string::replace(0, 1, cwd());
+        }
+    }
+    else if (s[0] == '~')
+    {
+        // Expand initial ~
+        //   ~/        => home directory
+        //   ~OpenFOAM => site/user OpenFOAM configuration directory
+        //   ~user     => home directory for specified user
+
+        string user;
+        fileName file;
+
+        const auto slash = s.find('/');
+        if (slash == std::string::npos)
+        {
+            user = s.substr(1);
+        }
+        else
+        {
+            user = s.substr(1, slash - 1);
+            file = s.substr(slash + 1);
+        }
+
+        // NB: be a bit lazy and expand ~unknownUser as an
+        // empty string rather than leaving it untouched.
+        // otherwise add extra test
+
+        if (user == "OpenFOAM")
+        {
+            s = findEtcFile(file);
+        }
+        else
+        {
+            s = home(user)/file;
+        }
+    }
+}
+}
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 //! \cond fileScope
 //  Find the type/position of the ":-" or ":+" alternative values
+//  Returns 0, '-', '+' corresponding to not-found or ':-' or ':+'
 static inline int findParameterAlternative
 (
     const std::string& s,
@@ -70,6 +130,49 @@ static inline int findParameterAlternative
 //! \endcond
 
 
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+std::string::size_type Foam::stringOps::count
+(
+    const std::string& str,
+    const char c
+)
+{
+    std::string::size_type n = 0;
+
+    for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
+    {
+        if (*iter == c)
+        {
+            ++n;
+        }
+    }
+
+    return n;
+}
+
+
+std::string::size_type Foam::stringOps::count(const char* str, const char c)
+{
+    if (!str)
+    {
+        return 0;
+    }
+
+    std::string::size_type n = 0;
+
+    for (const char *iter = str; *iter; ++iter)
+    {
+        if (*iter == c)
+        {
+            ++n;
+        }
+    }
+
+    return n;
+}
+
+
 Foam::string Foam::stringOps::expand
 (
     const string& original,
@@ -257,13 +360,14 @@ Foam::string Foam::stringOps::getVariable
 {
     string value;
 
-    const entry* ePtr = dict.lookupScopedEntryPtr
+    const entry* eptr = dict.lookupScopedEntryPtr
     (
         name,
         true,
         false
     );
-    if (ePtr)
+
+    if (eptr)
     {
         OStringStream buf;
         // Force floating point numbers to be printed with at least
@@ -271,11 +375,8 @@ Foam::string Foam::stringOps::getVariable
         buf << fixed;
         buf.precision(IOstream::defaultPrecision());
 
-        // fail for non-primitiveEntry
-        dynamicCast<const primitiveEntry>
-        (
-            *ePtr
-        ).write(buf, true);
+        // Fails for non-primitiveEntry
+        dynamicCast<const primitiveEntry>(*eptr).write(buf, true);
 
         value = buf.str();
     }
@@ -308,8 +409,11 @@ Foam::string Foam::stringOps::getVariable
                 }
             }
         }
+    }
 
-        if (!allowEmpty && value.empty())
+    if (!allowEmpty && value.empty())
+    {
+        if (allowEnvVars)
         {
             FatalIOErrorInFunction
             (
@@ -317,15 +421,14 @@ Foam::string Foam::stringOps::getVariable
             )   << "Cannot find dictionary or environment variable "
                 << name << exit(FatalIOError);
         }
-    }
-
-    if (!allowEmpty && value.empty())
-    {
-        FatalIOErrorInFunction
-        (
-            dict
-        )   << "Cannot find dictionary variable "
-            << name << exit(FatalIOError);
+        else
+        {
+            FatalIOErrorInFunction
+            (
+                dict
+            )   << "Cannot find dictionary variable "
+                << name << exit(FatalIOError);
+        }
     }
 
     return value;
@@ -360,8 +463,9 @@ Foam::string Foam::stringOps::expand
         {
             newString.append(string(s[index]));
         }
-        index++;
+        ++index;
     }
+
     return newString;
 }
 
@@ -390,7 +494,7 @@ Foam::string& Foam::stringOps::inplaceExpand
             if (s[begVar+1] == '{')
             {
                 // Recursive variable expansion mode
-                label stringStart = begVar;
+                auto stringStart = begVar;
                 begVar += 2;
                 string varValue
                 (
@@ -471,53 +575,8 @@ Foam::string& Foam::stringOps::inplaceExpand
         }
     }
 
-    if (!s.empty())
-    {
-        if (s[0] == '~')
-        {
-            // Expand initial ~
-            //   ~/        => home directory
-            //   ~OpenFOAM => site/user OpenFOAM configuration directory
-            //   ~user     => home directory for specified user
-
-            string user;
-            fileName file;
-
-            if ((begVar = s.find('/')) != string::npos)
-            {
-                user = s.substr(1, begVar - 1);
-                file = s.substr(begVar + 1);
-            }
-            else
-            {
-                user = s.substr(1);
-            }
-
-            // NB: be a bit lazy and expand ~unknownUser as an
-            // empty string rather than leaving it untouched.
-            // otherwise add extra test
-            if (user == "OpenFOAM")
-            {
-                s = findEtcFile(file);
-            }
-            else
-            {
-                s = home(user)/file;
-            }
-        }
-        else if (s[0] == '.')
-        {
-            // Expand a lone '.' and an initial './' into cwd
-            if (s.size() == 1)
-            {
-                s = cwd();
-            }
-            else if (s[1] == '/')
-            {
-                s.std::string::replace(0, 1, cwd());
-            }
-        }
-    }
+    // Standard handling of "~/", "./" etc.
+    standardExpansions(s);
 
     return s;
 }
@@ -596,32 +655,33 @@ Foam::string& Foam::stringOps::inplaceExpand
                 );
 
 
-                // lookup in the dictionary
-                const entry* ePtr = dict.lookupScopedEntryPtr
+                // Lookup in the dictionary without wildcards.
+                // See note in primitiveEntry
+                const entry* eptr = dict.lookupScopedEntryPtr
                 (
                     varName,
                     true,
-                    false   // wildcards disabled. See primitiveEntry
+                    false
                 );
 
                 // if defined - copy its entries
-                if (ePtr)
+                if (eptr)
                 {
                     OStringStream buf;
                     // Force floating point numbers to be printed with at least
                     // some decimal digits.
                     buf << fixed;
                     buf.precision(IOstream::defaultPrecision());
-                    if (ePtr->isDict())
+                    if (eptr->isDict())
                     {
-                        ePtr->dict().write(buf, false);
+                        eptr->dict().write(buf, false);
                     }
                     else
                     {
-                        // fail for other types
+                        // Fail for non-primitiveEntry
                         dynamicCast<const primitiveEntry>
                         (
-                            *ePtr
+                            *eptr
                         ).write(buf, true);
                     }
 
@@ -816,53 +876,8 @@ Foam::string& Foam::stringOps::inplaceExpand
         }
     }
 
-    if (!s.empty())
-    {
-        if (s[0] == '~')
-        {
-            // Expand initial ~
-            //   ~/        => home directory
-            //   ~OpenFOAM => site/user OpenFOAM configuration directory
-            //   ~user     => home directory for specified user
-
-            string user;
-            fileName file;
-
-            if ((begVar = s.find('/')) != string::npos)
-            {
-                user = s.substr(1, begVar - 1);
-                file = s.substr(begVar + 1);
-            }
-            else
-            {
-                user = s.substr(1);
-            }
-
-            // NB: be a bit lazy and expand ~unknownUser as an
-            // empty string rather than leaving it untouched.
-            // otherwise add extra test
-            if (user == "OpenFOAM")
-            {
-                s = findEtcFile(file);
-            }
-            else
-            {
-                s = home(user)/file;
-            }
-        }
-        else if (s[0] == '.')
-        {
-            // Expand a lone '.' and an initial './' into cwd
-            if (s.size() == 1)
-            {
-                s = cwd();
-            }
-            else if (s[1] == '/')
-            {
-                s.std::string::replace(0, 1, cwd());
-            }
-        }
-    }
+    // Standard handling of "~/", "./" etc.
+    standardExpansions(s);
 
     return s;
 }
@@ -886,11 +901,9 @@ bool Foam::stringOps::inplaceReplaceVar(string& s, const word& varName)
     {
         return false;
     }
-    else
-    {
-        s.replace(i, content.size(), string("${" + varName + "}"));
-        return true;
-    }
+
+    s.replace(i, content.size(), string("${" + varName + "}"));
+    return true;
 }
 
 
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
index 92092f9d5207ddf0370d1b499bb1600892248b6c..7146891d37ba4f82e000b1a44b562e2ff56d769b 100644
--- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
@@ -41,6 +41,8 @@ SourceFiles
 #include "word.H"
 #include "dictionary.H"
 #include "HashTable.H"
+#include "stringOpsSort.H"
+#include "wordRes.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -53,6 +55,21 @@ namespace Foam
 
 namespace stringOps
 {
+    //- Count the number of occurences of the specified character
+    std::string::size_type count(const std::string& str, const char c);
+
+    //- Count the number of occurences of the specified character
+    //  Correctly handles nullptr.
+    std::string::size_type count(const char* str, const char c);
+
+    //- Return true if text matches one of the regular expressions.
+    //  Simply forwards a wordReList to a wordRes for the matching.
+    inline bool match(const wordReList& patterns, const std::string& text)
+    {
+        return wordRes(patterns).match(text);
+    }
+
+
     //- Expand occurences of variables according to the mapping
     //  Expansion includes:
     //  -# variables
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C
new file mode 100644
index 0000000000000000000000000000000000000000..ca37276b8fd8680e3f19291aa1f93942a97dc107
--- /dev/null
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.C
@@ -0,0 +1,324 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+Changes for OpenFOAM
+
+   Code cleanup, reduction, elimination of redundant code.
+\*---------------------------------------------------------------------------*/
+
+//========================================================================
+// Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, distribute with modifications, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+// THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name(s) of the above copyright
+// holders shall not be used in advertising or otherwise to promote the
+// sale, use or other dealings in this Software without prior written
+// authorization.
+//========================================================================
+
+//========================================================================
+//  Original Author: Jan-Marten Spit <jmspit@euronet.nl>
+//========================================================================
+
+#include "stringOpsSort.H"
+#include <cctype>
+#include <cstring>
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// Local tweaks/preferences:
+//
+// [DIGITS_ALWAYS_FIRST] : as per original code
+// This results in "file123.txt" sorting before "file.txt", which is
+// inconsistent with what 'ls -v' produces
+// - normally do not want this (Mark Olesen: Oct-2017)
+#undef DIGITS_ALWAYS_FIRST
+
+// [MANUAL_NUMCOMPARE] : handwritten code instead of strncmp
+// The orignal code has a mix of strncmp for equality but handwritten code
+// for greater-than/less-than.
+//
+// -> this does to be unneeded, rely on strncmp() return values
+//    (Mark Olesen: Oct-2017)
+#undef MANUAL_NUMCOMPARE
+
+// [DEBUG_NATSTRCMP] : debug info to std::cerr (for development purposes only)
+#undef DEBUG_NATSTRCMP
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef DEBUG_NATSTRCMP
+#include <iostream>
+
+template<class T>
+static inline void debugPrint(const char* text, T item1, T item2)
+{
+    std::cerr << text << ": <" << item1 << "> <" << item2 << ">\n";
+}
+
+// Character sequences, end pointer is _inclusive_.
+static inline void debugPrint
+(
+    const char* b1, const char* e1,
+    const char* b2, const char* e2
+)
+{
+    std::cerr << "<";
+    while (b1 < e1) { std::cerr << *b1++; }
+    std::cerr << *e1 << "> ";
+
+    std::cerr << "<";
+    while (b2 < e2) { std::cerr << *b2++; }
+    std::cerr << *e2 << ">\n";
+}
+#endif
+
+#ifdef MANUAL_NUMCOMPARE
+// Manual comparison of identical length (digit) sequences
+static inline int manual_numcompare(const char* s1, const char* s2)
+{
+    while (*s1 && *s2)
+    {
+        const int cmp = (*s1 - *s2);
+        if (!cmp) return cmp;
+
+        ++s1; ++s2;
+    }
+    return 0;  // Length check done before in caller.
+}
+#endif
+
+
+// ------------------------------------------------------------------------- //
+
+int Foam::stringOps::natstrcmp(const char* s1, const char* s2)
+{
+    #ifdef DEBUG_NATSTRCMP
+    debugPrint("natstrcmp", s1, s2);
+    #endif
+
+    // States for state engine
+    enum stateType { SCAN, ALPHA, NUMERIC };
+
+    // Number of leading zeroes
+    unsigned zeros1 = 0;
+    unsigned zeros2 = 0;
+
+    // Pointers to begin/end of integer sequences (without leading zeros)
+    const char* numbeg1 = nullptr;
+    const char* numbeg2 = nullptr;
+    const char* numend1 = nullptr;
+    const char* numend2 = nullptr;
+
+    stateType state = SCAN;
+
+    const char* p1 = s1;
+    const char* p2 = s2;
+
+    while (*p1 && *p2)
+    {
+        // Bitmask for digits vs alpha
+        // - 0: neither are digits
+        // - 1: p1 is the only digit
+        // - 2: p2 is the only digit
+        // - 3: both p1 and p2 are digits
+
+        const unsigned digitMask =
+            ((isdigit(*p2) ? 2:0) | (isdigit(*p1) ? 1:0));
+
+        switch (state)
+        {
+            case SCAN:
+            {
+                #ifdef DEBUG_NATSTRCMP
+                debugPrint("SCAN", *p1, *p2);
+                #endif
+
+                switch (digitMask)
+                {
+                    case 0:         // (alpha,alpha)
+                    {
+                        state = ALPHA;
+
+                        if (*p1 == *p2)
+                        {
+                            ++p1; ++p2;
+                        }
+                        else
+                        {
+                            // Lexical compare
+                            return (*p1 - *p2);
+                        }
+                        break;
+                    }
+
+                    #ifdef DIGITS_ALWAYS_FIRST
+                    case 0x1:        // (digit,alpha) : digit < alpha
+                    {
+                        return -1;
+                        break;
+                    }
+                    case 0x2:        // (alpha,digit) : alpha > digit
+                    {
+                        return 1;
+                        break;
+                    }
+                    #else /* DIGITS_ALWAYS_FIRST */
+                    case 0x1:        // (digit,alpha)
+                    case 0x2:        // (alpha,digit)
+                    {
+                        // Lexical compare for digits/alpha
+                        return (*p1 - *p2);
+                        break;
+                    }
+                    #endif /* DIGITS_ALWAYS_FIRST */
+
+                    default:        // (digit,digit)
+                    {
+                        state = NUMERIC;
+
+                        // State changed from SCAN to NUMERIC, so skip leading
+                        // leading zeros so the numeric comparison is
+                        // untainted by them, but capture the first occurrence
+                        // of leading zeroes for a final tie-break if needed.
+
+                        if (!zeros1)
+                        {
+                            // First occurrence of any leading zeroes
+                            while (*p1 == '0') { ++p1; ++zeros1; }
+                        }
+                        else
+                        {
+                            while (*p1 == '0') { ++p1; }
+                        }
+
+                        if (!zeros2)
+                        {
+                            // First occurrence of any leading zeroes
+                            while (*p2 == '0') { ++p2; ++zeros2; }
+                        }
+                        else
+                        {
+                            while (*p2 == '0') { ++p2; }
+                        }
+
+                        if (zeros1 == zeros2)
+                        {
+                            // Same number of zeros - so irrelevant
+                            zeros1 = zeros2 = 0;
+                        }
+
+                        if (!isdigit(*p1)) --p1;
+                        if (!isdigit(*p2)) --p2;
+
+                        numbeg1 = numend1 = p1;
+                        numbeg2 = numend2 = p2;
+
+                        break;
+                    }
+                }
+                break;
+            }
+
+            case ALPHA:
+            {
+                #ifdef DEBUG_NATSTRCMP
+                debugPrint("ALPHA", *p1, *p2);
+                #endif
+
+                if (digitMask)
+                {
+                    state = SCAN;
+                }
+                else                // (alpha,alpha)
+                {
+                    if (*p1 == *p2)
+                    {
+                        ++p1; ++p2;
+                    }
+                    else
+                    {
+                        // Lexical compare
+                        return (*p1 - *p2);
+                    }
+                }
+                break;
+            }
+
+            case NUMERIC:
+            {
+                while (isdigit(*p1)) numend1 = p1++;
+                while (isdigit(*p2)) numend2 = p2++;
+
+                #ifdef DEBUG_NATSTRCMP
+                debugPrint("NUMERIC", *p1, *p2);
+                debugPrint(numbeg1,numend1, numbeg2,numend2);
+                #endif
+
+                // Length (minus 1) of each sequence
+                const size_t len1 = (numend1 - numbeg1);
+                const size_t len2 = (numend2 - numbeg2);
+
+                if (len1 < len2)
+                {
+                    return -1;
+                }
+                else if (len1 > len2)
+                {
+                    return 1;
+                }
+
+                // Same number of digits, leading zeros have been skipped.
+                // - so lexical and numerical compares are equivalent.
+
+                const int cmp = strncmp(numbeg1, numbeg2, len1+1);
+                if (!cmp)
+                {
+                    // Identical (digit) sequence - continue
+                    state = SCAN;
+                }
+                else
+                {
+                    #ifdef MANUAL_STRNCMP
+                    return manual_numcompare(numbeg1, numbeg2);
+                    #else
+                    return cmp;
+                    #endif
+                }
+                break;
+            }
+        }
+    }
+
+    if (zeros1 < zeros2) return -1;
+    if (zeros1 > zeros2) return 1;
+    if (!*p1 && *p2) return -1;  // s1 shorter than s2
+    if (*p1 && !*p2) return 1;   // s1 longer  than s2
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H
new file mode 100644
index 0000000000000000000000000000000000000000..8e6344f27a81bfeb6f9662953204d677af75b384
--- /dev/null
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOpsSort.H
@@ -0,0 +1,133 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+InNamespace
+    Foam::stringOps
+
+Description
+    Specialized string sorting.
+
+SourceFiles
+    stringOpsSort.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef stringOpsSort_H
+#define stringOpsSort_H
+
+#include "stringOps.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace stringOps
+{
+
+    //- 'Natural' compare for C-strings
+    //  Uses algorithm and code from Jan-Marten Spit <jmspit@euronet.nl>
+    //
+    //  In the 'natural' comparison, strings are compared alphabetically
+    //  and numerically. Thus 'file010.txt' sorts after 'file2.txt'
+    //
+    //  \param s1 left string
+    //  \param s2 right string
+    //  \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2
+    int natstrcmp(const char* s1, const char* s2);
+
+
+    //- Encapsulation of natural order sorting for algorithms
+    struct natural_sort
+    {
+        //- Natural compare for std::string
+        //  \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2
+        static inline int compare
+        (
+            const std::string& s1,
+            const std::string& s2
+        )
+        {
+            return natstrcmp(s1.data(), s2.data());
+        }
+
+        //- Default (forward) natural sorting
+        bool operator()(const std::string& s1, const std::string& s2) const
+        {
+            return natural_sort::compare(s1, s2) < 0;
+        }
+
+        //- Reverse natural sorting
+        struct reverse
+        {
+            //- Reverse natural sorting
+            bool operator()(const std::string& s1, const std::string& s2) const
+            {
+                return natural_sort::compare(s1, s2) > 0;
+            }
+        };
+
+
+        //- A list compare binary predicate for natural sort
+        template<class T>
+        struct less
+        {
+            const UList<T>& values;
+
+            less(const UList<T>& list)
+            :
+                values(list)
+            {}
+
+            bool operator()(const label a, const label b) const
+            {
+                return natural_sort::compare(values[a], values[b]) < 0;
+            }
+        };
+
+
+        //- A list compare binary predicate for reverse natural sort
+        template<class T>
+        struct greater
+        {
+            const UList<T>& values;
+
+            greater(const UList<T>& list)
+            :
+                values(list)
+            {}
+
+            bool operator()(const label a, const label b) const
+            {
+                return natural_sort::compare(values[a], values[b]) > 0;
+            }
+        };
+    };
+
+} // End namespace stringOps
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/word/word.C b/src/OpenFOAM/primitives/strings/word/word.C
index 932f10af4cb83c5070e7edf82830de83b8005c50..c51d489c914632e3f8cdf2d44b7c899c4bd1df24 100644
--- a/src/OpenFOAM/primitives/strings/word/word.C
+++ b/src/OpenFOAM/primitives/strings/word/word.C
@@ -25,6 +25,7 @@ License
 
 #include "word.H"
 #include "debug.H"
+#include <cctype>
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -77,10 +78,8 @@ Foam::word Foam::word::lessExt() const
     {
         return *this;
     }
-    else
-    {
-        return substr(0, i);
-    }
+
+    return substr(0, i);
 }
 
 
@@ -109,4 +108,28 @@ bool Foam::word::hasExt(const wordRe& ending) const
 }
 
 
+// * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
+
+Foam::word Foam::operator&(const word& a, const word& b)
+{
+    if (a.size())
+    {
+        if (b.size())
+        {
+            // Two non-empty words: can concatenate and perform camel case
+            word camelCase(a + b);
+            camelCase[a.size()] = char(toupper(b[0]));
+
+            return camelCase;
+        }
+
+        return a;
+    }
+
+    // Or, if the first string is empty (or both are empty)
+
+    return b;
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H
index b92d7209342b33015644dd1088d7077700f0e65c..b840928cef1f5cea22d69fc23d41855f2020975d 100644
--- a/src/OpenFOAM/primitives/strings/word/word.H
+++ b/src/OpenFOAM/primitives/strings/word/word.H
@@ -31,6 +31,7 @@ Description
     semicolons or brace brackets. Words are delimited by whitespace.
 
 SourceFiles
+    wordI.H
     word.C
     wordIO.C
 
@@ -48,7 +49,6 @@ namespace Foam
 
 // Forward declaration of friend functions and operators
 class word;
-inline word operator&(const word& a, const word& b);
 Istream& operator>>(Istream& is, word& w);
 Ostream& operator<<(Ostream& os, const word& w);
 
@@ -84,7 +84,7 @@ public:
         //- Construct null
         inline word();
 
-        //- Construct as copy
+        //- Copy construct
         inline word(const word& w);
 
         //- Construct as copy of character array
@@ -98,12 +98,21 @@ public:
             const bool doStripInvalid
         );
 
-        //- Construct as copy of string
+        //- Construct as copy of Foam::string
         inline word(const string& s, const bool doStripInvalid=true);
 
         //- Construct as copy of std::string
         inline word(const std::string& s, const bool doStripInvalid=true);
 
+        //- Move construct
+        inline word(word&& w);
+
+        //- Move construct from Foam::string
+        inline word(string&& s, const bool doStripInvalid=true);
+
+        //- Move construct from std::string
+        inline word(std::string&& s, const bool doStripInvalid=true);
+
         //- Construct from Istream
         word(Istream& is);
 
@@ -149,24 +158,26 @@ public:
 
       // Assignment
 
-        //- Copy, no character validation required
+        //- Copy assignment, no character validation required
         inline void operator=(const word& w);
 
-        //- Copy, stripping invalid characters
+        //- Copy assignment from Foam::string, stripping invalid characters
         inline void operator=(const string& s);
 
-        //- Copy, stripping invalid characters
+        //- Copy assignment from std::string, stripping invalid characters
         inline void operator=(const std::string& s);
 
         //- Copy, stripping invalid characters
         inline void operator=(const char* s);
 
+        //- Move assignment
+        inline void operator=(word&& w);
 
-    // Friend Operators
+        //- Move assignment from Foam::string, stripping invalid characters
+        inline void operator=(string&& s);
 
-        //- Join word a and b, capitalising the first letter of b
-        //  (so-called camelCase)
-        friend word operator&(const word& a, const word& b);
+        //- Move assignment from std::string, stripping invalid characters
+        inline void operator=(std::string&& s);
 
 
     // IOstream operators
@@ -176,6 +187,13 @@ public:
 };
 
 
+// Global Operators
+
+//- Join words as camelCase, capitalizing the first letter of b.
+//  No effect if either argument is empty.
+word operator&(const word& a, const word& b);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/primitives/strings/word/wordI.H b/src/OpenFOAM/primitives/strings/word/wordI.H
index 2fa48801a7309bdeb6961434769182136c6b4eb1..7ee9e0a08da7c3e651a9f45b68333404c6b8ed7d 100644
--- a/src/OpenFOAM/primitives/strings/word/wordI.H
+++ b/src/OpenFOAM/primitives/strings/word/wordI.H
@@ -111,6 +111,34 @@ inline Foam::word::word
 }
 
 
+inline Foam::word::word(word&& w)
+:
+    string(std::move(w))
+{}
+
+
+inline Foam::word::word(string&& s, const bool doStripInvalid)
+:
+    string(std::move(s))
+{
+    if (doStripInvalid)
+    {
+        stripInvalid();
+    }
+}
+
+
+inline Foam::word::word(std::string&& s, const bool doStripInvalid)
+:
+    string(std::move(s))
+{
+    if (doStripInvalid)
+    {
+        stripInvalid();
+    }
+}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 inline bool Foam::word::valid(char c)
@@ -148,6 +176,12 @@ inline void Foam::word::operator=(const word& w)
 }
 
 
+inline void Foam::word::operator=(word&& w)
+{
+    string::operator=(std::move(w));
+}
+
+
 inline void Foam::word::operator=(const string& s)
 {
     string::operator=(s);
@@ -155,35 +189,31 @@ inline void Foam::word::operator=(const string& s)
 }
 
 
-inline void Foam::word::operator=(const std::string& s)
+inline void Foam::word::operator=(string&& s)
 {
-    string::operator=(s);
+    string::operator=(std::move(s));
     stripInvalid();
 }
 
 
-inline void Foam::word::operator=(const char* s)
+inline void Foam::word::operator=(const std::string& s)
 {
     string::operator=(s);
     stripInvalid();
 }
 
 
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
-
-inline Foam::word Foam::operator&(const word& a, const word& b)
+inline void Foam::word::operator=(std::string&& s)
 {
-    if (b.size())
-    {
-        string ub = b;
-        ub.string::operator[](0) = char(toupper(ub.string::operator[](0)));
+    string::operator=(std::move(s));
+    stripInvalid();
+}
 
-        return a + ub;
-    }
-    else
-    {
-        return a;
-    }
+
+inline void Foam::word::operator=(const char* s)
+{
+    string::operator=(s);
+    stripInvalid();
 }
 
 
diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
index 8195abb90ecc732da936202161f89d083257939b..a7573068bec61aff4b85b4d6e694f76344f400b9 100644
--- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
+++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
@@ -154,6 +154,9 @@ public:
         //- Construct as copy of word, use specified compile option
         inline wordRe(const word& str, const compOption);
 
+        //- Move construct
+        inline wordRe(wordRe&& str);
+
         //- Construct from Istream
         //  Words are treated as literals, strings with an auto-test
         wordRe(Istream& is);
@@ -191,6 +194,9 @@ public:
         //- Clear string and regular expression
         inline void clear();
 
+        //- Swap contents
+        inline void swap(wordRe& str);
+
 
      // Matching/Searching
 
@@ -210,17 +216,11 @@ public:
 
     // Member operators
 
-        //- Avoid masking the normal operator()
-        using word::operator();
-
         //- Perform smart match on text, as per match()
         inline bool operator()(const std::string& text) const;
 
 
-      // Assignment
-
-        //- Copy wordRe and its type (literal or regex)
-        //  Always case sensitive
+        //- Copy assignment, retaining type (literal or regex)
         inline void operator=(const wordRe& str);
 
         //- Copy word, never a regular expression
@@ -242,6 +242,9 @@ public:
         //  Always case sensitive
         inline void operator=(const char* str);
 
+        //- Move assignment.
+        inline void operator=(wordRe&& str);
+
 
     // IOstream operators
 
diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H
index 658df00695f479913f9caafae3c11fd603b6daf0..c269e321a47e9e0b27266a7e4bc6acbcdecb294c 100644
--- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H
+++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H
@@ -148,6 +148,13 @@ inline Foam::wordRe::wordRe(const word& str, const compOption opt)
 }
 
 
+inline Foam::wordRe::wordRe(wordRe&& str)
+:
+    word(std::move(static_cast<word&>(str))),
+    re_(std::move(str.re_))
+{}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 inline bool Foam::wordRe::isPattern() const
@@ -249,6 +256,13 @@ inline void Foam::wordRe::set(const char* str, const compOption opt)
 }
 
 
+inline void Foam::wordRe::swap(wordRe& str)
+{
+    word::swap(static_cast<word&>(str));
+    re_.swap(str.re_);
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 inline bool Foam::wordRe::operator()(const std::string& text) const
@@ -313,4 +327,11 @@ inline void Foam::wordRe::operator=(const char* str)
 }
 
 
+inline void Foam::wordRe::operator=(wordRe&& str)
+{
+    clear();
+    swap(str);
+}
+
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H b/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H
index b7b63a5680ee48b56bda0aebdd2abbe1c8964a73..d456dfbd3633f3427537bc914e3eff7e7396a157 100644
--- a/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H
+++ b/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H
@@ -39,13 +39,11 @@ Description
 
 namespace Foam
 {
-
      typedef wordRes wordReListMatcher;
+}
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 #endif
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/wordRes/wordResI.H b/src/OpenFOAM/primitives/strings/wordRes/wordResI.H
index 600c228340d80851c6b96be1c57cde3648d387ce..504c0642b48f78fb4d0110ab2bb51a0bc9aaa75e 100644
--- a/src/OpenFOAM/primitives/strings/wordRes/wordResI.H
+++ b/src/OpenFOAM/primitives/strings/wordRes/wordResI.H
@@ -23,7 +23,6 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 inline Foam::wordRes::wordRes
diff --git a/src/OpenFOAM/primitives/zero/nil.H b/src/OpenFOAM/primitives/zero/nil.H
new file mode 100644
index 0000000000000000000000000000000000000000..b331b89636ed64a0ef52abd3b5a86c9852eab840
--- /dev/null
+++ b/src/OpenFOAM/primitives/zero/nil.H
@@ -0,0 +1,24 @@
+/*---------------------------------------------------------------------------*\
+Compatibility include
+
+Typedef
+    Foam::nil
+
+Description
+    The older name for Foam::zero::null.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef nil_H
+#define nil_H
+
+#include "zero.H"
+
+namespace Foam
+{
+    typedef zero::null nil;
+}
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/zero/zero.H b/src/OpenFOAM/primitives/zero/zero.H
index b0156929b63c438477df35811413ff1aadd229f0..84cbf2c362cf04192242dfe9493b666df623f15c 100644
--- a/src/OpenFOAM/primitives/zero/zero.H
+++ b/src/OpenFOAM/primitives/zero/zero.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -43,6 +43,12 @@ SourceFiles
 namespace Foam
 {
 
+// Forward declarations
+class Istream;
+class Ostream;
+
+class zero;
+
 /*---------------------------------------------------------------------------*\
                            Class zero Declaration
 \*---------------------------------------------------------------------------*/
@@ -50,15 +56,22 @@ namespace Foam
 class zero
 {
 public:
-
     typedef zero value_type;
 
+    // Forward declaration
+    class null;
+
+
     // Constructors
 
-        //- Construct null
+        //- Null constructible
         zero()
         {}
 
+        //- Construct null from Istream. Consumes no content.
+        explicit zero(Istream&)
+        {}
+
 
     // Member operators
 
@@ -85,9 +98,47 @@ public:
         {
             return 0;
         }
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class zero::null Declaration
+\*---------------------------------------------------------------------------*/
+
+//- A zero class with a null output adapter.
+class zero::null
+:
+    public zero
+{
+public:
+    typedef null value_type;
+
+    //- Null constructible
+    null()
+    {}
+
+    //- Construct null from Istream without consuming any content.
+    explicit null(Istream&)
+    {}
 };
 
 
+// IOstream Operators
+
+//- Read from Istream consumes no content.
+inline Istream& operator>>(Istream& is, zero&)
+{
+    return is;
+}
+
+//- Write to Ostream emits no content.
+inline Ostream& operator<<(Ostream& os, const zero::null&)
+{
+    return os;
+}
+
+
 // Global zero
 static const zero Zero;
 
diff --git a/src/Pstream/dummy/Make/options b/src/Pstream/dummy/Make/options
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e4319f9dfc1f17077749096a34aacb8f3468f1f9 100644
--- a/src/Pstream/dummy/Make/options
+++ b/src/Pstream/dummy/Make/options
@@ -0,0 +1 @@
+LIB_LIBS = -lpthread
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C
index 3819066c887c9af6469ab59c297f1f81e35c985f..6ba0630240d52dfb34c65dd7c57b1921b7468e25 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C
@@ -161,7 +161,7 @@ void convectiveHeatTransferFvPatchScalarField::updateCoeffs()
 void convectiveHeatTransferFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("L") << L_ << token::END_STATEMENT << nl;
+    os.writeEntry("L", L_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
index 52de5b816bb2cb3258c9f67745f149714459033e..fefc7a9409c70b6a3be7239fd24e9b35075a9fab 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
@@ -190,9 +190,8 @@ void Foam::lumpedMassWallTemperatureFvPatchScalarField::write
     mixedFvPatchScalarField::write(os);
     temperatureCoupledBase::write(os);
 
-    os.writeKeyword("Cp")<< Cp_ << token::END_STATEMENT << nl;
-    os.writeKeyword("mass")<< mass_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("Cp", Cp_);
+    os.writeEntry("mass", mass_);
 }
 
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C
index d495bdbb8cff642095ef58361e527c3124613439..3cf2ce56d610b7d1e03064af60440b52fe621275 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/outletMappedUniformInletHeatAddition/outletMappedUniformInletHeatAdditionFvPatchField.C
@@ -189,12 +189,11 @@ void Foam::outletMappedUniformInletHeatAdditionFvPatchField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("outletPatch")
-        << outletPatchName_ << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    os.writeKeyword("Q") << Q_ << token::END_STATEMENT << nl;
-    os.writeKeyword("TMin") << TMin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("TMax") << TMax_ << token::END_STATEMENT << nl;
+    os.writeEntry("outletPatch", outletPatchName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntry("Q", Q_);
+    os.writeEntry("TMin", TMin_);
+    os.writeEntry("TMax", TMax_);
 
     this->writeEntry("value", os);
 }
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C
index 4221ad93de1d4b126d77672c84ba5fc0439b860f..00883665e82ff2c972af04498e7c2b5720562570 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C
@@ -436,9 +436,8 @@ void thermalBaffle1DFvPatchScalarField<solidType>::write(Ostream& os) const
     }
 
     qrPrevious_.writeEntry("qrPrevious", os);
-    os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("relaxation")<< qrRelaxation_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("qr", qrName_);
+    os.writeEntry("relaxation", qrRelaxation_);
 }
 
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C
index f870ed2abaffbee67bc0c42b19c6f0030dc9d228..eba0fea41f7c009885881996cdb11e42a901c72c 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C
@@ -202,10 +202,9 @@ void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::
 write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("massFluxFraction") << massFluxFraction_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("phi", phiName_);
+    os.writeEntry("rho", rhoName_);
+    os.writeEntry("massFluxFraction", massFluxFraction_);
     this->writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
index 1548c37e626662a52942b1a24721e71ca63e4015..ff02c97357b3e0455dfdf58b319828d2232fc5d3 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
@@ -260,8 +260,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write
 ) const
 {
     mixedFvPatchScalarField::write(os);
-    os.writeKeyword("Tnbr")<< TnbrName_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("Tnbr", TnbrName_);
     thicknessLayers_.writeEntry("thicknessLayers", os);
     kappaLayers_.writeEntry("kappaLayers", os);
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
index e232b8198f4f90a9969a5c983f0364e0b5151770..edcdabfa3b0e7f49f093e748399a9662afa9235b 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
@@ -343,12 +343,11 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
 ) const
 {
     mixedFvPatchScalarField::write(os);
-    os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl;
+    os.writeEntry("Tnbr", TnbrName_);
 
-    os.writeKeyword("qrNbr")<< qrNbrName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("thermalInertia")<< thermalInertia_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("qrNbr", qrNbrName_);
+    os.writeEntry("qr", qrName_);
+    os.writeEntry("thermalInertia", thermalInertia_);
 
     thicknessLayers_.writeEntry("thicknessLayers", os);
     kappaLayers_.writeEntry("kappaLayers", os);
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
index 3840262bd216952b22114930c419d1e271ba3a0e..4aee2a4da74125b558737215cb8ef39e867f958a 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
@@ -300,10 +300,10 @@ void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs()
 void alphatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Prt", Prt_);
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H
index 763e71df51471b298a1f6db41f6e9ae84150c049..8184600ff13d7dda26c94d990a455fa89480baa8 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatPhaseChangeWallFunction/alphatPhaseChangeWallFunctionFvPatchScalarField.H
@@ -39,8 +39,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef compressibleAlphatPhaseChangeWallFunctionFvPatchScalarField_H
-#define compressibleAlphatPhaseChangeWallFunctionFvPatchScalarField_H
+#ifndef compressible_alphatPhaseChangeWallFunctionFvPatchScalarField_H
+#define compressible_alphatPhaseChangeWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
index 127f58e9fa4a815f4a4e88bdf657d97ae364d02d..e8c910680d7a5f737b040875afd223a5875255d3 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
@@ -129,7 +129,7 @@ void alphatWallFunctionFvPatchScalarField::updateCoeffs()
 void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
+    os.writeEntry("Prt", Prt_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H
index ca4c35bc5d531675c6440a4f5144d0103b8e1eb4..8aeddced40cbfa883dffe9f04c946087404edeb0 100644
--- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H
+++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H
@@ -72,8 +72,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef compressibleAlphatWallFunctionFvPatchScalarField_H
-#define compressibleAlphatWallFunctionFvPatchScalarField_H
+#ifndef compressible_alphatWallFunctionFvPatchScalarField_H
+#define compressible_alphatWallFunctionFvPatchScalarField_H
 
 #include "fixedValueFvPatchFields.H"
 
diff --git a/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
index 8677d5f864272d6661a274f138894e73c1979652..c1cb91df3fede0bcc50dd46b7ab97decfe76c1f7 100644
--- a/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/incompressible/turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
@@ -268,10 +268,10 @@ void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs()
 void alphatJayatillekeWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Prt", Prt_);
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H
index eef6e95959bf77569411df8be781710560fc5292..55b0332e84a892c3f6c90a7c22804bcb804a01c7 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H
+++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.H
@@ -34,8 +34,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef IDDESDeltaDelta_H
-#define IDDESDeltaDelta_H
+#ifndef LESModels_IDDESDelta_H
+#define LESModels_IDDESDelta_H
 
 #include "maxDeltaxyz.H"
 
diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H
index de439813221efc3f63d1f5793a3a761fcf942d8f..f981aaf6eab633a5e17121ec932fdc40f5365371 100644
--- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H
+++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/maxDeltaxyz/maxDeltaxyz.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef maxDeltaxyzDelta_H
-#define maxDeltaxyzDelta_H
+#ifndef LESModels_maxDeltaxyz_H
+#define LESModels_maxDeltaxyz_H
 
 #include "LESdelta.H"
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C
index 1f95e729cd8c4cc721051e86adea38bfb975a14a..aabf2bab690b74bb3bc361e4813e4786ae960c85 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C
@@ -154,18 +154,12 @@ tmp<scalarField> atmBoundaryLayer::epsilon(const vectorField& p) const
 void atmBoundaryLayer::write(Ostream& os) const
 {
     z0_.writeEntry("z0", os) ;
-    os.writeKeyword("flowDir")
-        << flowDir_ << token::END_STATEMENT << nl;
-    os.writeKeyword("zDir")
-        << zDir_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa")
-        << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Cmu")
-        << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Uref")
-        << Uref_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Zref")
-        << Zref_ << token::END_STATEMENT << nl;
+    os.writeEntry("flowDir", flowDir_);
+    os.writeEntry("zDir", zDir_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("Uref", Uref_);
+    os.writeEntry("Zref", Zref_);
     zGround_.writeEntry("zGround", os) ;
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
index cd362bfd3b5b7a4b5771a1698b96a52979168221..5da68948f99cacfbb6fc34adc991051006492f70 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
@@ -159,10 +159,9 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("mixingLength")
-        << mixingLength_ << token::END_STATEMENT << nl;
-    os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl;
+    os.writeEntry("mixingLength", mixingLength_);
+    os.writeEntry("phi", this->phiName_);
+    os.writeEntry("k", kName_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H
index d71c85ea81055201ffd1ea239baa55f0446d0d8d..2a4ab54c601870c40f1683b017b4d1eb32ccd1b0 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H
+++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H
@@ -74,8 +74,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef turbulentMixingLengthDissipationRateInlet_H
-#define turbulentMixingLengthDissipationRateInlet_H
+#ifndef turbulentMixingLengthDissipationRateInletFvPatchScalarField_H
+#define turbulentMixingLengthDissipationRateInletFvPatchScalarField_H
 
 #include "inletOutletFvPatchFields.H"
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
index 548c7db73882fa1271fa86936a221746f33bb18c..7107217c85856155994b9062273bab62a8741b1f 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
@@ -155,10 +155,9 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("mixingLength")
-        << mixingLength_ << token::END_STATEMENT << nl;
-    os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl;
+    os.writeEntry("mixingLength", mixingLength_);
+    os.writeEntry("phi", this->phiName_);
+    os.writeEntry("k", kName_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C
index 5d14d97bf9c1de7b89b7315a7242859107c22c0d..371b0a51f1e912eddfc1c8e36a8465dce1082855 100644
--- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C
+++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C
@@ -373,7 +373,8 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM
         alphaRhoPhi,
         phi,
         transport,
-        propertiesName
+        propertiesName,
+        typeName
     ),
 
     ca1_
@@ -477,7 +478,12 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM
         this->mesh_,
         dimensionedScalar("0", dimless, 0)
     )
-{}
+{
+    if (type == typeName)
+    {
+        this->printCoeffs(type);
+    }
+}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C
index 0a4ae1c7fee9900c0b3eb398909f84ed7cae5243..1f2caddd510bd6133aea23aa1417af4a43d03b7c 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C
@@ -126,7 +126,7 @@ void Foam::fixedShearStressFvPatchVectorField::updateCoeffs()
 void Foam::fixedShearStressFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("tau") << tau0_ << token::END_STATEMENT << nl;
+    os.writeEntry("tau", tau0_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C
index df4557580f5df950f250a55b2731d4e72c48050b..486581871a9de273f3f67b89897d4a648cf26e50 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C
@@ -190,13 +190,12 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
 void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const
 {
     fixedJumpFvPatchField<scalar>::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     D_->writeData(os);
     I_->writeData(os);
-    os.writeKeyword("length") << length_ << token::END_STATEMENT << nl;
-    os.writeKeyword("uniformJump") << uniformJump_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("length", length_);
+    os.writeEntry("uniformJump", uniformJump_);
 }
 
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H
index 946f45d0762a167f5c0e26d852e339e728599424..2e5d92089cbcad91c1ca1de154cd248644cedab4 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchFieldFwd.H
@@ -23,8 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef porousBafflePressureFvPatchFieldsFwd_H
-#define porousBafflePressureFvPatchFieldsFwd_H
+#ifndef porousBafflePressureFvPatchFieldFwd_H
+#define porousBafflePressureFvPatchFieldFwd_H
 
 #include "fieldTypes.H"
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
index 1d8e807045cbf5f1851612a91b2a81458e6761fb..c3cf3c22a998f9f666288db450798d2517f720e5 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C
@@ -57,9 +57,9 @@ void Foam::epsilonWallFunctionFvPatchScalarField::writeLocalEntries
     Ostream& os
 ) const
 {
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
 }
 
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C
index 862f7e647b64e0fbf3badf4b835dbeb655b3e4a3..967b4f4ef947158e5358681a110cc2a0f54a5c90 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/fWallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C
@@ -55,9 +55,9 @@ void fWallFunctionFvPatchScalarField::checkType()
 
 void fWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
 {
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
 }
 
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C
index 11873820e05d08bd3e884fec76cfc4ac5710c2d8..36d171f861928ddcef6f7c773ac8e6419c3f4ce0 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kLowReWallFunction/kLowReWallFunctionFvPatchScalarField.C
@@ -233,10 +233,10 @@ void kLowReWallFunctionFvPatchScalarField::evaluate
 
 void kLowReWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Ceps2") << Ceps2_ << token::END_STATEMENT << nl;
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
+    os.writeEntry("Ceps2", Ceps2_);
     fixedValueFvPatchField<scalar>::write(os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C
index 02844be1a8113a20dac6eea6d5a323eef83cd9a4..cef7574691dc16adb30954e6e86569336970649b 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C
@@ -294,12 +294,9 @@ void nutURoughWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
     writeLocalEntries(os);
-    os.writeKeyword("roughnessHeight")
-        << roughnessHeight_ << token::END_STATEMENT << nl;
-    os.writeKeyword("roughnessConstant")
-        << roughnessConstant_ << token::END_STATEMENT << nl;
-    os.writeKeyword("roughnessFactor")
-        << roughnessFactor_ << token::END_STATEMENT << nl;
+    os.writeEntry("roughnessHeight", roughnessHeight_);
+    os.writeEntry("roughnessConstant", roughnessConstant_);
+    os.writeEntry("roughnessFactor", roughnessFactor_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C
index ee322ce34bedce66055460df0e0d1696a7c04e19..b40581055c04747816fc5975b59aed65391d70a3 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C
@@ -204,8 +204,7 @@ tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const
 void nutUTabulatedWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    os.writeKeyword("uPlusTable") << uPlusTableName_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("uPlusTable", uPlusTableName_);
     writeEntry("value", os);
 }
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
index 04c5d7674656750e862478114ffca6fa6f04486f..e2a8006ccf60d542ecaa5a4444fcfa643d3ccc13 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C
@@ -57,9 +57,9 @@ void Foam::nutWallFunctionFvPatchScalarField::writeLocalEntries
     Ostream& os
 ) const
 {
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
 }
 
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
index 59145dc98818eea9d508b91158f59b6b1f525610..2bcc382090f3da8142350350b3787b1359e83be4 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
@@ -59,11 +59,11 @@ void omegaWallFunctionFvPatchScalarField::checkType()
 
 void omegaWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
 {
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
-    os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
-    os.writeKeyword("blended") << blended_ << token::END_STATEMENT << nl;
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
+    os.writeEntry("beta1", beta1_);
+    os.writeEntry("blended", blended_);
 }
 
 
diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C
index e3704f287c53c66c968551eb0fae4422e2854e77..0546d6a6105ac2843109ff1af5de2aecd34ee6de 100644
--- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C
+++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/v2WallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C
@@ -55,9 +55,9 @@ void v2WallFunctionFvPatchScalarField::checkType()
 
 void v2WallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
 {
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("E", E_);
 }
 
 
diff --git a/src/conversion/ccm/reader/ccmReaderMesh.C b/src/conversion/ccm/reader/ccmReaderMesh.C
index 089b3f65bbdbb1535152bf85e3f408690a2dfede..d58016f768b1608f21e89e45add276364643192b 100644
--- a/src/conversion/ccm/reader/ccmReaderMesh.C
+++ b/src/conversion/ccm/reader/ccmReaderMesh.C
@@ -1120,7 +1120,7 @@ void Foam::ccm::reader::juggleSolids()
 
 
     // The corresponding Foam patch
-    const label patchIndex  = findIndex(origBndId_, defaultBoundaryRegion);
+    const label patchIndex  = origBndId_.find(defaultBoundaryRegion);
     const label nPatchFaces = patchSizes_[patchIndex];
 
     labelList patchStarts(patchStartList(nInternalFaces_));
@@ -1828,8 +1828,8 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
 
         labelPair patchPair
         (
-            findIndex(origBndId_, ifentry.bnd0),
-            findIndex(origBndId_, ifentry.bnd1)
+            origBndId_.find(ifentry.bnd0),
+            origBndId_.find(ifentry.bnd1)
         );
 
         if
diff --git a/src/conversion/ccm/reader/ccmSolutionTable.H b/src/conversion/ccm/reader/ccmSolutionTable.H
index cf954872e53ba03210dfcfbc6ab09ee0d885fb85..a2d740c8a0e79f93f40bcf76616d18f7aa865f8d 100644
--- a/src/conversion/ccm/reader/ccmSolutionTable.H
+++ b/src/conversion/ccm/reader/ccmSolutionTable.H
@@ -30,7 +30,7 @@ Description
 
 #include "SLList.H"
 #include "Ostream.H"
-#include "stringListOps.H"
+#include "stringOps.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -109,21 +109,21 @@ public:
         {
             List<word> matched(SLList<T>::size());
 
-            label matchI = 0;
+            label matchi = 0;
             forAllConstIters(*this, iter)
             {
                 const word& name = iter().name();
 
                 if
                 (
-                    findStrings(whiteLst, name)
-                 && !findStrings(blackLst, name)
+                    stringOps::match(whiteLst, name)
+                 && !stringOps::match(blackLst, name)
                 )
                 {
-                    matched[matchI++] = name;
+                    matched[matchi++] = name;
                 }
             }
-            matched.setSize(matchI);
+            matched.setSize(matchi);
 
             return matched;
         }
diff --git a/src/conversion/ccm/writer/ccmWriterMesh.C b/src/conversion/ccm/writer/ccmWriterMesh.C
index 4ac3c621b8215598fa9679fb9b167a3fbbe53a05..7b3e275d42d0661037f44fc2b3ad02a5e64efd05 100644
--- a/src/conversion/ccm/writer/ccmWriterMesh.C
+++ b/src/conversion/ccm/writer/ccmWriterMesh.C
@@ -39,7 +39,7 @@ Foam::label Foam::ccm::writer::prostarCellFaceId
     const cellShape&  shape = mesh_.cellShapes()[cellId];
     const labelList& cFaces = mesh_.cells()[cellId];
 
-    label cellFaceId = findIndex(cFaces, faceI);
+    label cellFaceId = cFaces.find(faceI);
     label mapIndex = shape.model().index();
 
     if (ccm::debug > 1)
diff --git a/src/conversion/common/tables/boundaryRegion.C b/src/conversion/common/tables/boundaryRegion.C
index 12930ef06f35d6b4086709b46b963bd5739d4cf3..a6ff68b1e0ec9c68350e71c2cdb8432b1cc95c89 100644
--- a/src/conversion/common/tables/boundaryRegion.C
+++ b/src/conversion/common/tables/boundaryRegion.C
@@ -26,7 +26,7 @@ License
 #include "boundaryRegion.H"
 #include "IOMap.H"
 #include "OFstream.H"
-#include "stringListOps.H"
+#include "stringOps.H"
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
@@ -109,7 +109,7 @@ Foam::Map<Foam::word> Foam::boundaryRegion::names
             "boundaryRegion_" + Foam::name(iter.key())
         );
 
-        if (findStrings(patterns, lookupName))
+        if (stringOps::match(patterns, lookupName))
         {
             lookup.insert(iter.key(), lookupName);
         }
diff --git a/src/conversion/common/tables/cellTable.C b/src/conversion/common/tables/cellTable.C
index 5d9e137caba2c3177d113e7695d97e082172f578..6478f499120c737428a00becdece135b20210c04 100644
--- a/src/conversion/common/tables/cellTable.C
+++ b/src/conversion/common/tables/cellTable.C
@@ -27,7 +27,7 @@ License
 #include "IOMap.H"
 #include "OFstream.H"
 #include "wordList.H"
-#include "stringListOps.H"
+#include "stringOps.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -179,7 +179,7 @@ Foam::Map<Foam::word> Foam::cellTable::names
             "cellTable_" + Foam::name(iter.key())
         );
 
-        if (findStrings(patterns, lookupName))
+        if (stringOps::match(patterns, lookupName))
         {
             lookup.insert(iter.key(), lookupName);
         }
@@ -523,7 +523,7 @@ void Foam::cellTable::combine(const dictionary& mapDict, labelList& tableIds)
         Map<word> matches;
         forAllConstIter(Map<word>, origNames, namesIter)
         {
-            if (findStrings(patterns, namesIter()))
+            if (stringOps::match(patterns, namesIter()))
             {
                 matches.insert(namesIter.key(), namesIter());
             }
diff --git a/src/conversion/polyDualMesh/polyDualMesh.C b/src/conversion/polyDualMesh/polyDualMesh.C
index 8102547c4f97cda6bc5ebdd1f26c25a596fa462b..04b26d29c0c5920ca0e2cc3c97b511f513d04d36 100644
--- a/src/conversion/polyDualMesh/polyDualMesh.C
+++ b/src/conversion/polyDualMesh/polyDualMesh.C
@@ -165,7 +165,7 @@ void Foam::polyDualMesh::getPointEdges
         if (e[0] == pointi)
         {
             // One of the edges using pointi. Check which one.
-            label index = findIndex(f, pointi);
+            label index = f.find(pointi);
 
             if (f.nextLabel(index) == e[1])
             {
@@ -184,7 +184,7 @@ void Foam::polyDualMesh::getPointEdges
         else if (e[1] == pointi)
         {
             // One of the edges using pointi. Check which one.
-            label index = findIndex(f, pointi);
+            label index = f.find(pointi);
 
             if (f.nextLabel(index) == e[0])
             {
@@ -929,7 +929,7 @@ void Foam::polyDualMesh::calcDual
         label startFacei = -1;
         label endFacei = -1;
 
-        label index = findIndex(f0, neighbour);
+        label index = f0.find(neighbour);
 
         if (f0.nextLabel(index) == owner)
         {
@@ -1062,7 +1062,7 @@ void Foam::polyDualMesh::calcDual
             // the face uses the owner, neighbour
             const face& f0 = mesh.faces()[face0];
 
-            label index = findIndex(f0, neighbour);
+            label index = f0.find(neighbour);
 
             bool f0OrderOk = (f0.nextLabel(index) == owner);
 
diff --git a/src/conversion/starcd/STARCDMeshWriter.C b/src/conversion/starcd/STARCDMeshWriter.C
index a2e6bdb1ffb9d32cc10649d6d4a2e0301a78cb11..85cba78d595e0b06700b4e1c33e2ebf6c414f785 100644
--- a/src/conversion/starcd/STARCDMeshWriter.C
+++ b/src/conversion/starcd/STARCDMeshWriter.C
@@ -380,7 +380,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
             label cellId = owner[facei];
             const labelList& cFaces  = cells[cellId];
             const cellShape& shape = shapes[cellId];
-            label cellFaceId = findIndex(cFaces, facei);
+            label cellFaceId = cFaces.find(facei);
 
             //      Info<< "cell " << cellId + 1 << " face " << facei
             //          << " == " << faces[facei]
diff --git a/src/conversion/vtk/output/foamVtkPatchWriter.C b/src/conversion/vtk/output/foamVtkPatchWriter.C
index fcbe032cfd25baef27eacd90e8145d1d4230614b..18764148cd6cc6b351bb13ed71fd2450e5487fa3 100644
--- a/src/conversion/vtk/output/foamVtkPatchWriter.C
+++ b/src/conversion/vtk/output/foamVtkPatchWriter.C
@@ -245,7 +245,7 @@ Foam::vtk::patchWriter::patchWriter
     nFaces_(0)
 {
     outputOptions opts(outOpts);
-    opts.append(false);  // No append
+    opts.append(false);  // No append supported
 
     os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
     format_ = opts.newFormatter(os_);
diff --git a/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C b/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C
index df54f039cda22b571fb51747c7222a90f4520993..f5ba90efc171b7cb0a2e2946fae57e95429700d9 100644
--- a/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C
+++ b/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.C
@@ -193,7 +193,7 @@ Foam::vtk::surfaceMeshWriter::surfaceMeshWriter
     os_()
 {
     outputOptions opts(outOpts);
-    opts.legacy(true);  // No append supported
+    opts.append(false);  // No append supported
 
     os_.open((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
     format_ = opts.newFormatter(os_);
diff --git a/src/dummyThirdParty/Allwmake b/src/dummyThirdParty/Allwmake
index 3dac95f4106ee4aa1fdb1c3f869f769b1b5a99b9..a1628e356fbfd99ca5942bd05ce496b349a5f652 100755
--- a/src/dummyThirdParty/Allwmake
+++ b/src/dummyThirdParty/Allwmake
@@ -7,6 +7,7 @@ cd ${0%/*} || exit 1    # Run from this directory
 wmake $targetType scotchDecomp
 wmake $targetType ptscotchDecomp
 wmake $targetType metisDecomp
+wmake $targetType kahipDecomp
 wmake $targetType MGridGen
 
 #------------------------------------------------------------------------------
diff --git a/src/dummyThirdParty/kahipDecomp/Make/files b/src/dummyThirdParty/kahipDecomp/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..1a0227567673cdcf37523150efa34acc1ff94b25
--- /dev/null
+++ b/src/dummyThirdParty/kahipDecomp/Make/files
@@ -0,0 +1,3 @@
+dummyKahipDecomp.C
+
+LIB = $(FOAM_LIBBIN)/dummy/libkahipDecomp
diff --git a/src/dummyThirdParty/kahipDecomp/Make/options b/src/dummyThirdParty/kahipDecomp/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..0aad6a146fa63c9bc92a594d13d34ef9a43a2d95
--- /dev/null
+++ b/src/dummyThirdParty/kahipDecomp/Make/options
@@ -0,0 +1,5 @@
+EXE_INC = \
+    -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
+    -I$(LIB_SRC)/parallel/decompose/kahipDecomp/lnInclude
+
+LIB_LIBS =
diff --git a/src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C b/src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C
new file mode 100644
index 0000000000000000000000000000000000000000..d3844087e44b3ecfb8ba75bf6ccb749fad073250
--- /dev/null
+++ b/src/dummyThirdParty/kahipDecomp/dummyKahipDecomp.C
@@ -0,0 +1,83 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "kahipDecomp.H"
+#include "addToRunTimeSelectionTable.H"
+#include "Time.H"
+
+static const char* notImplementedMessage =
+"You are trying to use kahip but do not have the kahipDecomp library loaded."
+"\nThis message is from the dummy kahipDecomp stub library instead.\n"
+"\n"
+"Please install kahip and make sure that libkahip.so is in your "
+"LD_LIBRARY_PATH.\n"
+"The kahipDecomp library can then be built from "
+"src/parallel/decompose/kahipDecomp and dynamically loading or linking"
+" this library will add kahip as a decomposition method.\n";
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(kahipDecomp, 0);
+
+    addToRunTimeSelectionTable
+    (
+        decompositionMethod,
+        kahipDecomp,
+        dictionary
+    );
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+Foam::label Foam::kahipDecomp::decomposeSerial
+(
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cellWeights,
+    List<label>& decomp
+)
+{
+    FatalErrorInFunction
+        << notImplementedMessage << exit(FatalError);
+
+    return -1;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::kahipDecomp::kahipDecomp
+(
+    const dictionary& decompositionDict
+)
+:
+    metisLikeDecomp(decompositionDict)
+{}
+
+
+// ************************************************************************* //
diff --git a/src/dummyThirdParty/kahipDecomp/kaHIP_interface.h b/src/dummyThirdParty/kahipDecomp/kaHIP_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..90bf1afc23b4f77fb10356e58653dee7f142b5fc
--- /dev/null
+++ b/src/dummyThirdParty/kahipDecomp/kaHIP_interface.h
@@ -0,0 +1,37 @@
+#ifndef KAHIP_H
+#define KAHIP_H
+
+/* *** DUMMY VERSION of kaHIP_interface.h - this file should not be included if you have KaHIP
+ *     installed in the correct position in $WM_THIRD_PARTY_DIR - see
+ *     decompositionMethods/kahipDecomp/Make/options
+ */
+
+#warning "Dummy kahip.h - included since it cannot find KaHIP installation."
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void kaffpa
+(
+    // [inputs]
+    int* n,
+    int* vwgt,
+    int* xadj,
+    int* adjcwgt,
+    int* adjncy,
+    int* nparts,
+    double* imbalance,
+    bool suppress_output,
+    int seed,
+    int mode,
+    // [outputs]
+    int* edgecut,
+    int* part
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C b/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C
index ea3ee98863f90952819a2c734ccab49105a2c6ac..aabfa95fee9eecc17f91c2e4d756bb06c707bde2 100644
--- a/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C
+++ b/src/dummyThirdParty/metisDecomp/dummyMetisDecomp.C
@@ -35,8 +35,7 @@ static const char* notImplementedMessage =
 "LD_LIBRARY_PATH.\n"
 "The metisDecomp library can then be built from "
 "src/parallel/decompose/metisDecomp and dynamically loading or linking"
-" this library will add metis as a decomposition method.\n"
-"Please be aware that there are license restrictions on using Metis.";
+" this library will add metis as a decomposition method.\n";
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -55,12 +54,12 @@ namespace Foam
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-Foam::label Foam::metisDecomp::decompose
+Foam::label Foam::metisDecomp::decomposeSerial
 (
-    const List<label>& adjncy,
-    const List<label>& xadj,
-    const scalarField& cellWeights,
-    List<label>& finalDecomp
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cellWeights,
+    List<label>& decomp
 )
 {
     FatalErrorInFunction
@@ -77,53 +76,8 @@ Foam::metisDecomp::metisDecomp
     const dictionary& decompositionDict
 )
 :
-    decompositionMethod(decompositionDict)
+    metisLikeDecomp(decompositionDict)
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::labelList Foam::metisDecomp::decompose
-(
-    const polyMesh& mesh,
-    const pointField& points,
-    const scalarField& pointWeights
-)
-{
-    FatalErrorInFunction
-        << notImplementedMessage << exit(FatalError);
-
-    return labelList();
-}
-
-
-Foam::labelList Foam::metisDecomp::decompose
-(
-    const polyMesh& mesh,
-    const labelList& agglom,
-    const pointField& agglomPoints,
-    const scalarField& agglomWeights
-)
-{
-    FatalErrorInFunction
-        << notImplementedMessage << exit(FatalError);
-
-    return labelList();
-}
-
-
-Foam::labelList Foam::metisDecomp::decompose
-(
-    const labelListList& globalCellCells,
-    const pointField& cellCentres,
-    const scalarField& cellWeights
-)
-{
-    FatalErrorInFunction
-        << notImplementedMessage << exit(FatalError);
-
-    return labelList();
-}
-
-
 // ************************************************************************* //
diff --git a/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C b/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C
index 25287d72befdacd028480e72acc1a147ff8b3a89..d924b711b64464740db829e2f450b1dddc3a0321 100644
--- a/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C
+++ b/src/dummyThirdParty/ptscotchDecomp/dummyPtscotchDecomp.C
@@ -54,17 +54,19 @@ namespace Foam
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+void Foam::ptscotchDecomp::graphPath(const polyMesh& unused)
+{}
+
+
 void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 {}
 
 
 Foam::label Foam::ptscotchDecomp::decompose
 (
-    const fileName& meshPath,
-    const List<label>& initxadj,
-    const List<label>& initadjncy,
-    const scalarField& initcWeights,
-
+    const UList<label>& initxadj,
+    const UList<label>& initadjncy,
+    const UList<scalar>& initcWeights,
     List<label>& finalDecomp
 ) const
 {
@@ -77,12 +79,11 @@ Foam::label Foam::ptscotchDecomp::decompose
 
 Foam::label Foam::ptscotchDecomp::decompose
 (
-    const fileName& meshPath,
     const label adjncySize,
     const label adjncy[],
     const label xadjSize,
     const label xadj[],
-    const scalarField& cWeights,
+    const UList<scalar>& cWeights,
     List<label>& finalDecomp
 ) const
 {
diff --git a/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C b/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C
index f1088d487bce61935a622fc3350db8fdab6ffeb7..e5102774b5e74b146810ab2915340fd5b88adefc 100644
--- a/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C
+++ b/src/dummyThirdParty/scotchDecomp/dummyScotchDecomp.C
@@ -53,18 +53,20 @@ namespace Foam
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+void Foam::scotchDecomp::graphPath(const polyMesh& unused)
+{}
+
+
 void Foam::scotchDecomp::check(const int retVal, const char* str)
 {}
 
 
-Foam::label Foam::scotchDecomp::decompose
+Foam::label Foam::scotchDecomp::decomposeSerial
 (
-    const fileName& meshPath,
-    const List<label>& adjncy,
-    const List<label>& xadj,
-    const scalarField& cWeights,
-
-    List<label>& finalDecomp
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cWeights,
+    List<label>& decomp
 )
 {
     FatalErrorInFunction
@@ -81,7 +83,7 @@ Foam::scotchDecomp::scotchDecomp
     const dictionary& decompositionDict
 )
 :
-    decompositionMethod(decompositionDict)
+    metisLikeDecomp(decompositionDict)
 {}
 
 
diff --git a/src/dynamicMesh/attachDetach/attachDetach.C b/src/dynamicMesh/attachDetach/attachDetach.C
index 8ce76a11c35af6267c11b85249e283a0987bd53f..aa8f22f8437e3aeecef6d97ebfc209bf30b1fcbe 100644
--- a/src/dynamicMesh/attachDetach/attachDetach.C
+++ b/src/dynamicMesh/attachDetach/attachDetach.C
@@ -463,22 +463,18 @@ void Foam::attachDetach::write(Ostream& os) const
 
 void Foam::attachDetach::writeDict(Ostream& os) const
 {
-    os  << nl << name() << nl << token::BEGIN_BLOCK << nl
-        << "    type " << type()
-        << token::END_STATEMENT << nl
-        << "    faceZoneName " << faceZoneID_.name()
-        << token::END_STATEMENT << nl
-        << "    masterPatchName " << masterPatchID_.name()
-        << token::END_STATEMENT << nl
-        << "    slavePatchName " << slavePatchID_.name()
-        << token::END_STATEMENT << nl
-        << "    triggerTimes " << triggerTimes_
-        << token::END_STATEMENT << nl
-        << "    manualTrigger " << manualTrigger()
-        << token::END_STATEMENT << nl
-        << "    active " << active()
-        << token::END_STATEMENT << nl
-        << token::END_BLOCK << endl;
+    os  << nl;
+    os.beginBlock(name());
+
+    os.writeEntry("type", type());
+    os.writeEntry("faceZoneName", faceZoneID_.name());
+    os.writeEntry("masterPatchName", masterPatchID_.name());
+    os.writeEntry("slavePatchName", slavePatchID_.name());
+    os.writeEntry("triggerTimes", triggerTimes_);
+    os.writeEntry("manualTrigger", manualTrigger());
+    os.writeEntry("active", active());
+
+    os.endBlock();
 }
 
 
diff --git a/src/dynamicMesh/boundaryPatch/boundaryPatch.C b/src/dynamicMesh/boundaryPatch/boundaryPatch.C
index fe2f9796e4ce679facb71467d8e5d3d323225cd2..38c1d6b91eea399c7aa00b78d77dbc00e8f989ec 100644
--- a/src/dynamicMesh/boundaryPatch/boundaryPatch.C
+++ b/src/dynamicMesh/boundaryPatch/boundaryPatch.C
@@ -90,8 +90,8 @@ Foam::boundaryPatch::~boundaryPatch()
 void Foam::boundaryPatch::write(Ostream& os) const
 {
     patchIdentifier::write(os);
-    os.writeKeyword("nFaces") << size_ << token::END_STATEMENT << nl;
-    os.writeKeyword("startFace") << start_ << token::END_STATEMENT << nl;
+    os.writeEntry("nFaces", size_);
+    os.writeEntry("startFace", start_);
 }
 
 
diff --git a/src/dynamicMesh/createShellMesh/createShellMesh.C b/src/dynamicMesh/createShellMesh/createShellMesh.C
index 300e7f03a3970702605052cdad1a85e75dab6e1a..76feaaf60a0120a1c2ef375683f20746eb3f6667 100644
--- a/src/dynamicMesh/createShellMesh/createShellMesh.C
+++ b/src/dynamicMesh/createShellMesh/createShellMesh.C
@@ -226,8 +226,8 @@ void Foam::createShellMesh::calcPointRegions
             label facei = patch.edgeFaces()[edgeI][0];
             const face& f = patch.localFaces()[facei];
 
-            label fp0 = findIndex(f, e[0]);
-            label fp1 = findIndex(f, e[1]);
+            label fp0 = f.find(e[0]);
+            label fp1 = f.find(e[1]);
             allEdgeData[edgeI] = labelPair
             (
                 pointGlobalRegions[facei][fp0],
@@ -283,7 +283,7 @@ void Foam::createShellMesh::calcPointRegions
                 const face& f = patch.localFaces()[facei];
 
                 // Combine edgeData with face data
-                label fp0 = findIndex(f, e[0]);
+                label fp0 = f.find(e[0]);
                 if (pointGlobalRegions[facei][fp0] > edgeData[0])
                 {
                     pointGlobalRegions[facei][fp0] = edgeData[0];
@@ -294,7 +294,7 @@ void Foam::createShellMesh::calcPointRegions
                     }
                 }
 
-                label fp1 = findIndex(f, e[1]);
+                label fp1 = f.find(e[1]);
                 if (pointGlobalRegions[facei][fp1] > edgeData[1])
                 {
                     pointGlobalRegions[facei][fp1] = edgeData[1];
@@ -334,9 +334,9 @@ void Foam::createShellMesh::calcPointRegions
                 if (!nonManifoldEdge[edgeI])
                 {
                     const edge& e = patch.edges()[edgeI];
-                    label fp0 = findIndex(f, e[0]);
+                    label fp0 = f.find(e[0]);
                     label region0 = pointGlobalRegions[facei][fp0];
-                    label fp1 = findIndex(f, e[1]);
+                    label fp1 = f.find(e[1]);
                     label region1 = pointGlobalRegions[facei][fp1];
 
                     if
@@ -696,7 +696,7 @@ void Foam::createShellMesh::setRefinement
         const face& f = patch_.localFaces()[eFaces[0]];
         const edge& e = patch_.edges()[edgeI];
 
-        label fp0 = findIndex(f, e[0]);
+        label fp0 = f.find(e[0]);
         label fp1 = f.fcIndex(fp0);
 
         if (f[fp1] != e[1])
@@ -815,7 +815,7 @@ void Foam::createShellMesh::setRefinement
                 const face& f = patch_.localFaces()[minFacei];
 
                 const edge& e = patch_.edges()[edgeI];
-                label fp0 = findIndex(f, e[0]);
+                label fp0 = f.find(e[0]);
                 label fp1 = f.fcIndex(fp0);
 
                 if (f[fp1] != e[1])
diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
index 89245c0094c518492ef9e64f8f67e87d4534a199..0e546f1b3efc02a8ab210d154c5e42d5d6828e2e 100644
--- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
+++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
@@ -656,7 +656,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::repatch
 
     if (debug)
     {
-        label index = findIndex(map().reverseFaceMap(), -1);
+        label index = map().reverseFaceMap().find(-1);
 
         if (index != -1)
         {
diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
index 5e436c4544def1232f0e9b253573564cf7eb0518..32e36d279c7cb7e386bdafbc4794d15d7ee2695a 100644
--- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
+++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -189,12 +189,12 @@ void Foam::cellCuts::syncProc()
                             if (isEdge(cuts[i]))
                             {
                                 label edgei = getEdge(cuts[i]);
-                                label index = findIndex(fEdges, edgei);
+                                label index = fEdges.find(edgei);
                                 relCuts[bFacei][i] = -index-1;
                             }
                             else
                             {
-                                label index = findIndex(f, getVertex(cuts[i]));
+                                label index = f.find(getVertex(cuts[i]));
                                 relCuts[bFacei][i] = index+1;
                             }
                         }
@@ -390,13 +390,9 @@ Foam::label Foam::cellCuts::edgeEdgeToFace
 
         const labelList& fEdges = mesh().faceEdges()[facei];
 
-        if
-        (
-            findIndex(fEdges, edgeA) != -1
-         && findIndex(fEdges, edgeB) != -1
-        )
+        if (fEdges.found(edgeA) && fEdges.found(edgeB))
         {
-           return facei;
+            return facei;
         }
     }
 
@@ -432,13 +428,9 @@ Foam::label Foam::cellCuts::edgeVertexToFace
 
         const labelList& fEdges = mesh().faceEdges()[facei];
 
-        if
-        (
-            findIndex(fEdges, edgeI) != -1
-         && findIndex(f, vertI) != -1
-        )
+        if (fEdges.found(edgeI) && f.found(vertI))
         {
-           return facei;
+            return facei;
         }
     }
 
@@ -469,13 +461,9 @@ Foam::label Foam::cellCuts::vertexVertexToFace
 
         const face& f = mesh().faces()[facei];
 
-        if
-        (
-            findIndex(f, vertA) != -1
-         && findIndex(f, vertB) != -1
-        )
+        if (f.found(vertA) && f.found(vertB))
         {
-           return facei;
+            return facei;
         }
     }
 
@@ -608,9 +596,12 @@ void Foam::cellCuts::calcFaceCuts() const
 
         if (allVerticesCut)
         {
-            WarningInFunction
-                << "Face " << facei << " vertices " << f
-                << " has all its vertices cut. Not cutting face." << endl;
+            if (verbose_ || debug)
+            {
+                WarningInFunction
+                    << "Face " << facei << " vertices " << f
+                    << " has all its vertices cut. Not cutting face." << endl;
+            }
 
             cutI = 0;
         }
@@ -677,7 +668,7 @@ Foam::label Foam::cellCuts::loopFace
 
             if (isEdge(cut))
             {
-                if (findIndex(fEdges, getEdge(cut)) == -1)
+                if (!fEdges.found(getEdge(cut)))
                 {
                     // Edge not on face. Skip face.
                     allOnFace = false;
@@ -686,7 +677,7 @@ Foam::label Foam::cellCuts::loopFace
             }
             else
             {
-                if (findIndex(f, getVertex(cut)) == -1)
+                if (!f.found(getVertex(cut)))
                 {
                     // Vertex not on face. Skip face.
                     allOnFace = false;
@@ -820,13 +811,17 @@ bool Foam::cellCuts::addCut
         labelList truncVisited(visited);
         truncVisited.setSize(nVisited);
 
-        Pout<< "For cell " << celli << " : trying to add duplicate cut " << cut;
-        labelList cuts(1, cut);
-        writeCuts(Pout, cuts, loopWeights(cuts));
+        if (verbose_ || debug)
+        {
+            Pout<< "For cell " << celli << " : trying to add duplicate cut "
+                << cut;
+            labelList cuts(1, cut);
+            writeCuts(Pout, cuts, loopWeights(cuts));
 
-        Pout<< " to path:";
-        writeCuts(Pout, truncVisited, loopWeights(truncVisited));
-        Pout<< endl;
+            Pout<< " to path:";
+            writeCuts(Pout, truncVisited, loopWeights(truncVisited));
+            Pout<< endl;
+        }
 
         return false;
     }
@@ -917,9 +912,12 @@ bool Foam::cellCuts::walkFace
     }
     else
     {
-        WarningInFunction
-            << "In middle of cut. cell:" << celli << " face:" << facei
-            << " cuts:" << fCuts << " current cut:" << cut << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "In middle of cut. cell:" << celli << " face:" << facei
+                << " cuts:" << fCuts << " current cut:" << cut << endl;
+        }
 
         return false;
     }
@@ -1175,7 +1173,7 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells)
         bool validLoop = false;
 
         // Quick rejection: has enough faces that are cut?
-        if (nCutFaces[celli] >= 3)
+        if (nCutFaces[celli] >= 1)
         {
             const labelList& cFaces = mesh().cells()[celli];
 
@@ -1261,11 +1259,14 @@ void Foam::cellCuts::calcCellLoops(const labelList& cutCells)
             {
                 // Invalid loop. Leave cellLoops_[celli] zero size which
                 // flags this.
-                Pout<< "calcCellLoops(const labelList&) : did not find valid"
-                    << " loop for cell " << celli << endl;
-                // Dump cell and cuts on cell.
-                writeUncutOBJ(".", celli);
-
+                if (verbose_ || debug)
+                {
+                    Pout<< "calcCellLoops(const labelList&) :"
+                        << " did not find valid"
+                        << " loop for cell " << celli << endl;
+                    // Dump cell and cuts on cell.
+                    writeUncutOBJ(".", celli);
+                }
                 cellLoops_[celli].setSize(0);
             }
         }
@@ -1333,8 +1334,8 @@ Foam::labelList Foam::cellCuts::nonAnchorPoints
 
         if
         (
-            findIndex(anchorPoints, pointi) == -1
-         && findIndex(loop, vertToEVert(pointi)) == -1
+            !anchorPoints.found(pointi)
+         && !loop.found(vertToEVert(pointi))
         )
         {
             newElems[newElemI++] = pointi;
@@ -1439,12 +1440,15 @@ bool Foam::cellCuts::calcAnchors
 
     if (uncutIndex == -1)
     {
-        WarningInFunction
-            << "Invalid loop " << loop << " for cell " << celli << endl
-            << "Can not find point on cell which is not cut by loop."
-            << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "Invalid loop " << loop << " for cell " << celli << endl
+                << "Can not find point on cell which is not cut by loop."
+                << endl;
 
-        writeOBJ(".", celli, loopPts, labelList(0));
+            writeOBJ(".", celli, loopPts, labelList(0));
+        }
 
         return false;
     }
@@ -1459,12 +1463,15 @@ bool Foam::cellCuts::calcAnchors
     {
         // All vertices either in loop or in anchor. So split is along single
         // face.
-        WarningInFunction
-            << "Invalid loop " << loop << " for cell " << celli << endl
-            << "All vertices of cell are either in loop or in anchor set"
-            << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "Invalid loop " << loop << " for cell " << celli << endl
+                << "All vertices of cell are either in loop or in anchor set"
+                << endl;
 
-        writeOBJ(".", celli, loopPts, labelList(0));
+            writeOBJ(".", celli, loopPts, labelList(0));
+        }
 
         return false;
     }
@@ -1496,11 +1503,14 @@ bool Foam::cellCuts::calcAnchors
 
     if (uncutIndex != -1)
     {
-        WarningInFunction
-            << "Invalid loop " << loop << " for cell " << celli
-            << " since it splits the cell into more than two cells" << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "Invalid loop " << loop << " for cell " << celli
+                << " since it splits the cell into more than two cells" << endl;
 
-        writeOBJ(".", celli, loopPts, connectedPoints);
+            writeOBJ(".", celli, loopPts, connectedPoints);
+        }
 
         return false;
     }
@@ -1540,24 +1550,30 @@ bool Foam::cellCuts::calcAnchors
 
     if (connectedFaces.size() < 3)
     {
-        WarningInFunction
-            << "Invalid loop " << loop << " for cell " << celli
-            << " since would have too few faces on one side." << nl
-            << "All faces:" << cFaces << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "Invalid loop " << loop << " for cell " << celli
+                << " since would have too few faces on one side." << nl
+                << "All faces:" << cFaces << endl;
 
-        writeOBJ(".", celli, loopPts, connectedPoints);
+            writeOBJ(".", celli, loopPts, connectedPoints);
+        }
 
         return false;
     }
 
     if (otherFaces.size() < 3)
     {
-        WarningInFunction
-            << "Invalid loop " << loop << " for cell " << celli
-            << " since would have too few faces on one side." << nl
-            << "All faces:" << cFaces << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "Invalid loop " << loop << " for cell " << celli
+                << " since would have too few faces on one side." << nl
+                << "All faces:" << cFaces << endl;
 
-        writeOBJ(".", celli, loopPts, otherPoints);
+            writeOBJ(".", celli, loopPts, otherPoints);
+        }
 
         return false;
     }
@@ -1596,13 +1612,16 @@ bool Foam::cellCuts::calcAnchors
                     if (hasSet1)
                     {
                         // Second occurence of set1.
-                        WarningInFunction
-                            << "Invalid loop " << loop << " for cell " << celli
-                            << " since face " << f << " would be split into"
-                            << " more than two faces" << endl;
-
-                        writeOBJ(".", celli, loopPts, otherPoints);
+                        if (verbose_ || debug)
+                        {
+                            WarningInFunction
+                                << "Invalid loop " << loop << " for cell "
+                                << celli
+                                << " since face " << f << " would be split into"
+                                << " more than two faces" << endl;
 
+                            writeOBJ(".", celli, loopPts, otherPoints);
+                        }
                         return false;
                     }
 
@@ -1613,13 +1632,16 @@ bool Foam::cellCuts::calcAnchors
                     if (hasSet2)
                     {
                         // Second occurence of set1.
-                        WarningInFunction
-                            << "Invalid loop " << loop << " for cell " << celli
-                            << " since face " << f << " would be split into"
-                            << " more than two faces" << endl;
-
-                        writeOBJ(".", celli, loopPts, otherPoints);
+                        if (verbose_ || debug)
+                        {
+                            WarningInFunction
+                                << "Invalid loop " << loop << " for cell "
+                                << celli
+                                << " since face " << f << " would be split into"
+                                << " more than two faces" << endl;
 
+                            writeOBJ(".", celli, loopPts, otherPoints);
+                        }
                         return false;
                     }
 
@@ -1651,12 +1673,16 @@ bool Foam::cellCuts::calcAnchors
                     if (hasSet1)
                     {
                         // Second occurence of set1.
-                        WarningInFunction
-                            << "Invalid loop " << loop << " for cell " << celli
-                            << " since face " << f << " would be split into"
-                            << " more than two faces" << endl;
+                        if (verbose_ || debug)
+                        {
+                            WarningInFunction
+                                << "Invalid loop " << loop << " for cell "
+                                << celli
+                                << " since face " << f << " would be split into"
+                                << " more than two faces" << endl;
 
-                        writeOBJ(".", celli, loopPts, otherPoints);
+                            writeOBJ(".", celli, loopPts, otherPoints);
+                        }
 
                         return false;
                     }
@@ -1668,13 +1694,16 @@ bool Foam::cellCuts::calcAnchors
                     if (hasSet2)
                     {
                         // Second occurence of set1.
-                        WarningInFunction
-                            << "Invalid loop " << loop << " for cell " << celli
-                            << " since face " << f << " would be split into"
-                            << " more than two faces" << endl;
-
-                        writeOBJ(".", celli, loopPts, otherPoints);
+                        if (verbose_ || debug)
+                        {
+                            WarningInFunction
+                                << "Invalid loop " << loop << " for cell "
+                                << celli
+                                << " since face " << f << " would be split into"
+                                << " more than two faces" << endl;
 
+                            writeOBJ(".", celli, loopPts, otherPoints);
+                        }
                         return false;
                     }
 
@@ -1826,7 +1855,7 @@ Foam::label Foam::cellCuts::countFaceCuts
         if
         (
             pointIsCut_[vertI]
-         || (findIndex(loop, vertToEVert(vertI)) != -1)
+         || loop.found(vertToEVert(vertI))
         )
         {
             nCuts++;
@@ -1844,7 +1873,7 @@ Foam::label Foam::cellCuts::countFaceCuts
         if
         (
             edgeIsCut_[edgeI]
-         || (findIndex(loop, edgeToEVert(edgeI)) != -1)
+         || loop.found(edgeToEVert(edgeI))
         )
         {
             nCuts++;
@@ -2095,9 +2124,12 @@ bool Foam::cellCuts::validLoop
 
     if (faceContainingLoop != -1)
     {
-        WarningInFunction
-            << "Found loop on cell " << celli << " with all points"
-            << " on face " << faceContainingLoop << endl;
+        if (verbose_ || debug)
+        {
+            WarningInFunction
+                << "Found loop on cell " << celli << " with all points"
+                << " on face " << faceContainingLoop << endl;
+        }
 
         //writeOBJ(".", celli, loopPoints(loop, loopWeights), labelList(0));
 
@@ -2149,12 +2181,14 @@ void Foam::cellCuts::setFromCellLoops()
             )
             {
                 //writeOBJ(".", celli, loopPoints(celli), anchorPoints);
-
-                WarningInFunction
-                    << "Illegal loop " << loop
-                    << " when recreating cut-addressing"
-                    << " from existing cellLoops for cell " << celli
-                    << endl;
+                if (verbose_ || debug)
+                {
+                    WarningInFunction
+                        << "Illegal loop " << loop
+                        << " when recreating cut-addressing"
+                        << " from existing cellLoops for cell " << celli
+                        << endl;
+                }
 
                 cellLoops_[celli].setSize(0);
                 cellAnchorPoints_[celli].setSize(0);
@@ -2764,7 +2798,7 @@ void Foam::cellCuts::check() const
             if
             (
                 !isEdge(cut)
-             && findIndex(anchors, getVertex(cut)) != -1
+             && anchors.found(getVertex(cut))
             )
             {
                 FatalErrorInFunction
@@ -2834,10 +2868,12 @@ Foam::cellCuts::cellCuts
     const labelList& cutCells,
     const labelList& meshVerts,
     const labelList& meshEdges,
-    const scalarField& meshEdgeWeights
+    const scalarField& meshEdgeWeights,
+    const bool verbose
 )
 :
     edgeVertex(mesh),
+    verbose_(verbose),
     pointIsCut_(expand(mesh.nPoints(), meshVerts)),
     edgeIsCut_(expand(mesh.nEdges(), meshEdges)),
     edgeWeight_(expand(mesh.nEdges(), meshEdges, meshEdgeWeights)),
@@ -2876,10 +2912,12 @@ Foam::cellCuts::cellCuts
     const polyMesh& mesh,
     const labelList& meshVerts,
     const labelList& meshEdges,
-    const scalarField& meshEdgeWeights
+    const scalarField& meshEdgeWeights,
+    const bool verbose
 )
 :
     edgeVertex(mesh),
+    verbose_(verbose),
     pointIsCut_(expand(mesh.nPoints(), meshVerts)),
     edgeIsCut_(expand(mesh.nEdges(), meshEdges)),
     edgeWeight_(expand(mesh.nEdges(), meshEdges, meshEdgeWeights)),
@@ -2923,10 +2961,12 @@ Foam::cellCuts::cellCuts
     const polyMesh& mesh,
     const labelList& cellLabels,
     const labelListList& cellLoops,
-    const List<scalarField>& cellEdgeWeights
+    const List<scalarField>& cellEdgeWeights,
+    const bool verbose
 )
 :
     edgeVertex(mesh),
+    verbose_(verbose),
     pointIsCut_(mesh.nPoints(), false),
     edgeIsCut_(mesh.nEdges(), false),
     edgeWeight_(mesh.nEdges(), -GREAT),
@@ -2968,10 +3008,12 @@ Foam::cellCuts::cellCuts
 (
     const polyMesh& mesh,
     const cellLooper& cellCutter,
-    const List<refineCell>& refCells
+    const List<refineCell>& refCells,
+    const bool verbose
 )
 :
     edgeVertex(mesh),
+    verbose_(verbose),
     pointIsCut_(mesh.nPoints(), false),
     edgeIsCut_(mesh.nEdges(), false),
     edgeWeight_(mesh.nEdges(), -GREAT),
@@ -3014,10 +3056,12 @@ Foam::cellCuts::cellCuts
     const polyMesh& mesh,
     const cellLooper& cellCutter,
     const labelList& cellLabels,
-    const List<plane>& cutPlanes
+    const List<plane>& cutPlanes,
+    const bool verbose
 )
 :
     edgeVertex(mesh),
+    verbose_(verbose),
     pointIsCut_(mesh.nPoints(), false),
     edgeIsCut_(mesh.nEdges(), false),
     edgeWeight_(mesh.nEdges(), -GREAT),
@@ -3066,10 +3110,12 @@ Foam::cellCuts::cellCuts
     const Map<edge>& faceSplitCut,
     const labelListList& cellLoops,
     const label nLoops,
-    const labelListList& cellAnchorPoints
+    const labelListList& cellAnchorPoints,
+    const bool verbose
 )
 :
     edgeVertex(mesh),
+    verbose_(verbose),
     pointIsCut_(pointIsCut),
     edgeIsCut_(edgeIsCut),
     edgeWeight_(edgeWeight),
diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.H b/src/dynamicMesh/meshCut/cellCuts/cellCuts.H
index 33760cdb9a3c9daa8a78ab4a1affd8a494cb9ef8..90dbd212ff816f6af6e3085f4bb7ecfb5c432407 100644
--- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.H
+++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.H
@@ -112,6 +112,10 @@ class cellCuts
 {
     // Private data
 
+        //- Warn for illegal cuts
+        const bool verbose_;
+
+
         // Per point/edge status
 
             //- Is mesh point cut
@@ -472,7 +476,8 @@ public:
             const labelList& cutCells,
             const labelList& meshVerts,
             const labelList& meshEdges,
-            const scalarField& meshEdgeWeights
+            const scalarField& meshEdgeWeights,
+            const bool verbose = true
         );
 
         //- Construct from pattern of cuts. Detect cells to cut.
@@ -481,7 +486,8 @@ public:
             const polyMesh& mesh,
             const labelList& meshVerts,
             const labelList& meshEdges,
-            const scalarField& meshEdgeWeights
+            const scalarField& meshEdgeWeights,
+            const bool verbose = true
         );
 
         //- Construct from complete cellLoops through specified cells.
@@ -492,7 +498,8 @@ public:
             const polyMesh& mesh,
             const labelList& cellLabels,
             const labelListList& cellLoops,
-            const List<scalarField>& cellEdgeWeights
+            const List<scalarField>& cellEdgeWeights,
+            const bool verbose = true
         );
 
         //- Construct from list of cells to cut and direction to cut in
@@ -501,7 +508,8 @@ public:
         (
             const polyMesh& mesh,
             const cellLooper& cellCutter,
-            const List<refineCell>& refCells
+            const List<refineCell>& refCells,
+            const bool verbose = true
         );
 
         //- Construct from list of cells to cut and plane to cut with and
@@ -511,7 +519,8 @@ public:
             const polyMesh& mesh,
             const cellLooper& cellCutter,
             const labelList& cellLabels,
-            const List<plane>& cutPlanes
+            const List<plane>& cutPlanes,
+            const bool verbose = true
         );
 
         //- Construct from components
@@ -524,7 +533,8 @@ public:
             const Map<edge>& faceSplitCut,
             const labelListList& cellLoops,
             const label nLoops,
-            const labelListList& cellAnchorPoints
+            const labelListList& cellAnchorPoints,
+            const bool verbose = true
         );
 
 
@@ -630,7 +640,6 @@ public:
 
             //- debugging:Write edges of cell and loop
             void writeCellOBJ(const fileName& dir, const label celli) const;
-
 };
 
 
diff --git a/src/dynamicMesh/meshCut/cellLooper/cellLooper.C b/src/dynamicMesh/meshCut/cellLooper/cellLooper.C
index 934553826668960841df6fb40424024ab1b26fd9..45918f8283bda66cf56789a33168c64e7e8aabf7 100644
--- a/src/dynamicMesh/meshCut/cellLooper/cellLooper.C
+++ b/src/dynamicMesh/meshCut/cellLooper/cellLooper.C
@@ -148,7 +148,7 @@ Foam::labelList Foam::cellLooper::getVertEdgesNonFace
 
         if
         (
-            (findIndex(exclEdges, edgeI) == -1)
+            !exclEdges.found(edgeI)
          && meshTools::edgeOnCell(mesh(), celli, edgeI)
         )
         {
diff --git a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C
index 6e0a010cdafe1425a55bf68dc68883286bf17c3f..5528d9dad5348e0950abee38367fb3a5fb4b78d0 100644
--- a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C
+++ b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C
@@ -363,7 +363,7 @@ bool Foam::geomCellLooper::cut
                     // endpoint so only insert if unique.
                     label cut = vertToEVert(cutVertI);
 
-                    if (findIndex(localLoop, cut) == -1)
+                    if (!localLoop.found(cut))
                     {
                         localLoop.append(vertToEVert(cutVertI));
                         localLoopWeights.append(-GREAT);
diff --git a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C
index 70a1347169b231358c61ffc706346f9741c103f6..b7637869d601bffcfa2562cc796679aa2f1b54a5 100644
--- a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C
+++ b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C
@@ -407,17 +407,8 @@ void Foam::topoCellLooper::walkSplitHex
 
         if
         (
-            (vertI != -1)
-         && (
-                (startLoop =
-                    findIndex
-                    (
-                        loop,
-                        vertToEVert(vertI)
-                    )
-                )
-            != -1
-            )
+            vertI != -1
+         && (startLoop = loop.find(vertToEVert(vertI))) != -1
         )
         {
             // Breaking walk since vertI already cut
@@ -430,17 +421,8 @@ void Foam::topoCellLooper::walkSplitHex
         }
         if
         (
-            (edgeI != -1)
-         && (
-                (startLoop =
-                    findIndex
-                    (
-                        loop,
-                        edgeToEVert(edgeI)
-                    )
-                )
-             != -1
-            )
+            edgeI != -1
+         && (startLoop = loop.find(edgeToEVert(edgeI))) != -1
         )
         {
             // Breaking walk since edgeI already cut
diff --git a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C
index 3ef151d7396ad4fabe4c441a0eadb18f9c1f99ef..253945632ce5e102b58de7aaa6808fb864e0c0da 100644
--- a/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C
+++ b/src/dynamicMesh/meshCut/directions/directionInfo/directionInfo.C
@@ -115,8 +115,8 @@ Foam::label Foam::directionInfo::edgeToFaceIndex
     // - connected (but not in) to face. Return -1.
     // - in face opposite facei. Convert into index in face.
 
-    label fpA = findIndex(f, e.start());
-    label fpB = findIndex(f, e.end());
+    label fpA = f.find(e.start());
+    label fpB = f.find(e.end());
 
     if (fpA != -1)
     {
@@ -158,8 +158,8 @@ Foam::label Foam::directionInfo::edgeToFaceIndex
 
             const edge& e0 = mesh.edges()[edge0I];
 
-            fpA = findIndex(f, e0.start());
-            fpB = findIndex(f, e0.end());
+            fpA = f.find(e0.start());
+            fpB = f.find(e0.end());
 
             if ((fpA != -1) && (fpB != -1))
             {
@@ -176,8 +176,8 @@ Foam::label Foam::directionInfo::edgeToFaceIndex
             // Check if edge on facei.
             const edge& e1 = mesh.edges()[edge1I];
 
-            fpA = findIndex(f, e1.start());
-            fpB = findIndex(f, e1.end());
+            fpA = f.find(e1.start());
+            fpB = f.find(e1.end());
 
             if ((fpA != -1) && (fpB != -1))
             {
diff --git a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C
index 8a0f2a16052f016e76c1b20bc1cfb32a99628fda..982785c18bf792f7967f6e33ebdad8aa927bc9b8 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C
@@ -657,8 +657,8 @@ void Foam::boundaryCutter::setRefinement
         // Split face from one side of diagonal to other.
         const labelPair& diag = iter();
 
-        label fp0 = findIndex(newFace, f[diag[0]]);
-        label fp1 = findIndex(newFace, f[diag[1]]);
+        label fp0 = newFace.find(f[diag[0]]);
+        label fp1 = newFace.find(f[diag[1]]);
 
         if (fp0 == -1 || fp1 == -1 || fp0 == fp1)
         {
diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
index d169c6e56ab54b174a99de913d9c65f22541a056..b6549c9dcb3a66e9a14927071bc3f9725accdd95 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
@@ -54,7 +54,7 @@ Foam::label Foam::meshCutAndRemove::firstCommon
 {
     forAll(elems1, elemI)
     {
-        label index1 = findIndex(elems2, elems1[elemI]);
+        label index1 = elems2.find(elems1[elemI]);
 
         if (index1 != -1)
         {
@@ -72,7 +72,7 @@ bool Foam::meshCutAndRemove::isIn
     const labelList& cuts
 )
 {
-    label index = findIndex(cuts, twoCuts[0]);
+    label index = cuts.find(twoCuts[0]);
 
     if (index == -1)
     {
@@ -434,7 +434,7 @@ void Foam::meshCutAndRemove::splitFace
 ) const
 {
     // Check if we find any new vertex which is part of the splitEdge.
-    label startFp = findIndex(f, v0);
+    label startFp = f.find(v0);
 
     if (startFp == -1)
     {
@@ -444,7 +444,7 @@ void Foam::meshCutAndRemove::splitFace
             << abort(FatalError);
     }
 
-    label endFp = findIndex(f, v1);
+    label endFp = f.find(v1);
 
     if (endFp == -1)
     {
diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
index 2cc5833ad41db4e68efeda49e849332068909e0d..bae27fde251fbae6333f5e36ec3b7d4f4a833315 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
@@ -49,7 +49,7 @@ bool Foam::meshCutter::uses(const labelList& elems1, const labelList& elems2)
 {
     forAll(elems1, elemI)
     {
-        if (findIndex(elems2, elems1[elemI]) != -1)
+        if (elems2.found(elems1[elemI]))
         {
             return true;
         }
@@ -64,7 +64,7 @@ bool Foam::meshCutter::isIn
     const labelList& cuts
 )
 {
-    label index = findIndex(cuts, twoCuts[0]);
+    label index = cuts.find(twoCuts[0]);
 
     if (index == -1)
     {
@@ -380,7 +380,7 @@ void Foam::meshCutter::splitFace
 ) const
 {
     // Check if we find any new vertex which is part of the splitEdge.
-    label startFp = findIndex(f, v0);
+    label startFp = f.find(v0);
 
     if (startFp == -1)
     {
@@ -390,7 +390,7 @@ void Foam::meshCutter::splitFace
             << abort(FatalError);
     }
 
-    label endFp = findIndex(f, v1);
+    label endFp = f.find(v1);
 
     if (endFp == -1)
     {
diff --git a/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C b/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C
index 1ee72682f3bbd08a4686c2eb5cabc3279e09c1c1..94e9b2f24c2fbc0e708fd0cbe92065a3fa46e256 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C
@@ -174,7 +174,7 @@ void Foam::multiDirRefinement::addCells
             added[0] = masterI;
             added[1] = newCelli;
         }
-        else if (findIndex(added, newCelli) == -1)
+        else if (!added.found(newCelli))
         {
             label sz = added.size();
             added.setSize(sz + 1);
diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C b/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C
index 7f3b08d1e96314de40f7722e9296e922789e7246..86043002269e6a71521fa9f7ca7fc468a1c98073 100644
--- a/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C
+++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C
@@ -174,8 +174,8 @@ write(Ostream& os) const
     // Note: write value
     fixedValuePointPatchVectorField::write(os);
 
-    os.writeKeyword(solidBodyMotionFunction::typeName) << SBMFPtr_->type()
-        << token::END_STATEMENT << nl;
+    os.writeEntry(solidBodyMotionFunction::typeName, SBMFPtr_->type());
+
     os  << indent << word(SBMFPtr_->type() + "Coeffs");
     SBMFPtr_->writeData(os);
 }
diff --git a/src/dynamicMesh/perfectInterface/perfectInterface.C b/src/dynamicMesh/perfectInterface/perfectInterface.C
index 5aa0b5ed99313218c7d3a873ae85588d8bfa4342..1b2475dc47915f5c8e52f3ce875927c94ea5e5cb 100644
--- a/src/dynamicMesh/perfectInterface/perfectInterface.C
+++ b/src/dynamicMesh/perfectInterface/perfectInterface.C
@@ -506,34 +506,16 @@ void Foam::perfectInterface::write(Ostream& os) const
 
 void Foam::perfectInterface::writeDict(Ostream& os) const
 {
-    os  << nl << name() << nl << token::BEGIN_BLOCK << nl
-
-        << "    type " << type()
-        << token::END_STATEMENT << nl
-
-        << "    active " << active()
-        << token::END_STATEMENT << nl
-
-        << "    faceZoneName " << faceZoneID_.name()
-        << token::END_STATEMENT << nl
-
-        << "    masterPatchName " << masterPatchID_.name()
-        << token::END_STATEMENT << nl
-
-        << "    slavePatchName " << slavePatchID_.name()
-        << token::END_STATEMENT << nl
-
-        << token::END_BLOCK << endl;
+    os  << nl;
+
+    os.beginBlock(name());
+    os.writeEntry("type", type());
+    os.writeEntry("active", active());
+    os.writeEntry("faceZoneName", faceZoneID_.name());
+    os.writeEntry("masterPatchName", masterPatchID_.name());
+    os.writeEntry("slavePatchName", slavePatchID_.name());
+    os.endBlock();
 }
 
 
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
-
-
 // ************************************************************************* //
diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C
index b4f8f7449f51d2753480751abf1369653fcc244f..79bc1bf688798f5244cd21fe39a6a87f241c721f 100644
--- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C
+++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C
@@ -1290,7 +1290,7 @@ Foam::label Foam::faceCoupleInfo::matchEdgeFaces
 
                         forAll(masterEFaces, j)
                         {
-                            if (findIndex(masterFaces, masterEFaces[j]) != -1)
+                            if (masterFaces.found(masterEFaces[j]))
                             {
                                 newCandidates.append(masterEFaces[j]);
                             }
diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C
index 0c8a179b57fe79658f70b30b99cf859db4e3a110..edd8818ff6f7237caab97d4031544e6f9fa3d601 100644
--- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C
+++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C
@@ -51,7 +51,7 @@ Foam::label Foam::polyMeshAdder::patchIndex
     const word& pType = p.type();
     const word& pName = p.name();
 
-    label patchi = findIndex(allPatchNames, pName);
+    label patchi = allPatchNames.find(pName);
 
     if (patchi == -1)
     {
@@ -96,7 +96,7 @@ Foam::label Foam::polyMeshAdder::zoneIndex
     DynamicList<word>& names
 )
 {
-    label zoneI = findIndex(names, curName);
+    label zoneI = names.find(curName);
 
     if (zoneI != -1)
     {
@@ -912,7 +912,7 @@ void Foam::polyMeshAdder::mergePointZones
             else if (pointToZone[allPointi] != zoneI)
             {
                 labelList& pZones = addPointToZones[allPointi];
-                if (findIndex(pZones, zoneI) == -1)
+                if (!pZones.found(zoneI))
                 {
                     pZones.append(zoneI);
                 }
@@ -938,7 +938,7 @@ void Foam::polyMeshAdder::mergePointZones
             else if (pointToZone[allPointi] != allZoneI)
             {
                 labelList& pZones = addPointToZones[allPointi];
-                if (findIndex(pZones, allZoneI) == -1)
+                if (!pZones.found(allZoneI))
                 {
                     pZones.append(allZoneI);
                 }
@@ -1070,7 +1070,7 @@ void Foam::polyMeshAdder::mergeFaceZones
                     labelList& fZones = addFaceToZones[allFacei];
                     boolList& flipZones = addFaceToFlips[allFacei];
 
-                    if (findIndex(fZones, zoneI) == -1)
+                    if (!fZones.found(zoneI))
                     {
                         fZones.append(zoneI);
                         flipZones.append(flip0);
@@ -1113,7 +1113,7 @@ void Foam::polyMeshAdder::mergeFaceZones
                     labelList& fZones = addFaceToZones[allFacei];
                     boolList& flipZones = addFaceToFlips[allFacei];
 
-                    if (findIndex(fZones, allZoneI) == -1)
+                    if (!fZones.found(allZoneI))
                     {
                         fZones.append(allZoneI);
                         flipZones.append(flip1);
@@ -1235,7 +1235,7 @@ void Foam::polyMeshAdder::mergeCellZones
             else if (cellToZone[cell0] != zoneI)
             {
                 labelList& cZones = addCellToZones[cell0];
-                if (findIndex(cZones, zoneI) == -1)
+                if (!cZones.found(zoneI))
                 {
                     cZones.append(zoneI);
                 }
@@ -1260,7 +1260,7 @@ void Foam::polyMeshAdder::mergeCellZones
             else if (cellToZone[allCelli] != allZoneI)
             {
                 labelList& cZones = addCellToZones[allCelli];
-                if (findIndex(cZones, allZoneI) == -1)
+                if (!cZones.found(allZoneI))
                 {
                     cZones.append(allZoneI);
                 }
@@ -2035,7 +2035,7 @@ Foam::Map<Foam::label> Foam::polyMeshAdder::findSharedPoints
             label sz = connectedPointLabels.size();
 
             // Check just to make sure.
-            if (findIndex(connectedPointLabels, pointi) != -1)
+            if (connectedPointLabels.found(pointi))
             {
                 FatalErrorInFunction
                     << "Duplicate point in sharedPoint addressing." << endl
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
index 536f7296b22982bbbe14fad001ae623b2811aecb..5135d80e9823148ff512ae0678086d84e0db7bf7 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
@@ -540,7 +540,7 @@ void Foam::addPatchCellLayer::findZoneFace
 
         if
         (
-            (findIndex(excludeFaces, faceI) == -1)
+            !excludeFaces.found(faceI)
          && (
                 (mesh.isInternalFace(faceI) && useInternalFaces)
              || (!mesh.isInternalFace(faceI) && useBoundaryFaces)
@@ -749,7 +749,7 @@ void Foam::addPatchCellLayer::calcExtrudeInfo
 
             if (otherProci != -1)
             {
-                if (findIndex(gd[Pstream::myProcNo()], otherProci) != -1)
+                if (gd[Pstream::myProcNo()].found(otherProci))
                 {
                     // There is already a processorPolyPatch to otherProci.
                     // Use it. Note that we can only index procPatchMap
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
index 8a035779ad620f34d121e31b8febd7907b094b06..485ee56ee2af2f31af1065276269ab8a452a7678 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H
@@ -146,7 +146,7 @@ class addPatchCellLayer
                 {
                     forAll(y, yi)
                     {
-                        if (findIndex(x, y[yi]) == -1)
+                        if (!x.found(y[yi]))
                         {
                             label sz = x.size();
                             x.setSize(sz+1);
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
index 9d1140a71ef129e1bfcdfa2e4e70b7046bc7c4d1..10e5ee81c631ba9196338feb9cc2af0e2365a7a6 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
@@ -254,7 +254,7 @@ bool Foam::combineFaces::faceNeighboursValid
 
                 if (iter == faceRegion.end())
                 {
-                    if (findIndex(neighbourFaces, nbrI) == -1)
+                    if (!neighbourFaces.found(nbrI))
                     {
                         neighbourFaces.append(nbrI);
                     }
@@ -453,8 +453,8 @@ Foam::face Foam::combineFaces::getOutsideFace
     bool edgeLoopConsistent = false;
 
     {
-        label index0 = findIndex(outsideLoop, e[0]);
-        label index1 = findIndex(outsideLoop, e[1]);
+        label index0 = outsideLoop.find(e[0]);
+        label index1 = outsideLoop.find(e[1]);
 
         if (index0 == -1 || index1 == -1)
         {
@@ -496,7 +496,7 @@ Foam::face Foam::combineFaces::getOutsideFace
 
     {
         // Find edge in face.
-        label index = findIndex(fp.faceEdges()[eFaces[0]], bEdgeI);
+        label index = fp.faceEdges()[eFaces[0]].find(bEdgeI);
 
         if (index == -1)
         {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C
index 15d9df7f3e19884c88373a7146cf5ac0ac4646e1..ad9e8dd92e63c2cc25c2e1cdf888fe158ce89b23 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/duplicatePoints.C
@@ -135,7 +135,7 @@ void Foam::duplicatePoints::setRefinement
                 const labelList& dupPoints = duplicates_[iter()];
 
                 // Look up index of my region in the regions for this point
-                label index = findIndex(regions, fRegion[fp]);
+                label index = regions.find(fRegion[fp]);
                 // Get the corresponding added point
                 newFace[fp] = dupPoints[index];
             }
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C
index 83d29c214c93ae3639630cafd8c1f502741d00ed..ce81b0a63deded2d02d06aa803ebdb5b964c2b82 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C
@@ -1138,9 +1138,9 @@ void Foam::edgeCollapser::filterFace
         // Do we have a local point for this index?
         if (collapseStrings.found(collapseIndex))
         {
-            label localPointi = collapseStrings[collapseIndex][0];
+            const label localPointi = collapseStrings[collapseIndex][0];
 
-            if (findIndex(SubList<label>(f, newFp), localPointi) == -1)
+            if (!SubList<label>(f, newFp).found(localPointi))
             {
                 f[newFp++] = localPointi;
             }
@@ -1176,7 +1176,7 @@ void Foam::edgeCollapser::filterFace
         label pointi = f[fp];
 
         // Search for previous occurrence.
-        label index = findIndex(SubList<label>(f, fp), pointi);
+        const label index = SubList<label>(f, fp).find(pointi);
 
         if (index == fp1)
         {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C
index 38a96855df9eb030c9ceefef6b64c503c052bfa1..43bb04496721e3381744dc36a7754f959d92f443 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C
@@ -544,7 +544,7 @@ Foam::label Foam::hexRef8::getAnchorCell
 {
     if (cellAnchorPoints[celli].size())
     {
-        label index = findIndex(cellAnchorPoints[celli], pointi);
+        label index = cellAnchorPoints[celli].find(pointi);
 
         if (index != -1)
         {
@@ -559,7 +559,7 @@ Foam::label Foam::hexRef8::getAnchorCell
 
         forAll(f, fp)
         {
-            label index = findIndex(cellAnchorPoints[celli], f[fp]);
+            label index = cellAnchorPoints[celli].find(f[fp]);
 
             if (index != -1)
             {
@@ -1849,7 +1849,7 @@ bool Foam::hexRef8::matchHexShape
                         if (iter != pointFaces.end())
                         {
                             labelList& pFaces = iter();
-                            if (findIndex(pFaces, facei) == -1)
+                            if (!pFaces.found(facei))
                             {
                                 pFaces.append(facei);
                             }
@@ -4376,12 +4376,12 @@ void Foam::hexRef8::updateMesh
             cellLevel_[newCelli] = fnd();
         }
 
-        //if (findIndex(cellLevel_, -1) != -1)
+        //if (cellLevel_.found(-1))
         //{
         //    WarningInFunction
         //        << "Problem : "
         //        << "cellLevel_ contains illegal value -1 after mapping
-        //        << " at cell " << findIndex(cellLevel_, -1) << endl
+        //        << " at cell " << cellLevel_.find(-1) << endl
         //        << "This means that another program has inflated cells"
         //        << " (created cells out-of-nothing) and hence we don't know"
         //        << " their cell level. Continuing with illegal value."
@@ -4450,12 +4450,12 @@ void Foam::hexRef8::updateMesh
             pointLevel_[newPointi] = fnd();
         }
 
-        //if (findIndex(pointLevel_, -1) != -1)
+        //if (pointLevel_.found(-1))
         //{
         //    WarningInFunction
         //        << "Problem : "
         //        << "pointLevel_ contains illegal value -1 after mapping"
-        //        << " at point" << findIndex(pointLevel_, -1) << endl
+        //        << " at point" << pointLevel_.find(-1) << endl
         //        << "This means that another program has inflated points"
         //        << " (created points out-of-nothing) and hence we don't know"
         //        << " their point level. Continuing with illegal value."
@@ -4516,7 +4516,7 @@ void Foam::hexRef8::subset
 
         cellLevel_.transfer(newCellLevel);
 
-        if (findIndex(cellLevel_, -1) != -1)
+        if (cellLevel_.found(-1))
         {
             FatalErrorInFunction
                 << "Problem : "
@@ -4537,7 +4537,7 @@ void Foam::hexRef8::subset
 
         pointLevel_.transfer(newPointLevel);
 
-        if (findIndex(pointLevel_, -1) != -1)
+        if (pointLevel_.found(-1))
         {
             FatalErrorInFunction
                 << "Problem : "
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
index 22599e045317372c52049be75cd9bc3c6b987328..d772f7c197812cd7fb9210c9d4765b4a01ae085a 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
@@ -313,7 +313,7 @@ void Foam::refinementHistory::freeSplitCell(const label index)
         {
             FixedList<label, 8>& subCells = subCellsPtr();
 
-            label myPos = findIndex(subCells, index);
+            label myPos = subCells.find(index);
 
             if (myPos == -1)
             {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C
index b60301b503491128279c133f2688a0ca008349b3..90c3c635201238863ac0704ad12d320593e81621 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -54,22 +54,22 @@ namespace Foam
 // Renumber with special handling for merged items (marked with <-1)
 void Foam::polyTopoChange::renumberReverseMap
 (
-    const labelList& map,
+    const labelUList& oldToNew,
     DynamicList<label>& elems
 )
 {
     forAll(elems, elemI)
     {
-        label val = elems[elemI];
+        const label val = elems[elemI];
 
         if (val >= 0)
         {
-            elems[elemI] = map[val];
+            elems[elemI] = oldToNew[val];
         }
         else if (val < -1)
         {
-            label mergedVal = -val-2;
-            elems[elemI] = -map[mergedVal]-2;
+            const label mergedVal = -val-2;
+            elems[elemI] = -oldToNew[mergedVal]-2;
         }
     }
 }
@@ -77,52 +77,52 @@ void Foam::polyTopoChange::renumberReverseMap
 
 void Foam::polyTopoChange::renumber
 (
-    const labelList& map,
-    labelHashSet& elems
+    const labelUList& oldToNew,
+    labelHashSet& labels
 )
 {
-    labelHashSet newElems(elems.size());
+    labelHashSet newSet(labels.capacity());
 
-    forAllConstIter(labelHashSet, elems, iter)
+    for (const label val : labels)
     {
-        label newElem = map[iter.key()];
+        const label newVal = oldToNew[val];
 
-        if (newElem >= 0)
+        if (newVal >= 0)
         {
-            newElems.insert(newElem);
+            newSet.insert(newVal);
         }
     }
 
-    elems.transfer(newElems);
+    labels.transfer(newSet);
 }
 
 
 // Renumber and remove -1 elements.
 void Foam::polyTopoChange::renumberCompact
 (
-    const labelList& map,
+    const labelUList& oldToNew,
     labelList& elems
 )
 {
-    label newElemI = 0;
+    label nElem = 0;
 
-    forAll(elems, elemI)
+    for (const label val : elems)
     {
-        label newVal = map[elems[elemI]];
+        const label newVal = oldToNew[val];
 
         if (newVal != -1)
         {
-            elems[newElemI++] = newVal;
+            elems[nElem++] = newVal;
         }
     }
-    elems.setSize(newElemI);
+    elems.setSize(nElem);
 }
 
 
 void Foam::polyTopoChange::countMap
 (
-    const labelList& map,
-    const labelList& reverseMap,
+    const labelUList& map,
+    const labelUList& reverseMap,
     label& nAdd,
     label& nInflate,
     label& nMerge,
@@ -136,7 +136,7 @@ void Foam::polyTopoChange::countMap
 
     forAll(map, newCelli)
     {
-        label oldCelli = map[newCelli];
+        const label oldCelli = map[newCelli];
 
         if (oldCelli >= 0)
         {
@@ -164,7 +164,7 @@ void Foam::polyTopoChange::countMap
 
     forAll(reverseMap, oldCelli)
     {
-        label newCelli = reverseMap[oldCelli];
+        const label newCelli = reverseMap[oldCelli];
 
         if (newCelli >= 0)
         {
@@ -224,8 +224,8 @@ void Foam::polyTopoChange::writeMeshStats(const polyMesh& mesh, Ostream& os)
 
 void Foam::polyTopoChange::getMergeSets
 (
-    const labelList& reverseCellMap,
-    const labelList& cellMap,
+    const labelUList& reverseCellMap,
+    const labelUList& cellMap,
     List<objectMap>& cellsFromCells
 )
 {
@@ -234,7 +234,7 @@ void Foam::polyTopoChange::getMergeSets
 
     forAll(reverseCellMap, oldCelli)
     {
-        label newCelli = reverseCellMap[oldCelli];
+        const label newCelli = reverseCellMap[oldCelli];
 
         if (newCelli < -1)
         {
@@ -267,15 +267,15 @@ void Foam::polyTopoChange::getMergeSets
 
     forAll(reverseCellMap, oldCelli)
     {
-        label newCelli = reverseCellMap[oldCelli];
+        const label newCelli = reverseCellMap[oldCelli];
 
         if (newCelli < -1)
         {
-            label mergeCelli = -newCelli-2;
+            const label mergeCelli = -newCelli-2;
 
             // oldCelli was merged into mergeCelli
 
-            label setI = cellToMergeSet[mergeCelli];
+            const label setI = cellToMergeSet[mergeCelli];
 
             objectMap& mergeSet = cellsFromCells[setI];
 
@@ -305,9 +305,9 @@ void Foam::polyTopoChange::getMergeSets
 
 bool Foam::polyTopoChange::hasValidPoints(const face& f) const
 {
-    forAll(f, fp)
+    for (const label fp : f)
     {
-        if (f[fp] < 0 || f[fp] >= points_.size())
+        if (fp < 0 || fp >= points_.size())
         {
             return false;
         }
@@ -404,7 +404,7 @@ void Foam::polyTopoChange::checkFace
         }
     }
 
-    if (f.size() < 3 || findIndex(f, -1) != -1)
+    if (f.size() < 3 || f.found(-1))
     {
         FatalErrorInFunction
             << "Illegal vertices in face"
@@ -595,7 +595,7 @@ void Foam::polyTopoChange::makeCellCells
 // Handles removed cells. Returns number of remaining cells.
 Foam::label Foam::polyTopoChange::getCellOrder
 (
-    const CompactListList<label>& cellCellAddressing,
+    const CompactListList<label, labelList>& cellCellAddressing,
     labelList& oldToNew
 ) const
 {
@@ -716,8 +716,8 @@ Foam::label Foam::polyTopoChange::getCellOrder
 void Foam::polyTopoChange::getFaceOrder
 (
     const label nActiveFaces,
-    const labelList& cellFaces,
-    const labelList& cellFaceOffsets,
+    const labelUList& cellFaces,
+    const labelUList& cellFaceOffsets,
 
     labelList& oldToNew,
     labelList& patchSizes,
@@ -882,7 +882,7 @@ void Foam::polyTopoChange::getFaceOrder
 void Foam::polyTopoChange::reorderCompactFaces
 (
     const label newSize,
-    const labelList& oldToNew
+    const labelUList& oldToNew
 )
 {
     reorder(oldToNew, faces_);
@@ -1069,9 +1069,9 @@ void Foam::polyTopoChange::compact
             newPointi = nActivePoints;
         }
 
-        forAllConstIter(labelHashSet, retiredPoints_, iter)
+        for (const label pointi : retiredPoints_)
         {
-            localPointMap[iter.key()] = newPointi++;
+            localPointMap[pointi] = newPointi++;
         }
 
 
@@ -1282,7 +1282,7 @@ void Foam::polyTopoChange::compact
 Foam::labelList Foam::polyTopoChange::selectFaces
 (
     const primitiveMesh& mesh,
-    const labelList& faceLabels,
+    const labelUList& faceLabels,
     const bool internalFacesOnly
 )
 {
@@ -1331,7 +1331,7 @@ Foam::labelList Foam::polyTopoChange::selectFaces
 // label)
 void Foam::polyTopoChange::calcPatchPointMap
 (
-    const List<Map<label>>& oldPatchMeshPointMaps,
+    const UList<Map<label>>& oldPatchMeshPointMaps,
     const polyBoundaryMesh& boundary,
     labelListList& patchPointMap
 ) const
@@ -1353,19 +1353,11 @@ void Foam::polyTopoChange::calcPatchPointMap
             if (meshPoints[i] < pointMap_.size())
             {
                 // Check if old point was part of same patch
-                Map<label>::const_iterator ozmpmIter = oldMeshPointMap.find
+                curPatchPointRnb[i] = oldMeshPointMap.lookup
                 (
-                    pointMap_[meshPoints[i]]
+                    pointMap_[meshPoints[i]],
+                    -1
                 );
-
-                if (ozmpmIter != oldMeshPointMap.end())
-                {
-                    curPatchPointRnb[i] = ozmpmIter();
-                }
-                else
-                {
-                    curPatchPointRnb[i] = -1;
-                }
             }
             else
             {
@@ -1394,38 +1386,24 @@ void Foam::polyTopoChange::calcFaceInflationMaps
         label nFacesFromPoints = 0;
 
         // Collect all still existing faces connected to this point.
-        forAllConstIter(Map<label>, faceFromPoint_, iter)
+        forAllConstIters(faceFromPoint_, iter)
         {
-            label newFacei = iter.key();
+            const label facei = iter.key();
+            const label pointi = iter.object();
 
-            if (region_[newFacei] == -1)
-            {
-                // Get internal faces using point on old mesh
-                facesFromPoints[nFacesFromPoints++] = objectMap
-                (
-                    newFacei,
-                    selectFaces
-                    (
-                        mesh,
-                        mesh.pointFaces()[iter()],
-                        true
-                    )
-                );
-            }
-            else
-            {
-                // Get patch faces using point on old mesh
-                facesFromPoints[nFacesFromPoints++] = objectMap
+            // Get internal or patch faces using point on old mesh
+            const bool internal = (region_[facei] == -1);
+
+            facesFromPoints[nFacesFromPoints++] = objectMap
+            (
+                facei,
+                selectFaces
                 (
-                    newFacei,
-                    selectFaces
-                    (
-                        mesh,
-                        mesh.pointFaces()[iter()],
-                        false
-                    )
-                );
-            }
+                    mesh,
+                    mesh.pointFaces()[pointi],
+                    internal
+                )
+            );
         }
     }
 
@@ -1440,38 +1418,24 @@ void Foam::polyTopoChange::calcFaceInflationMaps
         label nFacesFromEdges = 0;
 
         // Collect all still existing faces connected to this edge.
-        forAllConstIter(Map<label>, faceFromEdge_, iter)
+        forAllConstIters(faceFromEdge_, iter)
         {
-            label newFacei = iter.key();
+            const label facei = iter.key();
+            const label edgei = iter.object();
 
-            if (region_[newFacei] == -1)
-            {
-                // Get internal faces using edge on old mesh
-                facesFromEdges[nFacesFromEdges++] = objectMap
-                (
-                    newFacei,
-                    selectFaces
-                    (
-                        mesh,
-                        mesh.edgeFaces(iter()),
-                        true
-                    )
-                );
-            }
-            else
-            {
-                // Get patch faces using edge on old mesh
-                facesFromEdges[nFacesFromEdges++] = objectMap
+            // Get internal or patch faces using edge on old mesh
+            const bool internal = (region_[facei] == -1);
+
+            facesFromEdges[nFacesFromEdges++] = objectMap
+            (
+                facei,
+                selectFaces
                 (
-                    newFacei,
-                    selectFaces
-                    (
-                        mesh,
-                        mesh.edgeFaces(iter()),
-                        false
-                    )
-                );
-            }
+                    mesh,
+                    mesh.edgeFaces(edgei),
+                    internal
+                )
+            );
         }
     }
 
@@ -1503,13 +1467,16 @@ void Foam::polyTopoChange::calcCellInflationMaps
     {
         label nCellsFromPoints = 0;
 
-        // Collect all still existing faces connected to this point.
-        forAllConstIter(Map<label>, cellFromPoint_, iter)
+        // Collect all still existing cells connected to this point.
+        forAllConstIters(cellFromPoint_, iter)
         {
+            const label celli = iter.key();
+            const label pointi = iter.object();
+
             cellsFromPoints[nCellsFromPoints++] = objectMap
             (
-                iter.key(),
-                mesh.pointCells()[iter()]
+                celli,
+                mesh.pointCells()[pointi]
             );
         }
     }
@@ -1521,13 +1488,16 @@ void Foam::polyTopoChange::calcCellInflationMaps
     {
         label nCellsFromEdges = 0;
 
-        // Collect all still existing faces connected to this point.
-        forAllConstIter(Map<label>, cellFromEdge_, iter)
+        // Collect all still existing cells connected to this edge.
+        forAllConstIters(cellFromEdge_, iter)
         {
+            const label celli = iter.key();
+            const label edgei = iter.object();
+
             cellsFromEdges[nCellsFromEdges++] = objectMap
             (
-                iter.key(),
-                mesh.edgeCells()[iter()]
+                celli,
+                mesh.edgeCells()[edgei]
             );
         }
     }
@@ -1542,9 +1512,10 @@ void Foam::polyTopoChange::calcCellInflationMaps
         labelList twoCells(2);
 
         // Collect all still existing faces connected to this point.
-        forAllConstIter(Map<label>, cellFromFace_, iter)
+        forAllConstIters(cellFromFace_, iter)
         {
-            label oldFacei = iter();
+            const label celli = iter.key();
+            const label oldFacei = iter.object();
 
             if (mesh.isInternalFace(oldFacei))
             {
@@ -1552,7 +1523,7 @@ void Foam::polyTopoChange::calcCellInflationMaps
                 twoCells[1] = mesh.faceNeighbour()[oldFacei];
                 cellsFromFaces[nCellsFromFaces++] = objectMap
                 (
-                    iter.key(),
+                    celli,
                     twoCells
                 );
             }
@@ -1560,7 +1531,7 @@ void Foam::polyTopoChange::calcCellInflationMaps
             {
                 cellsFromFaces[nCellsFromFaces++] = objectMap
                 (
-                    iter.key(),
+                    celli,
                     labelList(1, mesh.faceOwner()[oldFacei])
                 );
             }
@@ -1600,49 +1571,51 @@ void Foam::polyTopoChange::resetZones
 
         labelList nPoints(pointZones.size(), 0);
 
-        forAllConstIter(Map<label>, pointZone_, iter)
+        forAllConstIters(pointZone_, iter)
         {
-            label zoneI = iter();
+            const label pointi = iter.key();
+            const label zonei = iter.object();
 
-            if (zoneI < 0 || zoneI >= pointZones.size())
+            if (zonei < 0 || zonei >= pointZones.size())
             {
                 FatalErrorInFunction
-                    << "Illegal zoneID " << zoneI << " for point "
-                    << iter.key() << " coord " << mesh.points()[iter.key()]
+                    << "Illegal zoneID " << zonei << " for point "
+                    << pointi << " coord " << mesh.points()[pointi]
                     << abort(FatalError);
             }
-            nPoints[zoneI]++;
+            nPoints[zonei]++;
         }
 
         // Distribute points per zone
 
         labelListList addressing(pointZones.size());
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            addressing[zoneI].setSize(nPoints[zoneI]);
+            addressing[zonei].setSize(nPoints[zonei]);
         }
         nPoints = 0;
 
-        forAllConstIter(Map<label>, pointZone_, iter)
+        forAllConstIters(pointZone_, iter)
         {
-            label zoneI = iter();
+            const label pointi = iter.key();
+            const label zonei = iter.object();
 
-            addressing[zoneI][nPoints[zoneI]++] = iter.key();
+            addressing[zonei][nPoints[zonei]++] = pointi;
         }
         // Sort the addressing
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            stableSort(addressing[zoneI]);
+            stableSort(addressing[zonei]);
         }
 
         // So now we both have old zones and the new addressing.
         // Invert the addressing to get pointZoneMap.
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            const pointZone& oldZone = pointZones[zoneI];
-            const labelList& newZoneAddr = addressing[zoneI];
+            const pointZone& oldZone = pointZones[zonei];
+            const labelList& newZoneAddr = addressing[zonei];
 
-            labelList& curPzRnb = pointZoneMap[zoneI];
+            labelList& curPzRnb = pointZoneMap[zonei];
             curPzRnb.setSize(newZoneAddr.size());
 
             forAll(newZoneAddr, i)
@@ -1660,17 +1633,17 @@ void Foam::polyTopoChange::resetZones
 
         // Reset the addresing on the zone
         newMesh.pointZones().clearAddressing();
-        forAll(newMesh.pointZones(), zoneI)
+        forAll(newMesh.pointZones(), zonei)
         {
             if (debug)
             {
-                Pout<< "pointZone:" << zoneI
-                    << "  name:" << newMesh.pointZones()[zoneI].name()
-                    << "  size:" << addressing[zoneI].size()
+                Pout<< "pointZone:" << zonei
+                    << "  name:" << newMesh.pointZones()[zonei].name()
+                    << "  size:" << addressing[zonei].size()
                     << endl;
             }
 
-            newMesh.pointZones()[zoneI] = addressing[zoneI];
+            newMesh.pointZones()[zonei] = addressing[zonei];
         }
     }
 
@@ -1684,71 +1657,73 @@ void Foam::polyTopoChange::resetZones
 
         labelList nFaces(faceZones.size(), 0);
 
-        forAllConstIter(Map<label>, faceZone_, iter)
+        forAllConstIters(faceZone_, iter)
         {
-            label zoneI = iter();
+            const label facei = iter.key();
+            const label zonei = iter.object();
 
-            if (zoneI < 0 || zoneI >= faceZones.size())
+            if (zonei < 0 || zonei >= faceZones.size())
             {
                 FatalErrorInFunction
-                    << "Illegal zoneID " << zoneI << " for face "
-                    << iter.key()
+                    << "Illegal zoneID " << zonei << " for face "
+                    << facei
                     << abort(FatalError);
             }
-            nFaces[zoneI]++;
+            nFaces[zonei]++;
         }
 
         labelListList addressing(faceZones.size());
         boolListList flipMode(faceZones.size());
 
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            addressing[zoneI].setSize(nFaces[zoneI]);
-            flipMode[zoneI].setSize(nFaces[zoneI]);
+            addressing[zonei].setSize(nFaces[zonei]);
+            flipMode[zonei].setSize(nFaces[zonei]);
         }
         nFaces = 0;
 
-        forAllConstIter(Map<label>, faceZone_, iter)
+        forAllConstIters(faceZone_, iter)
         {
-            label zoneI = iter();
-            label facei = iter.key();
+            const label facei = iter.key();
+            const label zonei = iter.object();
 
-            label index = nFaces[zoneI]++;
+            const label index = nFaces[zonei]++;
 
-            addressing[zoneI][index] = facei;
-            flipMode[zoneI][index] = faceZoneFlip_[facei];
+            addressing[zonei][index] = facei;
+            flipMode[zonei][index] = faceZoneFlip_[facei];
         }
+
         // Sort the addressing
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
             labelList newToOld;
-            sortedOrder(addressing[zoneI], newToOld);
+            sortedOrder(addressing[zonei], newToOld);
             {
-                labelList newAddressing(addressing[zoneI].size());
+                labelList newAddressing(addressing[zonei].size());
                 forAll(newAddressing, i)
                 {
-                    newAddressing[i] = addressing[zoneI][newToOld[i]];
+                    newAddressing[i] = addressing[zonei][newToOld[i]];
                 }
-                addressing[zoneI].transfer(newAddressing);
+                addressing[zonei].transfer(newAddressing);
             }
             {
-                boolList newFlipMode(flipMode[zoneI].size());
+                boolList newFlipMode(flipMode[zonei].size());
                 forAll(newFlipMode, i)
                 {
-                    newFlipMode[i] = flipMode[zoneI][newToOld[i]];
+                    newFlipMode[i] = flipMode[zonei][newToOld[i]];
                 }
-                flipMode[zoneI].transfer(newFlipMode);
+                flipMode[zonei].transfer(newFlipMode);
             }
         }
 
         // So now we both have old zones and the new addressing.
         // Invert the addressing to get faceZoneFaceMap.
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            const faceZone& oldZone = faceZones[zoneI];
-            const labelList& newZoneAddr = addressing[zoneI];
+            const faceZone& oldZone = faceZones[zonei];
+            const labelList& newZoneAddr = addressing[zonei];
 
-            labelList& curFzFaceRnb = faceZoneFaceMap[zoneI];
+            labelList& curFzFaceRnb = faceZoneFaceMap[zonei];
 
             curFzFaceRnb.setSize(newZoneAddr.size());
 
@@ -1769,20 +1744,20 @@ void Foam::polyTopoChange::resetZones
 
         // Reset the addresing on the zone
         newMesh.faceZones().clearAddressing();
-        forAll(newMesh.faceZones(), zoneI)
+        forAll(newMesh.faceZones(), zonei)
         {
             if (debug)
             {
-                Pout<< "faceZone:" << zoneI
-                    << "  name:" << newMesh.faceZones()[zoneI].name()
-                    << "  size:" << addressing[zoneI].size()
+                Pout<< "faceZone:" << zonei
+                    << "  name:" << newMesh.faceZones()[zonei].name()
+                    << "  size:" << addressing[zonei].size()
                     << endl;
             }
 
-            newMesh.faceZones()[zoneI].resetAddressing
+            newMesh.faceZones()[zonei].resetAddressing
             (
-                addressing[zoneI],
-                flipMode[zoneI]
+                addressing[zonei],
+                flipMode[zonei]
             );
         }
     }
@@ -1799,51 +1774,51 @@ void Foam::polyTopoChange::resetZones
 
         forAll(cellZone_, celli)
         {
-            label zoneI = cellZone_[celli];
+            const label zonei = cellZone_[celli];
 
-            if (zoneI >= cellZones.size())
+            if (zonei >= cellZones.size())
             {
                 FatalErrorInFunction
-                    << "Illegal zoneID " << zoneI << " for cell "
+                    << "Illegal zoneID " << zonei << " for cell "
                     << celli << abort(FatalError);
             }
 
-            if (zoneI >= 0)
+            if (zonei >= 0)
             {
-                nCells[zoneI]++;
+                nCells[zonei]++;
             }
         }
 
         labelListList addressing(cellZones.size());
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            addressing[zoneI].setSize(nCells[zoneI]);
+            addressing[zonei].setSize(nCells[zonei]);
         }
         nCells = 0;
 
         forAll(cellZone_, celli)
         {
-            label zoneI = cellZone_[celli];
+            const label zonei = cellZone_[celli];
 
-            if (zoneI >= 0)
+            if (zonei >= 0)
             {
-                addressing[zoneI][nCells[zoneI]++] = celli;
+                addressing[zonei][nCells[zonei]++] = celli;
             }
         }
         // Sort the addressing
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            stableSort(addressing[zoneI]);
+            stableSort(addressing[zonei]);
         }
 
         // So now we both have old zones and the new addressing.
         // Invert the addressing to get cellZoneMap.
-        forAll(addressing, zoneI)
+        forAll(addressing, zonei)
         {
-            const cellZone& oldZone = cellZones[zoneI];
-            const labelList& newZoneAddr = addressing[zoneI];
+            const cellZone& oldZone = cellZones[zonei];
+            const labelList& newZoneAddr = addressing[zonei];
 
-            labelList& curCellRnb = cellZoneMap[zoneI];
+            labelList& curCellRnb = cellZoneMap[zonei];
 
             curCellRnb.setSize(newZoneAddr.size());
 
@@ -1863,17 +1838,17 @@ void Foam::polyTopoChange::resetZones
 
         // Reset the addresing on the zone
         newMesh.cellZones().clearAddressing();
-        forAll(newMesh.cellZones(), zoneI)
+        forAll(newMesh.cellZones(), zonei)
         {
             if (debug)
             {
-                Pout<< "cellZone:" << zoneI
-                    << "  name:" << newMesh.cellZones()[zoneI].name()
-                    << "  size:" << addressing[zoneI].size()
+                Pout<< "cellZone:" << zonei
+                    << "  name:" << newMesh.cellZones()[zonei].name()
+                    << "  size:" << addressing[zonei].size()
                     << endl;
             }
 
-            newMesh.cellZones()[zoneI] = addressing[zoneI];
+            newMesh.cellZones()[zonei] = addressing[zonei];
         }
     }
 }
@@ -1882,7 +1857,7 @@ void Foam::polyTopoChange::resetZones
 void Foam::polyTopoChange::calcFaceZonePointMap
 (
     const polyMesh& mesh,
-    const List<Map<label>>& oldFaceZoneMeshPointMaps,
+    const UList<Map<label>>& oldFaceZoneMeshPointMaps,
     labelListList& faceZonePointMap
 ) const
 {
@@ -1890,15 +1865,15 @@ void Foam::polyTopoChange::calcFaceZonePointMap
 
     faceZonePointMap.setSize(faceZones.size());
 
-    forAll(faceZones, zoneI)
+    forAll(faceZones, zonei)
     {
-        const faceZone& newZone = faceZones[zoneI];
+        const faceZone& newZone = faceZones[zonei];
 
         const labelList& newZoneMeshPoints = newZone().meshPoints();
 
-        const Map<label>& oldZoneMeshPointMap = oldFaceZoneMeshPointMaps[zoneI];
+        const Map<label>& oldZoneMeshPointMap = oldFaceZoneMeshPointMaps[zonei];
 
-        labelList& curFzPointRnb = faceZonePointMap[zoneI];
+        labelList& curFzPointRnb = faceZonePointMap[zonei];
 
         curFzPointRnb.setSize(newZoneMeshPoints.size());
 
@@ -1906,20 +1881,12 @@ void Foam::polyTopoChange::calcFaceZonePointMap
         {
             if (newZoneMeshPoints[pointi] < pointMap_.size())
             {
-                Map<label>::const_iterator ozmpmIter =
-                    oldZoneMeshPointMap.find
+                curFzPointRnb[pointi] =
+                    oldZoneMeshPointMap.lookup
                     (
-                        pointMap_[newZoneMeshPoints[pointi]]
+                        pointMap_[newZoneMeshPoints[pointi]],
+                        -1
                     );
-
-                if (ozmpmIter != oldZoneMeshPointMap.end())
-                {
-                    curFzPointRnb[pointi] = ozmpmIter();
-                }
-                else
-                {
-                    curFzPointRnb[pointi] = -1;
-                }
             }
             else
             {
@@ -1934,8 +1901,8 @@ void Foam::polyTopoChange::reorderCoupledFaces
 (
     const bool syncParallel,
     const polyBoundaryMesh& boundary,
-    const labelList& patchStarts,
-    const labelList& patchSizes,
+    const labelUList& patchStarts,
+    const labelUList& patchSizes,
     const pointField& points
 )
 {
@@ -1986,7 +1953,7 @@ void Foam::polyTopoChange::reorderCoupledFaces
             labelList patchFaceMap(patchSizes[patchi], -1);
             labelList patchFaceRotation(patchSizes[patchi], 0);
 
-            bool changed = boundary[patchi].order
+            const bool changed = boundary[patchi].order
             (
                 pBufs,
                 primitivePatch
@@ -2006,7 +1973,7 @@ void Foam::polyTopoChange::reorderCoupledFaces
             if (changed)
             {
                 // Merge patch face reordering into mesh face reordering table
-                label start = patchStarts[patchi];
+                const label start = patchStarts[patchi];
 
                 forAll(patchFaceMap, patchFacei)
                 {
@@ -2169,11 +2136,11 @@ void Foam::polyTopoChange::compactAndReorder
     // later on to calculate the faceZone pointMaps.
     oldFaceZoneMeshPointMaps.setSize(mesh.faceZones().size());
 
-    forAll(mesh.faceZones(), zoneI)
+    forAll(mesh.faceZones(), zonei)
     {
-        const faceZone& oldZone = mesh.faceZones()[zoneI];
+        const faceZone& oldZone = mesh.faceZones()[zonei];
 
-        oldFaceZoneMeshPointMaps[zoneI] = oldZone().meshPointMap();
+        oldFaceZoneMeshPointMaps[zonei] = oldZone().meshPointMap();
     }
 }
 
@@ -2290,16 +2257,16 @@ void Foam::polyTopoChange::clear()
 void Foam::polyTopoChange::addMesh
 (
     const polyMesh& mesh,
-    const labelList& patchMap,
-    const labelList& pointZoneMap,
-    const labelList& faceZoneMap,
-    const labelList& cellZoneMap
+    const labelUList& patchMap,
+    const labelUList& pointZoneMap,
+    const labelUList& faceZoneMap,
+    const labelUList& cellZoneMap
 )
 {
     label maxRegion = nPatches_ - 1;
-    forAll(patchMap, i)
+    for (const label regioni : patchMap)
     {
-        maxRegion = max(maxRegion, patchMap[i]);
+        maxRegion = max(maxRegion, regioni);
     }
     nPatches_ = maxRegion + 1;
 
@@ -2318,13 +2285,13 @@ void Foam::polyTopoChange::addMesh
         // Precalc offset zones
         labelList newZoneID(points.size(), -1);
 
-        forAll(pointZones, zoneI)
+        forAll(pointZones, zonei)
         {
-            const labelList& pointLabels = pointZones[zoneI];
+            const labelList& pointLabels = pointZones[zonei];
 
-            forAll(pointLabels, j)
+            for (const label pointi : pointLabels)
             {
-                newZoneID[pointLabels[j]] = pointZoneMap[zoneI];
+                newZoneID[pointi] = pointZoneMap[zonei];
             }
         }
 
@@ -2362,14 +2329,12 @@ void Foam::polyTopoChange::addMesh
         // Precalc offset zones
         labelList newZoneID(nAllCells, -1);
 
-        forAll(cellZones, zoneI)
+        forAll(cellZones, zonei)
         {
-            const labelList& cellLabels = cellZones[zoneI];
+            const labelList& cellLabels = cellZones[zonei];
 
-            forAll(cellLabels, j)
+            for (const label celli : cellLabels)
             {
-                label celli = cellLabels[j];
-
                 if (newZoneID[celli] != -1)
                 {
                     WarningInFunction
@@ -2377,13 +2342,13 @@ void Foam::polyTopoChange::addMesh
                         << " centre:" << mesh.cellCentres()[celli]
                         << " is in two zones:"
                         << cellZones[newZoneID[celli]].name()
-                        << " and " << cellZones[zoneI].name() << endl
+                        << " and " << cellZones[zonei].name() << endl
                         << "    This is not supported."
                         << " Continuing with first zone only." << endl;
                 }
                 else
                 {
-                    newZoneID[celli] = cellZoneMap[zoneI];
+                    newZoneID[celli] = cellZoneMap[zonei];
                 }
             }
         }
@@ -2424,15 +2389,15 @@ void Foam::polyTopoChange::addMesh
         labelList newZoneID(nAllFaces, -1);
         boolList zoneFlip(nAllFaces, false);
 
-        forAll(faceZones, zoneI)
+        forAll(faceZones, zonei)
         {
-            const labelList& faceLabels = faceZones[zoneI];
-            const boolList& flipMap = faceZones[zoneI].flipMap();
+            const labelList& faceLabels = faceZones[zonei];
+            const boolList& flipMap = faceZones[zonei].flipMap();
 
-            forAll(faceLabels, j)
+            forAll(faceLabels, facei)
             {
-                newZoneID[faceLabels[j]] = faceZoneMap[zoneI];
-                zoneFlip[faceLabels[j]] = flipMap[j];
+                newZoneID[faceLabels[facei]] = faceZoneMap[zonei];
+                zoneFlip[faceLabels[facei]] = flipMap[facei];
             }
         }
 
@@ -2473,7 +2438,7 @@ void Foam::polyTopoChange::addMesh
             }
             forAll(pp, patchFacei)
             {
-                label facei = pp.start() + patchFacei;
+                const label facei = pp.start() + patchFacei;
 
                 addFace
                 (
@@ -2663,7 +2628,7 @@ Foam::label Foam::polyTopoChange::addPoint
     const bool inCell
 )
 {
-    label pointi = points_.size();
+    const label pointi = points_.size();
 
     points_.append(pt);
     pointMap_.append(masterPointID);
@@ -2687,7 +2652,7 @@ void Foam::polyTopoChange::modifyPoint
 (
     const label pointi,
     const point& pt,
-    const label newZoneID,
+    const label zoneID,
     const bool inCell
 )
 {
@@ -2706,22 +2671,13 @@ void Foam::polyTopoChange::modifyPoint
     }
     points_[pointi] = pt;
 
-    Map<label>::iterator pointFnd = pointZone_.find(pointi);
-
-    if (pointFnd != pointZone_.end())
+    if (zoneID >= 0)
     {
-        if (newZoneID >= 0)
-        {
-            pointFnd() = newZoneID;
-        }
-        else
-        {
-            pointZone_.erase(pointFnd);
-        }
+        pointZone_.set(pointi, zoneID);
     }
-    else if (newZoneID >= 0)
+    else
     {
-        pointZone_.insert(pointi, newZoneID);
+        pointZone_.erase(pointi);
     }
 
     if (inCell)
@@ -2889,29 +2845,24 @@ void Foam::polyTopoChange::modifyFace
     region_[facei] = patchID;
 
     flipFaceFlux_[facei] = (flipFaceFlux ? 1 : 0);
+    faceZoneFlip_[facei] = (zoneFlip ? 1 : 0);
 
-    Map<label>::iterator faceFnd = faceZone_.find(facei);
-
-    if (faceFnd != faceZone_.end())
+    if (zoneID >= 0)
     {
-        if (zoneID >= 0)
-        {
-            faceFnd() = zoneID;
-        }
-        else
-        {
-            faceZone_.erase(faceFnd);
-        }
+        faceZone_.set(facei, zoneID);
     }
-    else if (zoneID >= 0)
+    else
     {
-        faceZone_.insert(facei, zoneID);
+        faceZone_.erase(facei);
     }
-    faceZoneFlip_[facei] = (zoneFlip ? 1 : 0);
 }
 
 
-void Foam::polyTopoChange::removeFace(const label facei, const label mergeFacei)
+void Foam::polyTopoChange::removeFace
+(
+    const label facei,
+    const label mergeFacei
+)
 {
     if (facei < 0 || facei >= faces_.size())
     {
@@ -2949,8 +2900,8 @@ void Foam::polyTopoChange::removeFace(const label facei, const label mergeFacei)
     faceFromEdge_.erase(facei);
     faceFromPoint_.erase(facei);
     flipFaceFlux_[facei] = 0;
-    faceZone_.erase(facei);
     faceZoneFlip_[facei] = 0;
+    faceZone_.erase(facei);
 }
 
 
@@ -3001,7 +2952,11 @@ void Foam::polyTopoChange::modifyCell
 }
 
 
-void Foam::polyTopoChange::removeCell(const label celli, const label mergeCelli)
+void Foam::polyTopoChange::removeCell
+(
+    const label celli,
+    const label mergeCelli
+)
 {
     if (celli < 0 || celli >= cellMap_.size())
     {
@@ -3124,7 +3079,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh
 
         forAll(pointMap_, newPointi)
         {
-            label oldPointi = pointMap_[newPointi];
+            const label oldPointi = pointMap_[newPointi];
 
             if (oldPointi >= 0)
             {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H
index e97c6ef7dbf12e3a84ce1455349000b65fc89f18..f9d7640583cf5eae7f8028ac3803ee2c9b30863c 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H
@@ -197,30 +197,57 @@ class polyTopoChange
 
     // Private Member Functions
 
-        //- Reorder contents of container according to map
+        //- Reorder contents of container according to oldToNew map
         template<class T>
-        static void reorder(const labelList& map, DynamicList<T>&);
+        static void reorder
+        (
+            const labelUList& oldToNew,
+            DynamicList<T>& lst
+        );
+
         template<class T>
-        static void reorder(const labelList& map, List<DynamicList<T>>&);
+        static void reorder
+        (
+            const labelUList& oldToNew,
+            List<DynamicList<T>>& lst
+        );
+
         template<class T>
-        static void renumberKey(const labelList& map, Map<T>&);
+        static void renumberKey
+        (
+            const labelUList& oldToNew,
+            Map<T>& map
+        );
+
+        //- Renumber elements of container according to oldToNew map
+        static void renumber
+        (
+            const labelUList& oldToNew,
+            labelHashSet& labels
+        );
 
-        //- Renumber elements of container according to map
-        static void renumber(const labelList&, labelHashSet&);
         //- Special handling of reverse maps which have <-1 in them
-        static void renumberReverseMap(const labelList&, DynamicList<label>&);
+        static void renumberReverseMap
+        (
+            const labelUList& oldToNew,
+            DynamicList<label>& elems
+        );
 
         //- Renumber & compact elements of list according to map
-        static void renumberCompact(const labelList&, labelList&);
+        static void renumberCompact
+        (
+            const labelUList& oldToNew,
+            labelList& elems
+        );
 
         //- Get all set elements as a labelHashSet
-        static labelHashSet getSetIndices(const PackedBoolList&);
+        static labelHashSet getSetIndices(const PackedBoolList& lst);
 
         //- Count number of added and removed quantities from maps.
         static void countMap
         (
-            const labelList& map,
-            const labelList& reverseMap,
+            const labelUList& map,
+            const labelUList& reverseMap,
             label& nAdd,
             label& nInflate,
             label& nMerge,
@@ -228,19 +255,19 @@ class polyTopoChange
         );
 
         //- Print some stats about mesh
-        static void writeMeshStats(const polyMesh& mesh, Ostream&);
+        static void writeMeshStats(const polyMesh& mesh, Ostream& os);
 
         //- Calculate object maps. Requires reverseMap to have destination
         //  to be marked with <-1.
         static void getMergeSets
         (
-            const labelList& reverseCellMap,
-            const labelList& cellMap,
+            const labelUList& reverseCellMap,
+            const labelUList& cellMap,
             List<objectMap>& cellsFromCells
         );
 
         //- Are all face vertices valid
-        bool hasValidPoints(const face&) const;
+        bool hasValidPoints(const face& f) const;
 
         //- Return face points
         pointField facePoints(const face& f) const;
@@ -248,7 +275,7 @@ class polyTopoChange
         //- Check inputs to modFace or addFace
         void checkFace
         (
-            const face&,
+            const face& f,
             const label facei,
             const label own,
             const label nei,
@@ -274,16 +301,16 @@ class polyTopoChange
         //- Cell ordering (bandCompression). Returns number of remaining cells.
         label getCellOrder
         (
-            const CompactListList<label, labelList>&,
-            labelList&
+            const CompactListList<label, labelList>& cellCellAddressing,
+            labelList& oldToNew
         ) const;
 
         //- Do upper-triangular ordering and patch ordering.
         void getFaceOrder
         (
             const label nActiveFaces,
-            const labelList& cellFaces,
-            const labelList& cellFaceOffsets,
+            const labelUList& cellFaces,
+            const labelUList& cellFaceOffsets,
 
             labelList& oldToNew,
             labelList& patchSizes,
@@ -294,7 +321,7 @@ class polyTopoChange
         void reorderCompactFaces
         (
             const label newSize,
-            const labelList& oldToNew
+            const labelUList& oldToNew
         );
 
         //- Remove all unused/removed points/faces/cells and update
@@ -314,50 +341,50 @@ class polyTopoChange
         //- Select either internal or external faces out of faceLabels
         static labelList selectFaces
         (
-            const primitiveMesh&,
-            const labelList& faceLabels,
+            const primitiveMesh& mesh,
+            const labelUList& faceLabels,
             const bool internalFacesOnly
         );
 
         //- Calculate mapping for patchpoints only
         void calcPatchPointMap
         (
-            const List<Map<label>>&,
-            const polyBoundaryMesh&,
-            labelListList&
+            const UList<Map<label>>& oldPatchMeshPointMaps,
+            const polyBoundaryMesh& boundary,
+            labelListList& patchPointMap
         ) const;
 
         void calcFaceInflationMaps
         (
-            const polyMesh&,
-            List<objectMap>&,
-            List<objectMap>&,
-            List<objectMap>&
+            const polyMesh& mesh,
+            List<objectMap>& facesFromPoints,
+            List<objectMap>& facesFromEdges,
+            List<objectMap>& facesFromFaces
         ) const;
 
         void calcCellInflationMaps
         (
-            const polyMesh&,
-            List<objectMap>&,
-            List<objectMap>&,
-            List<objectMap>&,
-            List<objectMap>&
+            const polyMesh& mesh,
+            List<objectMap>& cellsFromPoints,
+            List<objectMap>& cellsFromEdges,
+            List<objectMap>& cellsFromFaces,
+            List<objectMap>& cellsFromCells
         ) const;
 
         void resetZones
         (
-            const polyMesh&,        // mesh to get existing info from
-            polyMesh&,              // mesh to change zones on
-            labelListList&,
-            labelListList&,
-            labelListList&
+            const polyMesh& mesh,   // mesh to get existing info from
+            polyMesh& newMesh,      // mesh to change zones on
+            labelListList& pointZoneMap,
+            labelListList& faceZoneFaceMap,
+            labelListList& cellZoneMap
         ) const;
 
         void calcFaceZonePointMap
         (
-            const polyMesh&,
-            const List<Map<label>>&,
-            labelListList&
+            const polyMesh& mesh,
+            const UList<Map<label>>& oldFaceZoneMeshPointMaps,
+            labelListList& faceZonePointMap
         ) const;
 
 
@@ -367,15 +394,15 @@ class polyTopoChange
             void reorderCoupledFaces
             (
                 const bool syncParallel,
-                const polyBoundaryMesh&,
-                const labelList& patchStarts,
-                const labelList& patchSizes,
+                const polyBoundaryMesh& boundary,
+                const labelUList& patchStarts,
+                const labelUList& patchSizes,
                 const pointField& points
             );
 
         void compactAndReorder
         (
-            const polyMesh&,
+            const polyMesh& mesh,
             const bool syncParallel,
             const bool orderCells,
             const bool orderPoints,
@@ -445,12 +472,15 @@ public:
             }
 
             //- Is point removed?
+            //  Considered removed if point is GREAT.
             inline bool pointRemoved(const label pointi) const;
 
             //- Is face removed?
+            //  Considered removed if face is empty
             inline bool faceRemoved(const label facei) const;
 
             //- Is cell removed?
+            //  Considered removed if the cellMap is -2
             inline bool cellRemoved(const label celli) const;
 
 
@@ -463,11 +493,11 @@ public:
             //  or zone ids.
             void addMesh
             (
-                const polyMesh&,
-                const labelList& patchMap,
-                const labelList& pointZoneMap,
-                const labelList& faceZoneMap,
-                const labelList& cellZoneMap
+                const polyMesh& mesh,
+                const labelUList& patchMap,
+                const labelUList& pointZoneMap,
+                const labelUList& faceZoneMap,
+                const labelUList& cellZoneMap
             );
 
             //- Explicitly pre-size the dynamic storage for expected mesh
@@ -491,7 +521,7 @@ public:
             //  - inCell = false: add retired point (to end of point list)
             label addPoint
             (
-                const point&,
+                const point& pt,
                 const label masterPointID,
                 const label zoneID,
                 const bool inCell
@@ -499,17 +529,18 @@ public:
 
             //- Modify coordinate.
             //  Notes:
+            //  - zoneID = +ve (add to zoneID), -ve (remove from zones)
             //  - inCell = false: add retired point (to end of point list)
             void modifyPoint
             (
-                const label,
-                const point&,
-                const label newZoneID,
+                const label pointi,
+                const point& pt,
+                const label zoneID,
                 const bool inCell
             );
 
             //- Remove/merge point.
-            void removePoint(const label, const label);
+            void removePoint(const label pointi, const label mergePointi);
 
             //- Add face to cells. Return new face label.
             //  own,nei<0, zoneID>=0 : add inactive face (to end of face list)
@@ -541,7 +572,7 @@ public:
             );
 
             //- Remove/merge face.
-            void removeFace(const label, const label);
+            void removeFace(const label facei, const label mergeFacei);
 
             //- Add cell. Return new cell label.
             label addCell
@@ -554,10 +585,10 @@ public:
             );
 
             //- Modify zone of cell
-            void modifyCell(const label, const label zoneID);
+            void modifyCell(const label celli, const label zoneID);
 
             //- Remove/merge cell.
-            void removeCell(const label, const label);
+            void removeCell(const label celli, const label mergeCelli);
 
             //- Explicitly set the number of patches if construct-without-mesh
             //  used.
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C
index ddca640d04e4a3c0faefb1bcf51e1da077c811bf..731d0beb018d3d2b1212aabe54e1cd3d25e633d7 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeTemplates.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -30,20 +30,20 @@ License
 template<class T>
 void Foam::polyTopoChange::reorder
 (
-    const labelList& oldToNew,
+    const labelUList& oldToNew,
     DynamicList<T>& lst
 )
 {
     // Create copy
     DynamicList<T> oldLst(lst);
 
-    forAll(oldToNew, elemI)
+    forAll(oldToNew, i)
     {
-        label newElemI = oldToNew[elemI];
+        const label newIdx = oldToNew[i];
 
-        if (newElemI != -1)
+        if (newIdx >= 0)
         {
-            lst[newElemI] = oldLst[elemI];
+            lst[newIdx] = oldLst[i];
         }
     }
 }
@@ -52,20 +52,20 @@ void Foam::polyTopoChange::reorder
 template<class T>
 void Foam::polyTopoChange::reorder
 (
-    const labelList& oldToNew,
+    const labelUList& oldToNew,
     List<DynamicList<T>>& lst
 )
 {
     // Create copy
     List<DynamicList<T>> oldLst(lst);
 
-    forAll(oldToNew, elemI)
+    forAll(oldToNew, i)
     {
-        label newElemI = oldToNew[elemI];
+        const label newIdx = oldToNew[i];
 
-        if (newElemI != -1)
+        if (newIdx >= 0)
         {
-            lst[newElemI].transfer(oldLst[elemI]);
+            lst[newIdx].transfer(oldLst[i]);
         }
     }
 }
@@ -74,23 +74,23 @@ void Foam::polyTopoChange::reorder
 template<class T>
 void Foam::polyTopoChange::renumberKey
 (
-    const labelList& oldToNew,
-    Map<T>& elems
+    const labelUList& oldToNew,
+    Map<T>& map
 )
 {
-    Map<T> newElems(elems.size());
+    Map<T> newMap(map.capacity());
 
-    forAllConstIter(typename Map<T>, elems, iter)
+    forAllConstIters(map, iter)
     {
-        label newElem = oldToNew[iter.key()];
+        const label newKey = oldToNew[iter.key()];
 
-        if (newElem >= 0)
+        if (newKey >= 0)
         {
-            newElems.insert(newElem, iter());
+            newMap.insert(newKey, iter.object());
         }
     }
 
-    elems.transfer(newElems);
+    map.transfer(newMap);
 }
 
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C
index 212620862eb347deedd71e5d9288c2ab5a6b8fca..720c109d90c1a193e5b3661c55e39ac0bee06898 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C
@@ -283,12 +283,12 @@ void Foam::removeFaces::mergeFaces
 
         const face& f = fp.localFaces()[facei];
 
-        label index1 = findIndex(f, edgeLoop[1]);
+        label index1 = f.find(edgeLoop[1]);
 
         if (index1 != -1)
         {
             // Check whether consecutive to edgeLoop[0]
-            label index0 = findIndex(f, edgeLoop[0]);
+            label index0 = f.find(edgeLoop[0]);
 
             if (index0 != -1)
             {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C
index 9ea5e44203cc713a08a6ae391e5095516101d325..88d9a05a40c1bd2a5c2ff8ed6ee36d4f0a44823d 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C
@@ -596,7 +596,7 @@ void Foam::tetDecomposer::setRefinement
                     // we are looping in the same order the tets added for
                     // otherFacei will be before those of facei
 
-                    label otherFp = findIndex(otherF, p0);
+                    label otherFp = otherF.find(p0);
                     if (otherF.nextLabel(otherFp) == p1)
                     {
                         // ok. otherFp is first vertex of edge.
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
index 8023a5d98b2831e90471f498bcbdce7689b7a868..ee40ecc48a9ce4fb465b610a9f48d98be435bb18 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -36,7 +36,7 @@ namespace Foam
 }
 
 
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void Foam::polyTopoChanger::readModifiers()
 {
@@ -73,7 +73,6 @@ void Foam::polyTopoChanger::readModifiers()
             );
         }
 
-        // Check state of IOstream
         is.check(FUNCTION_NAME);
 
         close();
@@ -81,6 +80,8 @@ void Foam::polyTopoChanger::readModifiers()
 }
 
 
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
 Foam::polyTopoChanger::polyTopoChanger
 (
     const IOobject& io,
@@ -95,10 +96,14 @@ Foam::polyTopoChanger::polyTopoChanger
 }
 
 
-Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
+Foam::polyTopoChanger::polyTopoChanger
+(
+    polyMesh& mesh,
+    const IOobject::readOption rOpt
+
+)
 :
-    PtrList<polyMeshModifier>(),
-    regIOobject
+    polyTopoChanger
     (
         IOobject
         (
@@ -107,32 +112,36 @@ Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
             (
                 mesh.meshDir(),
                 "meshModifiers",
-                IOobject::READ_IF_PRESENT
+                rOpt
             ),
             mesh.meshSubDir,
             mesh,
-            IOobject::READ_IF_PRESENT,
+            rOpt,
             IOobject::NO_WRITE
-        )
-    ),
-    mesh_(mesh)
-{
-    readModifiers();
-}
+        ),
+        mesh
+    )
+{}
+
+
+Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
+:
+    polyTopoChanger(mesh, IOobject::readOption::READ_IF_PRESENT)
+{}
 
 
 Foam::wordList Foam::polyTopoChanger::types() const
 {
     const PtrList<polyMeshModifier>& modifiers = *this;
 
-    wordList t(modifiers.size());
+    wordList lst(modifiers.size());
 
-    forAll(modifiers, modifierI)
+    forAll(modifiers, i)
     {
-        t[modifierI] = modifiers[modifierI].type();
+        lst[i] = modifiers[i].type();
     }
 
-    return t;
+    return lst;
 }
 
 
@@ -140,14 +149,14 @@ Foam::wordList Foam::polyTopoChanger::names() const
 {
     const PtrList<polyMeshModifier>& modifiers = *this;
 
-    wordList t(modifiers.size());
+    wordList lst(modifiers.size());
 
-    forAll(modifiers, modifierI)
+    forAll(modifiers, i)
     {
-        t[modifierI] = modifiers[modifierI].name();
+        lst[i] = modifiers[i].name();
     }
 
-    return t;
+    return lst;
 }
 
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H
index b9f4cbff2e527b26fd8e750c8a2a36361a61f197..94ff7bea97c6e4b27c1780920e646207827b8470 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -69,13 +69,13 @@ class polyTopoChanger
 {
     // Private Member Functions
 
+        void readModifiers();
+
         //- Disallow default bitwise copy construct
-        polyTopoChanger(const polyTopoChanger&);
+        polyTopoChanger(const polyTopoChanger&) = delete;
 
         //- Disallow default bitwise assignment
-        void operator=(const polyTopoChanger&);
-
-        void readModifiers();
+        void operator=(const polyTopoChanger&) = delete;
 
 
 protected:
@@ -93,11 +93,15 @@ public:
 
     // Constructors
 
-        //- Read constructor given IOobject and a polyMesh
-        polyTopoChanger(const IOobject&, polyMesh&);
+        //- Read construct given IOobject and a polyMesh
+        polyTopoChanger(const IOobject& io, polyMesh& mesh);
+
+        //- Read construct for given polyMesh and read-option
+        polyTopoChanger(polyMesh& mesh, const IOobject::readOption rOpt);
 
-        //- Read constructor for given polyMesh
-        explicit polyTopoChanger(polyMesh&);
+        //- Read construct for given polyMesh.
+        //  Uses read-option READ_IF_PRESENT
+        explicit polyTopoChanger(polyMesh& mesh);
 
 
     //- Destructor
diff --git a/src/dynamicMesh/setUpdater/setUpdater.C b/src/dynamicMesh/setUpdater/setUpdater.C
index c121af2a8465a4fde13d68b90cdafca20651e9bc..f7c4f8edc16633880ee894e3c7315b5a7207cde0 100644
--- a/src/dynamicMesh/setUpdater/setUpdater.C
+++ b/src/dynamicMesh/setUpdater/setUpdater.C
@@ -45,14 +45,8 @@ namespace Foam
     );
 }
 
-
-// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
-
-
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-// Construct from dictionary
 Foam::setUpdater::setUpdater
 (
     const word& name,
@@ -111,22 +105,13 @@ void Foam::setUpdater::write(Ostream& os) const
 
 void Foam::setUpdater::writeDict(Ostream& os) const
 {
-    os  << nl << name() << nl << token::BEGIN_BLOCK << nl
-        << "    type " << type()
-        << token::END_STATEMENT << nl
-        << "    active " << active()
-        << token::END_STATEMENT << nl
-        << token::END_BLOCK << endl;
-}
-
+    os  << nl;
 
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+    os.beginBlock(name());
+    os.writeEntry("type", type());
+    os.writeEntry("active", active());
+    os.endBlock();
+}
 
 
 // ************************************************************************* //
diff --git a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C
index 1d5794a5074e6036dfa946f867377d43a42344d5..edcdbb64a025f4f7c5f7ab14025d1b622acf72ac 100644
--- a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C
+++ b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -44,6 +44,7 @@ License
 
 const Foam::scalar Foam::slidingInterface::edgeCoPlanarTolDefault_ = 0.8;
 
+
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 // Index of debug signs:
@@ -69,16 +70,13 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 {
     if (debug)
     {
-        Pout<< "void slidingInterface::coupleInterface"
-            << "(polyTopoChange& ref) : "
-            << "Coupling sliding interface " << name() << endl;
+        Pout<< FUNCTION_NAME << nl
+            << ": Coupling sliding interface " << name() << endl;
     }
 
     const polyMesh& mesh = topoChanger().mesh();
-
     const pointField& points = mesh.points();
     const faceList& faces = mesh.faces();
-
     const labelList& own = mesh.faceOwner();
     const labelList& nei = mesh.faceNeighbour();
     const faceZoneMesh& faceZones = mesh.faceZones();
@@ -156,20 +154,19 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
     // Create mapping for every merged point of the slave patch
     forAll(slavePointPointHits, pointi)
     {
-        if (slavePointPointHits[pointi] >= 0)
-        {
-            // Pout<< "Inserting point merge pair: " << slaveMeshPoints[pointi]
-            //     << " : " << masterMeshPoints[slavePointPointHits[pointi]]
-            //     << endl;
+        const label slaveHitPti = slavePointPointHits[pointi];
 
+        if (slaveHitPti >= 0)
+        {
             pointMergeMap.insert
             (
                 slaveMeshPoints[pointi],
-                masterMeshPoints[slavePointPointHits[pointi]]
+                masterMeshPoints[slaveHitPti]
             );
         }
     }
 
+
     // Collect the list of used edges for every slave edge
 
     List<labelHashSet> usedMasterEdges(slaveEdges.size());
@@ -187,22 +184,20 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
             // Mark all current master edges as used for all the current slave
             // edges
-            forAll(curSlaveEdges, slaveEdgeI)
+            for (const label slaveEdgei : curSlaveEdges)
             {
-                labelHashSet& sm = usedMasterEdges[curSlaveEdges[slaveEdgeI]];
-
-                forAll(curMasterEdges, masterEdgeI)
-                {
-                    sm.insert(curMasterEdges[masterEdgeI]);
-                }
+                usedMasterEdges[slaveEdgei].insert
+                (
+                    curMasterEdges
+                );
             }
         }
         else if (slavePointEdgeHits[pointi] > -1)
         {
             // For edge hits, add the master edge
-            forAll(curSlaveEdges, slaveEdgeI)
+            for (const label slaveEdgei : curSlaveEdges)
             {
-                usedMasterEdges[curSlaveEdges[slaveEdgeI]].insert
+                usedMasterEdges[slaveEdgei].insert
                 (
                     slavePointEdgeHits[pointi]
                 );
@@ -219,21 +214,18 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
         {
             const labelList& curMasterEdges = masterPointEdges[masterPointi];
 
-            labelHashSet& sm =
-                usedMasterEdges[masterPointEdgeHits[masterPointi]];
-
-            forAll(curMasterEdges, masterEdgeI)
-            {
-                sm.insert(curMasterEdges[masterEdgeI]);
-            }
+            usedMasterEdges[masterPointEdgeHits[masterPointi]].insert
+            (
+                curMasterEdges
+            );
         }
     }
 
     // Pout<< "used edges: " << endl;
-    // forAll(usedMasterEdges, edgeI)
+    // forAll(usedMasterEdges, edgei)
     // {
-    //     Pout<< "edge: " << edgeI
-    //         << " used: " << usedMasterEdges[edgeI].toc()
+    //     Pout<< "edge: " << edgei
+    //         << " used: " << usedMasterEdges[edgei].toc()
     //         << endl;
     // }
 
@@ -249,13 +241,13 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
         {
             // Create a new point on the master edge
 
-            point edgeCutPoint =
+            const point edgeCutPoint =
                 masterEdges[slavePointEdgeHits[pointi]].line
                 (
                     masterLocalPoints
                 ).nearestDist(projectedSlavePoints[pointi]).hitPoint();
 
-            label newPoint =
+            const label newPointi =
                 ref.setAction
                 (
                     polyAddPoint
@@ -267,32 +259,37 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                     )
                 );
 
-            // Pout<< "Inserting merge pair off edge: "
-            //     << slaveMeshPoints[pointi] << " " << newPoint
-            //     << " cut point: " << edgeCutPoint
-            //     << " orig: " << slaveLocalPoints[pointi]
-            //     << " proj: " << projectedSlavePoints[pointi]
-            //     << endl;
-
             // Add the new edge point into the merge map
-            pointMergeMap.insert(slaveMeshPoints[pointi], newPoint);
+            pointMergeMap.insert
+            (
+                slaveMeshPoints[pointi],
+                newPointi
+            );
 
             pointsIntoMasterEdges[slavePointEdgeHits[pointi]].append
             (
-                newPoint
+                newPointi
             );
 
             // Add the point into the enriched patch map
             pointMap.insert
             (
-                newPoint,
+                newPointi,
                 edgeCutPoint
             );
 
             if (debug)
             {
                 Pout<< "e";
-                // Pout<< newPoint << " = " << edgeCutPoint << endl;
+
+                // Pout<< "Inserting merge pair off edge: "
+                //     << slaveMeshPoints[pointi] << " " << newPointi
+                //     << " cut point: " << edgeCutPoint
+                //     << " orig: " << slaveLocalPoints[pointi]
+                //     << " proj: " << projectedSlavePoints[pointi]
+                //     << endl;
+
+                // Pout<< newPointi << " = " << edgeCutPoint << endl;
             }
         }
     }
@@ -312,7 +309,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
          && slavePointFaceHits[pointi].hit()
         )
         {
-            label newPoint =
+            const label newPointi =
                 ref.setAction
                 (
                     polyAddPoint
@@ -326,22 +323,26 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
             // Pout<< "Inserting merge pair off face: "
             //     << slaveMeshPoints[pointi]
-            //     << " " << newPoint
+            //     << " " << newPointi
             //     << endl;
 
             // Add the new edge point into the merge map
-            pointMergeMap.insert(slaveMeshPoints[pointi], newPoint);
+            pointMergeMap.insert
+            (
+                slaveMeshPoints[pointi],
+                newPointi
+            );
 
             // Add the point into the enriched patch map
             pointMap.insert
             (
-                newPoint,
+                newPointi,
                 projectedSlavePoints[pointi]
             );
 
             if (debug)
             {
-                Pout<< "f: " << newPoint << " = "
+                Pout<< "f: " << newPointi << " = "
                     << projectedSlavePoints[pointi] << endl;
             }
         }
@@ -390,7 +391,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
     //
     if (debug)
     {
-        Pout<< "Processing slave edges " << endl;
+        Pout<< "Processing slave edges" << endl;
     }
 
     if (!cutPointEdgePairMapPtr_)
@@ -430,65 +431,72 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
             //     << " curUme: " << curUme
             //     << endl;
 
-            // Clear the maps
-            curFaceMap.clear();
-            addedFaces.clear();
-
             // Grab the faces for start and end points.
             const label startFace =
                 slavePointFaceHits[curEdge.start()].hitObject();
-            const label endFace = slavePointFaceHits[curEdge.end()].hitObject();
+
+            const label endFace =
+                slavePointFaceHits[curEdge.end()].hitObject();
 
             // Pout<< "startFace: " << slavePointFaceHits[curEdge.start()]
             //     << " endFace: " << slavePointFaceHits[curEdge.end()]
             //     << endl;
 
-            // Insert the start face into the list
-            curFaceMap.insert(startFace);
-            addedFaces.insert(startFace);
-
-            // Pout<< "curFaceMap: " << curFaceMap.toc() << endl;
-
-            label nSweeps = 0;
             bool completed = false;
 
-            while (nSweeps < edgeFaceEscapeLimit_)
+            if (!completed)
             {
-                nSweeps++;
+                // Forward sweep
 
-                if (addedFaces.found(endFace))
-                {
-                    completed = true;
-                }
-
-                // Add all face neighbours of face in the map
-                const labelList cf = addedFaces.toc();
+                // Clear the maps
+                curFaceMap.clear();
                 addedFaces.clear();
 
-                forAll(cf, cfI)
+                // Insert the start face into the list
+                curFaceMap.insert(startFace);
+                addedFaces.insert(startFace);
+
+                // Pout<< "curFaceMap: " << curFaceMap.toc() << endl;
+
+                for
+                (
+                    label nSweeps = 0;
+                    nSweeps < edgeFaceEscapeLimit_;
+                    ++nSweeps
+                )
                 {
-                    const labelList& curNbrs = masterFaceFaces[cf[cfI]];
+                    completed = addedFaces.found(endFace);
 
-                    forAll(curNbrs, nbrI)
+                    // Add all face neighbours of face in the map
+                    const labelList cf(addedFaces.toc());
+                    addedFaces.clear();
+
+                    for (const label cfi : cf)
                     {
-                        if (!curFaceMap.found(curNbrs[nbrI]))
+                        const labelList& curNbrs = masterFaceFaces[cfi];
+
+                        for (const label nbri : curNbrs)
                         {
-                            curFaceMap.insert(curNbrs[nbrI]);
-                            addedFaces.insert(curNbrs[nbrI]);
+                            if (curFaceMap.insert(nbri))
+                            {
+                                addedFaces.insert(nbri);
+                            }
                         }
                     }
-                }
 
-                if (completed) break;
+                    if (completed) break;
 
-                if (debug)
-                {
-                    Pout<< ".";
+                    if (debug)
+                    {
+                        Pout<< ".";
+                    }
                 }
             }
 
             if (!completed)
             {
+                // Reverse sweep
+
                 if (debug)
                 {
                     Pout<< "x";
@@ -497,34 +505,31 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                 // It is impossible to reach the end from the start, probably
                 // due to disconnected domain.  Do search in opposite direction
 
-                label nReverseSweeps = 0;
-
                 addedFaces.clear();
                 addedFaces.insert(endFace);
 
-                while (nReverseSweeps < edgeFaceEscapeLimit_)
+                for
+                (
+                    label nSweeps = 0;
+                    nSweeps < edgeFaceEscapeLimit_;
+                    ++nSweeps
+                )
                 {
-                    nReverseSweeps++;
-
-                    if (addedFaces.found(startFace))
-                    {
-                        completed = true;
-                    }
+                    completed = addedFaces.found(startFace);
 
                     // Add all face neighbours of face in the map
-                    const labelList cf = addedFaces.toc();
+                    const labelList cf(addedFaces.toc());
                     addedFaces.clear();
 
-                    forAll(cf, cfI)
+                    for (const label cfi : cf)
                     {
-                        const labelList& curNbrs = masterFaceFaces[cf[cfI]];
+                        const labelList& curNbrs = masterFaceFaces[cfi];
 
-                        forAll(curNbrs, nbrI)
+                        for (const label nbri : curNbrs)
                         {
-                            if (!curFaceMap.found(curNbrs[nbrI]))
+                            if (curFaceMap.insert(nbri))
                             {
-                                curFaceMap.insert(curNbrs[nbrI]);
-                                addedFaces.insert(curNbrs[nbrI]);
+                                addedFaces.insert(nbri);
                             }
                         }
                     }
@@ -561,27 +566,22 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                 nFacesPerSlaveEdge_*primitiveMesh::edgesPerFace_
             );
 
-            const labelList curFaces = curFaceMap.toc();
-
-            // Pout<< "curFaces: " << curFaces << endl;
-
-            forAll(curFaces, facei)
+            for (const label facei : curFaceMap)
             {
-                // Pout<< "face: " << curFaces[facei] << " "
-                //     << masterPatch[curFaces[facei]]
+                // Pout<< "face: " << facei << " "
+                //     << masterPatch[facei]
                 //     << " local: "
-                //     << masterPatch.localFaces()[curFaces[facei]]
+                //     << masterPatch.localFaces()[facei]
                 //     << endl;
 
-                const labelList& me = masterFaceEdges[curFaces[facei]];
-
-                forAll(me, meI)
-                {
-                    curMasterEdgesMap.insert(me[meI]);
-                }
+                curMasterEdgesMap.insert
+                (
+                    masterFaceEdges[facei]
+                );
             }
 
-            const labelList curMasterEdges = curMasterEdgesMap.toc();
+            const labelList curMasterEdges(curMasterEdgesMap.toc());
+            curMasterEdgesMap.clear();
 
             // For all master edges to intersect, skip the ones
             // already used and cut the rest with a cutting plane.  If
@@ -597,7 +597,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
             const point& a = projectedSlavePoints[curEdge.start()];
             const point& b = projectedSlavePoints[curEdge.end()];
 
-            point c =
+            const point c =
                 0.5*
                 (
                     slaveLocalPoints[curEdge.start()]
@@ -607,7 +607,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                 );
 
             // Create the plane
-            plane cutPlane(a, b, c);
+            const plane cutPlane(a, b, c);
 
             // Pout<< "a: " << a
             //     << " b: " << b
@@ -615,14 +615,16 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
             //     << " plane: " << cutPlane
             //     << endl;
 
-            linePointRef curSlaveLine = curEdge.line(projectedSlavePoints);
+            const linePointRef curSlaveLine =
+                curEdge.line(projectedSlavePoints);
+
             const scalar curSlaveLineMag = curSlaveLine.mag();
 
             // Pout<< "curSlaveLine: " << curSlaveLine << endl;
 
-            forAll(curMasterEdges, masterEdgeI)
+            for (const label cmeIndex : curMasterEdges)
             {
-                if (!curUme.found(curMasterEdges[masterEdgeI]))
+                if (!curUme.found(cmeIndex))
                 {
                     // New edge
                     if (debug)
@@ -630,7 +632,6 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                         Pout<< "n";
                     }
 
-                    const label cmeIndex = curMasterEdges[masterEdgeI];
                     const edge& cme = masterEdges[cmeIndex];
 
                     // Pout<< "Edge " << cmeIndex
@@ -638,7 +639,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                     //     << " line: " << cme.line(masterLocalPoints)
                     //     << endl;
 
-                    scalar cutOnMaster =
+                    const scalar cutOnMaster =
                         cutPlane.lineIntersect
                         (
                             cme.line(masterLocalPoints)
@@ -651,18 +652,18 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                     )
                     {
                         // Master is cut, check the slave
-                        point masterCutPoint =
+                        const point masterCutPoint =
                             masterLocalPoints[cme.start()]
                           + cutOnMaster*cme.vec(masterLocalPoints);
 
-                        pointHit slaveCut =
+                        const pointHit slaveCut =
                             curSlaveLine.nearestDist(masterCutPoint);
 
                         if (slaveCut.hit())
                         {
                             // Strict checking of slave cut to avoid capturing
                             // end points.
-                            scalar cutOnSlave =
+                            const scalar cutOnSlave =
                                 (
                                     (
                                         slaveCut.hitPoint()
@@ -672,7 +673,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
                             // Calculate merge tolerance from the
                             // target edge length
-                            scalar mergeTol = edgeCoPlanarTol_*mag(b - a);
+                            const scalar mergeTol = edgeCoPlanarTol_*mag(b - a);
 
                             // Pout<< "cutOnMaster: " << cutOnMaster
                             //     << " masterCutPoint: " << masterCutPoint
@@ -697,7 +698,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                 // to edge points The point is nominally
                                 // added from the start of the master edge
                                 // and added to the cut point zone
-                                label newPoint =
+                                const label newPointi =
                                     ref.setAction
                                     (
                                         polyAddPoint
@@ -709,7 +710,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                         )
                                     );
 
-                                // Pout<< "Inserting point: " << newPoint
+                                // Pout<< "Inserting point: " << newPointi
                                 //     << " as edge to edge intersection.  "
                                 //     << "Slave edge: "
                                 //     << edgeI << " " << curEdge
@@ -717,16 +718,19 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                 //     << cmeIndex << " " << cme
                                 //     << endl;
 
-                                pointsIntoSlaveEdges[edgeI].append(newPoint);
+                                pointsIntoSlaveEdges[edgeI].append
+                                (
+                                    newPointi
+                                );
                                 pointsIntoMasterEdges[cmeIndex].append
                                 (
-                                    newPoint
+                                    newPointi
                                 );
 
                                 // Add the point into the enriched patch map
                                 pointMap.insert
                                 (
-                                    newPoint,
+                                    newPointi,
                                     masterCutPoint
                                 );
 
@@ -734,25 +738,25 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                 // create cut point
                                 addToCpepm.insert
                                 (
-                                    newPoint,    // Cut point index
+                                    newPointi,   // Cut point index
                                     Pair<edge>
                                     (
                                         edge
                                         (
                                             masterMeshPoints[cme.start()],
                                             masterMeshPoints[cme.end()]
-                                        ),    // Master edge
+                                        ),  // Master edge
                                         edge
                                         (
                                             slaveMeshPoints[curEdge.start()],
                                             slaveMeshPoints[curEdge.end()]
-                                        )// Slave edge
+                                        )   // Slave edge
                                     )
                                 );
 
                                 if (debug)
                                 {
-                                    Pout<< " " << newPoint << " = "
+                                    Pout<< " " << newPointi << " = "
                                         << masterCutPoint << " ";
                                 }
                             }
@@ -955,12 +959,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
             forAll(rsf, i)
             {
-                Map<label>::const_iterator mpIter = pointMergeMap.find(rsf[i]);
-
-                if (mpIter != pointMergeMap.end())
-                {
-                    rsf[i] = mpIter();
-                }
+                rsf[i] = pointMergeMap.lookup(rsf[i], rsf[i]);
             }
 
             if (curCutFace == rsf)
@@ -1240,10 +1239,10 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
     if (debug)
     {
-        Pout<< "Number of orphaned faces: "
-            << "master = " << nOrphanedMasters << " out of "
+        Pout<< "Orphaned faces: "
+            << "master = " << nOrphanedMasters << "/"
             << orphanedMaster.size()
-            << " slave = " << nOrphanedSlaves << " out of "
+            << " slave = " << nOrphanedSlaves << "/"
             << orphanedSlave.size() << endl;
     }
 
@@ -1268,12 +1267,9 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
     // Pout<< "masterStickOuts: " << masterStickOuts << endl;
 
     // Re-create the master stick-out faces
-    forAll(masterStickOuts, facei)
+    for (const label curFaceID : masterStickOuts)
     {
         // Renumber the face and remove additional points
-
-        const label curFaceID = masterStickOuts[facei];
-
         const face& oldRichFace = faces[curFaceID];
 
         bool changed = false;
@@ -1282,47 +1278,46 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
         face oldFace(oldRichFace.size());
         label nOldFace = 0;
 
-        forAll(oldRichFace, pointi)
+        for (const label pointi : oldRichFace)
         {
-            if (ref.pointRemoved(oldRichFace[pointi]))
+            if (ref.pointRemoved(pointi))
             {
                 changed = true;
             }
             else
             {
                 // Point off patch
-                oldFace[nOldFace] = oldRichFace[pointi];
+                oldFace[nOldFace] = pointi;
                 nOldFace++;
             }
         }
 
         oldFace.setSize(nOldFace);
 
-        // Pout<< "old rich master face: " << oldRichFace
-        //     << " old face: " << oldFace
-        //     << endl;
+        // Pout<< "old rich face[" << curFaceID << "]: " << oldRichFace
+        //     << " old face: " << oldFace << endl;
 
         DynamicList<label> newFaceLabels(2*oldFace.size());
 
         forAll(oldFace, pointi)
         {
-            if (masterMeshPointMap.found(oldFace[pointi]))
+            const label localFirstLabel =
+                masterMeshPointMap.lookup(oldFace[pointi], -1);
+
+            if (localFirstLabel != -1)
             {
                 // Point is in master patch. Add it
 
-                // If the point is a direct hit, grab its label; otherwise
-                // keep the original
-                if (pointMergeMap.found(oldFace[pointi]))
+                // If the point is a direct hit, grab its label;
+                // otherwise keep the original
+                newFaceLabels.append
+                (
+                    pointMergeMap.lookup(oldFace[pointi], oldFace[pointi])
+                );
+
+                if (newFaceLabels.last() != oldFace[pointi])
                 {
                     changed = true;
-                    newFaceLabels.append
-                    (
-                        pointMergeMap.find(oldFace[pointi])()
-                    );
-                }
-                else
-                {
-                    newFaceLabels.append(oldFace[pointi]);
                 }
 
                 // Find if there are additional points inserted onto the edge
@@ -1331,39 +1326,35 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                 // 1) Find all the edges in the master patch coming
                 //    out of the current point.
                 // 2) If the next point in the face to pick the right edge
-                const label localFirstLabel =
-                    masterMeshPointMap.find(oldFace[pointi])();
 
                 const labelList& curEdges = masterPointEdges[localFirstLabel];
 
-                const label  nextLabel = oldFace.nextLabel(pointi);
+                const label nextLabel = oldFace.nextLabel(pointi);
 
-                Map<label>::const_iterator mmpmIter =
-                    masterMeshPointMap.find(nextLabel);
+                const label localNextLabel =
+                    masterMeshPointMap.lookup(nextLabel, -1);
 
-                if (mmpmIter != masterMeshPointMap.end())
+                if (localNextLabel != -1)
                 {
                     // Pout<< "found label pair " << oldFace[pointi]
                     //     << " and " << nextLabel;
                     // Find the points on the edge between them
-                    const label localNextLabel = mmpmIter();
 
-                    forAll(curEdges, curEdgeI)
+                    for (const label curEdgei : curEdges)
                     {
                         if
                         (
-                            masterEdges[curEdges[curEdgeI]].otherVertex
+                            masterEdges[curEdgei].otherVertex
                             (
                                 localFirstLabel
                             )
                          == localNextLabel
                         )
                         {
-                            // Pout<< " found edge: " << curEdges[curEdgeI]
-                            //     << endl;
+                            // Pout<< " found edge: " << curEdgei << endl;
 
                             // Get points on current edge
-                            const labelList& curPime = pime[curEdges[curEdgeI]];
+                            const labelList& curPime = pime[curEdgei];
 
                             if (curPime.size())
                             {
@@ -1374,9 +1365,10 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                 const point& startPoint =
                                     masterLocalPoints[localFirstLabel];
 
-                                vector e =
-                                    masterLocalPoints[localNextLabel]
-                                  - startPoint;
+                                const point& endPoint =
+                                    masterLocalPoints[localNextLabel];
+
+                                vector e = (endPoint - startPoint);
 
                                 e /= magSqr(e);
 
@@ -1385,13 +1377,13 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                 forAll(curPime, curPimeI)
                                 {
                                     edgePointWeights[curPimeI] =
-                                        (
-                                            e
-                                          & (
-                                              pointMap.find(curPime[curPimeI])()
-                                            - startPoint
-                                            )
-                                        );
+                                    (
+                                        e
+                                      & (
+                                           pointMap[curPime[curPimeI]]
+                                         - startPoint
+                                        )
+                                    );
                                 }
 
                                 if (debug)
@@ -1466,25 +1458,24 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
             }
 
             // Get face zone and its flip
-            label modifiedFaceZone = faceZones.whichZone(curFaceID);
-            bool modifiedFaceZoneFlip = false;
+            const label modifiedFaceZone = faceZones.whichZone(curFaceID);
 
-            if (modifiedFaceZone >= 0)
-            {
-                modifiedFaceZoneFlip =
-                    faceZones[modifiedFaceZone].flipMap()
-                    [
-                        faceZones[modifiedFaceZone].whichFace(curFaceID)
-                    ];
-            }
+            const bool modifiedFaceZoneFlip =
+            (
+                modifiedFaceZone >= 0
+              ?
+                faceZones[modifiedFaceZone].flipMap()
+                [
+                    faceZones[modifiedFaceZone].whichFace(curFaceID)
+                ]
+              : false
+            );
 
             face newFace;
             newFace.transfer(newFaceLabels);
 
-            // Pout<< "Modifying master stick-out face " << curFaceID
-            //     << " old face: " << oldFace
-            //     << " new face: " << newFace
-            //     << endl;
+            // Pout<< "Modifying master stick-out face[" << curFaceID
+            //     << "]: old: " << oldFace << " new: " << newFace << endl;
 
             // Modify the face
             if (mesh.isInternalFace(curFaceID))
@@ -1540,11 +1531,9 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
     // Re-create the slave stick-out faces
 
-    forAll(slaveStickOuts, facei)
+    for (const label curFaceID : slaveStickOuts)
     {
         // Renumber the face and remove additional points
-        const label curFaceID = slaveStickOuts[facei];
-
         const face& oldRichFace = faces[curFaceID];
 
         bool changed = false;
@@ -1553,33 +1542,28 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
         face oldFace(oldRichFace.size());
         label nOldFace = 0;
 
-        forAll(oldRichFace, pointi)
+        for (const label pointi : oldRichFace)
         {
             if
             (
-                rpm.found(oldRichFace[pointi])
-             || slaveMeshPointMap.found(oldRichFace[pointi])
+                rpm.found(pointi)
+             || slaveMeshPointMap.found(pointi)
             )
             {
                 // Point definitely live. Add it
-                oldFace[nOldFace] = oldRichFace[pointi];
+                oldFace[nOldFace] = pointi;
                 nOldFace++;
             }
-            else if
-            (
-                ref.pointRemoved(oldRichFace[pointi])
-             || masterMeshPointMap.found(oldRichFace[pointi])
-            )
+            else if (ref.pointRemoved(pointi))
             {
-                // Point removed and not on slave patch
-                // (first if takes care of that!) or
-                // point belonging to master patch
+                // Point removed, not on slave patch and not retired
+                // (first if takes care of that!)
                 changed = true;
             }
             else
             {
-                // Point off patch
-                oldFace[nOldFace] = oldRichFace[pointi];
+                // Point on master or slave patch
+                oldFace[nOldFace] = pointi;
                 nOldFace++;
             }
         }
@@ -1595,33 +1579,29 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
         forAll(oldFace, pointi)
         {
             // Try to find the point in retired points
-            label curP = oldFace[pointi];
-
-            Map<label>::const_iterator rpmIter = rpm.find(oldFace[pointi]);
+            const label curP = rpm.lookup(oldFace[pointi], oldFace[pointi]);
 
-            if (rpmIter != rpm.end())
+            if (curP != oldFace[pointi])
             {
                 changed = true;
-                curP = rpmIter();
             }
 
-            if (slaveMeshPointMap.found(curP))
+            const label localFirstLabel = slaveMeshPointMap.lookup(curP, -1);
+
+            if (localFirstLabel != -1)
             {
                 // Point is in slave patch. Add it
 
-                // If the point is a direct hit, grab its label; otherwise
-                // keep the original
-                if (pointMergeMap.found(curP))
+                // If the point is a direct hit, grab its label;
+                // otherwise keep the original
+                newFaceLabels.append
+                (
+                    pointMergeMap.lookup(curP, curP)
+                );
+
+                if (newFaceLabels.last() != curP)
                 {
                     changed = true;
-                    newFaceLabels.append
-                    (
-                        pointMergeMap.find(curP)()
-                    );
-                }
-                else
-                {
-                    newFaceLabels.append(curP);
                 }
 
                 // Find if there are additional points inserted onto the edge
@@ -1631,59 +1611,51 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                 //    out of the current point.
                 // 2) Use the next point in the face to pick the right edge
 
-                const label localFirstLabel =
-                    slaveMeshPointMap.find(curP)();
-
                 const labelList& curEdges = slavePointEdges[localFirstLabel];
 
                 label nextLabel = oldFace.nextLabel(pointi);
 
-                Map<label>::const_iterator rpmNextIter =
-                    rpm.find(nextLabel);
+                nextLabel = rpm.lookup(nextLabel, nextLabel);
 
-                if (rpmNextIter != rpm.end())
-                {
-                    nextLabel = rpmNextIter();
-                }
+                const label localNextLabel =
+                    slaveMeshPointMap.lookup(nextLabel, -1);
 
-                Map<label>::const_iterator mmpmIter =
-                    slaveMeshPointMap.find(nextLabel);
-
-                if (mmpmIter != slaveMeshPointMap.end())
+                if (localNextLabel != -1)
                 {
                     // Both points on the slave patch.
                     // Find the points on the edge between them
-                    const label localNextLabel = mmpmIter();
 
-                    forAll(curEdges, curEdgeI)
+                    for (const label curEdgei : curEdges)
                     {
                         if
                         (
-                            slaveEdges[curEdges[curEdgeI]].otherVertex
+                            slaveEdges[curEdgei].otherVertex
                             (
                                 localFirstLabel
                             )
                          == localNextLabel
                         )
                         {
-                            // Pout<< " found edge: " << curEdges[curEdgeI]
+                            // Pout<< " found edge: " << curEdgei
                             //     << endl;
 
                             // Get points on current edge
-                            const labelList& curPise = pise[curEdges[curEdgeI]];
+                            const labelList& curPise = pise[curEdgei];
 
                             if (curPise.size())
                             {
                                 changed = true;
+
                                 // Pout<< "curPise: " << curPise << endl;
                                 // Insert the edge points into the face
                                 // in the correct order
                                 const point& startPoint =
                                     projectedSlavePoints[localFirstLabel];
 
-                                vector e =
-                                    projectedSlavePoints[localNextLabel]
-                                  - startPoint;
+                                const point& endPoint =
+                                    projectedSlavePoints[localNextLabel];
+
+                                vector e = endPoint - startPoint;
 
                                 e /= magSqr(e);
 
@@ -1695,7 +1667,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
                                     (
                                         e
                                       & (
-                                            pointMap.find(curPise[curPiseI])()
+                                            pointMap[curPise[curPiseI]]
                                           - startPoint
                                         )
                                     );
@@ -1773,24 +1745,25 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
             }
 
             // Get face zone and its flip
-            label modifiedFaceZone = faceZones.whichZone(curFaceID);
-            bool modifiedFaceZoneFlip = false;
+            const label modifiedFaceZone =
+                faceZones.whichZone(curFaceID);
 
-            if (modifiedFaceZone >= 0)
-            {
-                modifiedFaceZoneFlip =
-                    faceZones[modifiedFaceZone].flipMap()
-                    [
-                        faceZones[modifiedFaceZone].whichFace(curFaceID)
-                    ];
-            }
+            const bool modifiedFaceZoneFlip
+            (
+                modifiedFaceZone >= 0
+              ?
+                faceZones[modifiedFaceZone].flipMap()
+                [
+                    faceZones[modifiedFaceZone].whichFace(curFaceID)
+                ]
+              : false
+            );
 
             face newFace;
             newFace.transfer(newFaceLabels);
 
-            // Pout<< "Modifying slave stick-out face " << curFaceID
-            //     << " old face: " << oldFace
-            //     << " new face: " << newFace
+            // Pout<< "Modifying slave stick-out face[" << curFaceID
+            //     << "]: old: " << oldFace << " new: " << newFace
             //     << endl;
 
             // Modify the face
@@ -1852,9 +1825,16 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
     label nRetiredPoints = 0;
 
-    forAll(slaveMeshPoints, pointi)
+    for (const label slavePointi : slaveMeshPoints)
     {
-        if (pointMergeMap.found(slaveMeshPoints[pointi]))
+        const label masterPointi = pointMergeMap.lookup(slavePointi, -1);
+
+        if (slavePointi == masterPointi)
+        {
+            // Identity mapping (ie, slave point already exists on master patch)
+            continue;
+        }
+        else if (masterPointi != -1)
         {
             // Retire the point - only used for supporting the detached
             // slave patch
@@ -1862,32 +1842,28 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
             // ref.setAction
             // (
-            //    polyModifyPoint
-            //    (
-            //        slaveMeshPoints[pointi],             // point ID
-            //        points[slaveMeshPoints[pointi]],     // point
-            //        false,                               // remove from zone
-            //        mesh.pointZones().whichZone(slaveMeshPoints[pointi]),
-            //                                             // zone
-            //        false                                // in a cell
-            //    )
+            //     polyModifyPoint
+            //     (
+            //         slavePointi,                         // point ID
+            //         points[slavePointi],                 // point
+            //         false,                               // remove from zone
+            //         mesh.pointZones().whichZone(slavePointi), // zone
+            //         false                                // in a cell
+            //     )
             // );
-            //Pout<< "MJ retire slave point " << slaveMeshPoints[pointi]
-            //    << " coord " << points[slaveMeshPoints[pointi]]
+            //
+            //Pout<< "MJ retire slave point " << slavePointi
+            //    << " coord " << points[slavePointi]
             //    << endl;
             ref.setAction
             (
                 polyRemovePoint
                 (
-                    slaveMeshPoints[pointi]
+                    slavePointi
                 )
             );
 
-            addToRpm.insert
-            (
-                pointMergeMap.find(slaveMeshPoints[pointi])(),
-                slaveMeshPoints[pointi]
-            );
+            addToRpm.insert(masterPointi, slavePointi);
         }
         else
         {
@@ -1895,10 +1871,10 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
             (
                 polyModifyPoint
                 (
-                    slaveMeshPoints[pointi],             // point ID
-                    points[slaveMeshPoints[pointi]],     // point
+                    slavePointi,                         // point ID
+                    points[slavePointi],                 // point
                     false,                               // remove from zone
-                    mesh.pointZones().whichZone(slaveMeshPoints[pointi]),// zone
+                    mesh.pointZones().whichZone(slavePointi),// zone
                     true                                 // in a cell
                 )
             );
@@ -1907,15 +1883,15 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
     if (debug)
     {
-        Pout<< "Retired " << nRetiredPoints << " out of "
+        Pout<< "Retired " << nRetiredPoints << "/"
             << slaveMeshPoints.size() << " points." << endl;
     }
 
     // Grab cut face master and slave addressing
-    if (cutFaceMasterPtr_) deleteDemandDrivenData(cutFaceMasterPtr_);
+    deleteDemandDrivenData(cutFaceMasterPtr_);
     cutFaceMasterPtr_ = new labelList(cutPatch.cutFaceMaster());
 
-    if (cutFaceSlavePtr_) deleteDemandDrivenData(cutFaceSlavePtr_);
+    deleteDemandDrivenData(cutFaceSlavePtr_);
     cutFaceSlavePtr_ = new labelList(cutPatch.cutFaceSlave());
 
     // Finished coupling
@@ -1923,9 +1899,8 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
 
     if (debug)
     {
-        Pout<< "void slidingInterface::coupleInterface("
-            << "polyTopoChange& ref) : "
-            << "Finished coupling sliding interface " << name() << endl;
+        Pout<< FUNCTION_NAME << nl
+            << ": Finished coupling sliding interface " << name() << endl;
     }
 }
 
diff --git a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C
index e454e31981100944105f98bf41da7c3c74abae4f..95c3f91f2e66eb39eb718f622ed95c4fd6a7022c 100644
--- a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C
+++ b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -40,18 +40,16 @@ void Foam::slidingInterface::decoupleInterface
 {
     if (debug)
     {
-        Pout<< "void slidingInterface::decoupleInterface("
-            << "polyTopoChange& ref) const : "
-            << "Decoupling sliding interface " << name() << endl;
+        Pout<< FUNCTION_NAME << nl
+            << ": Decoupling sliding interface " << name() << endl;
     }
 
     if (!attached_)
     {
         if (debug)
         {
-            Pout<< "void slidingInterface::decoupleInterface("
-                << "polyTopoChange& ref) const : "
-                << "Interface already decoupled." << endl;
+            Pout<< FUNCTION_NAME << nl
+                << ": Interface already decoupled." << endl;
         }
 
         return;
@@ -61,22 +59,23 @@ void Foam::slidingInterface::decoupleInterface
     clearCouple(ref);
 
     const polyMesh& mesh = topoChanger().mesh();
+    const pointField& points = mesh.points();
     const faceList& faces = mesh.faces();
     const cellList& cells = mesh.cells();
-
     const labelList& own = mesh.faceOwner();
     const labelList& nei = mesh.faceNeighbour();
+    const faceZoneMesh& faceZones = mesh.faceZones();
 
     // Master side
 
     const primitiveFacePatch& masterPatch =
-        mesh.faceZones()[masterFaceZoneID_.index()]();
+        faceZones[masterFaceZoneID_.index()]();
 
     const labelList& masterPatchAddr =
-        mesh.faceZones()[masterFaceZoneID_.index()];
+        faceZones[masterFaceZoneID_.index()];
 
     const boolList& masterPatchFlip =
-        mesh.faceZones()[masterFaceZoneID_.index()].flipMap();
+        faceZones[masterFaceZoneID_.index()].flipMap();
 
     const labelList& masterFc = masterFaceCells();
 
@@ -119,13 +118,13 @@ void Foam::slidingInterface::decoupleInterface
     // Slave side
 
     const primitiveFacePatch& slavePatch =
-        mesh.faceZones()[slaveFaceZoneID_.index()]();
+        faceZones[slaveFaceZoneID_.index()]();
 
     const labelList& slavePatchAddr =
-        mesh.faceZones()[slaveFaceZoneID_.index()];
+        faceZones[slaveFaceZoneID_.index()];
 
     const boolList& slavePatchFlip =
-        mesh.faceZones()[slaveFaceZoneID_.index()].flipMap();
+        faceZones[slaveFaceZoneID_.index()].flipMap();
 
     const labelList& slaveFc = slaveFaceCells();
 
@@ -147,16 +146,7 @@ void Foam::slidingInterface::decoupleInterface
         // Recover retired points on the slave side
         forAll(newFace, pointi)
         {
-            Map<label>::const_iterator rpmIter = rpm.find(newFace[pointi]);
-            if (rpmIter != rpm.end())
-            {
-                // Master of retired point; grab its original
-                // Pout<< "Reinstating retired point: " << newFace[pointi]
-                //     << " with old: " << rpm.find(newFace[pointi])()
-                //     << endl;
-
-                newFace[pointi] = rpmIter();
-            }
+            newFace[pointi] = rpm.lookup(newFace[pointi], newFace[pointi]);
         }
 
         ref.setAction
@@ -181,12 +171,10 @@ void Foam::slidingInterface::decoupleInterface
     // Grab the list of faces in the layer
     const labelList& masterStickOuts = masterStickOutFaces();
 
-    forAll(masterStickOuts, facei)
+    for (const label curFaceID : masterStickOuts)
     {
         // Renumber the face and remove additional points
 
-        const label curFaceID = masterStickOuts[facei];
-
         const face& oldFace = faces[curFaceID];
 
         DynamicList<label> newFaceLabels(oldFace.size());
@@ -219,17 +207,18 @@ void Foam::slidingInterface::decoupleInterface
             }
 
             // Get face zone and its flip
-            label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID);
-            bool modifiedFaceZoneFlip = false;
+            const label modifiedFaceZone = faceZones.whichZone(curFaceID);
 
-            if (modifiedFaceZone >= 0)
-            {
-                modifiedFaceZoneFlip =
-                    mesh.faceZones()[modifiedFaceZone].flipMap()
-                    [
-                        mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID)
-                    ];
-            }
+            const bool modifiedFaceZoneFlip =
+            (
+                modifiedFaceZone >= 0
+              ?
+                faceZones[modifiedFaceZone].flipMap()
+                [
+                    faceZones[modifiedFaceZone].whichFace(curFaceID)
+                ]
+              : false
+            );
 
             face newFace;
             newFace.transfer(newFaceLabels);
@@ -265,23 +254,22 @@ void Foam::slidingInterface::decoupleInterface
         primitiveMesh::facesPerCell_*(masterPatch.size() + slavePatch.size())
     );
 
-    forAll(slaveFc, facei)
+    for (const label slaveFci : slaveFc)
     {
-        const labelList& curFaces = cells[slaveFc[facei]];
+        const labelList& curFaces = cells[slaveFci];
 
-        forAll(curFaces, facei)
+        for (const label facei : curFaces)
         {
             // Check if the face belongs to the slave face zone; and
             // if it has been removed; if not add it
             if
             (
-                mesh.faceZones().whichZone(curFaces[facei])
+                faceZones.whichZone(facei)
              != slaveFaceZoneID_.index()
-             && !ref.faceRemoved(curFaces[facei])
-
+             && !ref.faceRemoved(facei)
             )
             {
-                slaveLayerCellFaceMap.insert(curFaces[facei]);
+                slaveLayerCellFaceMap.insert(facei);
             }
         }
     }
@@ -292,12 +280,10 @@ void Foam::slidingInterface::decoupleInterface
     // Grab master point mapping
     const Map<label>& masterPm = masterPatch.meshPointMap();
 
-    forAll(slaveStickOuts, facei)
+    for (const label curFaceID : slaveStickOuts)
     {
         // Renumber the face and remove additional points
 
-        const label curFaceID = slaveStickOuts[facei];
-
         const face& oldFace = faces[curFaceID];
 
         DynamicList<label> newFaceLabels(oldFace.size());
@@ -307,16 +293,19 @@ void Foam::slidingInterface::decoupleInterface
         forAll(oldFace, pointi)
         {
             // Check if the point is removed or retired
-            if (rpm.found(oldFace[pointi]))
+
+            const label retiredPointi = rpm.lookup(oldFace[pointi], -1);
+
+            if (retiredPointi != -1)
             {
                 // Master of retired point; grab its original
                 changed = true;
 
                 // Pout<< "Reinstating retired point: " << oldFace[pointi]
-                //     << " with old: " << rpm.find(oldFace[pointi])()
+                //     << " with old: " << retiredPointi
                 //     << endl;
 
-                newFaceLabels.append(rpm.find(oldFace[pointi])());
+                newFaceLabels.append(retiredPointi);
             }
             else if (ref.pointRemoved(oldFace[pointi]))
             {
@@ -346,17 +335,19 @@ void Foam::slidingInterface::decoupleInterface
             }
 
             // Get face zone and its flip
-            label modifiedFaceZone = mesh.faceZones().whichZone(curFaceID);
-            bool modifiedFaceZoneFlip = false;
+            const label modifiedFaceZone =
+                faceZones.whichZone(curFaceID);
 
-            if (modifiedFaceZone >= 0)
-            {
-                modifiedFaceZoneFlip =
-                    mesh.faceZones()[modifiedFaceZone].flipMap()
-                    [
-                        mesh.faceZones()[modifiedFaceZone].whichFace(curFaceID)
-                    ];
-            }
+            const bool modifiedFaceZoneFlip =
+            (
+                modifiedFaceZone >= 0
+              ?
+                faceZones[modifiedFaceZone].flipMap()
+                [
+                    faceZones[modifiedFaceZone].whichFace(curFaceID)
+                ]
+              : false
+            );
 
             face newFace;
             newFace.transfer(newFaceLabels);
@@ -386,22 +377,20 @@ void Foam::slidingInterface::decoupleInterface
     }
 
     // Bring all slave patch points back to life
-    const pointField& points = mesh.points();
-
     const labelList& slaveMeshPoints =
-        mesh.faceZones()[slaveFaceZoneID_.index()]().meshPoints();
+        faceZones[slaveFaceZoneID_.index()]().meshPoints();
 
-    forAll(slaveMeshPoints, pointi)
+    for (const label slavePointi : slaveMeshPoints)
     {
         ref.setAction
         (
             polyModifyPoint
             (
-                slaveMeshPoints[pointi],             // point ID
-                points[slaveMeshPoints[pointi]],     // point
-                false,                               // remove from zone
-                mesh.pointZones().whichZone(slaveMeshPoints[pointi]), // zone
-                true                                // in a cell
+                slavePointi,            // point ID
+                points[slavePointi],    // point
+                false,                  // remove from zone
+                mesh.pointZones().whichZone(slavePointi), // zone
+                true                    // in a cell
             )
         );
     }
@@ -414,9 +403,8 @@ void Foam::slidingInterface::decoupleInterface
 
     if (debug)
     {
-        Pout<< "void slidingInterface::coupleInterface("
-            << "polyTopoChange& ref) const : "
-            << "Finished decoupling sliding interface " << name() << endl;
+        Pout<< FUNCTION_NAME << nl
+            << ": Finished decoupling sliding interface " << name() << endl;
     }
 }
 
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C
index e0ba1fd8e2a7f3fb118a472c8916cc72338257c4..184216ac657d390a98149b672d5272c22cf627aa 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -88,7 +88,7 @@ void Foam::enrichedPatch::calcLocalFaces() const
 
         forAll(f, pointi)
         {
-            curlf[pointi] = mpLookup.find(f[pointi])();
+            curlf[pointi] = mpLookup.cfind(f[pointi])();
         }
     }
 }
@@ -110,7 +110,7 @@ void Foam::enrichedPatch::calcLocalPoints() const
 
     forAll(lp, i)
     {
-        lp[i] = pointMap().find(mp[i])();
+        lp[i] = pointMap().cfind(mp[i])();
     }
 }
 
@@ -131,14 +131,13 @@ void Foam::enrichedPatch::clearOut()
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-// Construct from components
 Foam::enrichedPatch::enrichedPatch
 (
     const primitiveFacePatch& masterPatch,
     const primitiveFacePatch& slavePatch,
-    const labelList& slavePointPointHits,
-    const labelList& slavePointEdgeHits,
-    const List<objectHit>& slavePointFaceHits
+    const labelUList& slavePointPointHits,
+    const labelUList& slavePointEdgeHits,
+    const UList<objectHit>& slavePointFaceHits
 )
 :
     masterPatch_(masterPatch),
@@ -252,36 +251,20 @@ void Foam::enrichedPatch::writeOBJ(const fileName& fName) const
 {
     OFstream str(fName);
 
-    const pointField& lp = localPoints();
-
-    forAll(lp, pointi)
-    {
-        meshTools::writeOBJ(str, lp[pointi]);
-    }
+    meshTools::writeOBJ(str, localPoints());
 
     const faceList& faces = localFaces();
 
-    forAll(faces, facei)
+    for (const face& f : faces)
     {
-        const face& f = faces[facei];
-
         str << 'f';
-        forAll(f, fp)
+        for (const label fp : f)
         {
-            str << ' ' << f[fp]+1;
+            str << ' ' << fp+1;
         }
         str << nl;
     }
 }
 
 
-// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
-
-
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
-
-
 // ************************************************************************* //
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H
index f47d46940ade6d6aeaed4bb8a14e66435bb784b3..6d04a55a33fb21a5f21ec2e5f9099ebab254d907 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatch.H
@@ -36,8 +36,7 @@ Description
 
     Note:
     If new points are created during master-slave edge cutting, they
-    should be registred with the pointMap.
-
+    should be registered with the pointMap.
 
 SourceFiles
     enrichedPatch.C
@@ -134,10 +133,10 @@ class enrichedPatch
     // Private Member Functions
 
         //- Disallow default bitwise copy construct
-        enrichedPatch(const enrichedPatch&);
+        enrichedPatch(const enrichedPatch&) = delete;
 
         //- Disallow default bitwise assignment
-        void operator=(const enrichedPatch&);
+        void operator=(const enrichedPatch&) = delete;
 
         // Creation of demand-driven private data
 
@@ -196,11 +195,11 @@ public:
         (
             const primitiveFacePatch& masterPatch,
             const primitiveFacePatch& slavePatch,
-            const labelList& slavePointPointHits,
+            const labelUList& slavePointPointHits,
                                             // -1 or common point snapped to
-            const labelList& slavePointEdgeHits,
+            const labelUList& slavePointEdgeHits,
                                             // -1 or common edge snapped to
-            const List<objectHit>& slavePointFaceHits
+            const UList<objectHit>& slavePointFaceHits
                                             // master face snapped to
         );
 
@@ -213,23 +212,17 @@ public:
 
         // Access
 
-            //- Return non-const access to point map to add points
-            Map<point>& pointMap();
-
             //- Return map of points
-            const Map<point>& pointMap() const;
+            inline const Map<point>& pointMap() const;
+
+            //- Return non-const access to point map to add points
+            inline Map<point>& pointMap();
 
             //- Return map of point merges
-            Map<label>& pointMergeMap()
-            {
-                return pointMergeMap_;
-            }
+            inline const Map<label>& pointMergeMap() const;
 
             //- Return map of point merges
-            const Map<label>& pointMergeMap() const
-            {
-                return pointMergeMap_;
-            }
+            inline Map<label>& pointMergeMap();
 
 
         // Topological data
@@ -278,7 +271,7 @@ public:
 
 
         //- Debugging: dump graphical representation to obj format file
-        void writeOBJ(const fileName&) const;
+        void writeOBJ(const fileName& fName) const;
 };
 
 
@@ -288,6 +281,10 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "enrichedPatchI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C
index 50c1af29f30e31445542210f5295c3bb202ee9d3..4c1fd310968a35b53cb22789410ae3bfbcd8d757 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -32,7 +32,7 @@ Description
 #include "DynamicList.H"
 #include "labelPair.H"
 #include "primitiveMesh.H"
-#include "HashSet.H"
+#include "edgeHashes.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -94,9 +94,8 @@ void Foam::enrichedPatch::calcCutFaces() const
     //    the points projected onto the face.
 
     // Create a set of edge usage parameters
-    HashSet<edge, Hash<edge>> edgesUsedOnce(pp.size());
-    HashSet<edge, Hash<edge>> edgesUsedTwice
-        (pp.size()*primitiveMesh::edgesPerPoint_);
+    edgeHashSet edgesUsedOnce(pp.size());
+    edgeHashSet edgesUsedTwice(pp.size()*primitiveMesh::edgesPerPoint_);
 
 
     forAll(lf, facei)
@@ -145,9 +144,9 @@ void Foam::enrichedPatch::calcCutFaces() const
 
         // Insert the edges of current face into the seed list.
         edgeList cfe = curLocalFace.edges();
-        forAll(curLocalFace, edgeI)
+        for (const edge& e : cfe)
         {
-            edgeSeeds.append(cfe[edgeI]);
+            edgeSeeds.append(e);
         }
 
         // Grab face normal
@@ -156,9 +155,7 @@ void Foam::enrichedPatch::calcCutFaces() const
 
         while (edgeSeeds.size())
         {
-            // Pout<< "edgeSeeds.size(): "
-            //     << edgeSeeds.size()
-            //     << endl;
+            // Pout<< "edgeSeeds.size(): " << edgeSeeds.size() << endl;
 
             const edge curEdge = edgeSeeds.removeHead();
 
@@ -198,6 +195,7 @@ void Foam::enrichedPatch::calcCutFaces() const
             cutFaceGlobalPoints.append(mp[prevPointLabel]);
             cutFaceLocalPoints.append(prevPointLabel);
             // Pout<< "prevPointLabel: " << mp[prevPointLabel] << endl;
+
             // Grab current point and append it to the list
             label curPointLabel = curEdge.end();
             point curPoint = lp[curPointLabel];
@@ -266,7 +264,7 @@ void Foam::enrichedPatch::calcCutFaces() const
 
                         newDir /= magNewDir;
 
-                        scalar curAtanTurn =
+                        const scalar curAtanTurn =
                             atan2(newDir & right, newDir & ahead);
 
                         // Pout<< " atan: " << curAtanTurn << endl;
@@ -352,19 +350,18 @@ void Foam::enrichedPatch::calcCutFaces() const
                     // If the edge corresponds to a starting face edge,
                     // mark the starting face edge as true
 
-                    forAll(cutFaceLocal, cutI)
+                    forAll(cutFaceLocal, cuti)
                     {
                         const edge curCutFaceEdge
                         (
-                            cutFaceLocal[cutI],
-                            cutFaceLocal.nextLabel(cutI)
+                            cutFaceLocal[cuti],
+                            cutFaceLocal.nextLabel(cuti)
                         );
 
                         // Increment the usage count using two hash sets
-                        HashSet<edge, Hash<edge>>::iterator euoIter =
-                            edgesUsedOnce.find(curCutFaceEdge);
+                        auto euoIter = edgesUsedOnce.find(curCutFaceEdge);
 
-                        if (euoIter == edgesUsedOnce.end())
+                        if (!euoIter.found())
                         {
                             // Pout<< "Found edge not used before: "
                             //     << curCutFaceEdge
@@ -435,12 +432,12 @@ void Foam::enrichedPatch::calcCutFaces() const
 
                     if (facei < slavePatch_.size())
                     {
-                        Map<labelList>::const_iterator mpfAddrIter =
-                            masterPointFaceAddr.find(cutFaceGlobal[0]);
+                        const auto mpfAddrIter =
+                            masterPointFaceAddr.cfind(cutFaceGlobal[0]);
 
                         bool otherSideFound = false;
 
-                        if (mpfAddrIter != masterPointFaceAddr.end())
+                        if (mpfAddrIter.found())
                         {
                             bool miss = false;
 
@@ -456,18 +453,13 @@ void Foam::enrichedPatch::calcCutFaces() const
                                 pointi++
                             )
                             {
-                                Map<labelList>::const_iterator
-                                    mpfAddrPointIter =
-                                        masterPointFaceAddr.find
-                                        (
-                                            cutFaceGlobal[pointi]
-                                        );
+                                const auto mpfAddrPointIter =
+                                    masterPointFaceAddr.cfind
+                                    (
+                                        cutFaceGlobal[pointi]
+                                    );
 
-                                if
-                                (
-                                    mpfAddrPointIter
-                                 == masterPointFaceAddr.end()
-                                )
+                                if (!mpfAddrPointIter.found())
                                 {
                                     // Point is off the master patch. Skip
                                     miss = true;
@@ -479,15 +471,11 @@ void Foam::enrichedPatch::calcCutFaces() const
 
                                 // For every current face, try to find it in the
                                 // zero-list
-                                forAll(curMasterFaces, i)
+                                for (const label facei : curMasterFaces)
                                 {
                                     forAll(masterFacesOfPZero, j)
                                     {
-                                        if
-                                        (
-                                            curMasterFaces[i]
-                                         == masterFacesOfPZero[j]
-                                        )
+                                        if (facei == masterFacesOfPZero[j])
                                         {
                                             hits[j]++;
                                             break;
@@ -644,7 +632,7 @@ void Foam::enrichedPatch::calcCutFaces() const
 
     } // end of local faces
 
-    // Re-pack the list into compact storage
+    // Re-pack lists into compact storage
     cutFacesPtr_ = new faceList();
     cutFacesPtr_->transfer(cf);
 
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C
index f6eb9de42e4e4c93d0a63af6ec13173fdaf937be..af4947e9127fac8eea92b8e00f2545fbc73e48fa 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,11 +26,11 @@ License
 #include "enrichedPatch.H"
 #include "DynamicList.H"
 
-
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 const Foam::label Foam::enrichedPatch::enrichedFaceRatio_ = 3;
 
+
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void Foam::enrichedPatch::calcEnrichedFaces
@@ -79,68 +79,57 @@ void Foam::enrichedPatch::calcEnrichedFaces
 
     forAll(slavePatch_, facei)
     {
-        const face oldFace = slavePatch_[facei];
-        const face oldLocalFace = slaveLocalFaces[facei];
-//         Info<< "old slave face " << facei << ": " << oldFace << endl;
+        const face& oldFace = slavePatch_[facei];
+        const face& oldLocalFace = slaveLocalFaces[facei];
         const labelList& curEdges = slaveFaceEdges[facei];
 
+        // Info<< "old slave face[" << facei << "] " << oldFace << endl;
+
         DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_);
 
         // Note: The number of points and edges in a face is always identical
         // so both can be done is the same loop
         forAll(oldFace, i)
         {
-            // Add the point
-            Map<label>::const_iterator mpIter =
-                pmm.find(oldFace[i]);
+            // Add the point.
+            // Using the mapped point id if possible
 
-            if (mpIter == pmm.end())
-            {
-                // Point not mapped
-                newFace.append(oldFace[i]);
-
-                // Add the projected point into the patch support
-                pointMap().insert
-                (
-                    oldFace[i],    // Global label of point
-                    projectedSlavePoints[oldLocalFace[i]] // Projected position
-                );
-            }
-            else
-            {
-                // Point mapped
-                newFace.append(mpIter());
-
-                // Add the projected point into the patch support
-                pointMap().insert
-                (
-                    mpIter(),    // Merged global label of point
-                    projectedSlavePoints[oldLocalFace[i]] // Projected position
-                );
-            }
+            const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]);
+
+            newFace.append(mappedPointi);
+
+            // Add the projected point into the patch support
+            pointMap().insert
+            (
+                mappedPointi,   // Global label of point
+                projectedSlavePoints[oldLocalFace[i]] // Projected position
+            );
 
             // Grab the edge points
 
-            const labelList& slavePointsOnEdge =
+            const labelList& pointsOnEdge =
                 pointsIntoSlaveEdges[curEdges[i]];
 
-            // Info<< "slavePointsOnEdge for "
-            //     << curEdges[i] << ": " << slavePointsOnEdge
+            // Info<< "slave pointsOnEdge for "
+            //     << curEdges[i] << ": " << pointsOnEdge
             //     << endl;
 
             // If there are no points on the edge, skip everything
             // If there is only one point, no need for sorting
-            if (slavePointsOnEdge.size())
+            if (pointsOnEdge.size())
             {
                 // Sort edge points in order
-                scalarField edgePointWeights(slavePointsOnEdge.size());
-                const point& startPoint = projectedSlavePoints[oldLocalFace[i]];
+                scalarField weightOnEdge(pointsOnEdge.size());
+
+                const point& startPoint =
+                    projectedSlavePoints[oldLocalFace[i]];
 
-                vector e =
-                    projectedSlavePoints[oldLocalFace.nextLabel(i)]
-                  - startPoint;
+                const point& endPoint =
+                    projectedSlavePoints[oldLocalFace.nextLabel(i)];
 
-                scalar magSqrE = magSqr(e);
+                vector e = (endPoint - startPoint);
+
+                const scalar magSqrE = magSqr(e);
 
                 if (magSqrE > SMALL)
                 {
@@ -154,27 +143,34 @@ void Foam::enrichedPatch::calcEnrichedFaces
                         << abort(FatalError);
                 }
 
-                pointField slavePosOnEdge(slavePointsOnEdge.size());
+                pointField positionOnEdge(pointsOnEdge.size());
 
-                forAll(slavePointsOnEdge, edgePointi)
+                forAll(pointsOnEdge, edgePointi)
                 {
-                    slavePosOnEdge[edgePointi] =
-                        pointMap().find(slavePointsOnEdge[edgePointi])();
+                    positionOnEdge[edgePointi] =
+                        pointMap()[pointsOnEdge[edgePointi]];
 
-                    edgePointWeights[edgePointi] =
-                        (e & (slavePosOnEdge[edgePointi] - startPoint));
+                    weightOnEdge[edgePointi] =
+                    (
+                        e
+                      &
+                        (
+                            positionOnEdge[edgePointi]
+                          - startPoint
+                        )
+                    );
                 }
 
                 if (debug)
                 {
                     // Check weights: all new points should be on the edge
-                    if (min(edgePointWeights) < 0 || max(edgePointWeights) > 1)
+                    if (min(weightOnEdge) < 0 || max(weightOnEdge) > 1)
                     {
                         FatalErrorInFunction
                             << " not on the edge for edge " << curEdges[i]
                             << " of face " << facei << " in slave patch." << nl
-                            << "Min weight: " << min(edgePointWeights)
-                            << " Max weight: " << max(edgePointWeights)
+                            << "Min weight: " << min(weightOnEdge)
+                            << " Max weight: " << max(weightOnEdge)
                             << abort(FatalError);
                     }
                 }
@@ -182,101 +178,98 @@ void Foam::enrichedPatch::calcEnrichedFaces
                 // Go through the points and collect them based on
                 // weights from lower to higher.  This gives the
                 // correct order of points along the edge.
-                forAll(edgePointWeights, passI)
+                forAll(weightOnEdge, passI)
                 {
                     // Max weight can only be one, so the sorting is
                     // done by elimination.
                     label nextPoint = -1;
                     scalar dist = 2;
 
-                    forAll(edgePointWeights, wI)
+                    forAll(weightOnEdge, wI)
                     {
-                        if (edgePointWeights[wI] < dist)
+                        if (weightOnEdge[wI] < dist)
                         {
-                            dist = edgePointWeights[wI];
+                            dist = weightOnEdge[wI];
                             nextPoint = wI;
                         }
                     }
 
                     // Insert the next point and reset its weight to exclude it
                     // from future picks
-                    newFace.append(slavePointsOnEdge[nextPoint]);
-                    edgePointWeights[nextPoint] = GREAT;
+                    newFace.append(pointsOnEdge[nextPoint]);
+                    weightOnEdge[nextPoint] = GREAT;
 
                     // Add the point into patch support
                     pointMap().insert
                     (
-                        slavePointsOnEdge[nextPoint],
-                        slavePosOnEdge[nextPoint]
+                        pointsOnEdge[nextPoint],
+                        positionOnEdge[nextPoint]
                     );
                 }
             }
         }
-        // Info<< "New slave face " << facei << ": " << newFace << endl;
+
+        // Info<< "New slave face[" << facei << "] "
+        //     << flatOutput(newFace) << " was " << flatOutput(oldFace)
+        //     << endl;
 
         // Add the new face to the list
         enrichedFaces[nEnrichedFaces].transfer(newFace);
         nEnrichedFaces++;
     }
 
+
     // Add master faces into the enriched faces list
 
     forAll(masterPatch_, facei)
     {
         const face& oldFace = masterPatch_[facei];
         const face& oldLocalFace = masterLocalFaces[facei];
-//         Info<< "old master face: " << oldFace << endl;
         const labelList& curEdges = masterFaceEdges[facei];
 
+        // Info<< "old master face[" << facei << "] " << oldFace << endl;
+
         DynamicList<label> newFace(oldFace.size()*enrichedFaceRatio_);
 
         // Note: The number of points and edges in a face is always identical
         // so both can be done is the same loop
         forAll(oldFace, i)
         {
-            // Add the point
-            Map<label>::const_iterator mpIter =
-                pmm.find(oldFace[i]);
+            // Add the point.
+            // Using the mapped point id if possible
 
-            if (mpIter == pmm.end())
-            {
-                // Point not mapped
-                newFace.append(oldFace[i]);
-
-                // Add the point into patch support
-                pointMap().insert
-                (
-                    oldFace[i],
-                    masterLocalPoints[oldLocalFace[i]]
-                );
-            }
-            else
-            {
-                // Point mapped
-                newFace.append(mpIter());
+            const label mappedPointi = pmm.lookup(oldFace[i], oldFace[i]);
 
-                // Add the point into support
-                pointMap().insert(mpIter(), masterLocalPoints[oldLocalFace[i]]);
-            }
+            newFace.append(mappedPointi);
+
+            // Add the point into patch support
+            pointMap().insert
+            (
+                mappedPointi,   // Global label of point
+                masterLocalPoints[oldLocalFace[i]]
+            );
 
             // Grab the edge points
 
-            const labelList& masterPointsOnEdge =
+            const labelList& pointsOnEdge =
                 pointsIntoMasterEdges[curEdges[i]];
 
             // If there are no points on the edge, skip everything
             // If there is only one point, no need for sorting
-            if (masterPointsOnEdge.size())
+            if (pointsOnEdge.size())
             {
                 // Sort edge points in order
-                scalarField edgePointWeights(masterPointsOnEdge.size());
-                const point& startPoint = masterLocalPoints[oldLocalFace[i]];
+                scalarField weightOnEdge(pointsOnEdge.size());
+
+                const point& startPoint =
+                    masterLocalPoints[oldLocalFace[i]];
+
+                const point& endPoint =
+                    masterLocalPoints[oldLocalFace.nextLabel(i)];
 
-                vector e =
-                    masterLocalPoints[oldLocalFace.nextLabel(i)]
-                  - startPoint;
+                vector e = (endPoint - startPoint);
 
-                scalar magSqrE = magSqr(e);
+                const scalar magSqrE = magSqr(e);
 
                 if (magSqrE > SMALL)
                 {
@@ -290,27 +283,33 @@ void Foam::enrichedPatch::calcEnrichedFaces
                         << abort(FatalError);
                 }
 
-                pointField masterPosOnEdge(masterPointsOnEdge.size());
+                pointField positionOnEdge(pointsOnEdge.size());
 
-                forAll(masterPointsOnEdge, edgePointi)
+                forAll(pointsOnEdge, edgePointi)
                 {
-                    masterPosOnEdge[edgePointi] =
-                        pointMap().find(masterPointsOnEdge[edgePointi])();
+                    positionOnEdge[edgePointi] =
+                        pointMap()[pointsOnEdge[edgePointi]];
 
-                    edgePointWeights[edgePointi] =
-                        (e & (masterPosOnEdge[edgePointi] - startPoint));
+                    weightOnEdge[edgePointi] =
+                    (
+                        e
+                      &
+                        (
+                            positionOnEdge[edgePointi] - startPoint
+                        )
+                    );
                 }
 
                 if (debug)
                 {
                     // Check weights: all new points should be on the edge
-                    if (min(edgePointWeights) < 0 || max(edgePointWeights) > 1)
+                    if (min(weightOnEdge) < 0 || max(weightOnEdge) > 1)
                     {
                         FatalErrorInFunction
                             << " not on the edge for edge " << curEdges[i]
                             << " of face " << facei << " in master patch." << nl
-                            << "Min weight: " << min(edgePointWeights)
-                            << " Max weight: " << max(edgePointWeights)
+                            << "Min weight: " << min(weightOnEdge)
+                            << " Max weight: " << max(weightOnEdge)
                             << abort(FatalError);
                     }
                 }
@@ -318,37 +317,40 @@ void Foam::enrichedPatch::calcEnrichedFaces
                 // Go through the points and collect them based on
                 // weights from lower to higher.  This gives the
                 // correct order of points along the edge.
-                forAll(edgePointWeights, passI)
+                forAll(weightOnEdge, passI)
                 {
                     // Max weight can only be one, so the sorting is
                     // done by elimination.
                     label nextPoint = -1;
                     scalar dist = 2;
 
-                    forAll(edgePointWeights, wI)
+                    forAll(weightOnEdge, wI)
                     {
-                        if (edgePointWeights[wI] < dist)
+                        if (weightOnEdge[wI] < dist)
                         {
-                            dist = edgePointWeights[wI];
+                            dist = weightOnEdge[wI];
                             nextPoint = wI;
                         }
                     }
 
                     // Insert the next point and reset its weight to exclude it
                     // from future picks
-                    newFace.append(masterPointsOnEdge[nextPoint]);
-                    edgePointWeights[nextPoint] = GREAT;
+                    newFace.append(pointsOnEdge[nextPoint]);
+                    weightOnEdge[nextPoint] = GREAT;
 
                     // Add the point into patch support
                     pointMap().insert
                     (
-                        masterPointsOnEdge[nextPoint],
-                        masterPosOnEdge[nextPoint]
+                        pointsOnEdge[nextPoint],
+                        positionOnEdge[nextPoint]
                     );
                 }
             }
         }
-        // Info<< "New master face: " << newFace << endl;
+
+        // Info<< "New master face[" << facei << "] "
+        //     << flatOutput(newFace) << " was " << flatOutput(oldFace)
+        //     << endl;
 
         // Add the new face to the list
         enrichedFaces[nEnrichedFaces].transfer(newFace);
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H
new file mode 100644
index 0000000000000000000000000000000000000000..0a03eb2bd2220f8d894965d19e54151e1417b8ed
--- /dev/null
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchI.H
@@ -0,0 +1,63 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+inline const Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() const
+{
+    if (!pointMapComplete_)
+    {
+        completePointMap();
+    }
+
+    return pointMap_;
+}
+
+
+inline Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap()
+{
+    if (!pointMapComplete_)
+    {
+        completePointMap();
+    }
+
+    return pointMap_;
+}
+
+
+inline const Foam::Map<Foam::label>& Foam::enrichedPatch::pointMergeMap() const
+{
+    return pointMergeMap_;
+}
+
+
+inline Foam::Map<Foam::label>& Foam::enrichedPatch::pointMergeMap()
+{
+    return pointMergeMap_;
+}
+
+
+
+// ************************************************************************* //
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C
index 280f4324d29e558367699977718d11dda428dffd..18edef858ed1094f344939255da504bb9c4bed13 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -32,6 +32,7 @@ License
 
 const Foam::label Foam::enrichedPatch::nFaceHits_ = 4;
 
+
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void Foam::enrichedPatch::calcMasterPointFaces() const
@@ -51,7 +52,7 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
     // Master face points lists the points of the enriched master face plus
     // points projected into the master face
 
-    Map<DynamicList<label>> mpf(meshPoints().size());
+    Map<DynamicList<label>> mpf(2*meshPoints().size());
 
     const faceList& ef = enrichedFaces();
 
@@ -59,28 +60,14 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
     forAll(masterPatch_, facei)
     {
         const face& curFace = ef[facei + slavePatch_.size()];
-//         Pout<< "Cur face in pfAddr: " << curFace << endl;
-        forAll(curFace, pointi)
+
+        for (const label pointi : curFace)
         {
-            Map<DynamicList<label>>::iterator mpfIter =
-                mpf.find(curFace[pointi]);
-
-            if (mpfIter == mpf.end())
-            {
-                // Not found, add new dynamic list
-                mpf.insert
-                (
-                    curFace[pointi],
-                    DynamicList<label>(primitiveMesh::facesPerPoint_)
-                );
-
-                // Iterator is invalidated - have to find again
-                mpf.find(curFace[pointi])().append(facei);
-            }
-            else
-            {
-                mpfIter().append(facei);
-            }
+            DynamicList<label>& dynLst = mpf(pointi); // Get or create
+
+            dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list
+
+            dynLst.append(facei);
         }
     }
 
@@ -96,50 +83,27 @@ void Foam::enrichedPatch::calcMasterPointFaces() const
          && slavePointFaceHits_[pointi].hit()
         )
         {
-            // Get the index of projected point corresponding to this slave
-            // point
-            const label mergedSmp =
-                pointMergeMap().find(slaveMeshPoints[pointi])();
-
-            Map<DynamicList<label>>::iterator mpfIter =
-                mpf.find(mergedSmp);
-
-            if (mpfIter == mpf.end())
-            {
-                // Not found, add new dynamic list
-                mpf.insert
-                (
-                    mergedSmp,
-                    DynamicList<label>(primitiveMesh::facesPerPoint_)
-                );
-
-                // Iterator is invalidated - have to find again
-                mpf.find(mergedSmp)().append
-                (
-                    slavePointFaceHits_[pointi].hitObject()
-                );
-            }
-            else
-            {
-                mpfIter().append(slavePointFaceHits_[pointi].hitObject());
-            }
+            // Index of projected point corresponding to this slave point
+            const label mergedPointi = pointMergeMap()[slaveMeshPoints[pointi]];
+
+            DynamicList<label>& dynLst = mpf(mergedPointi); // Get or create
+
+            dynLst.reserve(primitiveMesh::facesPerPoint_); // Min size for list
+
+            dynLst.append(slavePointFaceHits_[pointi].hitObject());
         }
     }
 
     // Re-pack dynamic lists into normal lists
-    const labelList mpfToc = mpf.toc();
 
-    masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size());
-    Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_;
+    masterPointFacesPtr_ = new Map<labelList>(2*mpf.size());
+    Map<labelList>& masterPointFaceMap = *masterPointFacesPtr_;
 
-    forAll(mpfToc, mpfTocI)
+    forAllIters(mpf, mpfIter)
     {
-        labelList l;
-        l.transfer(mpf.find(mpfToc[mpfTocI])());
-
-        masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
+        masterPointFaceMap(mpfIter.key()).transfer(mpfIter.object());
     }
-    // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl;
+    // Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl;
 }
 
 
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C
index bab79f692662cf679b5de7b53f128114062462b9..632578586edb762ce74ff0777174e11e151f3c65 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointMap.C
@@ -40,8 +40,8 @@ void Foam::enrichedPatch::completePointMap() const
 
     const Map<label>& pmm = pointMergeMap();
 
-    // Get the mesh points for both patches.  If the point has not been
-    // merged away, add it to the map
+    // Get the mesh points for both patches.
+    // If the point has not been merged away, add it to the map
 
     // Do master patch
     const labelList& masterMeshPoints = masterPatch_.meshPoints();
@@ -77,29 +77,4 @@ void Foam::enrichedPatch::completePointMap() const
 }
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-
-Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap()
-{
-    if (!pointMapComplete_)
-    {
-        completePointMap();
-    }
-
-    return pointMap_;
-}
-
-
-const Foam::Map<Foam::point>& Foam::enrichedPatch::pointMap() const
-{
-    if (!pointMapComplete_)
-    {
-        completePointMap();
-    }
-
-    return pointMap_;
-}
-
-
 // ************************************************************************* //
diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C
index c0f8dd6fa7d18fd8f987b080dbd5eb768e30e607..0bd562692a2b116721665d3601a89acba28861de 100644
--- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C
+++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C
@@ -27,9 +27,6 @@ License
 #include "primitiveMesh.H"
 #include "DynamicList.H"
 
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void Foam::enrichedPatch::calcPointPoints() const
@@ -46,24 +43,20 @@ void Foam::enrichedPatch::calcPointPoints() const
     // Go through all faces and add the previous and next point as the
     // neighbour for each point. While inserting points, reject the
     // duplicates (as every internal edge will be visited twice).
-    List<DynamicList<label, primitiveMesh::edgesPerPoint_>>
-        pp(meshPoints().size());
+    List<DynamicList<label>> pp(meshPoints().size());
 
     const faceList& lf = localFaces();
 
     bool found = false;
 
-    forAll(lf, facei)
+    for (const face& curFace : lf)
     {
-        const face& curFace = lf[facei];
-
         forAll(curFace, pointi)
         {
-            DynamicList<label, primitiveMesh::edgesPerPoint_>&
-                curPp = pp[curFace[pointi]];
+            DynamicList<label>& curPp = pp[curFace[pointi]];
 
             // Do next label
-            label next = curFace.nextLabel(pointi);
+            const label next = curFace.nextLabel(pointi);
 
             found = false;
 
@@ -82,7 +75,7 @@ void Foam::enrichedPatch::calcPointPoints() const
             }
 
             // Do previous label
-            label prev = curFace.prevLabel(pointi);
+            const label prev = curFace.prevLabel(pointi);
             found = false;
 
             forAll(curPp, i)
diff --git a/src/dynamicMesh/slidingInterface/slidingInterface.C b/src/dynamicMesh/slidingInterface/slidingInterface.C
index 7048a5713aba786c0e9c42fdb31664e3e02c283f..84caf4901b33b8e7d7ca45b6fdfd15d06f881863 100644
--- a/src/dynamicMesh/slidingInterface/slidingInterface.C
+++ b/src/dynamicMesh/slidingInterface/slidingInterface.C
@@ -765,30 +765,22 @@ void Foam::slidingInterface::write(Ostream& os) const
 
 void Foam::slidingInterface::writeDict(Ostream& os) const
 {
-    os  << nl << name() << nl << token::BEGIN_BLOCK << nl
-        << "    type " << type() << token::END_STATEMENT << nl
-        << "    masterFaceZoneName " << masterFaceZoneID_.name()
-        << token::END_STATEMENT << nl
-        << "    slaveFaceZoneName " << slaveFaceZoneID_.name()
-        << token::END_STATEMENT << nl
-        << "    cutPointZoneName " << cutPointZoneID_.name()
-        << token::END_STATEMENT << nl
-        << "    cutFaceZoneName " << cutFaceZoneID_.name()
-        << token::END_STATEMENT << nl
-        << "    masterPatchName " << masterPatchID_.name()
-        << token::END_STATEMENT << nl
-        << "    slavePatchName " << slavePatchID_.name()
-        << token::END_STATEMENT << nl
-        << "    typeOfMatch " << typeOfMatchNames_[matchType_]
-        << token::END_STATEMENT << nl
-        << "    coupleDecouple " << coupleDecouple_
-        << token::END_STATEMENT << nl
-        << "    projection " << intersection::algorithmNames_[projectionAlgo_]
-        << token::END_STATEMENT << nl
-        << "    attached " << attached_
-        << token::END_STATEMENT << nl
-        << "    active " << active()
-        << token::END_STATEMENT << nl;
+    os  << nl;
+
+    os.beginBlock(name());
+
+    os.writeEntry("type", type());
+    os.writeEntry("masterFaceZoneName", masterFaceZoneID_.name());
+    os.writeEntry("slaveFaceZoneName", slaveFaceZoneID_.name());
+    os.writeEntry("cutPointZoneName", cutPointZoneID_.name());
+    os.writeEntry("cutFaceZoneName", cutFaceZoneID_.name());
+    os.writeEntry("masterPatchName", masterPatchID_.name());
+    os.writeEntry("slavePatchName", slavePatchID_.name());
+    os.writeEntry("typeOfMatch", typeOfMatchNames_[matchType_]);
+    os.writeEntry("coupleDecouple", coupleDecouple_);
+    os.writeEntry("projection", intersection::algorithmNames_[projectionAlgo_]);
+    os.writeEntry("attached", attached_);
+    os.writeEntry("active", active());
 
     if (attached_)
     {
@@ -797,10 +789,8 @@ void Foam::slidingInterface::writeDict(Ostream& os) const
         masterStickOutFacesPtr_->writeEntry("masterStickOutFaces", os);
         slaveStickOutFacesPtr_->writeEntry("slaveStickOutFaces", os);
 
-         os << "    retiredPointMap " << retiredPointMap()
-            << token::END_STATEMENT << nl
-            << "    cutPointEdgePairMap " << cutPointEdgePairMap()
-            << token::END_STATEMENT << nl;
+        os.writeEntry("retiredPointMap", retiredPointMap());
+        os.writeEntry("cutPointEdgePairMap", cutPointEdgePairMap());
     }
 
     WRITE_NON_DEFAULT(pointMergeTol)
@@ -812,7 +802,7 @@ void Foam::slidingInterface::writeDict(Ostream& os) const
     WRITE_NON_DEFAULT(edgeCoPlanarTol)
     WRITE_NON_DEFAULT(edgeEndCutoffTol)
 
-    os  << token::END_BLOCK << endl;
+    os.endBlock();
 }
 
 
diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C b/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C
index 34504028ce53f202b8d9107aa99fbcc3546646e6..29a26d62af2c8b56b5c85578e72b0b713bcf9e66 100644
--- a/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C
+++ b/src/dynamicMesh/slidingInterface/slidingInterfaceAttachedAddressing.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -34,7 +34,7 @@ void Foam::slidingInterface::calcAttachedAddressing() const
 {
     if (debug)
     {
-        Pout<< "void Foam::slidingInterface::calcAttachedAddressing() const "
+        Pout<< FUNCTION_NAME
             << " for object " << name() << " : "
             << "Calculating zone face-cell addressing."
             << endl;
@@ -140,64 +140,83 @@ void Foam::slidingInterface::calcAttachedAddressing() const
         // Calculate stick-out faces
         const labelListList& pointFaces = mesh.pointFaces();
 
-        // Master side
-        labelHashSet masterStickOutFaceMap
+        labelHashSet stickOutFaceMap
         (
-            primitiveMesh::facesPerCell_*(masterPatch.size())
+            primitiveMesh::facesPerCell_
+          * max(masterPatch.size(), slavePatch.size())
         );
 
+        // Master side
         const labelList& masterMeshPoints = masterPatch.meshPoints();
 
-        forAll(masterMeshPoints, pointi)
-        {
-            const labelList& curFaces = pointFaces[masterMeshPoints[pointi]];
+        stickOutFaceMap.clear();
 
-            forAll(curFaces, facei)
+        for (const label pointi : masterMeshPoints)
+        {
+            for (const label facei : pointFaces[pointi])
             {
-                // Check if the face belongs to the master face zone;
-                // if not add it
+                const label zoneIdx = faceZones.whichZone(facei);
+
+                // Add if face not already part of master or slave face zone
+                // This handles partially attached faces.
                 if
                 (
-                    faceZones.whichZone(curFaces[facei])
-                 != masterFaceZoneID_.index()
+                    zoneIdx != masterFaceZoneID_.index()
+                 && zoneIdx != slaveFaceZoneID_.index()
                 )
                 {
-                    masterStickOutFaceMap.insert(curFaces[facei]);
+                    stickOutFaceMap.insert(facei);
                 }
             }
         }
 
-        masterStickOutFacesPtr_ = new labelList(masterStickOutFaceMap.toc());
+        // Sort in debug mode for easier diagnostics
+        if (debug)
+        {
+            masterStickOutFacesPtr_ =
+                new labelList(stickOutFaceMap.sortedToc());
+        }
+        else
+        {
+            masterStickOutFacesPtr_ = new labelList(stickOutFaceMap.toc());
+        }
 
         // Slave side
-        labelHashSet slaveStickOutFaceMap
-        (
-            primitiveMesh::facesPerCell_*(slavePatch.size())
-        );
-
         const labelList& slaveMeshPoints = slavePatch.meshPoints();
 
-        forAll(slaveMeshPoints, pointi)
-        {
-            const labelList& curFaces = pointFaces[slaveMeshPoints[pointi]];
+        stickOutFaceMap.clear();
 
-            forAll(curFaces, facei)
+        for (const label pointi : slaveMeshPoints)
+        {
+            for (const label facei : pointFaces[pointi])
             {
-                // Check if the face belongs to the slave face zone;
-                // if not add it
+                const label zoneIdx = faceZones.whichZone(facei);
+
+                // Add if face not already part of master or slave face zone
+                // This handles partially attached faces.
                 if
                 (
-                    faceZones.whichZone(curFaces[facei])
-                 != slaveFaceZoneID_.index()
+                    zoneIdx != masterFaceZoneID_.index()
+                 && zoneIdx != slaveFaceZoneID_.index()
                 )
                 {
-                    slaveStickOutFaceMap.insert(curFaces[facei]);
+                    stickOutFaceMap.insert(facei);
                 }
             }
         }
 
-        slaveStickOutFacesPtr_ = new labelList(slaveStickOutFaceMap.toc());
+        // Sort in debug mode for easier diagnostics
+        if (debug)
+        {
+            slaveStickOutFacesPtr_ =
+                new labelList(stickOutFaceMap.sortedToc());
+        }
+        else
+        {
+            slaveStickOutFacesPtr_ = new labelList(stickOutFaceMap.toc());
+        }
 
+        stickOutFaceMap.clear();
 
         // Retired point addressing does not exist at this stage.
         // It will be filled when the interface is coupled.
@@ -208,7 +227,6 @@ void Foam::slidingInterface::calcAttachedAddressing() const
             );
 
         // Ditto for cut point edge map.  This is a rough guess of its size
-        //
         cutPointEdgePairMapPtr_ =
             new Map<Pair<edge>>
             (
@@ -224,7 +242,7 @@ void Foam::slidingInterface::calcAttachedAddressing() const
 
     if (debug)
     {
-        Pout<< "void Foam::slidingInterface::calcAttachedAddressing() const "
+        Pout<< FUNCTION_NAME
             << " for object " << name() << " : "
             << "Finished calculating zone face-cell addressing."
             << endl;
diff --git a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C
index 7a0cfe1a08814054a4c6ba1544e3d6220496ac8c..2969cfa1a7c486e5e7a1bf1451d7a731ae83a569 100644
--- a/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C
+++ b/src/dynamicMesh/slidingInterface/slidingInterfaceProjectPoints.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -58,8 +58,8 @@ bool Foam::slidingInterface::projectPoints() const
 {
     if (debug)
     {
-        Pout<< "bool slidingInterface::projectPoints() : "
-            << " for object " << name() << " : "
+        Pout<< FUNCTION_NAME << nl
+            << ": for object " << name() << " : "
             << "Projecting slave points onto master surface." << endl;
     }
 
@@ -126,12 +126,11 @@ bool Foam::slidingInterface::projectPoints() const
     scalarField minMasterPointLength(masterLocalPoints.size(), GREAT);
     scalarField minMasterFaceLength(masterPatch.size(), GREAT);
 
-    forAll(masterEdges, edgeI)
+    forAll(masterEdges, edgei)
     {
-        const edge& curEdge = masterEdges[edgeI];
+        const edge& curEdge = masterEdges[edgei];
 
-        const scalar curLength =
-            masterEdges[edgeI].mag(masterLocalPoints);
+        const scalar curLength = curEdge.mag(masterLocalPoints);
 
         // Do points
         minMasterPointLength[curEdge.start()] =
@@ -149,14 +148,14 @@ bool Foam::slidingInterface::projectPoints() const
             );
 
         // Do faces
-        const labelList& curFaces = masterEdgeFaces[edgeI];
+        const labelList& curFaces = masterEdgeFaces[edgei];
 
-        forAll(curFaces, facei)
+        for (const label facei : curFaces)
         {
-            minMasterFaceLength[curFaces[facei]] =
+            minMasterFaceLength[facei] =
                 min
                 (
-                    minMasterFaceLength[curFaces[facei]],
+                    minMasterFaceLength[facei],
                     curLength
                 );
         }
@@ -169,12 +168,11 @@ bool Foam::slidingInterface::projectPoints() const
     scalarField minSlavePointLength(slaveLocalPoints.size(), GREAT);
     scalarField minSlaveFaceLength(slavePatch.size(), GREAT);
 
-    forAll(slaveEdges, edgeI)
+    forAll(slaveEdges, edgei)
     {
-        const edge& curEdge = slaveEdges[edgeI];
+        const edge& curEdge = slaveEdges[edgei];
 
-        const scalar curLength =
-            slaveEdges[edgeI].mag(slaveLocalPoints);
+        const scalar curLength = curEdge.mag(slaveLocalPoints);
 
         // Do points
         minSlavePointLength[curEdge.start()] =
@@ -192,14 +190,14 @@ bool Foam::slidingInterface::projectPoints() const
             );
 
         // Do faces
-        const labelList& curFaces = slaveEdgeFaces[edgeI];
+        const labelList& curFaces = slaveEdgeFaces[edgei];
 
-        forAll(curFaces, facei)
+        for (const label facei : curFaces)
         {
-            minSlaveFaceLength[curFaces[facei]] =
+            minSlaveFaceLength[facei] =
                 min
                 (
-                    minSlaveFaceLength[curFaces[facei]],
+                    minSlaveFaceLength[facei],
                     curLength
                 );
         }
@@ -219,25 +217,15 @@ bool Foam::slidingInterface::projectPoints() const
             projectionAlgo_
         );
 
-//     Pout<< "USING N-SQUARED!!!" << endl;
-//     List<objectHit> slavePointFaceHits =
-//         projectPointsNSquared<face, List, const pointField&>
-//         (
-//             slavePatch,
-//             masterPatch,
-//             slavePointNormals,
-//             projectionAlgo_
-//         );
-
     if (debug)
     {
         label nHits = 0;
 
-        forAll(slavePointFaceHits, pointi)
+        for (const auto& hit : slavePointFaceHits)
         {
-            if (slavePointFaceHits[pointi].hit())
+            if (hit.hit())
             {
-                nHits++;
+                ++nHits;
             }
         }
 
@@ -247,8 +235,7 @@ bool Foam::slidingInterface::projectPoints() const
     }
 
     // Projected slave points are stored for mesh motion correction
-    if (projectedSlavePointsPtr_) delete projectedSlavePointsPtr_;
-
+    deleteDemandDrivenData(projectedSlavePointsPtr_);
     projectedSlavePointsPtr_ =
         new pointField(slavePointFaceHits.size(), Zero);
     pointField& projectedSlavePoints = *projectedSlavePointsPtr_;
@@ -380,29 +367,27 @@ bool Foam::slidingInterface::projectPoints() const
 
         // Check for zero-length edges in slave projection
         scalar minEdgeLength = GREAT;
-        scalar el = 0;
         label nShortEdges = 0;
 
-        forAll(slaveEdges, edgeI)
+        for (const edge& e : slaveEdges)
         {
-            el = slaveEdges[edgeI].mag(projectedSlavePoints);
+            const scalar len = e.mag(projectedSlavePoints);
+            minEdgeLength = min(minEdgeLength, len);
 
-            if (el < SMALL)
+            if (len < SMALL)
             {
                 Pout<< "Point projection problems for edge: "
-                    << slaveEdges[edgeI] << ". Length = " << el
+                    << e << ". Length = " << len
                     << endl;
 
                 nShortEdges++;
             }
-
-            minEdgeLength = min(minEdgeLength, el);
         }
 
         if (nShortEdges > 0)
         {
             FatalErrorInFunction
-                << " short projected edges "
+                << nShortEdges << " short projected edges "
                 << "after adjustment for object " << name()
                 << abort(FatalError);
         }
@@ -439,10 +424,10 @@ bool Foam::slidingInterface::projectPoints() const
     {
         if (slavePointFaceHits[pointi].hit())
         {
-            // Taking a non-const reference so the point can be adjusted
+            // Use non-const reference so the point can be adjusted
             point& curPoint = projectedSlavePoints[pointi];
 
-            // Get the hit face
+            // Get the hit face (on master)
             const face& hitFace =
                 masterLocalFaces[slavePointFaceHits[pointi].hitObject()];
 
@@ -450,10 +435,10 @@ bool Foam::slidingInterface::projectPoints() const
             scalar mergeDist = GREAT;
 
             // Try all point before deciding on best fit.
-            forAll(hitFace, hitPointi)
+            for (const label hitPointi : hitFace)
             {
-                scalar dist =
-                    mag(masterLocalPoints[hitFace[hitPointi]] - curPoint);
+                const scalar dist =
+                    mag(masterLocalPoints[hitPointi] - curPoint);
 
                 // Calculate the tolerance
                 const scalar mergeTol =
@@ -461,12 +446,12 @@ bool Foam::slidingInterface::projectPoints() const
                     min
                     (
                         minSlavePointLength[pointi],
-                        minMasterPointLength[hitFace[hitPointi]]
+                        minMasterPointLength[hitPointi]
                     );
 
                 if (dist < mergeTol && dist < mergeDist)
                 {
-                    mergePoint = hitFace[hitPointi];
+                    mergePoint = hitPointi;
                     mergeDist = dist;
 
 //                     Pout<< "Merging slave point "
@@ -481,12 +466,17 @@ bool Foam::slidingInterface::projectPoints() const
 
             if (mergePoint > -1)
             {
-                // Point is to be merged with master point
+                // Slave point is to be merged with master point.
+                // This may also include a false positive when the two points
+                // already point to the same global point, but this will need
+                // to be addressed by the caller.
                 nMergedPoints++;
 
                 slavePointPointHits[pointi] = mergePoint;
-                curPoint = masterLocalPoints[mergePoint];
                 masterPointPointHits[mergePoint] = pointi;
+
+                // Adjust (snap) slave point
+                curPoint = masterLocalPoints[mergePoint];
             }
         }
     }
@@ -498,20 +488,18 @@ bool Foam::slidingInterface::projectPoints() const
     {
         // Check for zero-length edges in slave projection
         scalar minEdgeLength = GREAT;
-        scalar el = 0;
 
-        forAll(slaveEdges, edgeI)
+        for (const edge& e : slaveEdges)
         {
-            el = slaveEdges[edgeI].mag(projectedSlavePoints);
+            const scalar len = e.mag(projectedSlavePoints);
+            minEdgeLength = min(minEdgeLength, len);
 
-            if (el < SMALL)
+            if (len < SMALL)
             {
                 Pout<< "Point projection problems for edge: "
-                    << slaveEdges[edgeI] << ". Length = " << el
+                    << e << ". Length = " << len
                     << endl;
             }
-
-            minEdgeLength = min(minEdgeLength, el);
         }
 
         if (minEdgeLength < SMALL)
@@ -556,16 +544,16 @@ bool Foam::slidingInterface::projectPoints() const
 
             scalar minDistance = GREAT;
 
-            forAll(hitFaceEdges, edgeI)
+            for (const label edgei : hitFaceEdges)
             {
-                const edge& curEdge = masterEdges[hitFaceEdges[edgeI]];
+                const edge& curEdge = masterEdges[edgei];
 
                 pointHit edgeHit =
                     curEdge.line(masterLocalPoints).nearestDist(curPoint);
 
                 if (edgeHit.hit())
                 {
-                    scalar dist =
+                    const scalar dist =
                         mag(edgeHit.hitPoint() - projectedSlavePoints[pointi]);
 
                     if (dist < mergeTol && dist < minDistance)
@@ -573,7 +561,7 @@ bool Foam::slidingInterface::projectPoints() const
                         // Point is to be moved onto master edge
                         nMovedPoints++;
 
-                        slavePointEdgeHits[pointi] = hitFaceEdges[edgeI];
+                        slavePointEdgeHits[pointi] = edgei;
                         projectedSlavePoints[pointi] = edgeHit.hitPoint();
 
                         minDistance = dist;
@@ -582,7 +570,7 @@ bool Foam::slidingInterface::projectPoints() const
 //                             << slavePatch.meshPoints()[pointi]
 //                             << " (" << pointi
 //                             << ") at " << slaveLocalPoints[pointi]
-//                             << " onto master edge " << hitFaceEdges[edgeI]
+//                             << " onto master edge " << edgei
 //                             << " or ("
 //                             << masterLocalPoints[curEdge.start()]
 //                             << masterLocalPoints[curEdge.end()]
@@ -607,7 +595,7 @@ bool Foam::slidingInterface::projectPoints() const
 
                 forAll(hitMasterEdge, hmeI)
                 {
-                    scalar hmeDist =
+                    const scalar hmeDist =
                         mag(masterLocalPoints[hitMasterEdge[hmeI]] - curPoint);
 
                     // Calculate the tolerance
@@ -660,27 +648,25 @@ bool Foam::slidingInterface::projectPoints() const
 
         // Check for zero-length edges in slave projection
         scalar minEdgeLength = GREAT;
-        scalar el = 0;
 
-        forAll(slaveEdges, edgeI)
+        for (const edge& e : slaveEdges)
         {
-            el = slaveEdges[edgeI].mag(projectedSlavePoints);
+            const scalar len = e.mag(projectedSlavePoints);
+            minEdgeLength = min(minEdgeLength, len);
 
-            if (el < SMALL)
+            if (len < SMALL)
             {
                 Pout<< "Point projection problems for edge: "
-                    << slaveEdges[edgeI] << ". Length = " << el
+                    << e << ". Length = " << len
                     << endl;
             }
-
-            minEdgeLength = min(minEdgeLength, el);
         }
 
         if (minEdgeLength < SMALL)
         {
             FatalErrorInFunction
-            << " after correction for object " << name()
-            << abort(FatalError);
+                << " after correction for object " << name()
+                << abort(FatalError);
         }
     }
 
@@ -747,25 +733,19 @@ bool Foam::slidingInterface::projectPoints() const
 
     labelHashSet addedFaces(2*primitiveMesh::edgesPerFace_);
 
-    forAll(slaveEdges, edgeI)
+    forAll(slaveEdges, edgei)
     {
-        const edge& curEdge = slaveEdges[edgeI];
+        const edge& curEdge = slaveEdges[edgei];
 
         {
-            // Clear the maps
-            curFaceMap.clear();
-            addedFaces.clear();
-
             // Grab the faces for start and end points
             const label startFace =
                 slavePointFaceHits[curEdge.start()].hitObject();
-            const label endFace = slavePointFaceHits[curEdge.end()].hitObject();
 
-            // Insert the start face into the list
-            curFaceMap.insert(startFace);
-            addedFaces.insert(startFace);
+            const label endFace =
+                slavePointFaceHits[curEdge.end()].hitObject();
 
-            // Pout<< "Doing edge " << edgeI
+            // Pout<< "Doing edge " << edgei
             //     << " or " << curEdge
             //     << " start: "
             //     << slavePointFaceHits[curEdge.start()].hitObject()
@@ -774,46 +754,59 @@ bool Foam::slidingInterface::projectPoints() const
             //     << endl;
 
             // If the end face is on the list, the face collection is finished
-            label nSweeps = 0;
             bool completed = false;
 
-            while (nSweeps < edgeFaceEscapeLimit_)
+            if (!completed)
             {
-                nSweeps++;
+                // Forward sweep
 
-                if (addedFaces.found(endFace))
-                {
-                    completed = true;
-                }
-
-                // Add all face neighbours of face in the map
-                const labelList cf = addedFaces.toc();
+                // Clear the maps
+                curFaceMap.clear();
                 addedFaces.clear();
 
-                forAll(cf, cfI)
+                // Insert the start face into the list
+                curFaceMap.insert(startFace);
+                addedFaces.insert(startFace);
+
+                for
+                (
+                    label nSweeps = 0;
+                    nSweeps < edgeFaceEscapeLimit_;
+                    ++nSweeps
+                )
                 {
-                    const labelList& curNbrs = masterFaceFaces[cf[cfI]];
+                    completed = addedFaces.found(endFace);
+
+                    // Add all face neighbours of face in the map
+                    const labelList cf(addedFaces.toc());
+                    addedFaces.clear();
 
-                    forAll(curNbrs, nbrI)
+                    for (const label cfi : cf)
                     {
-                        if (!curFaceMap.found(curNbrs[nbrI]))
+                        const labelList& curNbrs = masterFaceFaces[cfi];
+
+                        for (const label nbri : curNbrs)
                         {
-                            curFaceMap.insert(curNbrs[nbrI]);
-                            addedFaces.insert(curNbrs[nbrI]);
+                            if (curFaceMap.insert(nbri))
+                            {
+                                addedFaces.insert(nbri);
+                            }
                         }
                     }
-                }
 
-                if (completed) break;
+                    if (completed) break;
 
-                if (debug)
-                {
-                    Pout<< ".";
+                    if (debug)
+                    {
+                        Pout<< ".";
+                    }
                 }
             }
 
             if (!completed)
             {
+                // Reverse sweep
+
                 if (debug)
                 {
                     Pout<< "x";
@@ -822,35 +815,32 @@ bool Foam::slidingInterface::projectPoints() const
                 // It is impossible to reach the end from the start, probably
                 // due to disconnected domain.  Do search in opposite direction
 
-                label nReverseSweeps = 0;
-
                 addedFaces.clear();
                 curFaceMap.insert(endFace);
                 addedFaces.insert(endFace);
 
-                while (nReverseSweeps < edgeFaceEscapeLimit_)
+                for
+                (
+                    label nSweeps = 0;
+                    nSweeps < edgeFaceEscapeLimit_;
+                    ++nSweeps
+                )
                 {
-                    nReverseSweeps++;
-
-                    if (addedFaces.found(startFace))
-                    {
-                        completed = true;
-                    }
+                    completed = addedFaces.found(startFace);
 
                     // Add all face neighbours of face in the map
-                    const labelList cf = addedFaces.toc();
+                    const labelList cf(addedFaces.toc());
                     addedFaces.clear();
 
-                    forAll(cf, cfI)
+                    for (const label cfi : cf)
                     {
-                        const labelList& curNbrs = masterFaceFaces[cf[cfI]];
+                        const labelList& curNbrs = masterFaceFaces[cfi];
 
-                        forAll(curNbrs, nbrI)
+                        for (const label nbri : curNbrs)
                         {
-                            if (!curFaceMap.found(curNbrs[nbrI]))
+                            if (curFaceMap.insert(nbri))
                             {
-                                curFaceMap.insert(curNbrs[nbrI]);
-                                addedFaces.insert(curNbrs[nbrI]);
+                                addedFaces.insert(nbri);
                             }
                         }
                     }
@@ -887,16 +877,11 @@ bool Foam::slidingInterface::projectPoints() const
                 nFacesPerSlaveEdge_*primitiveMesh::pointsPerFace_
             );
 
-            const labelList curFaces = curFaceMap.toc();
-//             Pout<< "curFaces: " << curFaces << endl;
-            forAll(curFaces, facei)
+            for (const label facei : curFaceMap)
             {
-                const face& f = masterLocalFaces[curFaces[facei]];
+                const face& f = masterLocalFaces[facei];
 
-                forAll(f, pointi)
-                {
-                    curPointMap.insert(f[pointi]);
-                }
+                curPointMap.insert(f);  // Insert all face points
             }
 
             const labelList curMasterPoints = curPointMap.toc();
@@ -912,7 +897,7 @@ bool Foam::slidingInterface::projectPoints() const
             // is used to reject master points out of reach.
             // Calculated as a combination of travel distance in projection and
             // edge length
-            scalar slaveCatchDist =
+            const scalar slaveCatchDist =
                 edgeMasterCatchFraction_*edgeMag
               + 0.5*
                 (
@@ -945,10 +930,8 @@ bool Foam::slidingInterface::projectPoints() const
 
             edgeNormalInPlane /= mag(edgeNormalInPlane);
 
-            forAll(curMasterPoints, pointi)
+            for (const label cmp : curMasterPoints)
             {
-                const label cmp = curMasterPoints[pointi];
-
                 // Skip the current point if the edge start or end has
                 // been adjusted onto in
                 if
@@ -974,11 +957,11 @@ bool Foam::slidingInterface::projectPoints() const
 
                     // Strict checking of slave cut to avoid capturing
                     // end points.
-                    scalar cutOnSlave =
+                    const scalar cutOnSlave =
                         ((edgeLineHit.hitPoint() - edgeLine.start()) & edgeVec)
                         /sqr(edgeMag);
 
-                    scalar distInEdgePlane =
+                    const scalar distInEdgePlane =
                         min
                         (
                             edgeLineHit.distance(),
@@ -1032,14 +1015,14 @@ bool Foam::slidingInterface::projectPoints() const
                         }
 
                         // Snap to point onto edge
-                        masterPointEdgeHits[cmp] = edgeI;
+                        masterPointEdgeHits[cmp] = edgei;
                         masterPointEdgeDist[cmp] = edgeLineHit.distance();
 
 //                         Pout<< "Inserting master point "
 //                             << masterPatch.meshPoints()[cmp]
 //                             << " (" << cmp
 //                             << ") at " << masterLocalPoints[cmp]
-//                             << " into slave edge " << edgeI
+//                             << " into slave edge " << edgei
 //                             << " " << curEdge
 //                             << " cutOnSlave: " << cutOnSlave
 //                             << " distInEdgePlane: " << distInEdgePlane
@@ -1096,16 +1079,20 @@ bool Foam::slidingInterface::projectPoints() const
 
         // Store the addressing arrays and projected points
         deleteDemandDrivenData(slavePointPointHitsPtr_);
-        slavePointPointHitsPtr_ = new labelList(slavePointPointHits);
+        slavePointPointHitsPtr_ = new labelList();
+        slavePointPointHitsPtr_->transfer(slavePointPointHits);
 
         deleteDemandDrivenData(slavePointEdgeHitsPtr_);
-        slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits);
+        slavePointEdgeHitsPtr_ = new labelList();
+        slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits);
 
         deleteDemandDrivenData(slavePointFaceHitsPtr_);
-        slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits);
+        slavePointFaceHitsPtr_ = new List<objectHit>();
+        slavePointFaceHitsPtr_->transfer(slavePointFaceHits);
 
         deleteDemandDrivenData(masterPointEdgeHitsPtr_);
-        masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits);
+        masterPointEdgeHitsPtr_ = new labelList();
+        masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits);
 
         if (debug)
         {
@@ -1128,16 +1115,20 @@ bool Foam::slidingInterface::projectPoints() const
         {
             // Must be restart.  Force topological change.
             deleteDemandDrivenData(slavePointPointHitsPtr_);
-            slavePointPointHitsPtr_ = new labelList(slavePointPointHits);
+            slavePointPointHitsPtr_ = new labelList();
+            slavePointPointHitsPtr_->transfer(slavePointPointHits);
 
             deleteDemandDrivenData(slavePointEdgeHitsPtr_);
-            slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits);
+            slavePointEdgeHitsPtr_ = new labelList();
+            slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits);
 
             deleteDemandDrivenData(slavePointFaceHitsPtr_);
-            slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits);
+            slavePointFaceHitsPtr_ = new List<objectHit>();
+            slavePointFaceHitsPtr_->transfer(slavePointFaceHits);
 
             deleteDemandDrivenData(masterPointEdgeHitsPtr_);
-            masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits);
+            masterPointEdgeHitsPtr_ = new labelList();
+            masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits);
 
             if (debug)
             {
@@ -1218,16 +1209,20 @@ bool Foam::slidingInterface::projectPoints() const
         {
             // Grab new data
             deleteDemandDrivenData(slavePointPointHitsPtr_);
-            slavePointPointHitsPtr_ = new labelList(slavePointPointHits);
+            slavePointPointHitsPtr_ = new labelList();
+            slavePointPointHitsPtr_->transfer(slavePointPointHits);
 
             deleteDemandDrivenData(slavePointEdgeHitsPtr_);
-            slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits);
+            slavePointEdgeHitsPtr_ = new labelList();
+            slavePointEdgeHitsPtr_->transfer(slavePointEdgeHits);
 
             deleteDemandDrivenData(slavePointFaceHitsPtr_);
-            slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits);
+            slavePointFaceHitsPtr_ = new List<objectHit>();
+            slavePointFaceHitsPtr_->transfer(slavePointFaceHits);
 
             deleteDemandDrivenData(masterPointEdgeHitsPtr_);
-            masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits);
+            masterPointEdgeHitsPtr_ = new labelList();
+            masterPointEdgeHitsPtr_->transfer(masterPointEdgeHits);
 
             if (debug)
             {
diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files
index abdef097789a7e2e7b2ca7ce1b67bbad24e20fe6..db88df52ae7abd5bd5f9f49e836c00cc74db6c03 100644
--- a/src/finiteVolume/Make/files
+++ b/src/finiteVolume/Make/files
@@ -93,6 +93,10 @@ $(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C
 
 functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C
 functionObjects/volRegion/volRegion.C
+functionObjects/fieldSelection/fieldSelection.C
+functionObjects/fieldSelection/fileFieldSelection.C
+functionObjects/fieldSelection/volFieldSelection.C
+functionObjects/fieldSelection/solverFieldSelection.C
 
 fvPatchFields = fields/fvPatchFields
 $(fvPatchFields)/fvPatchField/fvPatchFields.C
diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C
index b1f64847c586cf1c038cea5b1f40ff248f93e6ac..541b9b0d29c942fd9edd5efe7bb603e633c6c749 100644
--- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C
+++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C
@@ -571,21 +571,20 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const
 void Foam::MRFZone::writeData(Ostream& os) const
 {
     os  << nl;
-    os.write(name_) << nl;
-    os  << token::BEGIN_BLOCK << incrIndent << nl;
-    os.writeKeyword("active") << active_ << token::END_STATEMENT << nl;
-    os.writeKeyword("cellZone") << cellZoneName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
+    os.beginBlock(name_);
+
+    os.writeEntry("active", active_);
+    os.writeEntry("cellZone", cellZoneName_);
+    os.writeEntry("origin", origin_);
+    os.writeEntry("axis", axis_);
     omega_->writeData(os);
 
     if (excludedPatchNames_.size())
     {
-        os.writeKeyword("nonRotatingPatches") << excludedPatchNames_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("nonRotatingPatches", excludedPatchNames_);
     }
 
-    os  << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H b/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H
index 1b6499934fe6532db5459e7566d4f0ce72cf564e..1adaed982b6beac8624a17f24c4c6a5b0db15c73 100644
--- a/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H
+++ b/src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm/rpm.H
@@ -33,8 +33,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef SRFModelRpm_H
-#define SRFModelRpm_H
+#ifndef SRF_rpm_H
+#define SRF_rpm_H
 
 #include "SRFModel.H"
 
diff --git a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C
index 6749dfb74943d093e4f5139472ad698033e2c4e5..8f33573a0ff575783210dd243bc824299f11b3ef 100644
--- a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFFreestreamVelocityFvPatchVectorField/SRFFreestreamVelocityFvPatchVectorField.C
@@ -158,9 +158,9 @@ void Foam::SRFFreestreamVelocityFvPatchVectorField::updateCoeffs()
 void Foam::SRFFreestreamVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("relative") << relative_ << token::END_STATEMENT << nl;
-    os.writeKeyword("UInf") << UInf_ << token::END_STATEMENT << nl;
-    os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl;
+    os.writeEntry("relative", relative_);
+    os.writeEntry("UInf", UInf_);
+    os.writeEntry("phi", this->phiName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
index ba3a0457269c5797892d14affd7577550d78ecf9..590c53900881f88f67452070457575cf34fc4caf 100644
--- a/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
@@ -153,7 +153,7 @@ void Foam::SRFVelocityFvPatchVectorField::updateCoeffs()
 void Foam::SRFVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("relative") << relative_ << token::END_STATEMENT << nl;
+    os.writeEntry("relative", relative_);
     inletValue_.writeEntry("inletValue", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C
index 76042ef02419735ae4363825c05eec369bd79bd9..195d41a6842f31aa155267c533028e86bc9fec24 100644
--- a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C
+++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C
@@ -112,7 +112,7 @@ bool Foam::fv::option::isActive()
 
 Foam::label Foam::fv::option::applyToField(const word& fieldName) const
 {
-    return findIndex(fieldNames_, fieldName);
+    return fieldNames_.find(fieldName);
 }
 
 
diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C
index 88730167b863aa358ce6d30ffa98ce916759c8e8..36a87ffec4241b788b52f7c126a5e5ac59d51771 100644
--- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C
+++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionIO.C
@@ -29,24 +29,23 @@ License
 
 void Foam::fv::option::writeHeader(Ostream& os) const
 {
-    os  << indent << name_ << nl
-        << indent << token::BEGIN_BLOCK << incrIndent << nl;
+    os.beginBlock(name_);
 }
 
 
 void Foam::fv::option::writeFooter(Ostream& os) const
 {
-    os  << decrIndent << indent << token::END_BLOCK << endl;
+    os.endBlock();
 }
 
 
 void Foam::fv::option::writeData(Ostream& os) const
 {
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
-    os.writeKeyword("active") << active_ << token::END_STATEMENT << nl << nl;
+    os.writeEntry("type", type());
+    os.writeEntry("active", active_);
 
-    os << indent << word(type() + "Coeffs");
-    coeffs_.write(os);
+    os << nl;
+    coeffs_.writeEntry(word(type() + "Coeffs"), os);
 }
 
 
diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H
index 3d4ffefe3577299603cbd779c229f0df3845d13b..a173f7c6dda46f8c5cadfe2bda3752a1f21a9d33 100644
--- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H
+++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef options_H
-#define options_H
+#ifndef fv_options_H
+#define fv_options_H
 
 #include "fvOptionList.H"
 #include "IOdictionary.H"
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
index 18213659c7674dc484d1e76d8b8ce46ce74b7297..4761e61da7e4cfc2fb1e07fde2a96f39661b5005 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C
@@ -292,18 +292,12 @@ void Foam::activeBaffleVelocityFvPatchVectorField::updateCoeffs()
 void Foam::activeBaffleVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
-    os.writeKeyword("cyclicPatch")
-        << cyclicPatchName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("orientation")
-        << orientation_ << token::END_STATEMENT << nl;
-    os.writeKeyword("openingTime")
-        << openingTime_ << token::END_STATEMENT << nl;
-    os.writeKeyword("maxOpenFractionDelta")
-        << maxOpenFractionDelta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("openFraction")
-        << openFraction_ << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
+    os.writeEntry("cyclicPatch", cyclicPatchName_);
+    os.writeEntry("orientation", orientation_);
+    os.writeEntry("openingTime", openingTime_);
+    os.writeEntry("maxOpenFractionDelta", maxOpenFractionDelta_);
+    os.writeEntry("openFraction", openFraction_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C
index 438d135ff8d4b05cb0ba94934da7e35648b9e91f..a0f66f5739cc4e53c2d3b473d3b35e35a0789d30 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C
@@ -377,21 +377,14 @@ void Foam::activePressureForceBaffleVelocityFvPatchVectorField::
 write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
-    os.writeKeyword("cyclicPatch")
-        << cyclicPatchName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("openingTime")
-        << openingTime_ << token::END_STATEMENT << nl;
-    os.writeKeyword("maxOpenFractionDelta")
-        << maxOpenFractionDelta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("openFraction")
-        << openFraction_ << token::END_STATEMENT << nl;
-    os.writeKeyword("minThresholdValue")
-        << minThresholdValue_ << token::END_STATEMENT << nl;
-    os.writeKeyword("forceBased")
-        << fBased_ << token::END_STATEMENT << nl;
-    os.writeKeyword("opening")
-        << opening_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
+    os.writeEntry("cyclicPatch", cyclicPatchName_);
+    os.writeEntry("openingTime", openingTime_);
+    os.writeEntry("maxOpenFractionDelta", maxOpenFractionDelta_);
+    os.writeEntry("openFraction", openFraction_);
+    os.writeEntry("minThresholdValue", minThresholdValue_);
+    os.writeEntry("forceBased", fBased_);
+    os.writeEntry("opening", opening_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C
index aa86f9936c0bb92797752f68210d346b13565276..fe7567c9afea1901b2dd6dbfeb02daa8893a6df3 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C
@@ -339,13 +339,13 @@ void Foam::advectiveFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
 
-    this->template writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    this->template writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
 
     if (lInf_ > 0)
     {
-        os.writeKeyword("fieldInf") << fieldInf_ << token::END_STATEMENT << nl;
-        os.writeKeyword("lInf") << lInf_ << token::END_STATEMENT << nl;
+        os.writeEntry("fieldInf", fieldInf_);
+        os.writeEntry("lInf", lInf_);
     }
 
     this->writeEntry("value", os);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
index 12ab03384797bdb48fb766cd0b669508674121f0..2081404eac35b45cd95332e2268ac1488e570c88 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
@@ -268,8 +268,7 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
         // Make sure to construct the patchfield with up-to-date value
 
         OStringStream os;
-        os.writeKeyword("type") << name_ << token::END_STATEMENT
-            << nl;
+        os.writeEntry("type", name_);
         static_cast<const Field<Type>&>(*this).writeEntry("value", os);
         IStringStream is(os.str());
         dictionary dict(is);
@@ -331,8 +330,7 @@ template<class Type>
 void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const
 {
     fixedValueFvPatchField<Type>::write(os);
-    os.writeKeyword("name") << name_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("name", name_);
 
     codedBase::writeCodeDict(os, dict_);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
index 0dd3600e585be67f93b1b8883df2381758598290..6bbdb3c5a47a696773496e056b0b77e72d351756 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
@@ -343,8 +343,7 @@ template<class Type>
 void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
 {
     mixedFvPatchField<Type>::write(os);
-    os.writeKeyword("name") << name_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("name", name_);
 
     codedBase::writeCodeDict(os, dict_);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C
index d6223500e0d3d8a3d890fc7c83cf34f1f32c8dd8..31a67024a518c0203657eece4eca3ce002decea1 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C
@@ -147,8 +147,8 @@ void Foam::cylindricalInletVelocityFvPatchVectorField::updateCoeffs()
 void Foam::cylindricalInletVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchField<vector>::write(os);
-    os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
-    os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
+    os.writeEntry("centre", centre_);
+    os.writeEntry("axis", axis_);
     axialVelocity_->writeData(os);
     radialVelocity_->writeData(os);
     rpm_->writeData(os);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C
index e22d979213da147e8dcc874cf3ce2182d4003394..6e11699890657c5fd4b008c20758a9ff3a352cab 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C
@@ -132,12 +132,9 @@ template<class Type>
 void Foam::fanFvPatchField<Type>::write(Ostream& os) const
 {
     uniformJumpFvPatchField<Type>::write(os);
-    this->template writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    this->template writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    this->template writeEntryIfDifferent<bool>
-    (
-        os, "uniformJump", false, uniformJump_
-    );
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<bool>("uniformJump", false, uniformJump_);
 }
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H
index 1bdaee71b8aef270a01847f932963de639984295..9a1f051bf7ea0d74723dfdeb71d6d6e99ce0e319 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxExtrapolatedPressure/fixedFluxExtrapolatedPressureFvPatchScalarField.H
@@ -48,8 +48,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef fixedFluxExtrapolatedPressureFvPatchScalarFields_H
-#define fixedFluxExtrapolatedPressureFvPatchScalarFields_H
+#ifndef fixedFluxExtrapolatedPressureFvPatchScalarField_H
+#define fixedFluxExtrapolatedPressureFvPatchScalarField_H
 
 #include "fixedFluxPressureFvPatchScalarField.H"
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H
index aaafe055a900c897afb9c3b39b22d0828478143f..94bfcf9feeefdbaecf51fd294bb8de6206259e55 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H
@@ -48,8 +48,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef fixedFluxPressureFvPatchScalarFields_H
-#define fixedFluxPressureFvPatchScalarFields_H
+#ifndef fixedFluxPressureFvPatchScalarField_H
+#define fixedFluxPressureFvPatchScalarField_H
 
 #include "fvPatchFields.H"
 #include "fixedGradientFvPatchFields.H"
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C
index 52764fc6a3d6a8fcc4abad4507bc80b3cb0754b9..726084c732a4f38670f6b320c40d1a214051b636 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C
@@ -155,8 +155,7 @@ template<class Type>
 void Foam::fixedJumpFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    os.writeKeyword("patchType") << this->interfaceFieldType()
-        << token::END_STATEMENT << nl;
+    os.writeEntry("patchType", this->interfaceFieldType());
 
     if (this->cyclicPatch().owner())
     {
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C
index 2229069a14dac4f0bcc98710c8cf9e05b91f0353..d043e573c310d1064f5d47713283e456d6e4f298 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C
@@ -169,8 +169,7 @@ template<class Type>
 void Foam::fixedJumpAMIFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    os.writeKeyword("patchType") << this->interfaceFieldType()
-        << token::END_STATEMENT << nl;
+    os.writeEntry("patchType", this->interfaceFieldType());
 
     if (this->cyclicAMIPatch().owner())
     {
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C
index e2c2669d2e0987d2aece1c2b67e7b5385029b776..1155c5d022f8ebb9be4be3ed8c7c04c3327f0d66 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedNormalInletOutletVelocity/fixedNormalInletOutletVelocityFvPatchVectorField.C
@@ -181,13 +181,13 @@ void Foam::fixedNormalInletOutletVelocityFvPatchVectorField::write
 const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    os.writeKeyword("fixTangentialInflow")
-        << fixTangentialInflow_ << token::END_STATEMENT << nl;
-    os.writeKeyword("normalVelocity")
-        << nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntry("fixTangentialInflow", fixTangentialInflow_);
+
+    os.beginBlock("normalVelocity");
     normalVelocity_->write(os);
-    os << decrIndent << indent << token::END_BLOCK << endl;
+    os.endBlock();
+
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C
index 6190926fc8c4f279eda9c839d0cbecfadbfe6a84..cc1b0f4ff93e58158e795c386419b8772d5a6b77 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C
@@ -128,7 +128,7 @@ void Foam::fixedPressureCompressibleDensityFvPatchScalarField::write
 ) const
 {
     fvPatchField<scalar>::write(os);
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C
index be52334338351d2a6153861a75064c6d6ea45d6f..1deba5890f7824ffbf344ede020aa7aa93829e1c 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedProfile/fixedProfileFvPatchField.C
@@ -158,8 +158,8 @@ void Foam::fixedProfileFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
     profile_->writeData(os);
-    os.writeKeyword("direction") << dir_ << token::END_STATEMENT << nl;
-    os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
+    os.writeEntry("direction", dir_);
+    os.writeEntry("origin", origin_);
     this->writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C
index d42e353b693017412088e798314203ad496690d3..f40f399ad344ba7f9d8394a7c5ff4f418edf20bf 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C
@@ -169,7 +169,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateValues
         Up -= nUp*n;
 
         // Remove any reverse flow
-        nUp = min(nUp, 0.0);
+        nUp = min(nUp, scalar(0.0));
 
         const scalar flowRate = flowRate_->value(t);
         const scalar estimatedFlowRate = -gSum(rho*(this->patch().magSf()*nUp));
@@ -243,11 +243,10 @@ void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
     flowRate_->writeData(os);
     if (!volumetric_)
     {
-        writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-        writeEntryIfDifferent<scalar>(os, "rhoInlet", -VGREAT, rhoInlet_);
+        os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+        os.writeEntryIfDifferent<scalar>("rhoInlet", -VGREAT, rhoInlet_);
     }
-    os.writeKeyword("extrapolateProfile")
-        << extrapolateProfile_ << token::END_STATEMENT << nl;
+    os.writeEntry("extrapolateProfile", extrapolateProfile_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C
index cf331d9b7e0ae31af85132734b80563f1d79d725..ed9d095a2a1353753201fcd6f14a5fc48fff57a9 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C
@@ -160,7 +160,7 @@ void Foam::flowRateOutletVelocityFvPatchVectorField::updateValues
     Up -= nUp*n;
 
     // Remove any reverse flow
-    nUp = max(nUp, 0.0);
+    nUp = max(nUp, scalar(0.0));
 
     const scalar flowRate = flowRate_->value(t);
     const scalar estimatedFlowRate = gSum(rho*(this->patch().magSf()*nUp));
@@ -228,8 +228,8 @@ void Foam::flowRateOutletVelocityFvPatchVectorField::write(Ostream& os) const
     flowRate_->writeData(os);
     if (!volumetric_)
     {
-        writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-        writeEntryIfDifferent<scalar>(os, "rhoOutlet", -VGREAT, rhoOutlet_);
+        os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+        os.writeEntryIfDifferent<scalar>("rhoOutlet", -VGREAT, rhoOutlet_);
     }
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C
index 10124ec9f83717ee7fc1eb96b17ba28ffe144921..217b6734604f901d8fe6bb5bfbd51d5bf869a850 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C
@@ -138,8 +138,8 @@ void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate
 void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C
index 49ae3f5b27a484b0fa0fa1c31c417c9eac748639..eac0fe4feb00f4c75aaa6654d522658cf5fd8ebf 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/freestream/freestreamFvPatchField.C
@@ -108,11 +108,7 @@ template<class Type>
 void Foam::freestreamFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    if (this->phiName_ != "phi")
-    {
-        os.writeKeyword("phi")
-            << this->phiName_ << token::END_STATEMENT << nl;
-    }
+    os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
     freestreamValue().writeEntry("freestreamValue", os);
     this->writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C
index 1c8787e5e46fcdb860ecc6cbe0eedb772f65c551..1986bc40d68796e043fad7391894a2ad6b785af0 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C
@@ -156,9 +156,9 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs()
 void Foam::freestreamPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H
index e8b5f28114b5e155d9c44861bc5713be80652c6f..950e890845078e1c4c55c8233f2b50a3d0770090 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.H
@@ -60,8 +60,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef freestreamPressureFvPatchScalarFields_H
-#define freestreamPressureFvPatchScalarFields_H
+#ifndef freestreamPressureFvPatchScalarField_H
+#define freestreamPressureFvPatchScalarField_H
 
 #include "fvPatchFields.H"
 #include "zeroGradientFvPatchFields.H"
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C
index 49aa47efad401031a068edfee69fe4ef4cda2272..59654abb923cc240e96ba864735465459c2eb89b 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C
@@ -138,10 +138,7 @@ template<class Type>
 void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    if (phiName_ != "phi")
-    {
-        os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    }
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
     this->refValue().writeEntry("inletValue", os);
     this->writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C
index 5735ee62229af812716d1e8023c2b7ee5a7a748a..679cb1205525898ba1752a224f0419fb0b34dda1 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C
@@ -189,10 +189,10 @@ void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
 const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
-    writeEntryIfDifferent<word>(os, "psi", "psi", psiName_);
-    os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
+    os.writeEntryIfDifferent<word>("psi", "psi", psiName_);
+    os.writeEntry("gamma", gamma_);
     T0_.writeEntry("T0", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C
index 00f2a8307efe7c840f6d3e24ba64f982b36cb7a3..057be9e92133489d89872115ba6796bb4acec5dc 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/interstitialInletVelocity/interstitialInletVelocityFvPatchVectorField.C
@@ -143,7 +143,7 @@ void Foam::interstitialInletVelocityFvPatchVectorField::updateCoeffs()
 void Foam::interstitialInletVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchField<vector>::write(os);
-    writeEntryIfDifferent<word>(os, "alpha", "alpha", alphaName_);
+    os.writeEntryIfDifferent<word>("alpha", "alpha", alphaName_);
     inletVelocity_.writeEntry("inletVelocity", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C
index 52072044ccfcde88cfb8a564df28fe5804a88cdc..11349a08ca668c2339a0deb0c9b09fc20763dec4 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C
@@ -314,11 +314,10 @@ tmp<Field<Type>> mappedPatchFieldBase<Type>::mappedField() const
 template<class Type>
 void mappedPatchFieldBase<Type>::write(Ostream& os) const
 {
-    os.writeKeyword("field") << fieldName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl;
-    os.writeKeyword("average") << average_ << token::END_STATEMENT << nl;
-    os.writeKeyword("interpolationScheme") << interpolationScheme_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("field", fieldName_);
+    os.writeEntry("setAverage", setAverage_);
+    os.writeEntry("average", average_);
+    os.writeEntry("interpolationScheme", interpolationScheme_);
 }
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C
index 81cce9b1b52d078b1bb6ab5ca59755d1c5d106f2..27d67c67974276b165371bacb806f0882eb6fbaa 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedFlowRate/mappedFlowRateFvPatchVectorField.C
@@ -186,9 +186,9 @@ void Foam::mappedFlowRateFvPatchVectorField::write
 ) const
 {
     fvPatchField<vector>::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    os.writeKeyword("nbrPhi") << nbrPhiName_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntry("nbrPhi", nbrPhiName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C
index 89c0c11bf7c77707ee6a916ba4883882d0fe6734..e35b556c480f9a7a352409f9d8a6b714e357eb9b 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValueFvPatchField.C
@@ -233,7 +233,7 @@ void Foam::mappedVelocityFluxFixedValueFvPatchField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
     this->writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C
index 4ea359ee5b2470d47534aea006a3c24b4c32d866..30987e05dbbae32a5bd1cf229809b1abd5d2f3ff 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C
@@ -244,13 +244,11 @@ void Foam::matchedFlowRateOutletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchField<vector>::write(os);
-    os.writeKeyword("inletPatch")
-        << inletPatchName_ << token::END_STATEMENT << nl;
+    os.writeEntry("inletPatch", inletPatchName_);
     if (!volumetric_)
     {
-        os.writeKeyword("volumetric")
-            << volumetric_ << token::END_STATEMENT << nl;
-        writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+        os.writeEntry("volumetric", volumetric_);
+        os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     }
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C
index 408b40686b5f37355d89758430236140061440f0..80b94c5383927102582cf02989109e194173fd55 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/outletInlet/outletInletFvPatchField.C
@@ -138,10 +138,7 @@ template<class Type>
 void Foam::outletInletFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    if (phiName_ != "phi")
-    {
-        os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    }
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
     this->refValue().writeEntry("outletValue", os);
     this->writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C
index 6cb337ff099a438be3b8cb4dacc22cea4890dc3c..5490a8a930fd1ce54c08f5a8e966113ebaafcf28 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/outletMappedUniformInlet/outletMappedUniformInletFvPatchField.C
@@ -168,12 +168,8 @@ template<class Type>
 void Foam::outletMappedUniformInletFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    os.writeKeyword("outletPatch")
-        << outletPatchName_ << token::END_STATEMENT << nl;
-    if (phiName_ != "phi")
-    {
-        os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    }
+    os.writeEntry("outletPatch", outletPatchName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
     this->writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C
index f92a4bf136d2798445bb5c8ca86dc20c962279cf..b1fef5b04bee093d7b21d4fb165e14c07479e532 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/outletPhaseMeanVelocity/outletPhaseMeanVelocityFvPatchVectorField.C
@@ -167,10 +167,8 @@ void Foam::outletPhaseMeanVelocityFvPatchVectorField::write
 {
     fvPatchField<vector>::write(os);
 
-    os.writeKeyword("Umean") << Umean_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("alpha") << alphaName_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("Umean", Umean_);
+    os.writeEntry("alpha", alphaName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C
index 0dd82e8c443e61471ba4c15bb0b738a7a3f5891f..a585876bd4acaedae62d54c90f40cf5aa534d13e 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C
@@ -163,14 +163,10 @@ void Foam::phaseHydrostaticPressureFvPatchScalarField::updateCoeffs()
 void Foam::phaseHydrostaticPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    if (phaseFraction_ != "alpha")
-    {
-        os.writeKeyword("phaseFraction")
-            << phaseFraction_ << token::END_STATEMENT << nl;
-    }
-    os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
-    os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
-    os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("phaseFraction", "alpha", phaseFraction_);
+    os.writeEntry("rho", rho_);
+    os.writeEntry("pRefValue", pRefValue_);
+    os.writeEntry("pRefPoint", pRefPoint_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C
index f1dbf71611c96a0137b9f403206d8a40eb499947..8464d32d0d5c3aa7e5e8f6a0311922cdeafc5e7c 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/plenumPressure/plenumPressureFvPatchScalarField.C
@@ -300,32 +300,22 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs()
 void Foam::plenumPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("gamma") << gamma_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("R") << R_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("supplyMassFlowRate") << supplyMassFlowRate_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("supplyTotalTemperature") << supplyTotalTemperature_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("plenumVolume") << plenumVolume_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("plenumDensity") << plenumDensity_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("plenumTemperature") << plenumTemperature_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("gamma", gamma_);
+    os.writeEntry("R", R_);
+    os.writeEntry("supplyMassFlowRate", supplyMassFlowRate_);
+    os.writeEntry("supplyTotalTemperature", supplyTotalTemperature_);
+    os.writeEntry("plenumVolume", plenumVolume_);
+    os.writeEntry("plenumDensity", plenumDensity_);
+    os.writeEntry("plenumTemperature", plenumTemperature_);
     if (hasRho_)
     {
-        os.writeKeyword("rho") << rho_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("rho", rho_);
     }
-    os.writeKeyword("inletAreaRatio") << inletAreaRatio_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("inletDischargeCoefficient") << inletDischargeCoefficient_
-        << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<scalar>(os, "timeScale", 0.0, timeScale_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
+    os.writeEntry("inletAreaRatio", inletAreaRatio_);
+    os.writeEntry("inletDischargeCoefficient", inletDischargeCoefficient_);
+    os.writeEntryIfDifferent<scalar>("timeScale", 0.0, timeScale_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C
index c472c754eb8a7d3bb8da5c0bf8ddddf4b10e124d..d7b72b17bab0f73b6c7df482ca17688075c19ba4 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C
@@ -190,8 +190,8 @@ void Foam::pressureDirectedInletOutletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     inletDir_.writeEntry("inletDirection", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C
index 9ab1bc87ef46b0eb0f47bef14b843be094c7dec3..2d42d60d52228bbaf04a3bc4a059001265c49fea 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C
@@ -178,8 +178,8 @@ void Foam::pressureDirectedInletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     inletDir_.writeEntry("inletDirection", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C
index 84abe77c3f09feaed58c2b5a2b1b7ea771b30ecb..2ddaa235cf79c849f76ec3237bfe00d609713093 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletParSlipVelocity/pressureInletOutletParSlipVelocityFvPatchVectorField.C
@@ -164,8 +164,8 @@ void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C
index 32f8aa2cfb2b2aa47c228b2e94f561d7fbf0214e..84aab726fad829c24924362df5d0d70a99dd9489 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C
@@ -188,7 +188,7 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::write
 const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
     if (tangentialVelocity_.size())
     {
         tangentialVelocity_.writeEntry("tangentialVelocity", os);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
index 06e58e73bb78dbfff02aba60cb19c03aabb6eb76..e1a24d4ba0f22fd0531e22b46a8474fae3cf5a37 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C
@@ -143,8 +143,8 @@ void Foam::pressureInletVelocityFvPatchVectorField::updateCoeffs()
 void Foam::pressureInletVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C
index 84689bf1e9667f0178899c9d8352293669e180c4..08b71bf468d61c648ff6d93094da807e35444e56 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C
@@ -160,8 +160,8 @@ void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
+    os.writeEntry("phi", phiName_);
+    os.writeEntry("rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C
index 9b5e347fbd20ab75f8ccf01673f037b193ae8657..68c6e78cb36a5ea22b5d5dcab2acde79e0d1dccd 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/pressurePIDControlInletVelocity/pressurePIDControlInletVelocityFvPatchVectorField.C
@@ -365,20 +365,17 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::write
 {
     fvPatchField<vector>::write(os);
 
-    os.writeKeyword("deltaP") << deltaP_ << token::END_STATEMENT << nl;
-    os.writeKeyword("upstream") << upstreamName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("downstream")
-        << downstreamName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("shapeFactor") << shapeFactor_
-        << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
-    writeEntryIfDifferent<word>(os, "rho", "none", rhoName_);
-    os.writeKeyword("P") << P_ << token::END_STATEMENT << nl;
-    os.writeKeyword("I") << I_ << token::END_STATEMENT << nl;
-    os.writeKeyword("D") << D_ << token::END_STATEMENT << nl;
-    os.writeKeyword("error") << error_ << token::END_STATEMENT << nl;
-    os.writeKeyword("errorIntegral")
-        << errorIntegral_ << token::END_STATEMENT << nl;
+    os.writeEntry("deltaP", deltaP_);
+    os.writeEntry("upstream", upstreamName_);
+    os.writeEntry("downstream", downstreamName_);
+    os.writeEntry("shapeFactor", shapeFactor_);
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
+    os.writeEntryIfDifferent<word>("rho", "none", rhoName_);
+    os.writeEntry("P", P_);
+    os.writeEntry("I", I_);
+    os.writeEntry("D", D_);
+    os.writeEntry("error", error_);
+    os.writeEntry("errorIntegral", errorIntegral_);
 
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C
index c266d27f856511810bc0b20177bf43b7055622a5..e365010fa15553229372941cbf314185b7c2ceb5 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/prghPressure/prghPressureFvPatchScalarField.C
@@ -171,7 +171,7 @@ void Foam::prghPressureFvPatchScalarField::updateCoeffs()
 void Foam::prghPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     p_.writeEntry("p", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C
index e1705e24bcd632d2a04dfe560f3286bb1c5937a3..9558a893ee55516d8b88e99d85412101e6771ca5 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalHydrostaticPressure/prghTotalHydrostaticPressureFvPatchScalarField.C
@@ -146,10 +146,10 @@ void Foam::prghTotalHydrostaticPressureFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    writeEntryIfDifferent<word>(os, "ph_rgh", "ph_rgh", ph_rghName_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("ph_rgh", "ph_rgh", ph_rghName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C
index 9a4f9b1572154d9fb9fa7e80ef7248934c7f3930..feeed4843338a534350fb50064d8ba1053bdd1ee 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/prghTotalPressure/prghTotalPressureFvPatchScalarField.C
@@ -191,9 +191,9 @@ void Foam::prghTotalPressureFvPatchScalarField::updateCoeffs()
 void Foam::prghTotalPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     p0_.writeEntry("p0", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C
index 4f22a43edadc54d70adeb8a72fe52e7ced45829a..edaca467e2ee6e39d14f237185f718f3ab53de0e 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C
@@ -128,7 +128,7 @@ void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("phi") << phiName() << token::END_STATEMENT << nl;
+    os.writeEntry("phi", phiName());
     omega_->writeData(os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C
index ebc32b0790c26fb0e32d714dce7e41d9557a949e..d322862f4a6bb647b2fa3c01044d5be716c01a40 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C
@@ -145,8 +145,8 @@ void Foam::rotatingWallVelocityFvPatchVectorField::updateCoeffs()
 void Foam::rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
+    os.writeEntry("origin", origin_);
+    os.writeEntry("axis", axis_);
     omega_->writeData(os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C
index ddfb7c790c2b34507706267ba4f5a935d7fdbd51..39c06df42c944290f1fa16836bb6e77038ccf47e 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C
@@ -297,13 +297,13 @@ void Foam::supersonicFreestreamFvPatchVectorField::updateCoeffs()
 void Foam::supersonicFreestreamFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "T", "T", TName_);
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
-    writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
-    os.writeKeyword("UInf") << UInf_ << token::END_STATEMENT << nl;
-    os.writeKeyword("pInf") << pInf_ << token::END_STATEMENT << nl;
-    os.writeKeyword("TInf") << TInf_ << token::END_STATEMENT << nl;
-    os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("T", "T", TName_);
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
+    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
+    os.writeEntry("UInf", UInf_);
+    os.writeEntry("pInf", pInf_);
+    os.writeEntry("TInf", TInf_);
+    os.writeEntry("gamma", gamma_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H
index 54d0e92a69909664464eee2de6e75a7ef6003c36..69a6a04eab23523029cc30369d6a6328c6e45267 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.H
@@ -69,8 +69,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef supersonicFreestreamFvPatchVectorFields_H
-#define supersonicFreestreamFvPatchVectorFields_H
+#ifndef supersonicFreestreamFvPatchVectorField_H
+#define supersonicFreestreamFvPatchVectorField_H
 
 #include "fvPatchFields.H"
 #include "mixedFvPatchFields.H"
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C
index 861bac7f9b1eea04cfe793ab8dfc4f6536c0c5f3..44ddaa37ddb00018cc247c5b72cf465be8c80379 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C
@@ -199,10 +199,10 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchField<vector>::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntry("origin", origin_);
+    os.writeEntry("axis", axis_);
     flowRate_->writeData(os);
     rpm_->writeData(os);
     writeEntry("value", os);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C
index 79ee1cb2c96a30aa951e8437bbed88ab4324dc54..4b76142d9f68069b6564969c4375e5e021d5d3c6 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.C
@@ -145,8 +145,8 @@ void Foam::swirlInletVelocityFvPatchVectorField::updateCoeffs()
 void Foam::swirlInletVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchField<vector>::write(os);
-    os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
+    os.writeEntry("origin", origin_);
+    os.writeEntry("axis", axis_);
     axialVelocity_->writeData(os);
     radialVelocity_->writeData(os);
     tangentialVelocity_->writeData(os);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C
index c33db45ca26ec2d5a6d958b7903f0ff46c9588f3..a086f891608c453b8daaa7bb178894219ae95a9e 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C
@@ -233,17 +233,17 @@ void Foam::syringePressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
 
-    os.writeKeyword("Ap") << Ap_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Sp") << Sp_ << token::END_STATEMENT << nl;
-    os.writeKeyword("VsI") << VsI_ << token::END_STATEMENT << nl;
-    os.writeKeyword("tas") << tas_ << token::END_STATEMENT << nl;
-    os.writeKeyword("tae") << tae_ << token::END_STATEMENT << nl;
-    os.writeKeyword("tds") << tds_ << token::END_STATEMENT << nl;
-    os.writeKeyword("tde") << tde_ << token::END_STATEMENT << nl;
-    os.writeKeyword("psI") << psI_ << token::END_STATEMENT << nl;
-    os.writeKeyword("psi") << psi_ << token::END_STATEMENT << nl;
-    os.writeKeyword("ams") << ams_ << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
+    os.writeEntry("Ap", Ap_);
+    os.writeEntry("Sp", Sp_);
+    os.writeEntry("VsI", VsI_);
+    os.writeEntry("tas", tas_);
+    os.writeEntry("tae", tae_);
+    os.writeEntry("tds", tds_);
+    os.writeEntry("tde", tde_);
+    os.writeEntry("psI", psI_);
+    os.writeEntry("psi", psi_);
+    os.writeEntry("ams", ams_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
 
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
index 5ba985a24e248f1771e28de3527077a7ed1f3b6a..af626c2c5e4642414009513abed8e5188e73ccf8 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
@@ -568,23 +568,20 @@ void Foam::timeVaryingMappedFixedValueFvPatchField<Type>::write
 {
     fvPatchField<Type>::write(os);
 
-    this->writeEntryIfDifferent(os, "setAverage", Switch(false), setAverage_);
+    os.writeEntryIfDifferent("setAverage", Switch(false), setAverage_);
+    os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_);
 
-    this->writeEntryIfDifferent(os, "perturb", scalar(1e-5), perturb_);
-
-    this->writeEntryIfDifferent
+    os.writeEntryIfDifferent
     (
-        os,
         "fieldTable",
         this->internalField().name(),
         fieldTableName_
     );
 
-    this->writeEntryIfDifferent
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "mapMethod",
-        word("planarInterpolation"),
+        "planarInterpolation",
         mapMethod_
     );
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C
index de94aeeffe3ebabd7169b03ba23f9d6c157097d6..65461cc9c49d88f450bfd3efcc65bd632a4dc6df 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C
@@ -243,11 +243,11 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs()
 void Foam::totalPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntry("rho", rhoName_);
+    os.writeEntry("psi", psiName_);
+    os.writeEntry("gamma", gamma_);
     p0_.writeEntry("p0", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C
index df7d20629c5293f9bc3e2d1874d2f9e53c2d5a24..771ebb53d84ae49d3ed65ccdfcad86fa77de40e0 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C
@@ -177,10 +177,10 @@ void Foam::totalTemperatureFvPatchScalarField::updateCoeffs()
 void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
-    os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
+    os.writeEntry("gamma", gamma_);
     T0_.writeEntry("T0", os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
index 5d1bce06740e9ce5d804114e818d346865360b75..5dda836639265c5ba1e7d734e089921cc7440495 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C
@@ -1103,12 +1103,12 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchField<vector>::write(os);
     writeEntry("value", os);
-    os.writeKeyword("delta") << delta_ << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<scalar>(os, "d", 1.0, d_);
-    writeEntryIfDifferent<scalar>(os, "kappa", 0.41, kappa_);
-    writeEntryIfDifferent<scalar>(os, "perturb", 1e-5, perturb_);
-    writeEntryIfDifferent<label>(os, "nCellPerEddy", 5, nCellPerEddy_);
-    writeEntryIfDifferent(os, "writeEddies", false, writeEddies_);
+    os.writeEntry("delta", delta_);
+    os.writeEntryIfDifferent<scalar>("d", 1.0, d_);
+    os.writeEntryIfDifferent<scalar>("kappa", 0.41, kappa_);
+    os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_);
+    os.writeEntryIfDifferent<label>("nCellPerEddy", 5, nCellPerEddy_);
+    os.writeEntryIfDifferent("writeEddies", false, writeEddies_);
 
     if (!interpolateR_)
     {
@@ -1125,14 +1125,14 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::write(Ostream& os) const
         U_.writeEntry("U", os);
     }
 
-    if
-    (
-       !mapMethod_.empty()
-     && mapMethod_ != "planarInterpolation"
-    )
+    if (!mapMethod_.empty())
     {
-        os.writeKeyword("mapMethod") << mapMethod_
-            << token::END_STATEMENT << nl;
+        os.writeEntryIfDifferent<word>
+        (
+            "mapMethod",
+            "planarInterpolation",
+            mapMethod_
+        );
     }
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C
index b457ecd85a3f52700e0f9f7fc413b11e94304f83..57032e53c0ffa83f55d333615171c4a406d5cb71 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentInlet/turbulentInletFvPatchField.C
@@ -196,10 +196,9 @@ template<class Type>
 void Foam::turbulentInletFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    os.writeKeyword("fluctuationScale")
-        << fluctuationScale_ << token::END_STATEMENT << nl;
+    os.writeEntry("fluctuationScale", fluctuationScale_);
     referenceField_.writeEntry("referenceField", os);
-    os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl;
+    os.writeEntry("alpha", alpha_);
     this->writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C
index 20369fe63c32bfc79dd285968dfd47e7660de338..14ec2d187ffbcafa15010df3ab0c21017d6e6d30 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C
@@ -149,9 +149,9 @@ void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl;
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
+    os.writeEntry("intensity", intensity_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C
index ba14325c6a35d7094923ef2a625d2dac5b90052f..fb6367a51a6271bb4f5aca3d1566dc4b9f704bdd 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C
@@ -144,9 +144,9 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
-    os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
-    os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
+    os.writeEntry("rho", rho_);
+    os.writeEntry("pRefValue", pRefValue_);
+    os.writeEntry("pRefPoint", pRefPoint_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C
index 011b8552fd4af420da97a6d802a825014885fbc0..647398f4b054836e001c3e5b0158807e3739aa02 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C
@@ -160,10 +160,7 @@ template<class Type>
 void Foam::uniformInletOutletFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
-    if (phiName_ != "phi")
-    {
-        os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    }
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
     this->uniformInletValue_->writeData(os);
     this->writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C
index 152a74937c78f0be4dfc07867433614cdf281f7c..ea3c1705c6cf6e668d4494d3d857af0b21028f48 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C
@@ -227,11 +227,11 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs()
 void Foam::uniformTotalPressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntry("rho", rhoName_);
+    os.writeEntry("psi", psiName_);
+    os.writeEntry("gamma", gamma_);
     p0_->writeData(os);
     writeEntry("value", os);
 }
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C
index 341d6134325855d7cc9fbadbcd9fa55e716f9e14..9f9f89865ace32006432c115171e0f25bc63c875 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C
@@ -173,12 +173,9 @@ void Foam::variableHeightFlowRateFvPatchScalarField::updateCoeffs()
 void Foam::variableHeightFlowRateFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    if (phiName_ != "phi")
-    {
-        os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
-    }
-    os.writeKeyword("lowerBound") << lowerBound_ << token::END_STATEMENT << nl;
-    os.writeKeyword("upperBound") << upperBound_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntry("lowerBound", lowerBound_);
+    os.writeEntry("upperBound", upperBound_);
     this->writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C
index f0f3802339ca9f9ac960cf8f5efc2a7fc8349ceb..40a7ce65d96c5284a1bef6cdc92ba6697d148c23 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C
@@ -133,7 +133,7 @@ void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField::write
 {
     fvPatchField<vector>::write(os);
     flowRate_->writeData(os);
-    os.writeKeyword("alpha") << alphaName_ << token::END_STATEMENT << nl;
+    os.writeEntry("alpha", alphaName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C
index 4d986bd2914c237eade76b3b03bb05ced71e82b6..440c1e285955b9dad2f7bb24c74888ef8311feb5 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C
@@ -229,9 +229,9 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs()
 void Foam::waveSurfacePressureFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "zeta", "zeta", zetaName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("zeta", "zeta", zetaName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C
index eb80ace5c9cff330bc758cbe18a1bdb622c3b725..863ede5a13577fdd58617c12d52faa7ae6b71c97 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C
@@ -139,21 +139,16 @@ void Foam::waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
 {
     fvPatchField<Type>::write(os);
 
-    this->template
-        writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
-    this->template
-        writeEntryIfDifferent<word>(os, "rho", "rho", this->rhoName_);
-    this->template
-        writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", this->rhoName_);
+    os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
 
-    os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
+    os.writeEntry("gamma", gamma_);
 
     if (this->lInf_ > SMALL)
     {
-        os.writeKeyword("fieldInf") << this->fieldInf_
-            << token::END_STATEMENT << nl;
-        os.writeKeyword("lInf") << this->lInf_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("fieldInf", this->fieldInf_);
+        os.writeEntry("lInf", this->lInf_);
     }
 
     this->writeEntry("value", os);
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
index 52bd26e80950583cc398602c9ef9a797ac66df56..764a266517e963d1e5d34ae7cf4b82a6097ea361 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
@@ -362,29 +362,11 @@ void Foam::fvPatchField<Type>::manipulateMatrix
 template<class Type>
 void Foam::fvPatchField<Type>::write(Ostream& os) const
 {
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
 
     if (patchType_.size())
     {
-        os.writeKeyword("patchType") << patchType_
-            << token::END_STATEMENT << nl;
-    }
-}
-
-
-template<class Type>
-template<class EntryType>
-void Foam::fvPatchField<Type>::writeEntryIfDifferent
-(
-    Ostream& os,
-    const word& entryName,
-    const EntryType& value1,
-    const EntryType& value2
-) const
-{
-    if (value1 != value2)
-    {
-        os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
+        os.writeEntry("patchType", patchType_);
     }
 }
 
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
index da0953aeba9b018dbc643c7d59a1d0860725fc03..71d4a8ffd6fb915e0d0950dce3e719c5ddba8cf2 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
@@ -530,17 +530,6 @@ public:
             //- Write
             virtual void write(Ostream&) const;
 
-            //- Helper function to write the keyword and entry only if the
-            //  values are not equal. The value is then output as value2
-            template<class EntryType>
-            void writeEntryIfDifferent
-            (
-                Ostream& os,
-                const word& entryName,
-                const EntryType& value1,
-                const EntryType& value2
-            ) const;
-
 
         // Check
 
diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C
index 8a8c96244c34cd17bd23011729a7a3153eb74d63..61db751a5493bdee64a9dadcffa7ac728ac46795 100644
--- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C
+++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.C
@@ -166,7 +166,7 @@ void Foam::fvsPatchField<Type>::rmap
 template<class Type>
 void Foam::fvsPatchField<Type>::write(Ostream& os) const
 {
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
     this->writeEntry("value", os);
 }
 
diff --git a/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C
new file mode 100644
index 0000000000000000000000000000000000000000..b8f9ad29ba9265773b8f85d0155690db91dd46cc
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.C
@@ -0,0 +1,85 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "fieldSelection.H"
+#include "objectRegistry.H"
+#include "dictionary.H"
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::functionObjects::fieldSelection::fieldSelection
+(
+    const objectRegistry& obr
+)
+:
+    HashSet<wordRe>(),
+    obr_(obr),
+    selection_()
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::fieldSelection::~fieldSelection()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::fieldSelection::read(const dictionary& dict)
+{
+    dict.lookup("fields") >> *this;
+
+    return true;
+}
+
+
+bool Foam::functionObjects::fieldSelection::containsPattern() const
+{
+    for (const wordRe& fieldName : *this)
+    {
+        if (fieldName.isPattern())
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+
+void Foam::functionObjects::fieldSelection::clearSelection()
+{
+    selection_.clear();
+}
+
+
+bool Foam::functionObjects::fieldSelection::updateSelection()
+{
+    return false;
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H
new file mode 100644
index 0000000000000000000000000000000000000000..9d874f8322ffa467d42cec5a16b4e0b224c50e48
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H
@@ -0,0 +1,139 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::functionObjects::fieldSelection
+
+Description
+    Helper class to manage field selections
+
+SourceFiles
+    fieldSelection.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef functionObjects_fieldSelection_H
+#define functionObjects_fieldSelection_H
+
+#include "HashSet.H"
+#include "wordRe.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class dictionary;
+class objectRegistry;
+
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class fieldSelection Declaration
+\*---------------------------------------------------------------------------*/
+
+class fieldSelection
+:
+    public HashSet<wordRe>
+{
+private:
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        fieldSelection(const fieldSelection&) = delete;
+
+
+protected:
+
+    // Protected member data
+
+        //- Reference to the database
+        const objectRegistry& obr_;
+
+        //- Current field selection
+        wordHashSet selection_;
+
+
+    // Protected Member Functions
+
+        //- Add registered objects of a given type
+        template<class Type>
+        void addRegistered(wordHashSet& set) const;
+
+
+public:
+
+    //- Construct from object registry
+    fieldSelection(const objectRegistry& obr);
+
+
+    //- Destructor
+    virtual ~fieldSelection();
+
+
+    // Member Functions
+
+        //- Return the current field selection
+        const wordHashSet& selection() const
+        {
+            return selection_;
+        }
+
+        //- Return the current field selection
+        wordHashSet& selection()
+        {
+            return selection_;
+        }
+
+        //- Read the fieldSelection data from dictionary
+        virtual bool read(const dictionary& dict);
+
+        //- Return whether the field names contain a pattern
+        virtual bool containsPattern() const;
+
+        //- Clear the current selection
+        virtual void clearSelection();
+
+        //- Update the selection using current contents of obr_
+        virtual bool updateSelection();
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+    #include "fieldSelectionTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C b/src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..80c476a44e141c6096a4be814eb96d21aec4643e
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/fieldSelectionTemplates.C
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "DynamicList.H"
+#include "objectRegistry.H"
+
+// * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
+
+template<class Type>
+void Foam::functionObjects::fieldSelection::addRegistered
+(
+    wordHashSet& set
+) const
+{
+    DynamicList<word> names;
+    for (const wordRe& name : *this)
+    {
+        names.append(obr_.names<Type>(name));
+    }
+
+    set.insert(names);
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C
new file mode 100644
index 0000000000000000000000000000000000000000..9d55a55393916ba8f7cbd7dd5fee2b3d3555dbe3
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.C
@@ -0,0 +1,64 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "fileFieldSelection.H"
+#include "objectRegistry.H"
+#include "volMesh.H"
+#include "fvPatchField.H"
+#include "surfaceMesh.H"
+#include "fvsPatchField.H"
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::functionObjects::fileFieldSelection::fileFieldSelection
+(
+    const objectRegistry& obr
+)
+:
+    fieldSelection(obr)
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::fileFieldSelection::~fileFieldSelection()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::fileFieldSelection::updateSelection()
+{
+    wordHashSet oldSet;
+    oldSet.swap(selection_);
+
+    addFileGeoFields<fvPatchField, volMesh>(selection_);
+    addFileGeoFields<fvsPatchField, surfaceMesh>(selection_);
+
+    return selection_ != oldSet;
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H
new file mode 100644
index 0000000000000000000000000000000000000000..d1d3a986c70718c3eeec4c877f9001b59bf96590
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelection.H
@@ -0,0 +1,115 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::functionObjects::fileFieldSelection
+
+Description
+    Helper class to manage file-based field selections
+
+SourceFiles
+    fieldSelection.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef functionObjects_fileFieldSelection_H
+#define functionObjects_fileFieldSelection_H
+
+#include "fieldSelection.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class IOobjectList;
+
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+                    Class fileFieldSelection Declaration
+\*---------------------------------------------------------------------------*/
+
+class fileFieldSelection
+:
+    public fieldSelection
+{
+private:
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        fileFieldSelection(const fileFieldSelection&) = delete;
+
+
+protected:
+
+    // Protected Member Functions
+
+        //- Add registered GeometricField types to selection
+        template<template<class> class PatchType, class MeshType>
+        void addFileGeoFields(wordHashSet& set) const;
+
+        //- Add objects of a given type
+        template<class Type>
+        void addFromFile
+        (
+            const IOobjectList& allFileObjects,
+            wordHashSet& set
+        ) const;
+
+
+public:
+
+    //- Construct from object registry
+    fileFieldSelection(const objectRegistry& obr);
+
+
+    //- Destructor
+    virtual ~fileFieldSelection();
+
+
+    // Member Functions
+
+        //- Update the selection
+        virtual bool updateSelection();
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+    #include "fileFieldSelectionTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..f915d0499714358b4a5d835022dd53c2080e6100
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/fileFieldSelectionTemplates.C
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "IOobjectList.H"
+#include "GeometricField.H"
+#include "fvMesh.H"
+#include "DynamicList.H"
+
+// * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
+
+template<class Type>
+void Foam::functionObjects::fileFieldSelection::addFromFile
+(
+    const IOobjectList& allFileObjects,
+    wordHashSet& set
+) const
+{
+    DynamicList<word> names;
+
+    for (const wordRe& fieldName : *this)
+    {
+        names.append(allFileObjects.names(Type::typeName, fieldName));
+    }
+
+    set.insert(names);
+}
+
+
+template<template<class> class PatchType, class MeshType>
+void Foam::functionObjects::fileFieldSelection::addFileGeoFields
+(
+    wordHashSet& set
+) const
+{
+    const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
+
+    const IOobjectList allObjects(mesh, mesh.time().timeName());
+
+    addFromFile<GeometricField<scalar, PatchType, MeshType>>(allObjects, set);
+    addFromFile<GeometricField<vector, PatchType, MeshType>>(allObjects, set);
+    addFromFile<GeometricField<sphericalTensor, PatchType, MeshType>>
+    (
+        allObjects,
+        set
+    );
+    addFromFile<GeometricField<symmTensor, PatchType, MeshType>>
+    (
+        allObjects,
+        set
+    );
+    addFromFile<GeometricField<tensor, PatchType, MeshType>>(allObjects, set);
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C
new file mode 100644
index 0000000000000000000000000000000000000000..d7508642d220ec2f6d9cda9fd95371f06b4d331b
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.C
@@ -0,0 +1,81 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "solverFieldSelection.H"
+#include "fvMesh.H"
+#include "volMesh.H"
+#include "fvPatchField.H"
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::functionObjects::solverFieldSelection::solverFieldSelection
+(
+    const objectRegistry& obr
+)
+:
+    volFieldSelection(obr)
+{
+    if (!isA<fvMesh>(obr))
+    {
+        FatalErrorInFunction
+            << "Registry must be of type " << fvMesh::typeName
+            << abort(FatalError);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::solverFieldSelection::~solverFieldSelection()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::solverFieldSelection::updateSelection()
+{
+    wordHashSet oldSet;
+    oldSet.swap(selection_);
+
+    wordHashSet volFields;
+    addRegisteredGeoFields<fvPatchField, volMesh>(volFields);
+
+    const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
+
+    const Foam::dictionary& solverDict = mesh.solverPerformanceDict();
+
+    for (const word& fieldName : volFields)
+    {
+        if (solverDict.found(fieldName))
+        {
+            selection_.insert(fieldName);
+        }
+    }
+
+    return selection_ != oldSet;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/nil/nil.H b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H
similarity index 64%
rename from src/OpenFOAM/primitives/nil/nil.H
rename to src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H
index 3e5ae948e9c12558c260a25a4fa12e114f561509..55d860a199582ae152741581af935db71e3de313 100644
--- a/src/OpenFOAM/primitives/nil/nil.H
+++ b/src/finiteVolume/functionObjects/fieldSelection/solverFieldSelection.H
@@ -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) 2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -22,72 +22,64 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Class
-    Foam::nil
+    Foam::functionObjects::volFieldSelection
 
 Description
-    A zero-sized class without any storage. Used, for example, in HashSet.
+    Helper class to manage volume field selections
 
-Note
-    A zero-sized class actually does still require at least 1 byte storage.
+SourceFiles
+    volFieldSelection.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef nil_H
-#define nil_H
+#ifndef functionObjects_solverFieldSelection_H
+#define functionObjects_solverFieldSelection_H
+
+#include "volFieldSelection.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
-
-// Forward declaration of classes
-class Istream;
-class Ostream;
-
-// Forward declaration of friend functions and operators
-
-class nil;
-
-Istream& operator>>(Istream&, nil&);
-Ostream& operator<<(Ostream&, const nil&);
-
+namespace functionObjects
+{
 
 /*---------------------------------------------------------------------------*\
-                             Class nil Declaration
+                    Class solverFieldSelection Declaration
 \*---------------------------------------------------------------------------*/
 
-class nil
+class solverFieldSelection
+:
+    public volFieldSelection
 {
+private:
 
-public:
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        solverFieldSelection(const solverFieldSelection&) = delete;
 
-    // Constructors
 
-        //- Construct null
-        nil()
-        {}
+public:
+
+    //- Construct from object registry
+    solverFieldSelection(const objectRegistry& obr);
 
-        //- Construct from Istream
-        nil(Istream&)
-        {}
 
+    //- Destructor
+    virtual ~solverFieldSelection();
 
-    // IOstream Operators
 
-        friend Istream& operator>>(Istream& is, nil&)
-        {
-            return is;
-        }
+    // Member Functions
 
-        friend Ostream& operator<<(Ostream& os, const nil&)
-        {
-            return os;
-        }
+        //- Update the selection using current contents of obr_
+        virtual bool updateSelection();
 };
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+} // End namespace functionObjects
 } // End namespace Foam
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C
new file mode 100644
index 0000000000000000000000000000000000000000..b0b61eb5243cd1e34736fa74bebdb9b916e919d2
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.C
@@ -0,0 +1,61 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "volFieldSelection.H"
+#include "volMesh.H"
+#include "fvPatchField.H"
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::functionObjects::volFieldSelection::volFieldSelection
+(
+    const objectRegistry& obr
+)
+:
+    fieldSelection(obr)
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::volFieldSelection::~volFieldSelection()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::volFieldSelection::updateSelection()
+{
+    wordHashSet oldSet;
+
+    oldSet.swap(selection_);
+
+    addRegisteredGeoFields<fvPatchField, volMesh>(selection_);
+
+    return selection_ != oldSet;
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H
new file mode 100644
index 0000000000000000000000000000000000000000..cad0440bd735f1411453ea1648d5a74d3744d373
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelection.H
@@ -0,0 +1,104 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::functionObjects::volFieldSelection
+
+Description
+    Helper class to manage volume field selections
+
+SourceFiles
+    volFieldSelection.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef functionObjects_volFieldSelection_H
+#define functionObjects_volFieldSelection_H
+
+#include "fieldSelection.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+                      Class volFieldSelection Declaration
+\*---------------------------------------------------------------------------*/
+
+class volFieldSelection
+:
+    public fieldSelection
+{
+private:
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        volFieldSelection(const volFieldSelection&) = delete;
+
+
+protected:
+
+    // Protected Member Functions
+
+        //- Add registered GeometricField types to selection
+        template<template<class> class PatchType, class MeshType>
+        void addRegisteredGeoFields(wordHashSet& set) const;
+
+
+public:
+
+    //- Construct from object registry
+    volFieldSelection(const objectRegistry& obr);
+
+
+    //- Destructor
+    virtual ~volFieldSelection();
+
+
+    // Member Functions
+
+        //- Update the selection using current contents of obr_
+        virtual bool updateSelection();
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+    #include "volFieldSelectionTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..f1e0ea195f0a4c046a5f86b3d9dcdb379e84577d
--- /dev/null
+++ b/src/finiteVolume/functionObjects/fieldSelection/volFieldSelectionTemplates.C
@@ -0,0 +1,44 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "volFields.H"
+
+// * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
+
+template<template<class> class PatchType, class MeshType>
+void Foam::functionObjects::volFieldSelection::addRegisteredGeoFields
+(
+    wordHashSet& set
+) const
+{
+    addRegistered<GeometricField<scalar, PatchType, MeshType>>(set);
+    addRegistered<GeometricField<vector, PatchType, MeshType>>(set);
+    addRegistered<GeometricField<sphericalTensor, PatchType, MeshType>>(set);
+    addRegistered<GeometricField<symmTensor, PatchType, MeshType>>(set);
+    addRegistered<GeometricField<tensor, PatchType, MeshType>>(set);
+}
+
+
+// ************************************************************************* //
diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
index 43e22bb860dde53359c9ee5c9335e9bba106fdd3..78b2b90247e639199da5350757970f0a428494cf 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
@@ -179,7 +179,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
                         label nbrGlobalI = globalNumbering().toGlobal(nbrFacei);
 
                         // Check if already there. Note:should use hashset?
-                        if (findIndex(allGlobalFaces, nbrGlobalI) == -1)
+                        if (!allGlobalFaces.found(nbrGlobalI))
                         {
                             allGlobalFaces.append(nbrGlobalI);
                         }
@@ -196,7 +196,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
                     label nbrGlobalI = nbrGlobalFaces[j];
 
                     // Check if already there. Note:should use hashset?
-                    if (findIndex(allGlobalFaces, nbrGlobalI) == -1)
+                    if (!allGlobalFaces.found(nbrGlobalI))
                     {
                         allGlobalFaces.append(nbrGlobalI);
                     }
diff --git a/src/functionObjects/field/DESModelRegions/DESModelRegions.C b/src/functionObjects/field/DESModelRegions/DESModelRegions.C
index bb94a127677f96eb0000dc6c600151abfdb1e180..ba30876431518dce609fff9a6565576e31e0fb2b 100644
--- a/src/functionObjects/field/DESModelRegions/DESModelRegions.C
+++ b/src/functionObjects/field/DESModelRegions/DESModelRegions.C
@@ -172,6 +172,8 @@ bool Foam::functionObjects::DESModelRegions::write()
         << "    writing field " << DESModelRegions.name() << nl
         << endl;
 
+    DESModelRegions.write();
+
     return true;
 }
 
diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C
index be75c66f09be20e5587d34cac4acf5708f65369c..7c8aa89d080081fb1cf54d2f0ed207e30051ede3 100644
--- a/src/functionObjects/field/fieldAverage/fieldAverage.C
+++ b/src/functionObjects/field/fieldAverage/fieldAverage.C
@@ -42,79 +42,50 @@ namespace functionObjects
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
-void Foam::functionObjects::fieldAverage::resetFields()
-{
-    forAll(faItems_, i)
-    {
-        if (faItems_[i].mean())
-        {
-            if (obr().found(faItems_[i].meanFieldName()))
-            {
-                obr().checkOut(*obr()[faItems_[i].meanFieldName()]);
-            }
-        }
-
-        if (faItems_[i].prime2Mean())
-        {
-            if (obr().found(faItems_[i].prime2MeanFieldName()))
-            {
-                obr().checkOut(*obr()[faItems_[i].prime2MeanFieldName()]);
-            }
-        }
-    }
-}
-
-
 void Foam::functionObjects::fieldAverage::initialize()
 {
-    if (!totalIter_.size())
+    for (fieldAverageItem& item : faItems_)
     {
-        totalIter_.setSize(faItems_.size(), 1);
+        // Note: not clearing data needed for restart
+        item.clear(obr(), false);
     }
 
-    if (!totalTime_.size())
-    {
-        totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
-    }
-    else
-    {
-        // Check if totalTime_ has been set otherwise initialize
-        forAll(totalTime_, fieldi)
-        {
-            if (totalTime_[fieldi] < 0)
-            {
-                totalTime_[fieldi] = obr_.time().deltaTValue();
-            }
-        }
-    }
-
-    resetFields();
-
     Log << type() << " " << name() << ":" << nl;
 
     // Add mean fields to the field lists
-    forAll(faItems_, fieldi)
+    for (fieldAverageItem& item : faItems_)
     {
-        addMeanField<scalar>(fieldi);
-        addMeanField<vector>(fieldi);
-        addMeanField<sphericalTensor>(fieldi);
-        addMeanField<symmTensor>(fieldi);
-        addMeanField<tensor>(fieldi);
+        addMeanField<scalar>(item);
+        addMeanField<vector>(item);
+        addMeanField<sphericalTensor>(item);
+        addMeanField<symmTensor>(item);
+        addMeanField<tensor>(item);
     }
 
     // Add prime-squared mean fields to the field lists
-    forAll(faItems_, fieldi)
+    for (fieldAverageItem& item : faItems_)
     {
-        addPrime2MeanField<scalar, scalar>(fieldi);
-        addPrime2MeanField<vector, symmTensor>(fieldi);
+        addPrime2MeanField<scalar, scalar>(item);
+        addPrime2MeanField<vector, symmTensor>(item);
     }
 
-    forAll(faItems_, fieldi)
+    // Add window fields to the field lists
+    for (const fieldAverageItem& item : faItems_)
+    {
+        restoreWindowFields<scalar>(item);
+        restoreWindowFields<vector>(item);
+        restoreWindowFields<sphericalTensor>(item);
+        restoreWindowFields<symmTensor>(item);
+        restoreWindowFields<tensor>(item);
+    }
+
+
+    for (const fieldAverageItem& item : faItems_)
     {
-        if (!faItems_[fieldi].active())
+        if (!item.active())
         {
             WarningInFunction
-                << "Field " << faItems_[fieldi].fieldName()
+                << "Field " << item.fieldName()
                 << " not found in database for averaging";
         }
     }
@@ -133,8 +104,10 @@ void Foam::functionObjects::fieldAverage::restart()
         << obr().time().timeOutputValue()
         << nl << endl;
 
-    totalIter_.clear();
-    totalTime_.clear();
+    for (fieldAverageItem& item : faItems_)
+    {
+        item.clear(obr(), true);
+    }
 
     initialize();
 }
@@ -180,6 +153,17 @@ void Foam::functionObjects::fieldAverage::calcAverages()
     Log << type() << " " << name() << " write:" << nl
         << "    Calculating averages" << nl;
 
+    forAll(faItems_, fieldi)
+    {
+        faItems_[fieldi].evolve(obr());
+    }
+
+    storeWindowFields<scalar>();
+    storeWindowFields<vector>();
+    storeWindowFields<sphericalTensor>();
+    storeWindowFields<symmTensor>();
+    storeWindowFields<tensor>();
+
     addMeanSqrToPrime2Mean<scalar, scalar>();
     addMeanSqrToPrime2Mean<vector, symmTensor>();
 
@@ -192,12 +176,6 @@ void Foam::functionObjects::fieldAverage::calcAverages()
     calculatePrime2MeanFields<scalar, scalar>();
     calculatePrime2MeanFields<vector, symmTensor>();
 
-    forAll(faItems_, fieldi)
-    {
-        totalIter_[fieldi]++;
-        totalTime_[fieldi] += obr().time().deltaTValue();
-    }
-
     Log << endl;
 }
 
@@ -218,28 +196,17 @@ void Foam::functionObjects::fieldAverage::writeAverages() const
 
 void Foam::functionObjects::fieldAverage::writeAveragingProperties()
 {
-    forAll(faItems_, fieldi)
+    for (const fieldAverageItem& item : faItems_)
     {
-        const word& fieldName = faItems_[fieldi].fieldName();
-
         dictionary propsDict;
-        propsDict.add("totalIter", totalIter_[fieldi]);
-        propsDict.add("totalTime", totalTime_[fieldi]);
-        setProperty(fieldName, propsDict);
+        item.writeState(propsDict);
+        setProperty(item.fieldName(), propsDict);
     }
 }
 
 
 void Foam::functionObjects::fieldAverage::readAveragingProperties()
 {
-    totalIter_.clear();
-    totalIter_.setSize(faItems_.size(), 1);
-
-    // Initialize totalTime with negative values
-    // to indicate that it has not been set
-    totalTime_.clear();
-    totalTime_.setSize(faItems_.size(), -1);
-
     if (restartOnRestart_ || restartOnOutput_)
     {
         Info<< "    Starting averaging at time "
@@ -251,23 +218,32 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
         Info<< "    Restarting averaging for fields:" << nl;
 
 
-        forAll(faItems_, fieldi)
+        for (fieldAverageItem& item : faItems_)
         {
-            const word& fieldName = faItems_[fieldi].fieldName();
+            const word& fieldName = item.fieldName();
             if (foundProperty(fieldName))
             {
                 dictionary fieldDict;
                 getDict(fieldName, fieldDict);
-
-                totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
-                totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
-
-                scalar userTotalTime =
-                    obr().time().timeToUserTime(totalTime_[fieldi]);
-
-                Info<< "        " << fieldName
-                    << " iters = " << totalIter_[fieldi]
-                    << " time = " << userTotalTime << nl;
+                item.readState(fieldDict);
+
+                if (item.allowRestart())
+                {
+                    scalar userTotalTime =
+                        obr().time().timeToUserTime(item.totalTime());
+
+                    Info<< "        " << fieldName
+                        << ": iters = " << item.totalIter()
+                        << " time = " << userTotalTime << nl;
+                }
+                else
+                {
+                    item.clear(obr(), true);
+
+                    Info<< "        " << fieldName
+                        << ": starting averaging at time "
+                        << obr().time().timeOutputValue() << endl;
+                }
             }
             else
             {
@@ -298,8 +274,6 @@ Foam::functionObjects::fieldAverage::fieldAverage
     restartTime_(GREAT),
     initialised_(false),
     faItems_(),
-    totalIter_(),
-    totalTime_(),
     periodIndex_(1)
 {
     read(dict);
@@ -321,10 +295,10 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
     // Make certain that the values are consistent with the defaults:
     initialised_ = false;
     restartOnRestart_ = false;
-    restartOnOutput_  = false;
-    periodicRestart_  = false;
-    restartPeriod_    = GREAT;
-    restartTime_      = GREAT;
+    restartOnOutput_ = false;
+    periodicRestart_ = false;
+    restartPeriod_ = GREAT;
+    restartTime_ = GREAT;
 
     Info<< type() << " " << name() << ":" << nl;
 
diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.H b/src/functionObjects/field/fieldAverage/fieldAverage.H
index e0de5ee6fbcd099acb643e42aa5e6fa7f65fa465..b169bfa05128fd7599a87df0cf0ea8d33caad8aa 100644
--- a/src/functionObjects/field/fieldAverage/fieldAverage.H
+++ b/src/functionObjects/field/fieldAverage/fieldAverage.H
@@ -86,6 +86,7 @@ Usage
                 mean            on;
                 prime2Mean      on;
                 base            time;
+                windowType      exact;
                 window          10.0;
                 windowName      w1;
             }
@@ -131,6 +132,7 @@ SourceFiles
 #define functionObjects_fieldAverage_H
 
 #include "fvMeshFunctionObject.H"
+#include "FIFOStack.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -195,10 +197,6 @@ protected:
 
         // Initialisation routines
 
-            //- Checkout fields (causes deletion) from the database
-            //  and reset lists
-            void resetFields();
-
             //- Reset lists (clear existing values) and initialize averaging.
             //  Check requested field averages are valid, populate field lists
             void initialize();
@@ -208,19 +206,19 @@ protected:
 
             //- Add mean average field to database
             template<class Type>
-            void addMeanFieldType(const label fieldi);
+            void addMeanFieldType(fieldAverageItem& item);
 
             //- Add mean average field to database
             template<class Type>
-            void addMeanField(const label fieldi);
+            void addMeanField(fieldAverageItem& item);
 
             //- Add prime-squared average field to database
             template<class Type1, class Type2>
-            void addPrime2MeanFieldType(const label fieldi);
+            void addPrime2MeanFieldType(fieldAverageItem& item);
 
             //- Add prime-squared average field to database
             template<class Type1, class Type2>
-            void addPrime2MeanField(const label fieldi);
+            void addPrime2MeanField(fieldAverageItem& item);
 
 
         // Calculation functions
@@ -228,30 +226,33 @@ protected:
             //- Main calculation routine
             virtual void calcAverages();
 
-            //- Calculate mean average fields
-            template<class Type>
-            void calculateMeanFieldType(const label fieldi) const;
-
             //- Calculate mean average fields
             template<class Type>
             void calculateMeanFields() const;
 
-            //- Calculate prime-squared average fields
-            template<class Type1, class Type2>
-            void calculatePrime2MeanFieldType(const label fieldi) const;
-
             //- Calculate prime-squared average fields
             template<class Type1, class Type2>
             void calculatePrime2MeanFields() const;
 
             //- Add mean-squared field value to prime-squared mean field
             template<class Type1, class Type2>
-            void addMeanSqrToPrime2MeanType(const label fieldi) const;
+            void addMeanSqrToPrime2MeanType(const fieldAverageItem& item) const;
 
             //- Add mean-squared field value to prime-squared mean field
             template<class Type1, class Type2>
             void addMeanSqrToPrime2Mean() const;
 
+            template<class Type>
+            void storeWindowFieldType(fieldAverageItem& item);
+
+            template<class Type>
+            void storeWindowFields();
+
+            template<class Type>
+            void restoreWindowFieldsType(const fieldAverageItem& item);
+
+            template<class Type>
+            void restoreWindowFields(const fieldAverageItem& item);
 
         // I-O
 
diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C
index f42858f1f6915f4fdfcaae20be30197ba8eb5446..74927ea91f8a2e0c143cf3f21edc4512224fad46 100644
--- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C
+++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -32,6 +32,7 @@ const Foam::word Foam::functionObjects::fieldAverageItem::EXT_MEAN
     "Mean"
 );
 
+
 const Foam::word Foam::functionObjects::fieldAverageItem::EXT_PRIME2MEAN
 (
     "Prime2Mean"
@@ -49,19 +50,38 @@ Foam::functionObjects::fieldAverageItem::baseTypeNames_
 };
 
 
+const Foam::Enum
+<
+    Foam::functionObjects::fieldAverageItem::windowType
+>
+Foam::functionObjects::fieldAverageItem::windowTypeNames_
+{
+    { windowType::NONE, "none" },
+    { windowType::APPROXIMATE, "approximate" },
+    { windowType::EXACT, "exact" },
+};
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::functionObjects::fieldAverageItem::fieldAverageItem()
 :
     active_(false),
     fieldName_("unknown"),
-    mean_(0),
+    mean_(false),
     meanFieldName_("unknown"),
-    prime2Mean_(0),
+    prime2Mean_(false),
     prime2MeanFieldName_("unknown"),
-    base_(ITER),
-    window_(-1.0),
-    windowName_("")
+    base_(baseType::ITER),
+    totalIter_(0),
+    totalTime_(-1),
+    window_(-1),
+    windowName_(""),
+    windowType_(windowType::NONE),
+
+    windowTimes_(),
+    windowFieldNames_(),
+    allowRestart_(true)
 {}
 
 
@@ -77,8 +97,15 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem
     prime2Mean_(faItem.prime2Mean_),
     prime2MeanFieldName_(faItem.prime2MeanFieldName_),
     base_(faItem.base_),
+    totalIter_(faItem.totalIter_),
+    totalTime_(faItem.totalTime_),
     window_(faItem.window_),
-    windowName_(faItem.windowName_)
+    windowName_(faItem.windowName_),
+    windowType_(faItem.windowType_),
+
+    windowTimes_(faItem.windowTimes_),
+    windowFieldNames_(faItem.windowFieldNames_),
+    allowRestart_(faItem.allowRestart_)
 {}
 
 
@@ -88,6 +115,112 @@ Foam::functionObjects::fieldAverageItem::~fieldAverageItem()
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::functionObjects::fieldAverageItem::addToWindow
+(
+    const word& fieldName,
+    const scalar deltaT
+)
+{
+    windowTimes_.push(deltaT);
+    windowFieldNames_.push(fieldName);
+}
+
+
+void Foam::functionObjects::fieldAverageItem::evolve(const objectRegistry& obr)
+{
+    totalIter_++;
+    totalTime_ += obr.time().deltaTValue();
+    forAllIters(windowTimes_, timeIter)
+    {
+        timeIter() += obr.time().deltaTValue();
+    }
+
+    // Remove any fields that have passed out of the window
+    bool removeItem = true;
+
+    while (removeItem && windowTimes_.size())
+    {
+        removeItem = !(inWindow(windowTimes_.first()));
+
+        if (removeItem)
+        {
+            windowTimes_.pop();
+            const word fieldName = windowFieldNames_.pop();
+
+            //Info<< "evolve: removing field: " << fieldName << endl;
+            obr.checkOut(*obr[fieldName]);
+        }
+    }
+}
+
+
+void Foam::functionObjects::fieldAverageItem::clear
+(
+    const objectRegistry& obr,
+    bool fullClean
+)
+{
+    if (mean_ && obr.found(meanFieldName_))
+    {
+        obr.checkOut(*obr[meanFieldName_]);
+    }
+
+    if (prime2Mean_ && obr.found(prime2MeanFieldName_))
+    {
+        obr.checkOut(*obr[prime2MeanFieldName_]);
+    }
+
+    for (const word& fieldName : windowFieldNames_)
+    {
+        if (obr.found(fieldName))
+        {
+            obr.checkOut(*obr[fieldName]);
+        }
+    }
+
+    if (totalTime_ < 0 || fullClean)
+    {
+        totalIter_ = 0;
+        totalTime_ = 0;
+        windowTimes_.clear();
+        windowFieldNames_.clear();
+    }
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::readState(const dictionary& dict)
+{
+    dict.lookup("totalIter") >> totalIter_;
+    dict.lookup("totalTime") >> totalTime_;
+
+    if (window_ > 0)
+    {
+        dict.lookup("windowTimes") >> windowTimes_;
+        dict.lookup("windowFieldNames") >> windowFieldNames_;
+    }
+
+    return true;
+}
+
+
+void Foam::functionObjects::fieldAverageItem::writeState
+(
+    dictionary& dict
+) const
+{
+    dict.add("totalIter", totalIter_);
+    dict.add("totalTime", totalTime_);
+
+    if (window_ > 0)
+    {
+        dict.add("windowTimes", windowTimes_);
+        dict.add("windowFieldNames", windowFieldNames_);
+    }
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 void Foam::functionObjects::fieldAverageItem::operator=
@@ -111,8 +244,14 @@ void Foam::functionObjects::fieldAverageItem::operator=
     prime2Mean_ = rhs.prime2Mean_;
     prime2MeanFieldName_ = rhs.prime2MeanFieldName_;
     base_ = rhs.base_;
+    totalIter_ = rhs.totalIter_;
+    totalTime_ = rhs.totalTime_;
     window_ = rhs.window_;
     windowName_ = rhs.windowName_;
+    windowType_ = rhs.windowType_;
+    windowTimes_ = rhs.windowTimes_;
+    windowFieldNames_ = rhs.windowFieldNames_;
+    allowRestart_ = rhs.allowRestart_;
 }
 
 
diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H
index d683cafea7a4ca39745d86c147e15988c6c79431..24fecbae7cec1bf53091e11c01c9fca685e9dbd1 100644
--- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H
+++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItem.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -35,12 +35,21 @@ Description
         base            time; // iteration
         window          200;  // optional averaging window
         windowName      w1;   // optional window name (default = "")
+        windowType      approximate; // window type
+
+        allowRestart    yes;  // optional, used for windowType 'exact'
     }
     \endverbatim
 
     The averaging window corresponds to the averaging interval (iters or time)
     If not specified, the averaging is over 'all iters/time'
 
+    Available window types:
+    - \c none : no windowing
+    - \c exact : exact windowing - additional files will be stored and written
+    - \c approximate : approximate variant that does not store/write additional
+      fields
+
 SourceFiles
     fieldAverageItem.C
     fieldAverageItemIO.C
@@ -52,6 +61,7 @@ SourceFiles
 
 #include "Enum.H"
 #include "Switch.H"
+#include "FIFOStack.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -61,6 +71,7 @@ namespace Foam
 // Forward declaration of classes
 class Istream;
 class Ostream;
+class objectRegistry;
 
 namespace functionObjects
 {
@@ -88,13 +99,22 @@ public:
             //- Prime-squared average
             static const word EXT_PRIME2MEAN;
 
+
         //- Enumeration defining the averaging base type
-        enum baseType
+        enum class baseType
         {
             ITER,
             TIME
         };
 
+        //- Enumeration defining the averaging window type
+        enum class windowType
+        {
+            NONE,
+            APPROXIMATE,
+            EXACT
+        };
+
 
 private:
 
@@ -124,12 +144,33 @@ private:
         //- Averaging base type
         baseType base_;
 
+        //- Total number of iterations item has been evolved
+        label totalIter_;
+
+        //- Total time item has been evolved
+        scalar totalTime_;
+
         //- Averaging window - defaults to -1 for 'all iters/time'
         scalar window_;
 
         //- Averaging window name - defaults to 'window'
         word windowName_;
 
+        //- Averaging window type
+        windowType windowType_;
+
+        //- Averaging window type names
+        static const Enum<windowType> windowTypeNames_;
+
+        //- List of window times (windowType = EXACT)
+        FIFOStack<scalar> windowTimes_;
+
+        //- List of window field names (windowType = EXACT)
+        FIFOStack<word> windowFieldNames_;
+
+        //- Switch to write all necessary files for clean restart
+        bool allowRestart_;
+
 
 public:
 
@@ -154,86 +195,96 @@ public:
         // Access
 
             //- Return const access to the active flag
-            bool active() const
-            {
-                return active_;
-            }
+            inline bool active() const;
 
             //- Return non-const access to the active flag
-            bool& active()
-            {
-                return active_;
-            }
+            inline bool& active();
 
             //- Return const access to the field name
-            const word& fieldName() const
-            {
-                return fieldName_;
-            }
+            inline const word& fieldName() const;
 
             //- Return const access to the mean flag
-            bool mean() const
-            {
-                return mean_;
-            }
+            inline bool mean() const;
 
             //- Return non-const access to the mean flag
-            bool& mean()
-            {
-                return mean_;
-            }
+            inline bool& mean();
 
             //- Return const access to the mean field name
-            const word& meanFieldName() const
-            {
-                return meanFieldName_;
-            }
+            inline const word& meanFieldName() const;
 
             //- Return const access to the prime-squared mean flag
-            bool prime2Mean() const
-            {
-                return prime2Mean_;
-            }
+            inline bool prime2Mean() const;
 
             //- Return non-const access to the prime-squared mean flag
-            bool& prime2Mean()
-            {
-                return prime2Mean_;
-            }
+            inline bool& prime2Mean();
 
             //- Return const access to the prime-squared mean field name
-            const word& prime2MeanFieldName() const
-            {
-                return prime2MeanFieldName_;
-            }
+            inline const word& prime2MeanFieldName() const;
 
             //- Return averaging base type name
-            const word base() const
-            {
-                return baseTypeNames_[base_];
-            }
-
-            //- Return true if base is ITER
-            bool iterBase() const
-            {
-                return base_ == ITER;
-            }
-
-            //- Return true if base is time
-            bool timeBase() const
-            {
-                return base_ == TIME;
-            }
-
-            scalar window() const
-            {
-                return window_;
-            }
-
-            const word& windowName() const
-            {
-                return windowName_;
-            }
+            inline const word& base() const;
+
+            //- Return the total number of iterations item has been evolved
+            inline label totalIter() const;
+
+            //- Return the total time item has been evolved
+            inline scalar totalTime() const;
+
+            //- Return the window length (iterations or seconds)
+            inline scalar window() const;
+
+            //- Return the (optional) window name
+            inline const word& windowName() const;
+
+            //- Return the list of window times (windowType = EXACT)
+            inline const FIFOStack<scalar>& windowTimes() const;
+
+            //- Return the list of window field names (windowType = EXACT)
+            inline const FIFOStack<word>& windowFieldNames() const;
+
+            //- Return the allow restart flag
+            inline bool allowRestart() const;
+
+            //- Return the current time interval
+            inline scalar dt(const scalar deltaT) const;
+
+            //- Return the total time interval
+            inline scalar Dt() const;
+
+            //- Helper function to construct a window field name
+            inline word windowFieldName(const word& prefix) const;
+
+            //- Return true if time is inside window (including boundaries)
+            inline bool inWindow(const scalar t) const;
+
+            //- Return true if we wish to store window fields
+            inline bool storeWindowFields() const;
+
+            //- Return true if we wish to write window fields
+            inline bool writeWindowFields() const;
+
+            //- Add field to window
+            void addToWindow(const word& fieldName, const scalar deltaT);
+
+            //- Evolve and update
+            void evolve(const objectRegistry& obr);
+
+            //- Clear out all mean fields and (optionally) supporting data
+            void clear(const objectRegistry& obr, const bool fullClean);
+
+            //- Read state and re-initialise values
+            bool readState(const dictionary& dict);
+
+            //- Write state for restart
+            void writeState(dictionary& dict) const;
+
+            //- Calculate the mean field value
+            template<class Type>
+            bool calculateMeanField(const objectRegistry& obr) const;
+
+            //- Calculate prime-squared average fields
+            template<class Type1, class Type2>
+            bool calculatePrime2MeanField(const objectRegistry& obr) const;
 
 
     // Member Operators
@@ -257,8 +308,12 @@ public:
              && a.prime2Mean_ == b.prime2Mean_
              && a.prime2MeanFieldName_ == b.prime2MeanFieldName_
              && a.base_ == b.base_
+             && a.totalIter_ == b.totalIter_
+             && a.totalTime_ == b.totalTime_
              && a.window_ == b.window_
-             && a.windowName_ == b.windowName_;
+             && a.windowName_ == b.windowName_
+             && a.windowType_ == b.windowType_
+             && a.allowRestart_ == b.allowRestart_;
         }
 
         friend bool operator!=
@@ -285,6 +340,16 @@ public:
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
+#include "fieldAverageItemI.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+    #include "fieldAverageItemTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
 #endif
 
 // ************************************************************************* //
diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H
new file mode 100644
index 0000000000000000000000000000000000000000..371a3091e886ef0e889e3a534c84621c20ef1fa4
--- /dev/null
+++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemI.H
@@ -0,0 +1,230 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+
+\*---------------------------------------------------------------------------*/
+
+
+bool Foam::functionObjects::fieldAverageItem::active() const
+{
+    return active_;
+}
+
+
+bool& Foam::functionObjects::fieldAverageItem::active()
+{
+    return active_;
+}
+
+
+const Foam::word& Foam::functionObjects::fieldAverageItem::fieldName() const
+{
+    return fieldName_;
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::mean() const
+{
+    return mean_;
+}
+
+
+bool& Foam::functionObjects::fieldAverageItem::mean()
+{
+    return mean_;
+}
+
+
+const Foam::word&
+Foam::functionObjects::fieldAverageItem::meanFieldName() const
+{
+    return meanFieldName_;
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::prime2Mean() const
+{
+    return prime2Mean_;
+}
+
+
+bool& Foam::functionObjects::fieldAverageItem::prime2Mean()
+{
+    return prime2Mean_;
+}
+
+
+const Foam::word& Foam::functionObjects::fieldAverageItem::prime2MeanFieldName() const
+{
+    return prime2MeanFieldName_;
+}
+
+
+const Foam::word& Foam::functionObjects::fieldAverageItem::base() const
+{
+    return baseTypeNames_[base_];
+}
+
+
+Foam::label Foam::functionObjects::fieldAverageItem::totalIter() const
+{
+    return totalIter_;
+}
+
+
+Foam::scalar Foam::functionObjects::fieldAverageItem::totalTime() const
+{
+    return totalTime_;
+}
+
+
+Foam::scalar Foam::functionObjects::fieldAverageItem::window() const
+{
+    return window_;
+}
+
+
+const Foam::word& Foam::functionObjects::fieldAverageItem::windowName() const
+{
+    return windowName_;
+}
+
+
+const Foam::FIFOStack<Foam::scalar>&
+Foam::functionObjects::fieldAverageItem::windowTimes() const
+{
+    return windowTimes_;
+}
+
+
+const Foam::FIFOStack<Foam::word>&
+Foam::functionObjects::fieldAverageItem::windowFieldNames() const
+{
+    return windowFieldNames_;
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::allowRestart() const
+{
+    return allowRestart_;
+}
+
+
+Foam::scalar Foam::functionObjects::fieldAverageItem::dt
+(
+    const scalar deltaT
+) const
+{
+    switch (base_)
+    {
+        case baseType::TIME:
+        {
+            return deltaT;
+        }
+        case baseType::ITER:
+        {
+            return scalar(1);
+        }
+        default:
+        {
+            FatalErrorInFunction
+                << "Unhandled enumeration " << baseTypeNames_[base_]
+                << abort(FatalError);
+        }
+    }
+
+    return 0.0;
+}
+
+
+Foam::scalar Foam::functionObjects::fieldAverageItem::Dt() const
+{
+    switch (base_)
+    {
+        case baseType::TIME:
+        {
+            return totalTime_;
+        }
+        case baseType::ITER:
+        {
+            return scalar(totalIter_);
+        }
+        default:
+        {
+            FatalErrorInFunction
+                << "Unhandled enumeration " << baseTypeNames_[base_]
+                << abort(FatalError);
+        }
+    }
+
+    return 0.0;
+}
+
+
+Foam::word Foam::functionObjects::fieldAverageItem::windowFieldName
+(
+    const word& prefix
+) const
+{
+    return prefix + ':' + fieldName_ + ':' + Foam::name(totalIter_);
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::inWindow(const scalar t) const
+{
+    switch (base_)
+    {
+        case baseType::ITER:
+        {
+            return round(t) <= round(window_) + 1;
+        }
+        case baseType::TIME:
+        {
+            return t <= window_;
+        }
+        default:
+        {
+            FatalErrorInFunction
+                << "Unhandled baseType enumeration "
+                << baseTypeNames_[base_]
+                << abort(FatalError);
+        }
+    }
+
+    return false;
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::storeWindowFields() const
+{
+    return windowType_ == windowType::EXACT;
+}
+
+
+bool Foam::functionObjects::fieldAverageItem::writeWindowFields() const
+{
+    return (allowRestart_ && window_ > 0);
+}
+
+
+// ************************************************************************* //
diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C
index a057aba5762ec8767a0a91e9e73f081adf03d016..c1c3e1d19a4d6a5f4e5012333962b0b632ee5be0 100644
--- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C
+++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemIO.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2016-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -33,31 +33,22 @@ Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is)
 :
     active_(false),
     fieldName_("unknown"),
-    mean_(0),
+    mean_(false),
     meanFieldName_("unknown"),
-    prime2Mean_(0),
+    prime2Mean_(false),
     prime2MeanFieldName_("unknown"),
-    base_(ITER),
-    window_(-1.0)
+    base_(baseType::ITER),
+    totalIter_(0),
+    totalTime_(-1),
+    window_(-1.0),
+    windowName_(""),
+    windowType_(windowType::NONE),
+
+    windowTimes_(),
+    windowFieldNames_(),
+    allowRestart_(true)
 {
-    is.check(FUNCTION_NAME);
-
-    const dictionaryEntry entry(dictionary::null, is);
-
-    fieldName_ = entry.keyword();
-    mean_ = readBool(entry.lookup("mean"));
-    prime2Mean_ = readBool(entry.lookup("prime2Mean"));
-    base_ = baseTypeNames_.lookup("base", entry);
-    window_ = entry.lookupOrDefault<scalar>("window", -1.0);
-    windowName_ = entry.lookupOrDefault<word>("windowName", "");
-
-    meanFieldName_ = fieldName_ + EXT_MEAN;
-    prime2MeanFieldName_ = fieldName_ + EXT_PRIME2MEAN;
-    if ((window_ > 0) && (windowName_ != ""))
-    {
-        meanFieldName_ = meanFieldName_ + "_" + windowName_;
-        prime2MeanFieldName_ = prime2MeanFieldName_ + "_" + windowName_;
-    }
+    is >> *this;
 }
 
 
@@ -79,13 +70,61 @@ Foam::Istream& Foam::functionObjects::operator>>
     faItem.prime2Mean_ = readBool(entry.lookup("prime2Mean"));
     faItem.base_ = faItem.baseTypeNames_.lookup("base", entry);
     faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
-    faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");
+
+    if (faItem.window_ > 0)
+    {
+        faItem.windowType_ =
+            faItem.windowTypeNames_.lookup("windowType", entry);
+
+        if (faItem.windowType_ != fieldAverageItem::windowType::NONE)
+        {
+            if
+            (
+                faItem.base_ == fieldAverageItem::baseType::ITER
+             && label(faItem.window_) < 1
+            )
+            {
+                FatalIOErrorInFunction(entry)
+                    << "Window must be 1 or more for base type "
+                    << faItem.baseTypeNames_[fieldAverageItem::baseType::ITER]
+                    << exit(FatalIOError);
+            }
+
+            faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");
+
+            if (faItem.windowType_ == fieldAverageItem::windowType::EXACT)
+            {
+                faItem.allowRestart_ = readBool(entry.lookup("allowRestart"));
+
+                if (!faItem.allowRestart_)
+                {
+                    WarningInFunction
+                        << faItem.windowTypeNames_[faItem.windowType_]
+                        << " windowing for field " << faItem.fieldName_
+                        << " will not write intermediate files and restart will"
+                        << " not be possible.  To enable, please set"
+                        << " 'allowRestart' to 'yes'"
+                        << endl;
+                }
+            }
+        }
+        else
+        {
+            // Deactivate windowing
+            faItem.window_ = -1;
+        }
+    }
+    else
+    {
+        // Deactivate windowing
+        faItem.window_ = -1;
+    }
 
     faItem.meanFieldName_ = faItem.fieldName_ + fieldAverageItem::EXT_MEAN;
     faItem.prime2MeanFieldName_ =
         faItem.fieldName_ + fieldAverageItem::EXT_PRIME2MEAN;
 
-    if ((faItem.window_ > 0) && (faItem.windowName_ != ""))
+    if ((faItem.window_ > 0) && (!faItem.windowName_.empty()))
     {
         faItem.meanFieldName_ =
             faItem.meanFieldName_ + "_" + faItem.windowName_;
@@ -93,6 +132,7 @@ Foam::Istream& Foam::functionObjects::operator>>
         faItem.prime2MeanFieldName_ =
             faItem.prime2MeanFieldName_ + "_" + faItem.windowName_;
     }
+
     return is;
 }
 
@@ -105,28 +145,34 @@ Foam::Ostream& Foam::functionObjects::operator<<
 {
     os.check(FUNCTION_NAME);
 
-    os  << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl;
-    os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl;
-    os.writeKeyword("prime2Mean") << faItem.prime2Mean_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_]
-        << token::END_STATEMENT << nl;
+    os.beginBlock(faItem.fieldName_);
+
+    os.writeEntry("mean", faItem.mean_);
+    os.writeEntry("prime2Mean", faItem.prime2Mean_);
+    os.writeEntry("base", faItem.baseTypeNames_[faItem.base_]);
 
     if (faItem.window_ > 0)
     {
-        os.writeKeyword("window") << faItem.window_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("window", faItem.window_);
 
-        if (faItem.windowName_ != "")
+        if (!faItem.windowName_.empty())
         {
-            os.writeKeyword("windowName") << faItem.windowName_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("windowName", faItem.windowName_);
         }
+
+        os.writeEntry
+        (
+            "windowType",
+            faItem.windowTypeNames_[faItem.windowType_]
+        );
+
+        os.writeEntry("allowRestart", faItem.allowRestart_);
     }
 
-    os  << token::END_BLOCK << nl;
+    os.endBlock() << flush;
 
     os.check(FUNCTION_NAME);
+
     return os;
 }
 
diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C
new file mode 100644
index 0000000000000000000000000000000000000000..f7a752b993d1dfcc87e2106a12bebc61f42c31ed
--- /dev/null
+++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C
@@ -0,0 +1,291 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "objectRegistry.H"
+#include "Time.H"
+
+template<class Type>
+bool Foam::functionObjects::fieldAverageItem::calculateMeanField
+(
+    const objectRegistry& obr
+) const
+{
+    if (!mean_)
+    {
+        return false;
+    }
+
+    const Type* baseFieldPtr = obr.lookupObjectPtr<Type>(fieldName_);
+
+    if (!baseFieldPtr)
+    {
+        return false;
+    }
+
+    const Type& baseField = *baseFieldPtr;
+    Type& meanField = obr.lookupObjectRef<Type>(meanFieldName_);
+
+    switch (windowType_)
+    {
+        case windowType::NONE:
+        {
+            scalar dt = this->dt(obr.time().deltaTValue());
+            scalar Dt = this->Dt();
+            scalar beta = dt/Dt;
+
+            meanField = (1 - beta)*meanField + beta*baseField;
+
+            break;
+        }
+        case windowType::APPROXIMATE:
+        {
+            scalar dt = this->dt(obr.time().deltaTValue());
+            scalar Dt = this->Dt();
+            scalar beta = dt/Dt;
+
+            if (Dt - dt >= window_)
+            {
+                beta = dt/window_;
+            }
+
+            meanField = (1 - beta)*meanField + beta*baseField;
+
+            break;
+        }
+        case windowType::EXACT:
+        {
+            switch (base_)
+            {
+                case baseType::ITER:
+                {
+                    // Uniform time step - can use simplified algorithm
+                    // Note: stores an additional old time field, but only
+                    //       needs to do 1 field lookup
+
+                    label n = windowTimes_.size();
+                    const Type& lastField =
+                        obr.lookupObject<Type>(windowFieldNames_.first());
+
+                    if (n <= round(window_))
+                    {
+                        scalar beta = 1.0/scalar(n);
+                        meanField = (1 - beta)*meanField + beta*baseField;
+                    }
+                    else
+                    {
+                        meanField += (baseField - lastField)/scalar(n - 1);
+                    }
+
+                    break;
+                }
+                case baseType::TIME:
+                {
+                    // Assuming non-uniform time step
+                    // Note: looks up all window fields from the registry
+
+                    meanField = 0*baseField;
+                    FIFOStack<scalar>::const_iterator timeIter =
+                        windowTimes_.begin();
+                    FIFOStack<word>::const_iterator nameIter =
+                        windowFieldNames_.begin();
+
+                    const Type* wOld = nullptr;
+
+                    for
+                    (
+                        ;
+                        timeIter != windowTimes_.end();
+                        ++timeIter, ++nameIter
+                    )
+                    {
+                        const word& fieldName = nameIter();
+                        const scalar dt = timeIter();
+                        const Type* w = obr.lookupObjectPtr<Type>(fieldName);
+
+                        meanField += dt*(*w);
+
+                        if (wOld)
+                        {
+                            meanField -= dt*(*wOld);
+                        }
+
+                        wOld = w;
+                    }
+
+                    meanField /= windowTimes_.first();
+
+                    break;
+                }
+                default:
+                {
+                    FatalErrorInFunction
+                        << "Unhandled baseType enumeration "
+                        << baseTypeNames_[base_]
+                        << abort(FatalError);
+                }
+            }
+
+            break;
+        }
+        default:
+        {
+            FatalErrorInFunction
+                << "Unhandled windowType enumeration "
+                << windowTypeNames_[windowType_]
+                << abort(FatalError);
+        }
+    }
+
+    return true;
+}
+
+
+template<class Type1, class Type2>
+bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField
+(
+    const objectRegistry& obr
+) const
+{
+    if (!prime2Mean_)
+    {
+        return false;
+    }
+
+    const Type1* baseFieldPtr = obr.lookupObjectPtr<Type1>(fieldName_);
+
+    if (!baseFieldPtr)
+    {
+        return false;
+    }
+
+    const Type1& baseField = *baseFieldPtr;
+    const Type1& meanField = obr.lookupObject<Type1>(meanFieldName_);
+
+    Type2& prime2MeanField =
+        obr.lookupObjectRef<Type2>(prime2MeanFieldName_);
+
+    switch (windowType_)
+    {
+        case windowType::NONE:
+        {
+            scalar dt = this->dt(obr.time().deltaTValue());
+            scalar Dt = this->Dt();
+            scalar beta = dt/Dt;
+
+            prime2MeanField =
+                (1 - beta)*prime2MeanField
+              + beta*sqr(baseField)
+              - sqr(meanField);
+
+            break;
+        }
+        case windowType::APPROXIMATE:
+        {
+            scalar dt = this->dt(obr.time().deltaTValue());
+            scalar Dt = this->Dt();
+            scalar beta = dt/Dt;
+
+            if (Dt - dt >= window_)
+            {
+                beta = dt/window_;
+            }
+
+            prime2MeanField =
+                (1 - beta)*prime2MeanField
+              + beta*sqr(baseField)
+              - sqr(meanField);
+
+            break;
+        }
+        case windowType::EXACT:
+        {
+            // Not storing old time mean fields - treat all as TIME (integrated)
+            prime2MeanField = 0*prime2MeanField;
+            FIFOStack<scalar>::const_iterator timeIter =
+                windowTimes_.begin();
+            FIFOStack<word>::const_iterator nameIter =
+                windowFieldNames_.begin();
+
+            switch (base_)
+            {
+                case baseType::ITER:
+                {
+                    // ITER method stores an additional entry compared to TIME
+                    ++timeIter;
+                    ++nameIter;
+
+                    if (timeIter == windowTimes_.end()) return false;
+
+                    break;
+                }
+                default:
+                {}
+            }
+
+
+            scalar windowLength = timeIter();
+
+            const Type1* wOld = nullptr;
+
+            for
+            (
+                ;
+                timeIter != windowTimes_.end();
+                ++timeIter, ++nameIter
+            )
+            {
+                const word& fieldName = nameIter();
+                const scalar dt = timeIter();
+                const Type1* w = obr.lookupObjectPtr<Type1>(fieldName);
+
+                prime2MeanField += dt*(sqr((*w) - meanField));
+
+                if (wOld)
+                {
+                    prime2MeanField -= dt*(sqr((*wOld) - meanField));
+                }
+
+                wOld = w;
+            }
+
+            prime2MeanField /= windowLength;
+
+
+            break;
+        }
+        default:
+        {
+            FatalErrorInFunction
+                << "Unhandled windowType enumeration "
+                << windowTypeNames_[windowType_]
+                << abort(FatalError);
+        }
+    }
+
+    return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C
index 490325d809547e0ea174b40b63b35fa78ae326b1..5f34c9de2a0d7eef98ea1a5d0100527e45823da0 100644
--- a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C
+++ b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -32,13 +32,22 @@ License
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 template<class Type>
-void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
+void Foam::functionObjects::fieldAverage::addMeanFieldType
+(
+    fieldAverageItem& item
+)
 {
+    const word& fieldName = item.fieldName();
+
+    if (!foundObject<Type>(fieldName))
+    {
+        return;
+    }
+
     // Field has been found, so set active flag to true
-    faItems_[fieldi].active() = true;
+    item.active() = true;
 
-    const word& fieldName = faItems_[fieldi].fieldName();
-    const word& meanFieldName = faItems_[fieldi].meanFieldName();
+    const word& meanFieldName = item.meanFieldName();
 
     Log << "    Reading/initialising field " << meanFieldName << endl;
 
@@ -50,7 +59,7 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
             << " since an object with that name already exists."
             << " Disabling averaging for field." << endl;
 
-        faItems_[fieldi].mean() = false;
+        item.mean() = false;
     }
     else
     {
@@ -66,9 +75,9 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
                     meanFieldName,
                     obr().time().timeName(obr().time().startTime().value()),
                     obr(),
-                    restartOnOutput_
-                  ? IOobject::NO_READ
-                  : IOobject::READ_IF_PRESENT,
+                    restartOnOutput_ ?
+                        IOobject::NO_READ
+                      : IOobject::READ_IF_PRESENT,
                     IOobject::NO_WRITE
                 ),
                 1*baseField
@@ -79,41 +88,109 @@ void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldi)
 
 
 template<class Type>
-void Foam::functionObjects::fieldAverage::addMeanField(const label fieldi)
+void Foam::functionObjects::fieldAverage::addMeanField
+(
+    fieldAverageItem& item
+)
 {
     typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
     typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
     typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
 
-    if (faItems_[fieldi].mean())
+    if (item.mean())
     {
-        const word& fieldName = faItems_[fieldi].fieldName();
+        addMeanFieldType<VolFieldType>(item);
+        addMeanFieldType<SurfaceFieldType>(item);
+        addMeanFieldType<SurfFieldType>(item);
+    }
+}
 
-        if (foundObject<VolFieldType>(fieldName))
-        {
-            addMeanFieldType<VolFieldType>(fieldi);
-        }
-        else if (foundObject<SurfaceFieldType>(fieldName))
+
+template<class Type>
+void Foam::functionObjects::fieldAverage::restoreWindowFieldsType
+(
+    const fieldAverageItem& item
+)
+{
+    if (restartOnOutput_)
+    {
+        return;
+    }
+
+    const word& fieldName = item.fieldName();
+
+    const Type* fieldPtr = lookupObjectPtr<Type>(fieldName);
+
+    if (!fieldPtr)
+    {
+        return;
+    }
+
+    const FIFOStack<word>& fieldNames = item.windowFieldNames();
+
+    forAllConstIters(fieldNames, fieldIter)
+    {
+        const word& name = fieldIter();
+
+        IOobject io
+        (
+            name,
+            obr().time().timeName(obr().time().startTime().value()),
+            obr(),
+            IOobject::MUST_READ,
+            IOobject::NO_WRITE
+        );
+
+        if (io.typeHeaderOk<Type>(true))
         {
-            addMeanFieldType<SurfaceFieldType>(fieldi);
+            DebugInfo << "Read and store: " << name << endl;
+            obr().store(new Type(io, fieldPtr->mesh()));
         }
-        else if (foundObject<SurfFieldType>(fieldName))
+        else
         {
-            addMeanFieldType<SurfFieldType>(fieldi);
+            WarningInFunction
+                << "Unable to read window " << Type::typeName << " " << name
+                << ".  Averaging restart behaviour may be compromised"
+                << endl;
         }
     }
 }
 
 
+template<class Type>
+void Foam::functionObjects::fieldAverage::restoreWindowFields
+(
+    const fieldAverageItem& item
+)
+{
+    typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
+    typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
+    typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
+
+    if (item.window() > 0)
+    {
+        restoreWindowFieldsType<VolFieldType>(item);
+        restoreWindowFieldsType<SurfaceFieldType>(item);
+        restoreWindowFieldsType<SurfFieldType>(item);
+    }
+}
+
+
 template<class Type1, class Type2>
 void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
 (
-    const label fieldi
+    fieldAverageItem& item
 )
 {
-    const word& fieldName = faItems_[fieldi].fieldName();
-    const word& meanFieldName = faItems_[fieldi].meanFieldName();
-    const word& prime2MeanFieldName = faItems_[fieldi].prime2MeanFieldName();
+    const word& fieldName = item.fieldName();
+
+    if (!foundObject<Type1>(fieldName))
+    {
+        return;
+    }
+
+    const word& meanFieldName = item.meanFieldName();
+    const word& prime2MeanFieldName = item.prime2MeanFieldName();
 
     Log << "    Reading/initialising field " << prime2MeanFieldName << nl;
 
@@ -125,7 +202,7 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
             << " since an object with that name already exists."
             << " Disabling averaging for field." << endl;
 
-        faItems_[fieldi].prime2Mean() = false;
+        item.prime2Mean() = false;
     }
     else
     {
@@ -142,9 +219,9 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
                     prime2MeanFieldName,
                     obr().time().timeName(obr().time().startTime().value()),
                     obr(),
-                    restartOnOutput_
-                  ? IOobject::NO_READ
-                  : IOobject::READ_IF_PRESENT,
+                    restartOnOutput_?
+                        IOobject::NO_READ
+                      : IOobject::READ_IF_PRESENT,
                     IOobject::NO_WRITE
                 ),
                 sqr(baseField) - sqr(meanField)
@@ -155,7 +232,10 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
 
 
 template<class Type1, class Type2>
-void Foam::functionObjects::fieldAverage::addPrime2MeanField(const label fieldi)
+void Foam::functionObjects::fieldAverage::addPrime2MeanField
+(
+    fieldAverageItem& item
+)
 {
     typedef GeometricField<Type1, fvPatchField, volMesh> VolFieldType1;
     typedef GeometricField<Type1, fvsPatchField, surfaceMesh> SurfaceFieldType1;
@@ -165,144 +245,95 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanField(const label fieldi)
     typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
     typedef DimensionedField<Type2, surfGeoMesh> SurfFieldType2;
 
-    if (faItems_[fieldi].prime2Mean())
+    if (item.prime2Mean())
     {
-        const word& fieldName = faItems_[fieldi].fieldName();
-
-        if (!faItems_[fieldi].mean())
+        if (!item.mean())
         {
             FatalErrorInFunction
                 << "To calculate the prime-squared average, the "
                 << "mean average must also be selected for field "
-                << fieldName << nl << exit(FatalError);
+                << item.fieldName() << nl << exit(FatalError);
         }
 
-        if (foundObject<VolFieldType1>(fieldName))
-        {
-            addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(fieldi);
-        }
-        else if (foundObject<SurfaceFieldType1>(fieldName))
-        {
-            addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>
-            (
-                fieldi
-            );
-        }
-        else if (foundObject<SurfFieldType1>(fieldName))
-        {
-            addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>
-            (
-                fieldi
-            );
-        }
+        addPrime2MeanFieldType<VolFieldType1, VolFieldType2>(item);
+        addPrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>(item);
+        addPrime2MeanFieldType<SurfFieldType1, SurfFieldType2>(item);
     }
 }
 
 
 template<class Type>
-void Foam::functionObjects::fieldAverage::calculateMeanFieldType
+void Foam::functionObjects::fieldAverage::storeWindowFieldType
 (
-    const label fieldi
-) const
+    fieldAverageItem& item
+)
 {
-    const word& fieldName = faItems_[fieldi].fieldName();
-
-    if (foundObject<Type>(fieldName))
+    const word& fieldName = item.fieldName();
+    if (!foundObject<Type>(fieldName))
     {
-        const Type& baseField = lookupObject<Type>(fieldName);
-
-        Type& meanField = const_cast<Type&>
-        (
-            lookupObject<Type>(faItems_[fieldi].meanFieldName())
-        );
-
-        scalar dt = obr().time().deltaTValue();
-        scalar Dt = totalTime_[fieldi];
+        return;
+    }
 
-        if (faItems_[fieldi].iterBase())
-        {
-            dt = 1;
-            Dt = scalar(totalIter_[fieldi]);
-        }
+    const Type& baseField = lookupObject<Type>(fieldName);
 
-        scalar beta = dt/Dt;
+    const word windowFieldName = item.windowFieldName(this->name());
 
-        if (faItems_[fieldi].window() > 0)
-        {
-            const scalar w = faItems_[fieldi].window();
+    // Store on registry
+    obr().store
+    (
+        new Type
+        (
+            IOobject
+            (
+                windowFieldName,
+                obr().time().timeName(obr().time().startTime().value()),
+                obr(),
+                restartOnOutput_ ?
+                    IOobject::NO_READ
+                  : IOobject::READ_IF_PRESENT,
+                IOobject::NO_WRITE
+            ),
+            1*baseField
+        )
+    );
 
-            if (Dt - dt >= w)
-            {
-                beta = dt/w;
-            }
-        }
+    DebugInfo << "Create and store: " << windowFieldName << endl;
 
-        meanField = (1 - beta)*meanField + beta*baseField;
-    }
+    item.addToWindow(windowFieldName, obr().time().deltaTValue());
 }
 
 
 template<class Type>
-void Foam::functionObjects::fieldAverage::calculateMeanFields() const
+void Foam::functionObjects::fieldAverage::storeWindowFields()
 {
     typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
     typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
     typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
 
-    forAll(faItems_, i)
+    for (fieldAverageItem& item : faItems_)
     {
-        if (faItems_[i].mean())
+        if (item.storeWindowFields())
         {
-            calculateMeanFieldType<VolFieldType>(i);
-            calculateMeanFieldType<SurfaceFieldType>(i);
-            calculateMeanFieldType<SurfFieldType>(i);
+            storeWindowFieldType<VolFieldType>(item);
+            storeWindowFieldType<SurfaceFieldType>(item);
+            storeWindowFieldType<SurfFieldType>(item);
         }
     }
 }
 
 
-template<class Type1, class Type2>
-void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
-(
-    const label fieldi
-) const
+template<class Type>
+void Foam::functionObjects::fieldAverage::calculateMeanFields() const
 {
-    const word& fieldName = faItems_[fieldi].fieldName();
+    typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
+    typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
+    typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
 
-    if (foundObject<Type1>(fieldName))
+    for (const fieldAverageItem& item : faItems_)
     {
-        const Type1& baseField = lookupObject<Type1>(fieldName);
-        const Type1& meanField =
-            lookupObject<Type1>(faItems_[fieldi].meanFieldName());
-
-        Type2& prime2MeanField =
-            lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
-
-        scalar dt = obr().time().deltaTValue();
-        scalar Dt = totalTime_[fieldi];
-
-        if (faItems_[fieldi].iterBase())
-        {
-            dt = 1;
-            Dt = scalar(totalIter_[fieldi]);
-        }
-
-        scalar beta = dt/Dt;
-
-        if (faItems_[fieldi].window() > 0)
-        {
-            const scalar w = faItems_[fieldi].window();
-
-            if (Dt - dt >= w)
-            {
-                beta = dt/w;
-            }
-        }
-
-        prime2MeanField =
-            (1 - beta)*prime2MeanField
-          + beta*sqr(baseField)
-          - sqr(meanField);
+        item.calculateMeanField<VolFieldType>(obr());
+        item.calculateMeanField<SurfaceFieldType>(obr());
+        item.calculateMeanField<SurfFieldType>(obr());
     }
 }
 
@@ -318,21 +349,14 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
     typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
     typedef DimensionedField<Type2, surfGeoMesh> SurfFieldType2;
 
-    forAll(faItems_, i)
+    for (const fieldAverageItem& item : faItems_)
     {
-        if (faItems_[i].prime2Mean())
-        {
-            calculatePrime2MeanFieldType<VolFieldType1, VolFieldType2>(i);
-            calculatePrime2MeanFieldType<SurfaceFieldType1, SurfaceFieldType2>
-            (
-                i
-            );
-
-            calculatePrime2MeanFieldType<SurfFieldType1, SurfFieldType2>
-            (
-                i
-            );
-        }
+        item.calculatePrime2MeanField<VolFieldType1, VolFieldType2>(obr());
+        item.calculatePrime2MeanField<SurfaceFieldType1, SurfaceFieldType2>
+        (
+            obr()
+        );
+        item.calculatePrime2MeanField<SurfFieldType1, SurfFieldType2>(obr());
     }
 }
 
@@ -340,21 +364,21 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
 template<class Type1, class Type2>
 void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
 (
-    const label fieldi
+    const fieldAverageItem& item
 ) const
 {
-    const word& fieldName = faItems_[fieldi].fieldName();
+    const word& fieldName = item.fieldName();
 
-    if (foundObject<Type1>(fieldName))
+    if (!foundObject<Type1>(fieldName))
     {
-        const Type1& meanField =
-            lookupObject<Type1>(faItems_[fieldi].meanFieldName());
+        return;
+    }
 
-        Type2& prime2MeanField =
-            lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
+    const Type1& meanField = lookupObject<Type1>(item.meanFieldName());
 
-        prime2MeanField += sqr(meanField);
-    }
+    Type2& prime2MeanField = lookupObjectRef<Type2>(item.prime2MeanFieldName());
+
+    prime2MeanField += sqr(meanField);
 }
 
 
@@ -369,13 +393,16 @@ void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const
     typedef GeometricField<Type2, fvsPatchField, surfaceMesh> SurfaceFieldType2;
     typedef DimensionedField<Type2, surfGeoMesh> SurfFieldType2;
 
-    forAll(faItems_, i)
+    for (const fieldAverageItem& item : faItems_)
     {
-        if (faItems_[i].prime2Mean())
+        if (item.prime2Mean())
         {
-            addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(i);
-            addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>(i);
-            addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(i);
+            addMeanSqrToPrime2MeanType<VolFieldType1, VolFieldType2>(item);
+            addMeanSqrToPrime2MeanType<SurfaceFieldType1, SurfaceFieldType2>
+            (
+                item
+            );
+            addMeanSqrToPrime2MeanType<SurfFieldType1, SurfFieldType2>(item);
         }
     }
 }
@@ -402,22 +429,35 @@ void Foam::functionObjects::fieldAverage::writeFields() const
     typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
     typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
 
-    forAll(faItems_, i)
+    for (const fieldAverageItem& item : faItems_)
     {
-        if (faItems_[i].mean())
+        if (item.mean())
         {
-            const word& fieldName = faItems_[i].meanFieldName();
+            const word& fieldName = item.meanFieldName();
             writeFieldType<VolFieldType>(fieldName);
             writeFieldType<SurfaceFieldType>(fieldName);
             writeFieldType<SurfFieldType>(fieldName);
         }
-        if (faItems_[i].prime2Mean())
+
+        if (item.prime2Mean())
         {
-            const word& fieldName = faItems_[i].prime2MeanFieldName();
+            const word& fieldName = item.prime2MeanFieldName();
             writeFieldType<VolFieldType>(fieldName);
             writeFieldType<SurfaceFieldType>(fieldName);
             writeFieldType<SurfFieldType>(fieldName);
         }
+
+        if (item.writeWindowFields())
+        {
+            FIFOStack<word> fieldNames = item.windowFieldNames();
+            forAllConstIters(fieldNames, fieldNameIter)
+            {
+                const word& fieldName = fieldNameIter();
+                writeFieldType<VolFieldType>(fieldName);
+                writeFieldType<SurfaceFieldType>(fieldName);
+                writeFieldType<SurfFieldType>(fieldName);
+            }
+        }
     }
 }
 
diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C
index 296fb0d081a5b324dbe4f6eca387459cfc1935de..2c4ea97f34d8a7b837714a213d23bf69dfef30cb 100644
--- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C
+++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -55,7 +55,7 @@ fieldCoordinateSystemTransform
 )
 :
     fvMeshFunctionObject(name, runTime, dict),
-    fieldSet_(),
+    fieldSet_(mesh_),
     coordSys_(mesh_, dict.subDict("coordinateSystem"))
 {
     read(dict);
@@ -90,23 +90,27 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::read
     const dictionary& dict
 )
 {
-    fvMeshFunctionObject::read(dict);
-
-    dict.lookup("fields") >> fieldSet_;
+    if (fvMeshFunctionObject::read(dict))
+    {
+        fieldSet_.read(dict);
+        return true;
+    }
 
-    return true;
+    return false;
 }
 
 
 bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
 {
-    forAll(fieldSet_, fieldi)
+    fieldSet_.updateSelection();
+
+    for (const word& fieldName : fieldSet_.selection())
     {
-        transform<scalar>(fieldSet_[fieldi]);
-        transform<vector>(fieldSet_[fieldi]);
-        transform<sphericalTensor>(fieldSet_[fieldi]);
-        transform<symmTensor>(fieldSet_[fieldi]);
-        transform<tensor>(fieldSet_[fieldi]);
+        transform<scalar>(fieldName);
+        transform<vector>(fieldName);
+        transform<sphericalTensor>(fieldName);
+        transform<symmTensor>(fieldName);
+        transform<tensor>(fieldName);
     }
 
     return true;
@@ -115,9 +119,9 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
 
 bool Foam::functionObjects::fieldCoordinateSystemTransform::write()
 {
-    forAll(fieldSet_, fieldi)
+    forAllConstIters(fieldSet_, iter)
     {
-        writeObject(transformFieldName(fieldSet_[fieldi]));
+        writeObject(transformFieldName(iter()));
     }
 
     return true;
diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H
index f588d4f7341bd71634837db7b2d9c60789b44576..dbc0446cb7f9a4714ce2e09b07738aba109714ee 100644
--- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H
+++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H
@@ -83,6 +83,7 @@ SourceFiles
 
 #include "fvMeshFunctionObject.H"
 #include "coordinateSystem.H"
+#include "volFieldSelection.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -104,7 +105,7 @@ protected:
     // Protected data
 
         //- Fields to transform
-        wordList fieldSet_;
+        volFieldSelection fieldSet_;
 
         //- Co-ordinate system to transform to
         coordinateSystem coordSys_;
diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/functionObjects/field/fieldMinMax/fieldMinMax.C
index 35d68b92f0a5876b16aaf1a26edb2a9fe4376d7a..5d3e3f0bfdb8edd4b704a9c685f0bc7c4522543e 100644
--- a/src/functionObjects/field/fieldMinMax/fieldMinMax.C
+++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -51,9 +51,22 @@ Foam::functionObjects::fieldMinMax::modeTypeNames_
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
-void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const
+void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os)
 {
-    writeHeader(os, "Field minima and maxima");
+    if (!fieldSet_.updateSelection())
+    {
+        return;
+    }
+
+    if (writtenHeader_)
+    {
+        writeBreak(file());
+    }
+    else
+    {
+        writeHeader(os, "Field minima and maxima");
+    }
+
     writeCommented(os, "Time");
 
     if (location_)
@@ -77,14 +90,17 @@ void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const
     }
     else
     {
-        forAll(fieldSet_, fieldi)
+        forAllConstIters(fieldSet_.selection(), iter)
         {
-            writeTabbed(os, "min(" + fieldSet_[fieldi] + ')');
-            writeTabbed(os, "max(" + fieldSet_[fieldi] + ')');
+            const word& fieldName = iter();
+            writeTabbed(os, "min(" + fieldName + ')');
+            writeTabbed(os, "max(" + fieldName + ')');
         }
     }
 
     os  << endl;
+
+    writtenHeader_ = true;
 }
 
 
@@ -101,10 +117,9 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
     writeFile(mesh_, name, typeName, dict),
     location_(true),
     mode_(mdMag),
-    fieldSet_()
+    fieldSet_(mesh_)
 {
     read(dict);
-    writeFileHeader(file());
 }
 
 
@@ -124,7 +139,8 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
     location_ = dict.lookupOrDefault<Switch>("location", true);
 
     mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
-    dict.lookup("fields") >> fieldSet_;
+
+    fieldSet_.read(dict);
 
     return true;
 }
@@ -138,16 +154,18 @@ bool Foam::functionObjects::fieldMinMax::execute()
 
 bool Foam::functionObjects::fieldMinMax::write()
 {
+    writeFileHeader(file());
+
     if (!location_) writeTime(file());
     Log << type() << " " << name() <<  " write:" << nl;
 
-    forAll(fieldSet_, fieldi)
+    for (const word& fieldName : fieldSet_.selection())
     {
-        calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt);
-        calcMinMaxFields<vector>(fieldSet_[fieldi], mode_);
-        calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_);
-        calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_);
-        calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_);
+        calcMinMaxFields<scalar>(fieldName, mdCmpt);
+        calcMinMaxFields<vector>(fieldName, mode_);
+        calcMinMaxFields<sphericalTensor>(fieldName, mode_);
+        calcMinMaxFields<symmTensor>(fieldName, mode_);
+        calcMinMaxFields<tensor>(fieldName, mode_);
     }
 
     if (!location_) file()<< endl;
diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/functionObjects/field/fieldMinMax/fieldMinMax.H
index 588dc5c7fdd7ee22c41a43c601b583821fe6db54..9f7cd954a899f91f5e3cec466aa5c780f047c4f8 100644
--- a/src/functionObjects/field/fieldMinMax/fieldMinMax.H
+++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -82,6 +82,7 @@ SourceFiles
 #include "fvMeshFunctionObject.H"
 #include "writeFile.H"
 #include "vector.H"
+#include "volFieldSelection.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -124,7 +125,7 @@ protected:
         modeType mode_;
 
         //- Fields to assess min/max
-        wordList fieldSet_;
+        volFieldSelection fieldSet_;
 
 
     // Protected Member Functions
@@ -147,7 +148,7 @@ protected:
 
 
         //- Output file header information
-        virtual void writeFileHeader(Ostream& os) const;
+        virtual void writeFileHeader(Ostream& os);
 
         //- Disallow default bitwise copy construct
         fieldMinMax(const fieldMinMax&) = delete;
diff --git a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C
index 68291255d13db596b559b5ff0b58f43b0023a5f0..21c2cc459c9a24832e9f3551a56a4ae30274c1f6 100644
--- a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C
+++ b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C
@@ -68,7 +68,7 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::writeFileHeader
     DynamicList<word> commonFields(fields1.size());
     forAll(fields1, fieldi)
     {
-        label index = findIndex(fields2, fields1[fieldi]);
+        label index = fields2.find(fields1[fieldi]);
         if (index != -1)
         {
             commonFields.append(fields1[fieldi]);
diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.H b/src/functionObjects/field/nearWallFields/nearWallFields.H
index 9a2850c20a503125d07db5a8e1891ca9544fe0a5..85c67d9b2dab4056ee20922464b73d33ac2b7ea4 100644
--- a/src/functionObjects/field/nearWallFields/nearWallFields.H
+++ b/src/functionObjects/field/nearWallFields/nearWallFields.H
@@ -107,7 +107,7 @@ protected:
 
         // Read from dictionary
 
-            //- Fields to process
+            //- Fields to process (input-name output-name)
             List<Tuple2<word, word>> fieldSet_;
 
             //- Switch to send output to Info as well as to file
diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
index 8ae33b507f48aa30796f6932e9f8f19dfff7ae37..bf8a4a385605ae87ee29721fd602d984be6d6937 100644
--- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
+++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C
@@ -860,7 +860,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
             forAll(selected, i)
             {
                 const word& fldName = scalarNames[selected[i]];
-            Log << "    Scalar field " << fldName << endl;
+                Log << "    Scalar field " << fldName << endl;
 
                 const scalarField& fld = obr_.lookupObject
                 <
diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C
index 131d3ba025d6057121b3d7a9e34647d616f02db9..46406489c7865e7236eb382c41af46446346192d 100644
--- a/src/functionObjects/field/streamLine/streamLine.C
+++ b/src/functionObjects/field/streamLine/streamLine.C
@@ -52,7 +52,7 @@ void Foam::functionObjects::streamLine::track()
         initialParticles
     );
 
-    const sampledSet& seedPoints = sampledSetPtr_();
+    const sampledSet& seedPoints = sampledSetPoints();
 
     forAll(seedPoints, i)
     {
diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C
index 9eaae07a82229b7d9c6036c9ddc30931c2dc2b4f..d6a49bcce5b7746aa32ca2aa7d8566ef30c5e929 100644
--- a/src/functionObjects/field/streamLine/streamLineBase.C
+++ b/src/functionObjects/field/streamLine/streamLineBase.C
@@ -47,6 +47,38 @@ namespace functionObjects
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+const Foam::word&
+Foam::functionObjects::streamLineBase::sampledSetAxis() const
+{
+    if (sampledSetPtr_.empty())
+    {
+        sampledSetPoints();
+    }
+
+    return sampledSetAxis_;
+}
+
+
+const Foam::sampledSet&
+Foam::functionObjects::streamLineBase::sampledSetPoints() const
+{
+    if (sampledSetPtr_.empty())
+    {
+        sampledSetPtr_ = sampledSet::New
+        (
+            "seedSampleSet",
+            mesh_,
+            meshSearchMeshObject::New(mesh_),
+            dict_.subDict("seedSampleSet")
+        );
+
+        sampledSetAxis_ = sampledSetPtr_->axis();
+    }
+
+    return sampledSetPtr_();
+}
+
+
 Foam::autoPtr<Foam::indirectPrimitivePatch>
 Foam::functionObjects::streamLineBase::wallPatch() const
 {
@@ -54,12 +86,12 @@ Foam::functionObjects::streamLineBase::wallPatch() const
 
     label nFaces = 0;
 
-    forAll(patches, patchi)
+    for (const polyPatch& pp : patches)
     {
-        //if (!polyPatch::constraintType(patches[patchi].type()))
-        if (isA<wallPolyPatch>(patches[patchi]))
+        //if (!polyPatch::constraintType(pp.type()))
+        if (isA<wallPolyPatch>(pp))
         {
-            nFaces += patches[patchi].size();
+            nFaces += pp.size();
         }
     }
 
@@ -67,13 +99,11 @@ Foam::functionObjects::streamLineBase::wallPatch() const
 
     nFaces = 0;
 
-    forAll(patches, patchi)
+    for (const polyPatch& pp : patches)
     {
-        //if (!polyPatch::constraintType(patches[patchi].type()))
-        if (isA<wallPolyPatch>(patches[patchi]))
+        //if (!polyPatch::constraintType(pp.type()))
+        if (isA<wallPolyPatch>(pp))
         {
-            const polyPatch& pp = patches[patchi];
-
             forAll(pp, i)
             {
                 addressing[nFaces++] = pp.start()+i;
@@ -110,24 +140,24 @@ void Foam::functionObjects::streamLineBase::initInterpolations
     label nScalar = 0;
     label nVector = 0;
 
-    forAll(fields_, i)
+    for (const word& fieldName : fields_)
     {
-        if (foundObject<volScalarField>(fields_[i]))
+        if (foundObject<volScalarField>(fieldName))
         {
             nScalar++;
         }
-        else if (foundObject<volVectorField>(fields_[i]))
+        else if (foundObject<volVectorField>(fieldName))
         {
             nVector++;
         }
         else
         {
             FatalErrorInFunction
-                << "Cannot find field " << fields_[i] << nl
+                << "Cannot find field " << fieldName << nl
                 << "Valid scalar fields are:"
-                << mesh_.names(volScalarField::typeName) << nl
+                << flatOutput(mesh_.names(volScalarField::typeName)) << nl
                 << "Valid vector fields are:"
-                << mesh_.names(volVectorField::typeName)
+                << flatOutput(mesh_.names(volVectorField::typeName))
                 << exit(FatalError);
         }
     }
@@ -136,12 +166,11 @@ void Foam::functionObjects::streamLineBase::initInterpolations
     vvInterp.setSize(nVector);
     nVector = 0;
 
-    forAll(fields_, i)
+    for (const word& fieldName : fields_)
     {
-        if (foundObject<volScalarField>(fields_[i]))
+        if (foundObject<volScalarField>(fieldName))
         {
-            const volScalarField& f =
-                lookupObject<volScalarField>(fields_[i]);
+            const volScalarField& f = lookupObject<volScalarField>(fieldName);
             vsInterp.set
             (
                 nScalar++,
@@ -152,10 +181,9 @@ void Foam::functionObjects::streamLineBase::initInterpolations
                 )
             );
         }
-        else if (foundObject<volVectorField>(fields_[i]))
+        else if (foundObject<volVectorField>(fieldName))
         {
-            const volVectorField& f =
-                lookupObject<volVectorField>(fields_[i]);
+            const volVectorField& f = lookupObject<volVectorField>(fieldName);
 
             if (f.name() == UName_)
             {
@@ -231,7 +259,7 @@ void Foam::functionObjects::streamLineBase::storePoint
     DynamicList<vectorList>& newVectors
 ) const
 {
-    label sz = newTrack.size();
+    const label sz = newTrack.size();
 
     const List<point>& track = allTracks_[tracki];
 
@@ -274,6 +302,7 @@ void Foam::functionObjects::streamLineBase::trimToBox
 ) const
 {
     const List<point>& track = allTracks_[tracki];
+
     if (track.size())
     {
         for
@@ -287,7 +316,7 @@ void Foam::functionObjects::streamLineBase::trimToBox
             const point& endPt = track[segmenti];
 
             const vector d(endPt-startPt);
-            scalar magD = mag(d);
+            const scalar magD = mag(d);
             if (magD > ROOTVSMALL)
             {
                 if (bb.contains(startPt))
@@ -507,6 +536,12 @@ Foam::functionObjects::streamLineBase::~streamLineBase()
 
 bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
 {
+    if (&dict_ != &dict)
+    {
+        // Update local copy of dictionary:
+        dict_ = dict;
+    }
+
     fvMeshFunctionObject::read(dict);
 
     Info<< type() << " " << name() << ":" << nl;
@@ -516,7 +551,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
 
     Info<< "    Employing velocity field " << UName_ << endl;
 
-    if (findIndex(fields_, UName_) == -1)
+    if (!fields_.found(UName_))
     {
         FatalIOErrorInFunction(dict)
             << "Velocity field for tracking " << UName_
@@ -536,10 +571,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
 
 
     trackLength_ = VGREAT;
-    if (dict.found("trackLength"))
+    if (dict.readIfPresent("trackLength", trackLength_))
     {
-        dict.lookup("trackLength") >> trackLength_;
-
         Info<< type() << " : fixed track length specified : "
             << trackLength_ << nl << endl;
     }
@@ -562,14 +595,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
 
     cloudName_ = dict.lookupOrDefault<word>("cloud", type());
 
-    sampledSetPtr_ = sampledSet::New
-    (
-        "seedSampleSet",
-        mesh_,
-        meshSearchMeshObject::New(mesh_),
-        dict.subDict("seedSampleSet")
-    );
-    sampledSetAxis_ = sampledSetPtr_->axis();
+    sampledSetPtr_.clear();
+    sampledSetAxis_.clear();
 
     scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
     vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
@@ -756,7 +783,7 @@ bool Foam::functionObjects::streamLineBase::write()
                     new coordSet
                     (
                         "track" + Foam::name(nTracks),
-                        sampledSetAxis_                 //"xyz"
+                        sampledSetAxis()  // "xyz"
                     )
                 );
                 oldToNewTrack[tracki] = nTracks;
@@ -767,7 +794,7 @@ bool Foam::functionObjects::streamLineBase::write()
 
         // Convert scalar values
 
-        if (allScalars_.size() > 0 && tracks.size() > 0)
+        if (!allScalars_.empty() && !tracks.empty())
         {
             List<List<scalarField>> scalarValues(allScalars_.size());
 
@@ -781,7 +808,7 @@ bool Foam::functionObjects::streamLineBase::write()
                     scalarList& vals = allTrackVals[tracki];
                     if (vals.size())
                     {
-                        label newTracki = oldToNewTrack[tracki];
+                        const label newTracki = oldToNewTrack[tracki];
                         scalarValues[scalari][newTracki].transfer(vals);
                     }
                 }
@@ -811,7 +838,7 @@ bool Foam::functionObjects::streamLineBase::write()
 
         // Convert vector values
 
-        if (allVectors_.size() > 0 && tracks.size() > 0)
+        if (!allVectors_.empty() && !tracks.empty())
         {
             List<List<vectorField>> vectorValues(allVectors_.size());
 
@@ -825,7 +852,7 @@ bool Foam::functionObjects::streamLineBase::write()
                     vectorList& vals = allTrackVals[tracki];
                     if (vals.size())
                     {
-                        label newTracki = oldToNewTrack[tracki];
+                        const label newTracki = oldToNewTrack[tracki];
                         vectorValues[vectori][newTracki].transfer(vals);
                     }
                 }
@@ -854,20 +881,18 @@ bool Foam::functionObjects::streamLineBase::write()
     // File names are generated on the master but setProperty needs to
     // be across all procs
     Pstream::scatter(scalarVtkFile);
-    forAll(scalarNames_, namei)
+    for (const word& fieldName : scalarNames_)
     {
         dictionary propsDict;
         propsDict.add("file", scalarVtkFile);
-        const word& fieldName = scalarNames_[namei];
         setProperty(fieldName, propsDict);
     }
 
     Pstream::scatter(vectorVtkFile);
-    forAll(vectorNames_, namei)
+    for (const word& fieldName : vectorNames_)
     {
         dictionary propsDict;
         propsDict.add("file", vectorVtkFile);
-        const word& fieldName = vectorNames_[namei];
         setProperty(fieldName, propsDict);
     }
 
diff --git a/src/functionObjects/field/streamLine/streamLineBase.H b/src/functionObjects/field/streamLine/streamLineBase.H
index a87e3fd2109fb9decb105ee805da1240bd959c09..881ef4d140d7abf6fe966f206786fdb4fca257c9 100644
--- a/src/functionObjects/field/streamLine/streamLineBase.H
+++ b/src/functionObjects/field/streamLine/streamLineBase.H
@@ -63,6 +63,14 @@ class streamLineBase
 :
     public fvMeshFunctionObject
 {
+    // Private data
+
+        //- Seed set engine
+        mutable autoPtr<sampledSet> sampledSetPtr_;
+
+        //- Axis of the sampled points to output
+        mutable word sampledSetAxis_;
+
 protected:
 
         //- Input dictionary
@@ -102,35 +110,35 @@ protected:
         wordList vectorNames_;
 
 
-        // Demand driven
+      // Demand driven
 
-            //- Mesh searching enigne
-            autoPtr<meshSearch> meshSearchPtr_;
+        //- File writer for scalar data
+        autoPtr<writer<scalar>> scalarFormatterPtr_;
 
-            //- Seed set engine
-            autoPtr<sampledSet> sampledSetPtr_;
+        //- File writer for vector data
+        autoPtr<writer<vector>> vectorFormatterPtr_;
 
-            //- Axis of the sampled points to output
-            word sampledSetAxis_;
 
-            //- File writer for scalar data
-            autoPtr<writer<scalar>> scalarFormatterPtr_;
+      // Generated data
 
-            //- File writer for vector data
-            autoPtr<writer<vector>> vectorFormatterPtr_;
+        //- All tracks. Per track the points it passed through
+        DynamicList<List<point>> allTracks_;
 
+        //- Per scalarField, per track, the sampled values
+        List<DynamicList<scalarList>> allScalars_;
 
-        // Generated data
+        //- Per vectorField, per track, the sampled values
+        List<DynamicList<vectorList>> allVectors_;
 
-            //- All tracks. Per track the points it passed through
-            DynamicList<List<point>> allTracks_;
 
-            //- Per scalarField, per track, the sampled values
-            List<DynamicList<scalarList>> allScalars_;
+    // Protected Member Functions
 
-            //- Per vectorField, per track, the sampled values
-            List<DynamicList<vectorList>> allVectors_;
+        //- The axis of the sampledSet. Creates sampledSet if required.
+        const word& sampledSetAxis() const;
 
+        //- Demand driven construction of the sampledSet.
+        //  Also updates sampledSetAxis_
+        const sampledSet& sampledSetPoints() const;
 
         //- Construct patch out of all wall patch faces
         autoPtr<indirectPrimitivePatch> wallPatch() const;
diff --git a/src/functionObjects/field/streamLine/streamLineParticleCloud.H b/src/functionObjects/field/streamLine/streamLineParticleCloud.H
index 9fdbad50f5d8c52c59d42bf6650bc012186d93e1..dfe1461a7e9e042628a33b6e6d2a15e5280d2b69 100644
--- a/src/functionObjects/field/streamLine/streamLineParticleCloud.H
+++ b/src/functionObjects/field/streamLine/streamLineParticleCloud.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef streamLineCloud_H
-#define streamLineCloud_H
+#ifndef streamLineParticleCloud_H
+#define streamLineParticleCloud_H
 
 #include "Cloud.H"
 #include "streamLineParticle.H"
diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C
index 8a21bba8229227d128e1ef31002535a50a876d9b..89fc0d8b220bbd48c5456d02561b717a81e39f0c 100644
--- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C
+++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C
@@ -129,14 +129,14 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
             {
                 // Edge is in the forward circulation of this face, so
                 // work with the start point of the edge
-                eIndex = findIndex(otherFace, e.start());
+                eIndex = otherFace.find(e.start());
             }
             else
             {
                 // edDir == -1, so the edge is in the reverse
                 // circulation of this face, so work with the end
                 // point of the edge
-                eIndex = findIndex(otherFace, e.end());
+                eIndex = otherFace.find(e.end());
             }
 
             label tetBasePtI = mesh().tetBasePtIs()[facei];
@@ -194,7 +194,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace(const edge& meshEdge)
 
     // And adapt meshEdgeStart_.
     const Foam::face& f = mesh().faces()[tetFace()];
-    label fp = findIndex(f, meshEdge[0]);
+    label fp = f.find(meshEdge[0]);
 
     if (f.nextLabel(fp) == meshEdge[1])
     {
@@ -371,8 +371,8 @@ bool Foam::wallBoundedParticle::isTriAlongTrack
     if
     (
         currentE[0] == currentE[1]
-     || findIndex(triVerts, currentE[0]) == -1
-     || findIndex(triVerts, currentE[1]) == -1
+     || !triVerts.found(currentE[0])
+     || !triVerts.found(currentE[1])
     )
     {
         FatalErrorInFunction
diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
index ce96d787142c4c3a8a4899400aa661c9295d0f20..d5b25603293739717541e2f4463c520dad09af5b 100644
--- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
+++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
@@ -131,12 +131,11 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
         // Get the seed points
         // ~~~~~~~~~~~~~~~~~~~
 
-        const sampledSet& seedPoints = sampledSetPtr_();
-
+        const sampledSet& seedPoints = sampledSetPoints();
 
         forAll(seedPoints, i)
         {
-            label celli = seedPoints.cells()[i];
+            const label celli = seedPoints.cells()[i];
 
             if (celli != -1)
             {
diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H
index 8ce123d6a558617db83e4c9f694c482522ea365e..dc270ffa0d8505647c5c9872d388971cc758e067 100644
--- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H
+++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef streamLineCloud_H
-#define streamLineCloud_H
+#ifndef wallBoundedStreamLineParticleCloud_H
+#define wallBoundedStreamLineParticleCloud_H
 
 #include "Cloud.H"
 #include "wallBoundedStreamLineParticle.H"
diff --git a/src/functionObjects/solvers/Make/files b/src/functionObjects/solvers/Make/files
index 2b8e8f8d8e1369556a1a7e4ec7d171056e2a4076..ce5306b1c832eeec2a0dea067368eb313e450a49 100644
--- a/src/functionObjects/solvers/Make/files
+++ b/src/functionObjects/solvers/Make/files
@@ -1,3 +1,4 @@
 scalarTransport/scalarTransport.C
+energyTransport/energyTransport.C
 
 LIB = $(FOAM_LIBBIN)/libsolverFunctionObjects
diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C
new file mode 100644
index 0000000000000000000000000000000000000000..a8870378807ba179b430fb1ce18b0c70aaec70b0
--- /dev/null
+++ b/src/functionObjects/solvers/energyTransport/energyTransport.C
@@ -0,0 +1,487 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "energyTransport.H"
+#include "surfaceFields.H"
+#include "fvmDdt.H"
+#include "fvmDiv.H"
+#include "fvmLaplacian.H"
+#include "fvmSup.H"
+#include "turbulentTransportModel.H"
+#include "turbulentFluidThermoModel.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+    defineTypeNameAndDebug(energyTransport, 0);
+
+    addToRunTimeSelectionTable
+    (
+        functionObject,
+        energyTransport,
+        dictionary
+    );
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+Foam::volScalarField& Foam::functionObjects::energyTransport::transportedField()
+{
+    if (!foundObject<volScalarField>(fieldName_))
+    {
+        tmp<volScalarField> tfldPtr
+        (
+            new volScalarField
+            (
+                IOobject
+                (
+                    fieldName_,
+                    mesh_.time().timeName(),
+                    mesh_,
+                    IOobject::MUST_READ,
+                    IOobject::AUTO_WRITE
+                ),
+                mesh_
+            )
+        );
+        store(fieldName_, tfldPtr);
+    }
+
+    return lookupObjectRef<volScalarField>(fieldName_);
+}
+
+
+Foam::tmp<Foam::volScalarField>
+Foam::functionObjects::energyTransport::kappaEff() const
+{
+    // Incompressible
+    {
+        typedef incompressible::turbulenceModel turbType;
+
+        const turbType* turbPtr = lookupObjectPtr<turbType>
+        (
+            turbulenceModel::propertiesName
+        );
+
+        if (turbPtr)
+        {
+            return tmp<volScalarField>
+            (
+                new volScalarField
+                (
+                    kappa() + Cp()*turbPtr->nut()*rho()/Prt_
+                )
+            );
+        }
+    }
+
+    FatalErrorInFunction
+        << "Turbulence model not found" << exit(FatalError);
+    return tmp<volScalarField>();
+}
+
+
+Foam::tmp<Foam::volScalarField>
+Foam::functionObjects::energyTransport::rho() const
+{
+    tmp<volScalarField> trho
+    (
+        new volScalarField
+        (
+            IOobject
+            (
+                "trho",
+                mesh_.time().timeName(),
+                mesh_,
+                IOobject::NO_READ,
+                IOobject::NO_WRITE
+            ),
+            mesh_,
+            rho_
+        )
+    );
+
+    if (phases_.size())
+    {
+        trho.ref() = lookupObject<volScalarField>(rhoName_);
+    }
+    return trho;
+}
+
+
+Foam::tmp<Foam::volScalarField>
+Foam::functionObjects::energyTransport::Cp() const
+{
+    if (phases_.size())
+    {
+        tmp<volScalarField> tCp(phases_[0]*Cps_[0]);
+
+        for (label i = 1; i < phases_.size(); i++)
+        {
+            tCp.ref() += phases_[i]*Cps_[i];
+        }
+        return tCp;
+    }
+
+    tmp<volScalarField> tCp
+    (
+        new volScalarField
+        (
+            IOobject
+            (
+                "tCp",
+                mesh_.time().timeName(),
+                mesh_,
+                IOobject::NO_READ,
+                IOobject::NO_WRITE
+            ),
+            mesh_,
+            Cp_
+        )
+    );
+
+    return tCp;
+}
+
+
+Foam::tmp<Foam::volScalarField>
+Foam::functionObjects::energyTransport::kappa() const
+{
+    if (phases_.size())
+    {
+        tmp<volScalarField> tkappa(phases_[0]*kappas_[0]);
+
+        for (label i = 1; i < phases_.size(); i++)
+        {
+            tkappa.ref() += phases_[i]*kappas_[i];
+        }
+        return tkappa;
+    }
+
+    tmp<volScalarField> tkappa
+    (
+        new volScalarField
+        (
+            IOobject
+            (
+                "tkappa",
+                mesh_.time().timeName(),
+                mesh_,
+                IOobject::NO_READ,
+                IOobject::NO_WRITE
+            ),
+            mesh_,
+            kappa_
+        )
+    );
+
+    return tkappa;
+}
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::functionObjects::energyTransport::energyTransport
+(
+    const word& name,
+    const Time& runTime,
+    const dictionary& dict
+)
+:
+    fvMeshFunctionObject(name, runTime, dict),
+    fieldName_(dict.lookupOrDefault<word>("field", "T")),
+    phiName_(dict.lookupOrDefault<word>("phi", "phi")),
+    rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
+    nCorr_(0),
+    schemesField_("unknown-schemesField"),
+    fvOptions_(mesh_),
+    multiphaseThermo_(dict.subOrEmptyDict("phaseThermos")),
+    Cp_
+    (
+        dict.lookupOrDefault
+        (
+            "Cp",
+            dimensionedScalar("Cp", dimEnergy/dimMass/dimTemperature, 0)
+        )
+    ),
+    kappa_
+    (
+        dict.lookupOrDefault
+        (
+            "kappa",
+            dimensionedScalar
+            (
+                "kappa",
+                dimEnergy/dimTime/dimLength/dimTemperature,
+                0
+            )
+        )
+    ),
+    rho_
+    (
+        dict.lookupOrDefault("rhoInf", dimensionedScalar("rho", dimDensity, 0))
+    ),
+    Prt_(dict.lookupOrDefault("Prt", dimensionedScalar("Prt", dimless, 1))),
+    rhoCp_
+    (
+        IOobject
+        (
+            "rhoCp",
+            mesh_.time().timeName(),
+            mesh_,
+            IOobject::NO_READ,
+            IOobject::NO_WRITE
+        ),
+        mesh_,
+        dimensionedScalar("rhoCp", dimEnergy/dimTemperature/dimVolume, 0.0)
+    )
+{
+    read(dict);
+
+    // If the flow is multiphase
+    if (!multiphaseThermo_.empty())
+    {
+        Cps_.setSize(multiphaseThermo_.size());
+        kappas_.setSize(Cps_.size());
+        phaseNames_.setSize(Cps_.size());
+
+        label phasei = 0;
+        forAllConstIters(multiphaseThermo_, iter)
+        {
+            const word& key = iter().keyword();
+
+            if (!multiphaseThermo_.isDict(key))
+            {
+                FatalErrorInFunction
+                    << "Found non-dictionary entry " << iter()
+                    << " in top-level dictionary " << multiphaseThermo_
+                    << exit(FatalError);
+            }
+
+            const dictionary& dict = multiphaseThermo_.subDict(key);
+
+            phaseNames_[phasei] = key;
+
+            Cps_.set
+            (
+                phasei,
+                new dimensionedScalar
+                (
+                    "Cp",
+                    dimEnergy/dimMass/dimTemperature,
+                    dict.lookup("Cp")
+                )
+            );
+
+            kappas_.set
+            (
+                phasei,
+                new dimensionedScalar //[J/m/s/K]
+                (
+                    "kappa",
+                    dimEnergy/dimTime/dimLength/dimTemperature,
+                    dict.lookup("kappa")
+                )
+            );
+
+            ++phasei;
+        }
+
+        phases_.setSize(phaseNames_.size());
+        forAll(phaseNames_, i)
+        {
+            phases_.set
+            (
+                i,
+                mesh_.lookupObjectRefPtr<volScalarField>(phaseNames_[i])
+            );
+        }
+
+        rhoCp_ = rho()*Cp();
+        rhoCp_.oldTime();
+    }
+    else
+    {
+        if (Cp_.value() == 0.0 || kappa_.value() == 0.0)
+        {
+            FatalErrorInFunction
+                << " Multiphase thermo dictionary not found and Cp/kappa "
+                << " for single  phase are zero. Please entry either"
+                << exit(FatalError);
+        }
+
+    }
+
+    // Force creation of transported field so any BCs using it can
+    // look it up
+    volScalarField& s = transportedField();
+    s.correctBoundaryConditions();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::energyTransport::~energyTransport()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::energyTransport::read(const dictionary& dict)
+{
+    fvMeshFunctionObject::read(dict);
+
+    dict.readIfPresent("phi", phiName_);
+    dict.readIfPresent("rho", rhoName_);
+
+    schemesField_ = dict.lookupOrDefault("schemesField", fieldName_);
+
+    dict.readIfPresent("nCorr", nCorr_);
+
+    if (dict.found("fvOptions"))
+    {
+        fvOptions_.reset(dict.subDict("fvOptions"));
+    }
+
+    return true;
+}
+
+
+bool Foam::functionObjects::energyTransport::execute()
+{
+    volScalarField& s = transportedField();
+
+    Log << type() << " execute: " << s.name() << endl;
+
+    const surfaceScalarField& phi =
+        mesh_.lookupObject<surfaceScalarField>(phiName_);
+
+    // Calculate the diffusivity
+    const volScalarField kappaEff("kappaEff", this->kappaEff());
+
+    word divScheme("div(phi," + schemesField_ + ")");
+    word laplacianScheme
+    (
+        "laplacian(kappaEff," + schemesField_ + ")"
+    );
+
+    // Set under-relaxation coeff
+    scalar relaxCoeff = 0.0;
+    if (mesh_.relaxEquation(schemesField_))
+    {
+        relaxCoeff = mesh_.equationRelaxationFactor(schemesField_);
+    }
+
+    if (phi.dimensions() == dimMass/dimTime)
+    {
+        rhoCp_ = rho()*Cp();
+        const surfaceScalarField rhoCpPhi(fvc::interpolate(Cp())*phi);
+
+        for (label i = 0; i <= nCorr_; i++)
+        {
+            fvScalarMatrix sEqn
+            (
+                fvm::ddt(rhoCp_, s)
+              + fvm::div(rhoCpPhi, s, divScheme)
+              - fvm::Sp(fvc::ddt(rhoCp_) + fvc::div(rhoCpPhi), s)
+              - fvm::laplacian(kappaEff, s, laplacianScheme)
+             ==
+                fvOptions_(rhoCp_, s)
+            );
+
+            sEqn.relax(relaxCoeff);
+
+            fvOptions_.constrain(sEqn);
+
+            sEqn.solve(mesh_.solverDict(schemesField_));
+        }
+    }
+    else if (phi.dimensions() == dimVolume/dimTime)
+    {
+        dimensionedScalar rhoCp(rho_*Cp_);
+
+        const surfaceScalarField CpPhi(rhoCp*phi);
+
+        tmp<volScalarField> trhoCp
+        (
+            new volScalarField
+            (
+                IOobject
+                (
+                    "trhoCp",
+                    mesh_.time().timeName(),
+                    mesh_,
+                    IOobject::NO_READ,
+                    IOobject::NO_WRITE
+                ),
+                mesh_,
+                rhoCp
+            )
+        );
+
+        for (label i = 0; i <= nCorr_; i++)
+        {
+            fvScalarMatrix sEqn
+            (
+                fvm::ddt(rhoCp, s)
+              + fvm::div(CpPhi, s, divScheme)
+              - fvm::laplacian(kappaEff, s, laplacianScheme)
+             ==
+                fvOptions_(trhoCp.ref(), s)
+            );
+
+            sEqn.relax(relaxCoeff);
+
+            fvOptions_.constrain(sEqn);
+
+            sEqn.solve(mesh_.solverDict(schemesField_));
+        }
+    }
+    else
+    {
+        FatalErrorInFunction
+            << "Incompatible dimensions for phi: " << phi.dimensions() << nl
+            << "Dimensions should be " << dimMass/dimTime << " or "
+            << dimVolume/dimTime << exit(FatalError);
+    }
+
+    Log << endl;
+
+    return true;
+}
+
+
+bool Foam::functionObjects::energyTransport::write()
+{
+    return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.H b/src/functionObjects/solvers/energyTransport/energyTransport.H
new file mode 100644
index 0000000000000000000000000000000000000000..07dd407d484acba048ab8d655dbf515b80af4610
--- /dev/null
+++ b/src/functionObjects/solvers/energyTransport/energyTransport.H
@@ -0,0 +1,323 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::functionObjects::energyTransport
+
+Group
+    grpSolversFunctionObjects
+
+Description
+    Evolves a simplified energy transport equation for incompressible flows.
+    It takes into account the inertia, conduction and convection terms plus
+    a source.
+
+    - The field name must be temperature and its BC's specified in the time
+      directory.
+    - The turbulence model should be incompressible
+    - In order to use in a incompressible multi phase a list of thermal
+      properties are needed. See bellow
+
+
+Usage
+    Example of function object specification to solve a energy transport
+    equation for a single phase flow plus a source term
+    \verbatim
+    functions
+    {
+        energy
+        {
+            type            energyTransport;
+            libs             ("libenergyTransportFunctionObjects.so");
+
+            enabled         true;
+            writeControl    outputTime;
+            writeInterval   1;
+
+            field           T;
+
+            // volumetric Flux
+            phi             phi;
+
+            // Thermal properties
+            Cp              Cp    [J/kg/K]  1e3;
+            kappa           kappa [W/m/K]   0.0257;
+            rhoInf          rho   [kg/m^3]  1.2;
+
+            write           true;
+
+            fvOptions
+            {
+                viscousDissipation
+                {
+                    type            viscousDissipation;
+                    enabled         true;
+
+                    viscousDissipationCoeffs
+                    {
+                        fields          (T);
+                        rhoInf          $....rhoInf;
+                    }
+                }
+            }
+        }
+    }
+    \endverbatim
+
+    Example of function object specification to solve a energy transport
+    equation for a multiphase phase flow plus a source term
+
+    equation:
+    \verbatim
+    functions
+    {
+        energy
+        {
+            type            energyTransport;
+            libs            ("libenergyTransportFunctionObjects.so");
+
+            enabled         true;
+            writeControl    outputTime;
+            writeInterval   1;
+
+            field           T;
+
+            // rho field name
+            rho             rho;
+            // mass flux for multiphase
+            phi             rhoPhi;
+
+            write           true;
+
+            // Thermal properties of the phases
+            phaseThermos
+            {
+                alpha.air
+                {
+                    Cp          1e3;
+                    kappa       0.0243;
+                }
+                alpha.mercury
+                {
+                    Cp          140;
+                    kappa       8.2;
+                }
+                alpha.oil
+                {
+                    Cp          2e3;
+                    kappa       0.2;
+                }
+                alpha.water
+                {
+                    Cp          4e3;
+                    kappa       0.6;
+                }
+            }
+
+
+            fvOptions
+            {
+                viscousDissipation
+                {
+                    type            viscousDissipation;
+                    enabled         true;
+
+                    viscousDissipationCoeffs
+                    {
+                        fields          (T);
+                        rho             rho; //rho Field
+                    }
+                }
+            }
+        }
+    }
+    \endverbatim
+
+    Where the entries comprise:
+    \table
+        Property     | Description             | Required    | Default value
+        type         | Type name: energyTransport | yes      |
+        field        | Name of the scalar field | no         | T
+        phi          | Name of flux field      | no          | phi
+        rho          | Name of density field   | no          | rho
+        nCorr        | Number of correctors    | no          | 0
+        schemesField | Name of field to specify schemes | no | field name
+        fvOptions    | List of scalar sources  | no          |
+        Cp           | Heat capacity for single phase | no   | 0
+        rhoInf       | Density for single phase | no         | 0
+        kappa        | Thermal conductivity for single phase | no   | 0
+        Prt          | Turbulent Prandt number | no          | 1.0
+        phaseThermos | Dictionary for multi-phase thermo |no | null
+        fvOptions    | Opotional extra sources | no          | null
+    \endtable
+
+See also
+    Foam::functionObjects::fvMeshFunctionObject
+
+SourceFiles
+    energyTransport.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef functionObjects_energyTransport_H
+#define functionObjects_energyTransport_H
+
+#include "fvMeshFunctionObject.H"
+#include "volFields.H"
+#include "fvOptionList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class energyTransport Declaration
+\*---------------------------------------------------------------------------*/
+
+class energyTransport
+:
+    public fvMeshFunctionObject
+{
+    // Private data
+
+        //- Name of the transport field.
+        word fieldName_;
+
+        //- Name of flux field
+        word phiName_;
+
+        //- Name of density field
+        word rhoName_;
+
+        //- Number of corrector iterations (optional)
+        label nCorr_;
+
+        //- Name of field whose schemes are used (optional)
+        word schemesField_;
+
+        //- Run-time selectable finite volume options, e.g. sources, constraints
+        fv::optionList fvOptions_;
+
+        //- Dictionary for multiphase thermos
+        dictionary multiphaseThermo_;
+
+        //- List of phase names
+        wordList phaseNames_;
+
+        //- List of phase heat capacities
+        PtrList<dimensionedScalar> Cps_;
+
+        //- List of phase thermal diffusivity for temperature [J/m/s/K]
+        PtrList<dimensionedScalar> kappas_;
+
+        //- Unallocated phase list
+        UPtrList<volScalarField> phases_;
+
+        //- Heat capacity for single phase flows
+        dimensionedScalar Cp_;
+
+        //- Thermal diffusivity for temperature for single phase flows
+        dimensionedScalar kappa_;
+
+        //- Density for single phase flows
+        dimensionedScalar rho_;
+
+        //- Turbulent Prandt number
+        dimensionedScalar Prt_;
+
+        //- rhoCp
+        volScalarField rhoCp_;
+
+
+    // Private Member Functions
+
+        //- Return reference to registered transported field
+        volScalarField& transportedField();
+
+        //- Return the diffusivity field
+        tmp<volScalarField> kappaEff() const;
+
+        //- Return rho field
+        tmp<volScalarField> rho() const;
+
+        //- Return Cp
+        tmp<volScalarField> Cp() const;
+
+        //- Return kappa
+        tmp<volScalarField> kappa() const;
+
+        //- Disallow default bitwise copy construct
+        energyTransport(const energyTransport&) = delete;
+
+        //- Disallow default bitwise assignment
+        void operator=(const energyTransport&) = delete;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("energyTransport");
+
+
+    // Constructors
+
+        //- Construct from Time and dictionary
+        energyTransport
+        (
+            const word& name,
+            const Time& runTime,
+            const dictionary& dict
+        );
+
+
+    //- Destructor
+    virtual ~energyTransport();
+
+
+    // Member Functions
+
+        //- Read the energyTransport data
+        virtual bool read(const dictionary&);
+
+        //- Calculate the energyTransport
+        virtual bool execute();
+
+        //- Do nothing.
+        //  The volScalarField is registered and written automatically
+        virtual bool write();
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/functionObjects/utilities/residuals/residuals.C b/src/functionObjects/utilities/residuals/residuals.C
index a9f41a02b1b875215e59aeb6eb8a4406c6050406..0cdf2c6d97818767698d623ab806ee0d31b16350 100644
--- a/src/functionObjects/utilities/residuals/residuals.C
+++ b/src/functionObjects/utilities/residuals/residuals.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2015-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -46,15 +46,26 @@ namespace functionObjects
 
 // * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
 
-void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) const
+void Foam::functionObjects::residuals::writeFileHeader(Ostream& os)
 {
-    writeHeader(os, "Residuals");
-    writeCommented(os, "Time");
+    if (!fieldSet_.updateSelection())
+    {
+        return;
+    }
 
-    forAll(fieldSet_, fieldi)
+    if (writtenHeader_)
+    {
+        writeBreak(file());
+    }
+    else
     {
-        const word& fieldName = fieldSet_[fieldi];
+        writeHeader(os, "Residuals");
+    }
+
+    writeCommented(os, "Time");
 
+    for (const word& fieldName : fieldSet_.selection())
+    {
         writeFileHeader<scalar>(os, fieldName);
         writeFileHeader<vector>(os, fieldName);
         writeFileHeader<sphericalTensor>(os, fieldName);
@@ -63,6 +74,8 @@ void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) const
     }
 
     os << endl;
+
+    writtenHeader_ = true;
 }
 
 
@@ -77,10 +90,9 @@ Foam::functionObjects::residuals::residuals
 :
     fvMeshFunctionObject(name, runTime, dict),
     writeFile(obr_, name, typeName, dict),
-    fieldSet_()
+    fieldSet_(mesh_)
 {
     read(dict);
-    writeFileHeader(file());
 }
 
 
@@ -94,13 +106,13 @@ Foam::functionObjects::residuals::~residuals()
 
 bool Foam::functionObjects::residuals::read(const dictionary& dict)
 {
-    fvMeshFunctionObject::read(dict);
-
-    wordList allFields(dict.lookup("fields"));
-    wordHashSet uniqueFields(allFields);
-    fieldSet_ = uniqueFields.toc();
+    if (fvMeshFunctionObject::read(dict))
+    {
+        fieldSet_.read(dict);
+        return true;
+    }
 
-    return true;
+    return false;
 }
 
 
@@ -114,12 +126,12 @@ bool Foam::functionObjects::residuals::write()
 {
     if (Pstream::master())
     {
+        writeFileHeader(file());
+
         writeTime(file());
 
-        forAll(fieldSet_, fieldi)
+        for (const word& fieldName : fieldSet_.selection())
         {
-            const word& fieldName = fieldSet_[fieldi];
-
             writeResidual<scalar>(fieldName);
             writeResidual<vector>(fieldName);
             writeResidual<sphericalTensor>(fieldName);
diff --git a/src/functionObjects/utilities/residuals/residuals.H b/src/functionObjects/utilities/residuals/residuals.H
index 283e4738da88309544fbee7b7f4e6038d03a5f87..02e2db2843c4e62dd00e695fa0faf03cda813119 100644
--- a/src/functionObjects/utilities/residuals/residuals.H
+++ b/src/functionObjects/utilities/residuals/residuals.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2015-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -62,6 +62,7 @@ SourceFiles
 
 #include "fvMeshFunctionObject.H"
 #include "writeFile.H"
+#include "solverFieldSelection.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -84,13 +85,13 @@ protected:
     // Protected data
 
         //- Fields to write residuals
-        wordList fieldSet_;
+        solverFieldSelection fieldSet_;
 
 
     // Protected Member Functions
 
         //- Output file header information
-        void writeFileHeader(Ostream& os) const;
+        void writeFileHeader(Ostream& os);
 
         //- Output file header information per primitive type value
         template<class Type>
diff --git a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C
index e19f500b16c479721bf85503c83d2c658073939a..843b115d07e749cef26b6394c4c7800b83ec950e 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C
@@ -179,16 +179,11 @@ void angularOscillatingDisplacementPointPatchVectorField::write
 ) const
 {
     pointPatchField<vector>::write(os);
-    os.writeKeyword("axis")
-        << axis_ << token::END_STATEMENT << nl;
-    os.writeKeyword("origin")
-        << origin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("angle0")
-        << angle0_ << token::END_STATEMENT << nl;
-    os.writeKeyword("amplitude")
-        << amplitude_ << token::END_STATEMENT << nl;
-    os.writeKeyword("omega")
-        << omega_ << token::END_STATEMENT << nl;
+    os.writeEntry("axis", axis_);
+    os.writeEntry("origin", origin_);
+    os.writeEntry("angle0", angle0_);
+    os.writeEntry("amplitude", amplitude_);
+    os.writeEntry("omega", omega_);
     p0_.writeEntry("p0", os);
     writeEntry("value", os);
 }
diff --git a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C
index 5932d8402c370859d25b7082df07a6d9450d57b8..3f64821dd71b9311b08696d0898a78f6e035dfed 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C
@@ -184,16 +184,11 @@ void angularOscillatingVelocityPointPatchVectorField::write
 ) const
 {
     pointPatchField<vector>::write(os);
-    os.writeKeyword("axis")
-        << axis_ << token::END_STATEMENT << nl;
-    os.writeKeyword("origin")
-        << origin_ << token::END_STATEMENT << nl;
-    os.writeKeyword("angle0")
-        << angle0_ << token::END_STATEMENT << nl;
-    os.writeKeyword("amplitude")
-        << amplitude_ << token::END_STATEMENT << nl;
-    os.writeKeyword("omega")
-        << omega_ << token::END_STATEMENT << nl;
+    os.writeEntry("axis", axis_);
+    os.writeEntry("origin", origin_);
+    os.writeEntry("angle0", angle0_);
+    os.writeEntry("amplitude", amplitude_);
+    os.writeEntry("omega", omega_);
     p0_.writeEntry("p0", os);
     writeEntry("value", os);
 }
diff --git a/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C
index 9e36b8cefbe71521f0ba67a1ce9a75c68f490cc8..98e83d7b88b04f2c38bbd822e89f98972f00225d 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C
@@ -117,10 +117,8 @@ void oscillatingDisplacementPointPatchVectorField::updateCoeffs()
 void oscillatingDisplacementPointPatchVectorField::write(Ostream& os) const
 {
     pointPatchField<vector>::write(os);
-    os.writeKeyword("amplitude")
-        << amplitude_ << token::END_STATEMENT << nl;
-    os.writeKeyword("omega")
-        << omega_ << token::END_STATEMENT << nl;
+    os.writeEntry("amplitude", amplitude_);
+    os.writeEntry("omega", omega_);
     writeEntry("value", os);
 }
 
diff --git a/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C
index f75b568ecafed07ada806af13968d68aef483966..f99d53852846e240401b20414fcba24edd99e554 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C
@@ -160,10 +160,8 @@ void oscillatingVelocityPointPatchVectorField::updateCoeffs()
 void oscillatingVelocityPointPatchVectorField::write(Ostream& os) const
 {
     pointPatchField<vector>::write(os);
-    os.writeKeyword("amplitude")
-        << amplitude_ << token::END_STATEMENT << nl;
-    os.writeKeyword("omega")
-        << omega_ << token::END_STATEMENT << nl;
+    os.writeEntry("amplitude", amplitude_);
+    os.writeEntry("omega", omega_);
     p0_.writeEntry("p0", os);
     writeEntry("value", os);
 }
diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C
index 85d3cd19fd82f6f5f85058dbaee1f39394a9f1cc..5e2053ef99081e9d34c078a67be271039b84154f 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C
@@ -470,10 +470,12 @@ void Foam::surfaceDisplacementPointPatchVectorField::write(Ostream& os) const
     os.writeEntry("projectDirection", projectDir_);
     os.writeEntry("wedgePlane", wedgePlane_);
 
-    if (frozenPointsZone_ != word::null)
-    {
-        os.writeEntry("frozenPointsZone", frozenPointsZone_);
-    }
+    os.writeEntryIfDifferent<word>
+    (
+        "frozenPointsZone",
+        word::null,
+        frozenPointsZone_
+    );
 }
 
 
diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
index a85df2a86373406e533eda6df1e4ec4ba3e46a64..469cebfb79b848160b298624d9cb40477d4347fc 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C
@@ -431,10 +431,13 @@ void Foam::surfaceSlipDisplacementPointPatchVectorField::write
     os.writeEntry("projectMode", projectModeNames_[projectMode_]);
     os.writeEntry("projectDirection", projectDir_);
     os.writeEntry("wedgePlane", wedgePlane_);
-    if (frozenPointsZone_ != word::null)
-    {
-        os.writeEntry("frozenPointsZone", frozenPointsZone_);
-    }
+
+    os.writeEntryIfDifferent<word>
+    (
+        "frozenPointsZone",
+        word::null,
+        frozenPointsZone_
+    );
 }
 
 
diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C
index 886f9440e98b6d0a109d37e5828dd42ac8321f9b..1fbcb49f96bdd8ec7d14f2152bb2ced6cbe09c62 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C
@@ -596,23 +596,20 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write
 {
     fixedValuePointPatchField<Type>::write(os);
 
-    this->writeEntryIfDifferent(os, "setAverage", Switch(false), setAverage_);
+    os.writeEntryIfDifferent("setAverage", Switch(false), setAverage_);
+    os.writeEntryIfDifferent<scalar>("perturb", 1e-5, perturb_);
 
-    this->writeEntryIfDifferent(os, "perturb", scalar(1e-5), perturb_);
-
-    this->writeEntryIfDifferent
+    os.writeEntryIfDifferent
     (
-        os,
         "fieldTable",
         this->internalField().name(),
         fieldTableName_
     );
 
-    this->writeEntryIfDifferent
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "mapMethod",
-        word("planarInterpolation"),
+        "planarInterpolation",
         mapMethod_
     );
 
diff --git a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C
index ca1193bb432efdd3728bac6769c296b9e0029f72..82eee2cddcaec83ff0013edd2b7032ea5406917f 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C
@@ -260,10 +260,8 @@ void uniformInterpolatedDisplacementPointPatchVectorField::write(Ostream& os)
 const
 {
     pointPatchField<vector>::write(os);
-    os.writeKeyword("field")
-        << fieldName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("interpolationScheme")
-        << interpolationScheme_ << token::END_STATEMENT << nl;
+    os.writeEntry("field", fieldName_);
+    os.writeEntry("interpolationScheme", interpolationScheme_);
     writeEntry("value", os);
 }
 
diff --git a/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C
index 34976e9827e293cf771f92c8b7d13d51af1308ac..e5196ceab990694056568416926ea82195199f3c 100644
--- a/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C
+++ b/src/fvMotionSolver/pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C
@@ -121,12 +121,9 @@ void Foam::waveDisplacementPointPatchVectorField::updateCoeffs()
 void Foam::waveDisplacementPointPatchVectorField::write(Ostream& os) const
 {
     pointPatchField<vector>::write(os);
-    os.writeKeyword("amplitude")
-        << amplitude_ << token::END_STATEMENT << nl;
-    os.writeKeyword("omega")
-        << omega_ << token::END_STATEMENT << nl;
-    os.writeKeyword("waveNumber")
-        << waveNumber_ << token::END_STATEMENT << nl;
+    os.writeEntry("amplitude", amplitude_);
+    os.writeEntry("omega", omega_);
+    os.writeEntry("waveNumber", waveNumber_);
     writeEntry("value", os);
 }
 
diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files
index 9a8376a95cd20672f6f6037df3ced67776fc5cae..18c3d6fcb269ad3bdf1ffdaf2557f45533c69402 100644
--- a/src/fvOptions/Make/files
+++ b/src/fvOptions/Make/files
@@ -42,6 +42,7 @@ $(derivedSources)/solidificationMeltingSource/solidificationMeltingSource.C
 $(derivedSources)/solidificationMeltingSource/solidificationMeltingSourceIO.C
 $(derivedSources)/tabulatedAccelerationSource/tabulatedAccelerationSource.C
 $(derivedSources)/tabulatedAccelerationSource/tabulated6DoFAcceleration/tabulated6DoFAcceleration.C
+$(derivedSources)/viscousDissipation/viscousDissipation.C
 
 interRegion = sources/interRegion
 $(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
new file mode 100644
index 0000000000000000000000000000000000000000..9b4e9800890d55da659e34ed01b37ffda33f9d9e
--- /dev/null
+++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C
@@ -0,0 +1,222 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "viscousDissipation.H"
+#include "fvMatrices.H"
+#include "turbulentTransportModel.H"
+#include "turbulentFluidThermoModel.H"
+#include "basicThermo.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+    defineTypeNameAndDebug(viscousDissipation, 0);
+
+    addToRunTimeSelectionTable
+    (
+        option,
+        viscousDissipation,
+        dictionary
+    );
+}
+}
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+Foam::tmp<Foam::volScalarField> Foam::fv::viscousDissipation::rho() const
+{
+    tmp<volScalarField> trho
+    (
+        new volScalarField
+        (
+            IOobject
+            (
+                "trho",
+                mesh_.time().timeName(),
+                mesh_,
+                IOobject::NO_READ,
+                IOobject::NO_WRITE
+            ),
+            mesh_,
+            rho_
+        )
+    );
+
+    if (rho_.value() > 0)
+    {
+        return trho;
+    }
+    else if (rhoName_ != "none")
+    {
+        trho.ref() = mesh_.lookupObject<volScalarField>(rhoName_);
+        return trho;
+    }
+
+    FatalErrorInFunction
+        << "Neither rhoName nor rho are specified."
+        << exit(FatalError);
+
+    return tmp<volScalarField>();
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::fv::viscousDissipation::viscousDissipation
+(
+    const word& sourceName,
+    const word& modelType,
+    const dictionary& dict,
+    const fvMesh& mesh
+)
+:
+    option(sourceName, modelType, dict, mesh),
+    UName_(coeffs_.lookupOrDefault<word>("U", "U")),
+    rhoName_(coeffs_.lookupOrDefault<word>("rho", "none")),
+    rho_
+    (
+        coeffs_.lookupOrDefault
+        (
+            "rhoInf",
+            dimensionedScalar("rho", dimDensity, 0)
+        )
+    )
+{
+    const basicThermo* thermoPtr =
+        mesh_.lookupObjectPtr<basicThermo>(basicThermo::dictName);
+
+    if (thermoPtr)
+    {
+        fieldNames_.setSize(1, thermoPtr->he().name());
+    }
+
+    if (fieldNames_.empty())
+    {
+        coeffs_.lookup("fields") >> fieldNames_;
+    }
+
+    if (fieldNames_.size() != 1)
+    {
+        FatalErrorInFunction
+            << "settings are:" << fieldNames_ << exit(FatalError);
+    }
+
+    applied_.setSize(fieldNames_.size(), false);
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+Foam::tmp<Foam::volSymmTensorField> Foam::fv::viscousDissipation::
+devRhoReff() const
+{
+    // Incompressible
+    {
+        typedef incompressible::turbulenceModel turbType;
+
+        const turbType* turbPtr =
+            mesh_.lookupObjectPtr<turbType>(turbulenceModel::propertiesName);
+
+        if (turbPtr)
+        {
+            return tmp<volSymmTensorField>(rho()*turbPtr->devRhoReff());
+        }
+    }
+
+    // Compressible
+    {
+        typedef compressible::turbulenceModel turbType;
+
+        const turbType* turbPtr =
+            mesh_.lookupObjectPtr<turbType>(turbulenceModel::propertiesName);
+
+        if (turbPtr)
+        {
+            return tmp<volSymmTensorField>(turbPtr->devRhoReff());
+        }
+    }
+
+    FatalErrorInFunction
+        << " The turbulence model is not found in the database."
+        << exit(FatalError);
+
+    return tmp<volSymmTensorField>();
+}
+
+
+void Foam::fv::viscousDissipation::addSup
+(
+    const volScalarField& rho,
+    fvMatrix<scalar>& eqn,
+    const label fieldi
+)
+{
+    typedef typename outerProduct<vector, vector>::type GradType;
+    typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType;
+
+    word gradUName("grad(" + UName_ + ')');
+
+    tmp<GradFieldType> tgradU
+    (
+        new GradFieldType
+        (
+            IOobject
+            (
+                "gradU",
+                mesh_.time().timeName(),
+                mesh_.time(),
+                IOobject::NO_READ,
+                IOobject::NO_WRITE
+            ),
+            mesh_,
+            dimensionedTensor("zero", inv(dimTime) , tensor::zero)
+        )
+    );
+
+    // Cached?
+    const GradFieldType* gradUPtr =
+        mesh_.lookupObjectPtr<GradFieldType>(gradUName);
+
+    if (gradUPtr)
+    {
+        tgradU.ref() = *gradUPtr;
+    }
+    else
+    {
+        const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
+        tgradU.ref() = fvc::grad(U);
+    }
+
+    const volScalarField D("D", devRhoReff() && tgradU.ref());
+
+    eqn -= D;
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H
new file mode 100644
index 0000000000000000000000000000000000000000..5902080125ef9278d078648f14eb4cf315a3330e
--- /dev/null
+++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.H
@@ -0,0 +1,149 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::fv::viscousDissipation
+
+Group
+    grpFvOptionsSources
+
+Description
+    Calculates and applies the viscous dissipation energy source to the energy
+    equation.
+
+Usage
+    Example usage:
+    \verbatim
+    fields          (h);                    // Name of energy field
+    \endverbatim
+
+SourceFiles
+    viscousDissipation.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef viscousDissipation_H
+#define viscousDissipation_H
+
+#include "fvOption.H"
+#include "uniformDimensionedFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+
+/*---------------------------------------------------------------------------*\
+                    Class viscousDissipation Declaration
+\*---------------------------------------------------------------------------*/
+
+class viscousDissipation
+:
+    public option
+{
+    // Private data
+
+        //- Name of velocity field; default = U
+        word UName_;
+
+        //- Name of the rho field for incompressible solvers
+        word rhoName_;
+
+        //- Density for single phase flows
+        dimensionedScalar rho_;
+
+
+     // Private Member Functions
+
+        //- Return the viscosity field
+        tmp<volSymmTensorField> devRhoReff() const;
+
+        //- Disallow default bitwise copy construct
+        viscousDissipation(const viscousDissipation&) = delete;
+
+        //- Disallow default bitwise assignment
+        void operator=(const viscousDissipation&) = delete;
+
+private:
+
+    // Private member functions
+
+
+        //- Return rho field
+        tmp<volScalarField> rho() const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("viscousDissipation");
+
+
+    // Constructors
+
+        //- Construct from explicit source name and mesh
+        viscousDissipation
+        (
+            const word& sourceName,
+            const word& modelType,
+            const dictionary& dict,
+            const fvMesh& mesh
+        );
+
+
+    // Member Functions
+
+        // Evaluate
+
+            //- Add explicit contribution to compressible energy equation
+            virtual void addSup
+            (
+                const volScalarField& rho,
+                fvMatrix<scalar>& eqn,
+                const label fieldi
+            );
+
+
+        // IO
+
+            //- Read source dictionary
+            virtual bool read(const dictionary& dict)
+            {
+                return true;
+            }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace fv
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fvOptions/sources/general/codedSource/CodedSource.C b/src/fvOptions/sources/general/codedSource/CodedSource.C
index 4611cd23174a545c6401fea75a83844b3fc8e2fa..2ea05cf09a8962292ae5bf4ed59330523c817629 100644
--- a/src/fvOptions/sources/general/codedSource/CodedSource.C
+++ b/src/fvOptions/sources/general/codedSource/CodedSource.C
@@ -90,7 +90,7 @@ Foam::dlLibraryTable& Foam::fv::CodedSource<Type>::libs() const
 template<class Type>
 Foam::string Foam::fv::CodedSource<Type>::description() const
 {
-    return "fvOption:: " + name_;
+    return "fvOption::" + name_;
 }
 
 
diff --git a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C
index 24ccdccae6abe8259fae6d74827f543138bb8d5c..d0a7f439d2025b3805c0d6b655fb2e3ced9c10f7 100644
--- a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C
+++ b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C
@@ -774,7 +774,7 @@ const Foam::word& Foam::genericFvPatchField<Type>::actualType() const
 template<class Type>
 void Foam::genericFvPatchField<Type>::write(Ostream& os) const
 {
-    os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl;
+    os.writeEntry("type", actualTypeName_);
 
     forAllConstIter(dictionary, dict_, iter)
     {
diff --git a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C
index 815d7af99b06945e51ac2ee08f25ed67df5acac9..52744cdf3cd4a8b1d7f4449322b0d41baafc6b14 100644
--- a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C
+++ b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C
@@ -567,7 +567,7 @@ const Foam::word& Foam::genericPointPatchField<Type>::actualType() const
 template<class Type>
 void Foam::genericPointPatchField<Type>::write(Ostream& os) const
 {
-    os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl;
+    os.writeEntry("type", actualTypeName_);
 
     forAllConstIter(dictionary, dict_, iter)
     {
diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C
index 3648d6a0c25d639efa870db41141e87b3e24fa51..5bdcc7fb1a23282272915f3cbfc39a6c5a528e46 100644
--- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C
+++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C
@@ -127,7 +127,7 @@ void Foam::DSMCCloud<ParcelType>::initialise
             {
                 const word& moleculeName(molecules[i]);
 
-                label typeId(findIndex(typeIdList_, moleculeName));
+                label typeId = typeIdList_.find(moleculeName);
 
                 if (typeId == -1)
                 {
@@ -137,7 +137,7 @@ void Foam::DSMCCloud<ParcelType>::initialise
                 }
 
                 const typename ParcelType::constantProperties& cP =
-                constProps(typeId);
+                    constProps(typeId);
 
                 scalar numberDensity = numberDensities[i];
 
diff --git a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C
index 3b85d705876ba385ed5f54fb2a0d3eee13afd11b..154faee32bef5adb2f706b8d1d616322d91a68dc 100644
--- a/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C
+++ b/src/lagrangian/DSMC/submodels/InflowBoundaryModel/FreeStream/FreeStream.C
@@ -93,7 +93,7 @@ Foam::FreeStream<CloudType>::FreeStream
             numberDensitiesDict.lookup(molecules[i])
         );
 
-        moleculeTypeIds_[i] = findIndex(cloud.typeIdList(), molecules[i]);
+        moleculeTypeIds_[i] = cloud.typeIdList().find(molecules[i]);
 
         if (moleculeTypeIds_[i] == -1)
         {
diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C
index 4eba7f4cf753af6b3ad6824fc54c269c797037cb..5f07b4d1f228cd90960e23606f89967644802fb8 100644
--- a/src/lagrangian/basic/Cloud/Cloud.C
+++ b/src/lagrangian/basic/Cloud/Cloud.C
@@ -176,7 +176,7 @@ void Foam::Cloud<ParticleType>::move
         pIter().stepFraction() = 0;
     }
 
-    // List of lists of particles to be transfered for all of the
+    // List of lists of particles to be transferred for all of the
     // neighbour processors
     List<IDLList<ParticleType>> particleTransferLists
     (
@@ -292,19 +292,19 @@ void Foam::Cloud<ParticleType>::move
         pBufs.finishedSends(allNTrans);
 
 
-        bool transfered = false;
+        bool transferred = false;
 
         for (const label n : allNTrans)
         {
             if (n)
             {
-                transfered = true;
+                transferred = true;
                 break;
             }
         }
-        reduce(transfered, orOp<bool>());
+        reduce(transferred, orOp<bool>());
 
-        if (!transfered)
+        if (!transferred)
         {
             break;
         }
diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C
index 5ed13963da66da0d6dba2d15f95fb847ba1aa6c4..8115ad62f57392451df1e7bf1a2b69f4f9dc818a 100644
--- a/src/lagrangian/basic/particle/particleIO.C
+++ b/src/lagrangian/basic/particle/particleIO.C
@@ -199,7 +199,6 @@ void Foam::particle::writePosition(Ostream& os) const
         p.position = position();
         p.celli = celli_;
 
-        vector pos(position());
         os.write(reinterpret_cast<const char*>(&p.position), s);
     }
 
diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H b/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H
index 855d307277a4ad2389b604523be19aebc026b3b5..bbff6f2de6a8e6837fc3dd2c8ccbec668b10a01c 100644
--- a/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H
+++ b/src/lagrangian/intermediate/parcels/include/makeParcelDispersionModels.H
@@ -23,8 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef makeParcelDispersionModels_h
-#define makeParcelDispersionModels_h
+#ifndef makeParcelDispersionModels_H
+#define makeParcelDispersionModels_H
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C
index e981fc903b9ad38a5f8697f6122928de60b4c5f5..00ccbe77390059ce872cd4b68945cefafd357db6 100644
--- a/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C
+++ b/src/lagrangian/intermediate/phaseProperties/phaseProperties/phasePropertiesIO.C
@@ -43,9 +43,9 @@ Foam::phaseProperties::phaseProperties(Istream& is)
     phase_ = phaseTypeNames[phaseInfo.keyword()];
     stateLabel_ = phaseToStateLabel(phase_);
 
-    if (phaseInfo.size() > 0)
+    const label nComponents = phaseInfo.size();
+    if (nComponents)
     {
-        label nComponents = phaseInfo.size();
         names_.setSize(nComponents, "unknownSpecie");
         Y_.setSize(nComponents, 0.0);
         carrierIds_.setSize(nComponents, -1);
@@ -74,10 +74,9 @@ Foam::Istream& Foam::operator>>(Istream& is, phaseProperties& pp)
     pp.phase_ = pp.phaseTypeNames[phaseInfo.keyword()];
     pp.stateLabel_ = pp.phaseToStateLabel(pp.phase_);
 
-    if (phaseInfo.size() > 0)
+    const label nComponents = phaseInfo.size();
+    if (nComponents)
     {
-        label nComponents = phaseInfo.size();
-
         pp.names_.setSize(nComponents, "unknownSpecie");
         pp.Y_.setSize(nComponents, 0.0);
         pp.carrierIds_.setSize(nComponents, -1);
@@ -101,16 +100,14 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const phaseProperties& pp)
 {
     os.check(FUNCTION_NAME);
 
-    os  << pp.phaseTypeNames[pp.phase_] << nl << token::BEGIN_BLOCK << nl
-        << incrIndent;
+    os.beginBlock(pp.phaseTypeNames[pp.phase_]);
 
     forAll(pp.names_, cmptI)
     {
-        os.writeKeyword(pp.names_[cmptI]) << pp.Y_[cmptI]
-            << token::END_STATEMENT << nl;
+        os.writeEntry(pp.names_[cmptI], pp.Y_[cmptI]);
     }
 
-    os  << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 
     os.check(FUNCTION_NAME);
     return os;
diff --git a/src/lagrangian/intermediate/submodels/CloudSubModelBase.C b/src/lagrangian/intermediate/submodels/CloudSubModelBase.C
index 39bcb8da2f2b59db61f09af6b2e42f5ef5f06ad8..807fd4e6cece93433676528a2d02aa92a2e6be89 100644
--- a/src/lagrangian/intermediate/submodels/CloudSubModelBase.C
+++ b/src/lagrangian/intermediate/submodels/CloudSubModelBase.C
@@ -126,8 +126,7 @@ bool Foam::CloudSubModelBase<CloudType>::writeTime() const
 template<class CloudType>
 void Foam::CloudSubModelBase<CloudType>::write(Ostream& os) const
 {
-    os.writeKeyword("owner") << owner_.name() << token::END_STATEMENT
-        << nl;
+    os.writeEntry("owner", owner_.name());
 
     subModelBase::write(os);
 }
diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H
index 99a63183a27f7c13540eef08bfe5844b684a2222..336b29a1aa629f228ca74203166487ecef79d6c3 100644
--- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H
+++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationCloudAbsorptionEmission_H
-#define radiationCloudAbsorptionEmission_H
+#ifndef radiation_cloudAbsorptionEmission_H
+#define radiation_cloudAbsorptionEmission_H
 
 #include "absorptionEmissionModel.H"
 
diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H
index fa4a9338080b64ed989bdd6c514f3a2e09bc94c1..44b6de546c597fd23f2c633e81ea35fa43d8b0fc 100644
--- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H
+++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationCloudScatter_H
-#define radiationCloudScatter_H
+#ifndef radiation_cloudScatter_H
+#define radiation_cloudScatter_H
 
 #include "scatterModel.H"
 
diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H
index b1c9a354b4d623c35f17aef8b5d4a2bd8e51c9aa..947998d4c07bd29d9f7951728f806f178804e709 100644
--- a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H
+++ b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeI.H
@@ -319,10 +319,9 @@ inline void Foam::molecule::constantProperties::setInteracionSiteBools
 
     forAll(siteIds_, i)
     {
-        const word& id(siteIds[i]);
-
-        pairPotentialSites_[i] = (findIndex(pairPotSiteIds, id) > -1);
+        const word& id = siteIds[i];
 
+        pairPotentialSites_[i] = pairPotSiteIds.found(id);
         electrostaticSites_[i] = (mag(siteCharges_[i]) > VSMALL);
     }
 }
@@ -409,7 +408,7 @@ inline bool Foam::molecule::constantProperties::pairPotentialSite
     label sId
 ) const
 {
-    label s = findIndex(siteIds_, sId);
+    label s = siteIds_.find(sId);
 
     if (s == -1)
     {
@@ -434,7 +433,7 @@ inline bool Foam::molecule::constantProperties::electrostaticSite
     label sId
 ) const
 {
-    label s = findIndex(siteIds_, sId);
+    label s = siteIds_.find(sId);
 
     if (s == -1)
     {
diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C
index 6952e7ca55467d4ef0021dac33ffcaa09a8b3010..0b41ed96f8fe4dc26c3a62c25db3fbaf4b5dc04f 100644
--- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C
+++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C
@@ -74,7 +74,7 @@ void Foam::moleculeCloud::buildConstProps()
         {
             const word& siteId = siteIdNames[sI];
 
-            siteIds[sI] = findIndex(siteIdList, siteId);
+            siteIds[sI] = siteIdList.find(siteId);
 
             if (siteIds[sI] == -1)
             {
@@ -293,23 +293,22 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps()
 
                         if (evaluatePotentialLimit(*molI, *molJ))
                         {
-                            label idI = molI->id();
-
-                            label idJ = molJ->id();
+                            const label idI = molI->id();
+                            const label idJ = molJ->id();
 
                             if
                             (
                                 idI == idJ
-                             || findIndex(pot_.removalOrder(), idJ)
-                              < findIndex(pot_.removalOrder(), idI)
+                             || pot_.removalOrder().find(idJ)
+                              < pot_.removalOrder().find(idI)
                             )
                             {
-                                if (findIndex(molsToDelete, molJ) == -1)
+                                if (!molsToDelete.found(molJ))
                                 {
                                     molsToDelete.append(molJ);
                                 }
                             }
-                            else if (findIndex(molsToDelete, molI) == -1)
+                            else if (!molsToDelete.found(molI))
                             {
                                 molsToDelete.append(molI);
                             }
@@ -326,23 +325,22 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps()
                 {
                     if (evaluatePotentialLimit(*molI, *molJ))
                     {
-                        label idI = molI->id();
-
-                        label idJ = molJ->id();
+                        const label idI = molI->id();
+                        const label idJ = molJ->id();
 
                         if
                         (
                             idI == idJ
-                         || findIndex(pot_.removalOrder(), idJ)
-                          < findIndex(pot_.removalOrder(), idI)
+                         || pot_.removalOrder().find(idJ)
+                          < pot_.removalOrder().find(idI)
                         )
                         {
-                            if (findIndex(molsToDelete, molJ) == -1)
+                            if (!molsToDelete.found(molJ))
                             {
                                 molsToDelete.append(molJ);
                             }
                         }
-                        else if (findIndex(molsToDelete, molI) == -1)
+                        else if (!molsToDelete.found(molI))
                         {
                             molsToDelete.append(molI);
                         }
@@ -405,25 +403,24 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps()
 
                         if (evaluatePotentialLimit(*molI, *molJ))
                         {
-                            label idI = molI->id();
-
-                            label idJ = molJ->id();
+                            const label idI = molI->id();
+                            const label idJ = molJ->id();
 
                             if
                             (
-                                findIndex(pot_.removalOrder(), idI)
-                              < findIndex(pot_.removalOrder(), idJ)
+                                pot_.removalOrder().find(idI)
+                              < pot_.removalOrder().find(idJ)
                             )
                             {
-                                if (findIndex(molsToDelete, molI) == -1)
+                                if (!molsToDelete.found(molI))
                                 {
                                     molsToDelete.append(molI);
                                 }
                             }
                             else if
                             (
-                                findIndex(pot_.removalOrder(), idI)
-                             == findIndex(pot_.removalOrder(), idJ)
+                                pot_.removalOrder().find(idI)
+                             == pot_.removalOrder().find(idJ)
                             )
                             {
                                 // Remove one of the molecules
@@ -433,7 +430,7 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps()
 
                                 if (molI->origId() > molJ->origId())
                                 {
-                                    if (findIndex(molsToDelete, molI) == -1)
+                                    if (!molsToDelete.found(molI))
                                     {
                                         molsToDelete.append(molI);
                                     }
@@ -566,7 +563,7 @@ void Foam::moleculeCloud::initialiseMolecules
 
                     forAll(latticeIds, i)
                     {
-                        label id = findIndex(pot_.idList(), latticeIds[i]);
+                        label id = pot_.idList().find(latticeIds[i]);
 
                         const molecule::constantProperties& cP(constProps(id));
 
@@ -726,7 +723,7 @@ void Foam::moleculeCloud::initialiseMolecules
 
                         forAll(latticePositions, p)
                         {
-                            label id = findIndex(pot_.idList(), latticeIds[p]);
+                            label id = pot_.idList().find(latticeIds[p]);
 
                             const vector& latticePosition =
                                 vector
@@ -749,7 +746,7 @@ void Foam::moleculeCloud::initialiseMolecules
                             const label cell =
                                 mesh_.cellTree().findInside(globalPosition);
 
-                            if (findIndex(zone, cell) != -1)
+                            if (zone.found(cell))
                             {
                                 createMolecule
                                 (
@@ -792,11 +789,8 @@ void Foam::moleculeCloud::initialiseMolecules
                                 {
                                     forAll(latticePositions, p)
                                     {
-                                        label id = findIndex
-                                        (
-                                            pot_.idList(),
-                                            latticeIds[p]
-                                        );
+                                        const label id =
+                                            pot_.idList().find(latticeIds[p]);
 
                                         const vector& latticePosition =
                                             vector
@@ -829,7 +823,7 @@ void Foam::moleculeCloud::initialiseMolecules
                                                 globalPosition
                                             );
 
-                                        if (findIndex(zone, cell) != -1)
+                                        if (zone.found(cell))
                                         {
                                             createMolecule
                                             (
@@ -863,11 +857,8 @@ void Foam::moleculeCloud::initialiseMolecules
                                 {
                                     forAll(latticePositions, p)
                                     {
-                                        label id = findIndex
-                                        (
-                                            pot_.idList(),
-                                            latticeIds[p]
-                                        );
+                                        const label id =
+                                            pot_.idList().find(latticeIds[p]);
 
                                         const vector& latticePosition =
                                             vector
@@ -900,7 +891,7 @@ void Foam::moleculeCloud::initialiseMolecules
                                                 globalPosition
                                             );
 
-                                        if (findIndex(zone, cell) != -1)
+                                        if (zone.found(cell))
                                         {
                                             createMolecule
                                             (
diff --git a/src/lagrangian/molecularDynamics/potential/potential/potential.C b/src/lagrangian/molecularDynamics/potential/potential/potential.C
index 8c8b04e8b916a03d823067f16643d345ff3062e8..5c120c6e025e21b862b135c0fa092fd4210511c7 100644
--- a/src/lagrangian/molecularDynamics/potential/potential/potential.C
+++ b/src/lagrangian/molecularDynamics/potential/potential/potential.C
@@ -51,7 +51,7 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict)
         {
             const word& siteId = siteIdNames[sI];
 
-            if (findIndex(siteIdList, siteId) == -1)
+            if (!siteIdList.found(siteId))
             {
                 siteIdList.append(siteId);
             }
@@ -63,14 +63,14 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict)
         {
             const word& siteId = pairPotSiteIds[sI];
 
-            if (findIndex(siteIdNames, siteId) == -1)
+            if (!siteIdNames.found(siteId))
             {
                 FatalErrorInFunction
                     << siteId << " in pairPotentialSiteIds is not in siteIds: "
                     << siteIdNames << nl << abort(FatalError);
             }
 
-            if (findIndex(pairPotentialSiteIdList, siteId) == -1)
+            if (!pairPotentialSiteIdList.found(siteId))
             {
                 pairPotentialSiteIdList.append(siteId);
             }
@@ -83,7 +83,7 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict)
     {
         const word& siteId = siteIdList[aSIN];
 
-        if (findIndex(pairPotentialSiteIdList, siteId) == -1)
+        if (!pairPotentialSiteIdList.found(siteId))
         {
             pairPotentialSiteIdList.append(siteId);
         }
@@ -169,7 +169,7 @@ void Foam::potential::potential::readPotentialDict()
 
         forAll(removalOrder_, rO)
         {
-            removalOrder_[rO] = findIndex(idList_, remOrd[rO]);
+            removalOrder_[rO] = idList_.find(remOrd[rO]);
 
             if (removalOrder_[rO] == -1)
             {
@@ -288,7 +288,7 @@ void Foam::potential::potential::readMdInitialiseDict
                     << abort(FatalError);
             }
 
-            if (findIndex(idList,id) == -1)
+            if (!idList.found(id))
             {
                 idList.append(id);
             }
@@ -319,7 +319,7 @@ void Foam::potential::potential::readMdInitialiseDict
                     moleculePropertiesDict.subDict(id).lookup("siteIds")
                 );
 
-                if (findIndex(siteIds, tetherSiteId) != -1)
+                if (siteIds.found(tetherSiteId))
                 {
                     idFound = true;
                 }
diff --git a/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C b/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C
index 8833d793041db507bb6d3fb2336b717374e4c143..545f7a04f516b6ed2989937711427fa6cfce4023 100644
--- a/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C
+++ b/src/lagrangian/molecularDynamics/potential/tetherPotential/tetherPotentialList/tetherPotentialList.C
@@ -45,7 +45,7 @@ void Foam::tetherPotentialList::readTetherPotentialDict
     {
         word tetherPotentialName = tetherSiteIdList[t];
 
-        label tetherId = findIndex(siteIdList, tetherPotentialName);
+        label tetherId = siteIdList.find(tetherPotentialName);
 
         if (tetherId == -1)
         {
diff --git a/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H b/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H
index f10a12205700913037c7ed7d00f72602fd9b8a97..7d3473b062bf3ebc3b0ea921d0b4a91e261d5429 100644
--- a/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H
+++ b/src/lagrangian/turbulence/parcels/include/makeParcelTurbulenceDispersionModels.H
@@ -23,8 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef makeParcelTurbulenceDispersionModels_h
-#define makeParcelTurbulenceDispersionModels_h
+#ifndef makeParcelTurbulenceDispersionModels_H
+#define makeParcelTurbulenceDispersionModels_H
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H b/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H
index db6d224dd318cfbc730c0661f3bb145559748fc9..fccd7734b07e14230a7281567eb2bdd030e8e647 100644
--- a/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H
+++ b/src/lagrangian/turbulence/parcels/include/makeThermoParcelTurbulenceForces.H
@@ -23,8 +23,8 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef makeThermoParcelTurbulenceForces_h
-#define makeThermoParcelTurbulenceForces_h
+#ifndef makeThermoParcelTurbulenceForces_H
+#define makeThermoParcelTurbulenceForces_H
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C
index 1ed664749896ef3ec42c46703cbeb8f0c74f12fc..87bf0d84acb6b5293b4863c848bf61cb6a834ad8 100644
--- a/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C
+++ b/src/lagrangian/turbulence/submodels/Kinematic/DispersionModel/DispersionRASModel/DispersionRASModel.C
@@ -184,9 +184,8 @@ void Foam::DispersionRASModel<CloudType>::write(Ostream& os) const
 {
     DispersionModel<CloudType>::write(os);
 
-    os.writeKeyword("ownK") << ownK_ << token::END_STATEMENT << endl;
-    os.writeKeyword("ownEpsilon") << ownEpsilon_ << token::END_STATEMENT
-        << endl;
+    os.writeEntry("ownK", ownK_);
+    os.writeEntry("ownEpsilon", ownEpsilon_);
 }
 
 
diff --git a/src/lumpedPointMotion/lumpedPointState.C b/src/lumpedPointMotion/lumpedPointState.C
index 0ef9f5a48fd9b16eb62f56dc81c3650806dc56e8..e15e3371c1c91218be8f284f780152221d6d20dd 100644
--- a/src/lumpedPointMotion/lumpedPointState.C
+++ b/src/lumpedPointMotion/lumpedPointState.C
@@ -254,7 +254,7 @@ void Foam::lumpedPointState::writeDict(Ostream& os) const
     os.writeEntry("angles", angles_);
     if (degrees_)
     {
-        os.writeKeyword("degrees") << "true;" << nl;
+        os.writeEntry("degrees", word("true"));
     }
 }
 
diff --git a/src/mesh/Allwmake b/src/mesh/Allwmake
index 9aa9ba5bfcc7d030af4e9dcf45e8c5b5bef77e0f..52ef361a9fdeb96ee0f9668141597d213eae0930 100755
--- a/src/mesh/Allwmake
+++ b/src/mesh/Allwmake
@@ -8,4 +8,4 @@ wmake $targetType snappyHexMesh
 wmake $targetType blockMesh
 wmake $targetType extrudeModel
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
index 92eedd79ab043597b4683f1d69c8c4c56938652c..1c90b6a22757aa4446616b895e05200bcd4393ba 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
@@ -2037,7 +2037,7 @@ Foam::label Foam::meshRefinement::addMeshedPatch
     const dictionary& patchInfo
 )
 {
-    label meshedi = findIndex(meshedPatches_, name);
+    label meshedi = meshedPatches_.find(name);
 
     if (meshedi != -1)
     {
@@ -2341,7 +2341,7 @@ void Foam::meshRefinement::findRegions
         {
             // Do a quick check for locationsOutsideMesh overlapping with
             // inside ones.
-            label index = findIndex(insideRegions, regioni);
+            label index = insideRegions.find(regioni);
             if (index != -1)
             {
                 FatalErrorInFunction
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H
index f0a9af23d1f31d5348ffd085c2105d00b7807ce6..f807ad2dcfe77c5bed11ea30c7a17b4aad64bbb6 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H
@@ -511,6 +511,7 @@ private:
             //- Determine patches for baffles
             void getBafflePatches
             (
+                const label nErodeCellZones,
                 const labelList& globalToMasterPatch,
                 const pointField& locationsInMesh,
                 const wordList& regionsInMesh,
@@ -673,6 +674,17 @@ private:
                 labelList& cellToZone
             ) const;
 
+            //- Opposite of findCellTopo: finds assigned cell connected to
+            //  an unassigned one and puts it in the background zone.
+            void erodeCellZone
+            (
+                const label nErodeCellZones,
+                const label backgroundZoneID,
+                const labelList& unnamedSurfaceRegion,
+                const labelList& namedSurfaceIndex,
+                labelList& cellToZone
+            ) const;
+
             //- Make namedSurfaceIndex consistent with cellToZone
             //  - clear out any blocked faces inbetween same cell zone.
             void makeConsistentFaceIndex
@@ -686,6 +698,7 @@ private:
             void zonify
             (
                 const bool allowFreeStandingZoneFaces,
+                const label nErodeCellZones,
                 const label backgroundZoneID,
                 const pointField& locationsInMesh,
                 const wordList& zonesInMesh,
@@ -1037,6 +1050,7 @@ public:
                 const bool useTopologicalSnapDetection,
                 const bool removeEdgeConnectedCells,
                 const scalarField& perpendicularAngle,
+                const label nErodeCellZones,
                 const dictionary& motionDict,
                 Time& runTime,
                 const labelList& globalToMasterPatch,
@@ -1067,6 +1081,7 @@ public:
             autoPtr<mapPolyMesh> splitMesh
             (
                 const label nBufferLayers,
+                const label nErodeCellZones,
                 const labelList& globalToMasterPatch,
                 const labelList& globalToSlavePatch,
 
@@ -1148,6 +1163,7 @@ public:
             autoPtr<mapPolyMesh> zonify
             (
                 const bool allowFreeStandingZoneFaces,
+                const label nErodeCellZones,
                 const pointField& locationsInMesh,
                 const wordList& regionsInMesh,
                 wordPairHashTable& zonesToFaceZone
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C
index 99d642c1bd3428f137922b19341a3023ca08bb32..b18fcdc66d2572b26b5cfc6b1d000c69600b5140 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2014 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -279,6 +279,7 @@ void Foam::meshRefinement::getIntersections
 
 void Foam::meshRefinement::getBafflePatches
 (
+    const label nErodeCellZones,
     const labelList& globalToMasterPatch,
     const pointField& locationsInMesh,
     const wordList& zonesInMesh,
@@ -309,6 +310,7 @@ void Foam::meshRefinement::getBafflePatches
         zonify
         (
             true,               // allowFreeStandingZoneFaces
+            nErodeCellZones,
             -2,                 // zone to put unreached cells into
             locationsInMesh,
             zonesInMesh,
@@ -331,16 +333,13 @@ void Foam::meshRefinement::getBafflePatches
     labelList neiCellZone;
     syncTools::swapBoundaryCellList(mesh_, cellToZone, neiCellZone);
 
-    const labelList testFaces(intersectedFaces());
-
     ownPatch.setSize(mesh_.nFaces());
     ownPatch = -1;
     neiPatch.setSize(mesh_.nFaces());
     neiPatch = -1;
-    forAll(testFaces, i)
-    {
-        label faceI = testFaces[i];
 
+    forAll(ownPatch, faceI)
+    {
         if (unnamedRegion1[faceI] != -1 || unnamedRegion2[faceI] != -1)
         {
             label ownMasterPatch = -1;
@@ -672,7 +671,7 @@ Foam::labelList Foam::meshRefinement::getZones
         surfaceZonesInfo::faceZoneType fzType;
         bool hasInfo = getFaceZoneInfo(fZone.name(), mpI, spI, fzType);
 
-        if (hasInfo && findIndex(fzTypes, fzType) != -1)
+        if (hasInfo && fzTypes.found(fzType))
         {
             zoneIDs.append(zoneI);
         }
@@ -1550,7 +1549,7 @@ void Foam::meshRefinement::findCellZoneGeometric
             }
 
             // Make sure the cellZone originated from a closed surface
-            label geomSurfI = findIndex(surfaceToCellZone, minZone);
+            label geomSurfI = surfaceToCellZone.find(minZone);
 
             if (geomSurfI != -1)
             {
@@ -1594,7 +1593,7 @@ void Foam::meshRefinement::findCellZoneGeometric
                     }
 
                     // Make sure the cellZone originated from a closed surface
-                    label geomSurfI = findIndex(surfaceToCellZone, minZone);
+                    label geomSurfI = surfaceToCellZone.find(minZone);
 
                     if (geomSurfI != -1)
                     {
@@ -2060,6 +2059,111 @@ void Foam::meshRefinement::findCellZoneTopo
 }
 
 
+void Foam::meshRefinement::erodeCellZone
+(
+    const label nErodeCellZones,
+    const label backgroundZoneID,
+    const labelList& unnamedSurfaceRegion,
+    const labelList& namedSurfaceIndex,
+    labelList& cellToZone
+) const
+{
+    // This routine fixes small problems with left over unassigned regions
+    // (after all off the unreachable bits of the mesh have been removed).
+    // The problem is that the cell zone information might be inconsistent
+    // with the face zone information. So what we do here is to erode
+    // any cell zones until we hit a named face.
+    // - backgroundZoneID = -2 : do not change so remove cells
+    // - backgroundZoneID = -1 : put into background
+    // Note that is the opposite of findCellZoneTopo which moves unassigned
+    // regions into a neighbouring region(=cellZone) unless there is an
+    // intersected faces inbetween the two.
+
+    for (label iter = 0; iter < nErodeCellZones; iter++)
+    {
+        label nChanged = 0;
+
+        labelList erodedCellToZone(cellToZone);
+
+        // Do internal faces
+        for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
+        {
+            if
+            (
+                unnamedSurfaceRegion[facei] == -1
+             && namedSurfaceIndex[facei] == -1
+            )
+            {
+                label own = mesh_.faceOwner()[facei];
+                label nei = mesh_.faceNeighbour()[facei];
+                if (cellToZone[own] == -2 && cellToZone[nei] >= -1)
+                {
+                    erodedCellToZone[nei] = backgroundZoneID;
+                    nChanged++;
+                }
+                else if (cellToZone[nei] == -2 && cellToZone[own] >= -1)
+                {
+                    erodedCellToZone[own] = backgroundZoneID;
+                    nChanged++;
+                }
+            }
+        }
+
+        // Do boundary faces
+
+        const polyBoundaryMesh& patches = mesh_.boundaryMesh();
+
+        // Get coupled neighbour cellRegion
+        labelList neiCellZone;
+        syncTools::swapBoundaryCellList(mesh_, cellToZone, neiCellZone);
+
+        // Calculate region to zone from cellRegions on either side of coupled
+        // face.
+        forAll(patches, patchi)
+        {
+            const polyPatch& pp = patches[patchi];
+
+            if (pp.coupled())
+            {
+                forAll(pp, i)
+                {
+                    label facei = pp.start()+i;
+                    if
+                    (
+                        unnamedSurfaceRegion[facei] == -1
+                     && namedSurfaceIndex[facei] == -1
+                    )
+                    {
+                        label own = mesh_.faceOwner()[facei];
+                        label bFacei = facei-mesh_.nInternalFaces();
+                        if (neiCellZone[bFacei] == -2 && cellToZone[own] >= -1)
+                        {
+                            erodedCellToZone[own] = backgroundZoneID;
+                            nChanged++;
+                        }
+                    }
+                }
+            }
+        }
+
+        cellToZone.transfer(erodedCellToZone);
+
+        reduce(nChanged, sumOp<label>());
+        if (debug)
+        {
+            Pout<< "erodeCellZone : eroded " << nChanged
+                << " cells (moved from cellZone to background zone "
+                << backgroundZoneID << endl;
+        }
+
+        if (nChanged == 0)
+        {
+            break;
+        }
+    }
+}
+
+
 void Foam::meshRefinement::makeConsistentFaceIndex
 (
     const labelList& surfaceMap,
@@ -2281,6 +2385,7 @@ void Foam::meshRefinement::getIntersections
 void Foam::meshRefinement::zonify
 (
     const bool allowFreeStandingZoneFaces,
+    const label nErodeCellZones,
     const label backgroundZoneID,
     const pointField& locationsInMesh,
     const wordList& zonesInMesh,
@@ -2496,18 +2601,39 @@ void Foam::meshRefinement::zonify
 
     if (namedSurfaces.size())
     {
-        Info<< "Walking from known cellZones; crossing a faceZone "
-            << "face changes cellZone" << nl << endl;
+        if (nErodeCellZones <= 0)
+        {
+            Info<< "Walking from known cellZones; crossing a faceZone "
+                << "face changes cellZone" << nl << endl;
+
+            // Put unassigned regions into any connected cellZone
+            findCellZoneTopo
+            (
+                backgroundZoneID,
+                pointField(0),
+                unnamedRegion1,      // Intersections with unnamed surfaces
+                namedSurfaceIndex,   // Intersections with named surfaces
+                surfaceToCellZone,
+                cellToZone
+            );
+        }
+        else
+        {
+            Info<< "Eroding cellZone cells to make these consistent with"
+                << " faceZone faces" << nl << endl;
+
+            // Erode cell zone cells (connected to an unassigned cell)
+            // and put them into backgroundZone
+            erodeCellZone
+            (
+                nErodeCellZones,
+                backgroundZoneID,
+                unnamedRegion1,
+                namedSurfaceIndex,
+                cellToZone
+            );
+        }
 
-        findCellZoneTopo
-        (
-            backgroundZoneID,
-            pointField(0),
-            unnamedRegion1,      // Intersections with unnamed surfaces
-            namedSurfaceIndex,   // Intersections with named surfaces
-            surfaceToCellZone,
-            cellToZone
-        );
 
         // Make sure namedSurfaceIndex is unset inbetween same cell zones.
         if (!allowFreeStandingZoneFaces)
@@ -3424,6 +3550,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
     const bool useTopologicalSnapDetection,
     const bool removeEdgeConnectedCells,
     const scalarField& perpendicularAngle,
+    const label nErodeCellZones,
     const dictionary& motionDict,
     Time& runTime,
     const labelList& globalToMasterPatch,
@@ -3452,6 +3579,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
     labelList ownPatch, neiPatch;
     getBafflePatches
     (
+        nErodeCellZones,
         globalToMasterPatch,
 
         locationsInMesh,
@@ -3522,6 +3650,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
             labelList ownPatch, neiPatch;
             getBafflePatches
             (
+                nErodeCellZones,
                 globalToMasterPatch,
 
                 locationsInMesh,
@@ -3689,6 +3818,7 @@ void Foam::meshRefinement::mergeFreeStandingBaffles
 Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
 (
     const label nBufferLayers,
+    const label nErodeCellZones,
     const labelList& globalToMasterPatch,
     const labelList& globalToSlavePatch,
 
@@ -3709,6 +3839,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
     labelList ownPatch, neiPatch;
     getBafflePatches
     (
+        nErodeCellZones,
         globalToMasterPatch,
 
         locationsInMesh,
@@ -4202,6 +4333,7 @@ Foam::meshRefinement::dupNonManifoldBoundaryPoints()
 Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
 (
     const bool allowFreeStandingZoneFaces,
+    const label nErodeCellZones,
     const pointField& locationsInMesh,
     const wordList& zonesInMesh,
     wordPairHashTable& zonesToFaceZone
@@ -4278,6 +4410,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
         zonify
         (
             allowFreeStandingZoneFaces,
+            nErodeCellZones,// Use erosion (>0) or regionSplit to clean up
             -1,             // Set all cells with cellToZone -2 to -1
             locationsInMesh,
             zonesInMesh,
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C
index 2fb5844684f96d568dda20ba8ab8456c74ee7cfa..d714253c9dfe79947d8a9e3852601e0c7a7fda2a 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.C
@@ -68,7 +68,8 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
     interfaceRefine_
     (
         dict.lookupOrDefault<Switch>("interfaceRefine", true)
-    )
+    ),
+    nErodeCellZone_(dict.lookupOrDefault<label>("nCellZoneErodeIter", 0))
 {
     point locationInMesh;
     if (dict.readIfPresent("locationInMesh", locationInMesh))
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H
index 9504efa56726941156392b218c11636391f4c125..6ac70dc47fe673b1668ead088f4024c727847593 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/refinementParameters/refinementParameters.H
@@ -106,6 +106,9 @@ class refinementParameters
 
         Switch interfaceRefine_;
 
+        label nErodeCellZone_;
+
+
     // Private Member Functions
 
         //- Disallow default bitwise copy construct
@@ -212,6 +215,11 @@ public:
                 return interfaceRefine_;
             }
 
+            label nErodeCellZone() const
+            {
+                return nErodeCellZone_;
+            }
+
 
         // Other
 
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
index e24f9c549728a96f7b7ea933e12a60044428bd73..8516c3db43c9a4ed342387eee045387d4a03d60a 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
@@ -344,7 +344,7 @@ bool Foam::snappyLayerDriver::checkCommonOrder
     forAll(curFace, fp)
     {
         // Get the index in the neighbouring face shared with curFace
-        const label nb = findIndex(nbFace, curFace[fp]);
+        const label nb = nbFace.find(curFace[fp]);
 
         if (nb != -1)
         {
@@ -1936,7 +1936,7 @@ void Foam::snappyLayerDriver::getVertexString
 ) const
 {
     const labelList& fEdges = pp.faceEdges()[facei];
-    label fp = findIndex(fEdges, edgei);
+    label fp = fEdges.find(edgei);
 
     if (fp == -1)
     {
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C
index 1040094bb1410ec2faaf2ff2e2de4f29e3375032..bf988056236133e425cf4e2b9a9ee01da9485562 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyRefineDriver.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015-2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -80,6 +80,13 @@ Foam::label Foam::snappyRefineDriver::featureEdgeRefine
     const label minRefine
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     addProfiling(edge, "snappyHexMesh::refine::edge");
     const fvMesh& mesh = meshRefiner_.mesh();
 
@@ -190,6 +197,13 @@ Foam::label Foam::snappyRefineDriver::smallFeatureRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     addProfiling(feature, "snappyHexMesh::refine::smallFeature");
     const fvMesh& mesh = meshRefiner_.mesh();
 
@@ -313,6 +327,13 @@ Foam::label Foam::snappyRefineDriver::surfaceOnlyRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     addProfiling(surface, "snappyHexMesh::refine::surface");
     const fvMesh& mesh = meshRefiner_.mesh();
 
@@ -437,6 +458,13 @@ Foam::label Foam::snappyRefineDriver::gapOnlyRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     const fvMesh& mesh = meshRefiner_.mesh();
 
     // Determine the maximum refinement level over all surfaces. This
@@ -669,6 +697,13 @@ Foam::label Foam::snappyRefineDriver::bigGapOnlyRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     const fvMesh& mesh = meshRefiner_.mesh();
 
     label iter = 0;
@@ -811,6 +846,13 @@ Foam::label Foam::snappyRefineDriver::danglingCellRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     addProfiling(dangling, "snappyHexMesh::refine::danglingCell");
     const fvMesh& mesh = meshRefiner_.mesh();
 
@@ -957,6 +999,13 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     addProfiling(interface, "snappyHexMesh::refine::transition");
     const fvMesh& mesh = meshRefiner_.mesh();
 
@@ -1313,6 +1362,7 @@ void Foam::snappyRefineDriver::removeInsideCells
     meshRefiner_.splitMesh
     (
         nBufferLayers,                  // nBufferLayers
+        refineParams.nErodeCellZone(),
         globalToMasterPatch_,
         globalToSlavePatch_,
         refineParams.locationsInMesh(),
@@ -1348,6 +1398,13 @@ Foam::label Foam::snappyRefineDriver::shellRefine
     const label maxIter
 )
 {
+    if (refineParams.minRefineCells() == -1)
+    {
+        // Special setting to be able to restart shm on meshes with inconsistent
+        // cellLevel/pointLevel
+        return 0;
+    }
+
     addProfiling(shell, "snappyHexMesh::refine::shell");
     const fvMesh& mesh = meshRefiner_.mesh();
 
@@ -1549,6 +1606,7 @@ void Foam::snappyRefineDriver::baffleAndSplitMesh
         refineParams.useTopologicalSnapDetection(),
         false,                          // perpendicular edge connected cells
         scalarField(0),                 // per region perpendicular angle
+        refineParams.nErodeCellZone(),
 
         motionDict,
         const_cast<Time&>(mesh.time()),
@@ -1616,6 +1674,7 @@ void Foam::snappyRefineDriver::zonify
         meshRefiner_.zonify
         (
             refineParams.allowFreeStandingZoneFaces(),
+            refineParams.nErodeCellZone(),
             refineParams.locationsInMesh(),
             refineParams.zonesInMesh(),
             zonesToFaceZone
@@ -1675,6 +1734,7 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
         refineParams.useTopologicalSnapDetection(),
         handleSnapProblems,                 // remove perp edge connected cells
         perpAngle,                          // perp angle
+        refineParams.nErodeCellZone(),
 
         motionDict,
         const_cast<Time&>(mesh.time()),
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C
index ec9e7f3936d5ddd3020c449e35d1ee09b864b71a..fb9190add352cdd27d954bd2e150ba20da047773 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C
@@ -1703,7 +1703,7 @@ Foam::labelPair Foam::snappySnapDriver::findDiagonalAttraction
         //forAll(cPoints, i)
         //{
         //    label pointi = cPoints[i];
-        //    if (findIndex(meshF, pointi) == -1)
+        //    if (!meshF.found(pointi))
         //    {
         //        cc += mesh.points()[pointi];
         //    }
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
index 6253c95f9be1669907b9017fdae5a86529abedc3..d0a89190af41ff1db493bdad9cc56126c124fe7a 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
@@ -473,7 +473,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::agglomerate
                 label elemi = elems[i];
                 label coarseElemi = tgtCompactMap[elemi];
 
-                label index = findIndex(newElems, coarseElemi);
+                label index = newElems.find(coarseElemi);
                 if (index == -1)
                 {
                     newElems.append(coarseElemi);
@@ -519,7 +519,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::agglomerate
                 label elemi = elems[i];
                 label coarseElemi = targetRestrictAddressing[elemi];
 
-                label index = findIndex(newElems, coarseElemi);
+                label index = newElems.find(coarseElemi);
                 if (index == -1)
                 {
                     newElems.append(coarseElemi);
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C
index 070a4b7054947c1ea68a2f68c6a87614d95af5fe..051fc0d1881d6d618e58854ec132962e5a6b0636 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C
@@ -67,7 +67,7 @@ Foam::label Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcDistribution
         }
         else if (nHaveFaces == 1)
         {
-            proci = findIndex(facesPresentOnProc, 1);
+            proci = facesPresentOnProc.find(1);
             if (debug)
             {
                 InfoInFunction
diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C
index 344c92ded1bd623db09cd941f51cc340ddf2f8c5..badb6a93a6b19671675ce1f32ab84fbc93819b1e 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/mapNearestAMI/mapNearestAMI.C
@@ -137,7 +137,7 @@ Foam::label Foam::mapNearestAMI<SourcePatch, TargetPatch>::findMappedSrcFace
         // search target tgtFacei neighbours for match with source face
         label tgtI = testFaces.remove();
 
-        if (findIndex(visitedFaces, tgtI) == -1)
+        if (!visitedFaces.found(tgtI))
         {
             visitedFaces.append(tgtI);
 
@@ -151,7 +151,7 @@ Foam::label Foam::mapNearestAMI<SourcePatch, TargetPatch>::findMappedSrcFace
 
                 forAll(nbrFaces, i)
                 {
-                    if (findIndex(visitedFaces, nbrFaces[i]) == -1)
+                    if (!visitedFaces.found(nbrFaces[i]))
                     {
                         testFaces.append(nbrFaces[i]);
                     }
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C
index d801ec591ebea1e90440240efbcaf0b60d30f4bd..4fbd6e39c9441dd84306cf3f2974bb75d34887eb 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C
@@ -592,8 +592,7 @@ void Foam::cyclicACMIPolyPatch::write(Ostream& os) const
 {
     cyclicAMIPolyPatch::write(os);
 
-    os.writeKeyword("nonOverlapPatch") << nonOverlapPatchName_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("nonOverlapPatch", nonOverlapPatchName_);
 }
 
 
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
index 74015e3ece131becd743119842c206a20cb54d61..12f9546fcab5b8d44f470364d18b9fafa753dc82 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C
@@ -1058,8 +1058,7 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
     coupledPolyPatch::write(os);
     if (!nbrPatchName_.empty())
     {
-        os.writeKeyword("neighbourPatch") << nbrPatchName_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("neighbourPatch", nbrPatchName_);
     }
     coupleGroup_.write(os);
 
@@ -1067,23 +1066,19 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
     {
         case ROTATIONAL:
         {
-            os.writeKeyword("rotationAxis") << rotationAxis_
-                << token::END_STATEMENT << nl;
-            os.writeKeyword("rotationCentre") << rotationCentre_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("rotationAxis", rotationAxis_);
+            os.writeEntry("rotationCentre", rotationCentre_);
 
             if (rotationAngleDefined_)
             {
-                os.writeKeyword("rotationAngle") << radToDeg(rotationAngle_)
-                    << token::END_STATEMENT << nl;
+                os.writeEntry("rotationAngle", radToDeg(rotationAngle_));
             }
 
             break;
         }
         case TRANSLATIONAL:
         {
-            os.writeKeyword("separationVector") << separationVector_
-                << token::END_STATEMENT << nl;
+            os.writeEntry("separationVector", separationVector_);
             break;
         }
         case NOORDERING:
@@ -1098,30 +1093,29 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
 
     if (AMIMethod_ != AMIPatchToPatchInterpolation::imFaceAreaWeight)
     {
-        os.writeKeyword("method")
-            <<  AMIPatchToPatchInterpolation::interpolationMethodToWord
-                (
-                    AMIMethod_
-                )
-            << token::END_STATEMENT << nl;
+        os.writeEntry
+        (
+            "method",
+            AMIPatchToPatchInterpolation::interpolationMethodToWord
+            (
+                AMIMethod_
+            )
+        );
     }
 
     if (AMIReverse_)
     {
-        os.writeKeyword("flipNormals") << AMIReverse_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("flipNormals", AMIReverse_);
     }
 
     if (AMILowWeightCorrection_ > 0)
     {
-        os.writeKeyword("lowWeightCorrection") << AMILowWeightCorrection_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("lowWeightCorrection", AMILowWeightCorrection_);
     }
 
     if (!surfDict_.empty())
     {
-        os.writeKeyword(surfDict_.dictName());
-        os  << surfDict_;
+        surfDict_.writeEntry(surfDict_.dictName(), os);
     }
 }
 
diff --git a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
index fcbf9dd6ab0cd3ec299da377ed0bb9c0d1e4c972..46aad8db98593cbdb15cc13bb826625d0088c3a1 100644
--- a/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
+++ b/src/meshTools/AMIInterpolation/patches/cyclicPeriodicAMI/cyclicPeriodicAMIPolyPatch/cyclicPeriodicAMIPolyPatch.C
@@ -709,25 +709,10 @@ void Foam::cyclicPeriodicAMIPolyPatch::write(Ostream& os) const
 {
     cyclicAMIPolyPatch::write(os);
 
-    os.writeKeyword("periodicPatch") << periodicPatchName_
-        << token::END_STATEMENT << nl;
-
-    if (nTransforms_ != 0)
-    {
-        os.writeKeyword("nTransforms") << nTransforms_ <<
-            token::END_STATEMENT << nl;
-    }
-
-    if (nSectors_ != 0)
-    {
-        os.writeKeyword("nSectors") << nSectors_ <<
-            token::END_STATEMENT << nl;
-    }
-
-    if (maxIter_ != 36)
-    {
-        os.writeKeyword("maxIter") << maxIter_ << token::END_STATEMENT << nl;
-    }
+    os.writeEntry("periodicPatch", periodicPatchName_);
+    os.writeEntryIfDifferent<label>("nTransforms", 0, nTransforms_);
+    os.writeEntryIfDifferent<label>("nSectors", 0, nSectors_);
+    os.writeEntryIfDifferent<label>("maxIter", 36, maxIter_);
 }
 
 
diff --git a/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H b/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H
index 422b0b2e9e2bd4996704e15795c12e781ebbea56..07ae3a408775cc284ca73483ef2bb92a164c3cca 100644
--- a/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H
+++ b/src/meshTools/algorithms/PatchEdgeFaceWave/patchEdgeFaceRegionsI.H
@@ -63,7 +63,7 @@ inline const Foam::labelList& Foam::patchEdgeFaceRegions::regions() const
 template<class TrackingData>
 inline bool Foam::patchEdgeFaceRegions::valid(TrackingData& td) const
 {
-    return regions_.size() && (findIndex(regions_, labelMax) == -1);
+    return regions_.size() && !regions_.found(labelMax);
 }
 
 
@@ -94,7 +94,7 @@ inline bool Foam::patchEdgeFaceRegions::updateEdge
     const face& f = patch.localFaces()[facei];
     const edge& e = patch.edges()[edgeI];
 
-    label index = findIndex(patch.faceEdges()[facei], edgeI);
+    label index = patch.faceEdges()[facei].find(edgeI);
     bool sameOrientation = (f[index] == e.start());
 
     // Get information in edge-order
@@ -114,7 +114,7 @@ inline bool Foam::patchEdgeFaceRegions::updateEdge
             << "problem." << abort(FatalError);
     }
 
-    if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1))
+    if (orientedInfo.found(-1) || regions_.found(-1))
     {
         // Blocked edge/face
         return false;
@@ -161,7 +161,7 @@ inline bool Foam::patchEdgeFaceRegions::updateEdge
             << "problem." << abort(FatalError);
     }
 
-    if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1))
+    if (orientedInfo.found(-1) || regions_.found(-1))
     {
         // Blocked edge/face
         return false;
@@ -199,7 +199,7 @@ inline bool Foam::patchEdgeFaceRegions::updateFace
     const edge& e = patch.edges()[edgeI];
 
     // Find starting point of edge on face.
-    label index0 = findIndex(patch.faceEdges()[facei], edgeI);
+    label index0 = patch.faceEdges()[facei].find(edgeI);
     label index1 = f.fcIndex(index0);
     bool sameOrientation = (f[index0] == e.start());
 
@@ -221,7 +221,7 @@ inline bool Foam::patchEdgeFaceRegions::updateFace
             << "problem." << abort(FatalError);
     }
 
-    if ((findIndex(orientedInfo, -1) != -1) || (findIndex(regions_, -1) != -1))
+    if (orientedInfo.found(-1) || regions_.found(-1))
     {
         // Blocked edge/face
         return false;
diff --git a/src/meshTools/cellFeatures/cellFeatures.C b/src/meshTools/cellFeatures/cellFeatures.C
index b49a6b97261f0f3e6b038f4c8bfbb25ff72286fe..8ab57513f43188aededb38d2e535a39ee96d752a 100644
--- a/src/meshTools/cellFeatures/cellFeatures.C
+++ b/src/meshTools/cellFeatures/cellFeatures.C
@@ -137,12 +137,12 @@ bool Foam::cellFeatures::isCellFeatureEdge
 
     const face& f0 = mesh_.faces()[face0];
 
-    label face0Start = findIndex(f0, e.start());
+    label face0Start = f0.find(e.start());
     label face0End   = f0.fcIndex(face0Start);
 
     const face& f1 = mesh_.faces()[face1];
 
-    label face1Start = findIndex(f1, e.start());
+    label face1Start = f1.find(e.start());
     label face1End   = f1.fcIndex(face1Start);
 
     if
diff --git a/src/meshTools/coordinateSystems/coordinateSystem.C b/src/meshTools/coordinateSystems/coordinateSystem.C
index e8c507a7f848e6177ca7a6dbc697af94703b1841..b4a9e7882009046141db1ef497fbcfd16b26acae 100644
--- a/src/meshTools/coordinateSystems/coordinateSystem.C
+++ b/src/meshTools/coordinateSystems/coordinateSystem.C
@@ -297,25 +297,23 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
 {
     if (subDict)
     {
-        os  << indent << name_ << nl
-            << indent << token::BEGIN_BLOCK << incrIndent << nl;
+        os.beginBlock(name_);
     }
 
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
 
-
-    // The note entry is optional
     if (note_.size())
     {
-        os.writeKeyword("note") << note_ << token::END_STATEMENT << nl;
+        // note is optional
+        os.writeEntry("note", note_);
     }
 
-    os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
+    os.writeEntry("origin", origin_);
     R_->write(os);
 
     if (subDict)
     {
-        os  << decrIndent << indent << token::END_BLOCK << endl;
+        os.endBlock();
     }
 }
 
diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H
index 23c1f76faf4269482d161048c80f07ffb6e82388..1919b48299c2acfcbe8b3540b51a00168d4590e2 100644
--- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H
+++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H
@@ -143,7 +143,7 @@ Foam::label Foam::edgeFaceCirculator::getMinIndex
     const label v1
 )
 {
-    label fp = findIndex(f, v0);
+    label fp = f.find(v0);
 
     if (fp != -1)
     {
diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C
index 3cb86ec3a62e1d88bc077835c62f0b763aa8a215..b5d0fc3617a0465e022ea55a17d7f0a1d4c5b568 100644
--- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C
+++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C
@@ -379,7 +379,7 @@ void Foam::extendedEdgeMesh::sortPointsAndEdges
 
             forAll(ptEdNorms, k)
             {
-                if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1)
+                if (!tmpFtPtNorms.found(ptEdNorms[k]))
                 {
                     bool addNormal = true;
 
diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C
index 5b7eec3c5af0d282558fea23791e50344000690f..e6ef2557c87e06d19ac23951ac1015576fed2296 100644
--- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C
+++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C
@@ -379,7 +379,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
 
             forAll(ptEdNorms, k)
             {
-                if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1)
+                if (!tmpFtPtNorms.found(ptEdNorms[k]))
                 {
                     bool addNormal = true;
 
diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C
index b4fcf6b974a2111b94c4e54cd73a5955832eaa10..04d67382580e86cddce90113e639314eb4dba78e 100644
--- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C
+++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C
@@ -532,7 +532,7 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::operator()
     point& intersectionPoint
 ) const
 {
-    if (findIndex(shapeMask_, index) != -1)
+    if (shapeMask_.found(index))
     {
         return false;
     }
@@ -564,7 +564,7 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findSelfIntersectOp::operator()
     const typename PatchType::FaceType& f = patch.localFaces()[index];
     const edge& e = patch.edges()[edgeID_];
 
-    if (findIndex(f, e[0]) == -1 && findIndex(f, e[1]) == -1)
+    if (!f.found(e[0]) && !f.found(e[1]))
     {
         return findIntersection(tree_, index, start, end, intersectionPoint);
     }
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C
index 6f114e545b3fc11c9be299bb8b50a64727df7fdf..bf2a0801932536844c4ab31094d6a8126ba65a8c 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C
@@ -1432,8 +1432,7 @@ void Foam::mappedPatchBase::write(Ostream& os) const
 
             if (!surfDict_.empty())
             {
-                os.writeKeyword(surfDict_.dictName());
-                os  << surfDict_;
+                surfDict_.writeEntry(surfDict_.dictName(), os);
             }
         }
     }
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C
index 6732e5c7b18d8ca2462e9074dc6d4e22bcbfcbf3..db8f9fdb474d8a2c1481abe94f2b35e9866b10a6 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C
@@ -53,7 +53,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
     mappedPatchBase(static_cast<const polyPatch&>(*this))
 {
     //  mapped is not constraint type so add mapped group explicitly
-    if (findIndex(inGroups(), typeName) == -1)
+    if (!inGroups().found(typeName))
     {
         inGroups().append(typeName);
     }
@@ -123,7 +123,7 @@ Foam::mappedPolyPatch::mappedPolyPatch
     mappedPatchBase(*this, dict)
 {
     //  mapped is not constraint type so add mapped group explicitly
-    if (findIndex(inGroups(), typeName) == -1)
+    if (!inGroups().found(typeName))
     {
         inGroups().append(typeName);
     }
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
index 6248dce65062ca655ae9a61803446329a389117d..2a40a4695d6300c1801d309b904464c7851ed9a8 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedVariableThicknessWallPolyPatch.C
@@ -167,7 +167,7 @@ Foam::mappedVariableThicknessWallPolyPatch::
 void Foam::mappedVariableThicknessWallPolyPatch::
 write(Foam::Ostream& os) const
 {
-    os.writeKeyword("thickness") << thickness_ << token::END_STATEMENT << nl;
+    os.writeEntry("thickness", thickness_);
 }
 
 
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C
index 243d0a804ae10a776f5a4c0a69837ab0e7ae4f2d..ab36de56c45e5c268389d253d52cc80015b89841 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C
@@ -59,7 +59,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
     mappedPatchBase(static_cast<const polyPatch&>(*this))
 {
     //  mapped is not constraint type so add mapped group explicitly
-    if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
+    if (!inGroups().found(mappedPolyPatch::typeName))
     {
         inGroups().append(mappedPolyPatch::typeName);
     }
@@ -129,7 +129,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
     mappedPatchBase(*this, dict)
 {
     //  mapped is not constraint type so add mapped group explicitly
-    if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
+    if (!inGroups().found(mappedPolyPatch::typeName))
     {
         inGroups().append(mappedPolyPatch::typeName);
     }
diff --git a/src/meshTools/meshTools/meshTools.C b/src/meshTools/meshTools/meshTools.C
index 9a9012b925b67e57d1adc6587144712f88f686c7..dca4246471c5d0d07b6c426c363a42a85f57e8a5 100644
--- a/src/meshTools/meshTools/meshTools.C
+++ b/src/meshTools/meshTools/meshTools.C
@@ -319,7 +319,7 @@ bool Foam::meshTools::edgeOnCell
     const label edgeI
 )
 {
-    return findIndex(mesh.edgeCells(edgeI), celli) != -1;
+    return mesh.edgeCells(edgeI).found(celli);
 }
 
 
@@ -330,7 +330,7 @@ bool Foam::meshTools::edgeOnFace
     const label edgeI
 )
 {
-    return findIndex(mesh.faceEdges(facei), edgeI) != -1;
+    return mesh.faceEdges(facei).found(edgeI);
 }
 
 
diff --git a/src/meshTools/output/foamVtkWriteCellSetFaces.C b/src/meshTools/output/foamVtkWriteCellSetFaces.C
index 18c350629fed4fcec5e6e0a68a254ea16bd61f0a..4815a375ddb4c5d85e950b34171177206d8061af 100644
--- a/src/meshTools/output/foamVtkWriteCellSetFaces.C
+++ b/src/meshTools/output/foamVtkWriteCellSetFaces.C
@@ -41,7 +41,7 @@ void Foam::vtk::writeCellSetFaces
 )
 {
     outputOptions opts(outOpts);
-    opts.legacy(true);  // Legacy only, no append
+    opts.legacy(true);  // Legacy only, no xml, no append
 
     const bool legacy_(opts.legacy());
 
diff --git a/src/meshTools/output/foamVtkWriteFaceSet.C b/src/meshTools/output/foamVtkWriteFaceSet.C
index 5f1e1695fb9e69597e799a53b1d143f224c8cfed..81c54434a8d2489c7f7739ba1a8d9aa435eb7a01 100644
--- a/src/meshTools/output/foamVtkWriteFaceSet.C
+++ b/src/meshTools/output/foamVtkWriteFaceSet.C
@@ -41,7 +41,7 @@ void Foam::vtk::writeFaceSet
 )
 {
     outputOptions opts(outOpts);
-    opts.legacy(true);  // Legacy only, no append
+    opts.legacy(true);  // Legacy only, no xml, no append
 
     const bool legacy_(opts.legacy());
 
diff --git a/src/meshTools/output/foamVtkWritePointSet.C b/src/meshTools/output/foamVtkWritePointSet.C
index 0ad3b90047c8265a81ac72680bd3dd7e47baf0e2..64c88f0350a281660fd4fdf852bd79ec43a110f4 100644
--- a/src/meshTools/output/foamVtkWritePointSet.C
+++ b/src/meshTools/output/foamVtkWritePointSet.C
@@ -40,7 +40,7 @@ void Foam::vtk::writePointSet
 )
 {
     outputOptions opts(outOpts);
-    opts.legacy(true);  // Legacy only, no append
+    opts.legacy(true);  // Legacy only, no xml, no append
 
     const bool legacy_(opts.legacy());
 
diff --git a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C
index bbdb866f94f1b85d92afe6ab2ba15622922e52ae..9defb4090bdd86dbf044e011836948f6b0f129a3 100644
--- a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C
+++ b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C
@@ -331,21 +331,17 @@ bool Foam::regionCoupledBase::order
 
 void Foam::regionCoupledBase::write(Ostream& os) const
 {
-    os.writeKeyword("neighbourPatch") << nbrPatchName_
-    << token::END_STATEMENT << nl;
-    os.writeKeyword("neighbourRegion") << nbrRegionName_
-    << token::END_STATEMENT << nl;
+    os.writeEntry("neighbourPatch", nbrPatchName_);
+    os.writeEntry("neighbourRegion", nbrRegionName_);
 
     if (AMIReverse_)
     {
-        os.writeKeyword("flipNormals") << AMIReverse_
-            << token::END_STATEMENT << nl;
+        os.writeEntry("flipNormals", AMIReverse_);
     }
 
     if (!surfDict_.empty())
     {
-        os.writeKeyword(surfDict_.dictName());
-        os  << surfDict_;
+        surfDict_.writeEntry(surfDict_.dictName(), os);
     }
 }
 
diff --git a/src/meshTools/regionSplit/localPointRegion.C b/src/meshTools/regionSplit/localPointRegion.C
index 9a6cc288e4539e50272a6468525b8e5c3ceaac2d..38e2331f611e58285a5899e2387ae4c6c9b8e820 100644
--- a/src/meshTools/regionSplit/localPointRegion.C
+++ b/src/meshTools/regionSplit/localPointRegion.C
@@ -75,7 +75,7 @@ bool Foam::localPointRegion::isDuplicate
         return false;
     }
 
-    label fp1 = findIndex(f1, f0[0]);
+    label fp1 = f1.find(f0[0]);
 
     if (fp1 == -1)
     {
@@ -160,7 +160,7 @@ void Foam::localPointRegion::countPointRegions
                         if (iter != meshPointMap_.end())
                         {
                             labelList& regions = pointRegions[iter()];
-                            if (findIndex(regions, region) == -1)
+                            if (!regions.found(region))
                             {
                                 label sz = regions.size();
                                 regions.setSize(sz+1);
diff --git a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C
index dfe684bb4daf2a0a127e5212e2b03965eed0c628..9a5f3a49842c1616f249026156474a0afac1d57b 100644
--- a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C
+++ b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.C
@@ -503,7 +503,7 @@ void Foam::searchableBox::findLineAll
     info.setSize(start.size());
 
     // Work array
-    DynamicList<pointIndexHit, 1, 1> hits;
+    DynamicList<pointIndexHit> hits;
 
     // Tolerances:
     // To find all intersections we add a small vector to the last intersection
diff --git a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C
index ffb8dc9c5dcda4a1b0a6bb3e7008463dfaff9e4e..ab2329e744a2c2a442fbd4965acc3ceb28927e89 100644
--- a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C
+++ b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C
@@ -301,7 +301,7 @@ void Foam::searchableRotatedBox::findLineAll
     info.setSize(start.size());
 
     // Work array
-    DynamicList<pointIndexHit, 1, 1> hits;
+    DynamicList<pointIndexHit> hits;
 
     // Tolerances:
     // To find all intersections we add a small vector to the last intersection
diff --git a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C
index 9686901cec1774045d79d49738b76fe7a29b1341..2783cea76f996baa4d96f0555d185f0bade8c568 100644
--- a/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C
+++ b/src/meshTools/searchableSurfaces/searchableSurfaces/searchableSurfaces.C
@@ -129,7 +129,7 @@ Foam::searchableSurfaces::searchableSurfaces(const label size)
 //                    // Get the dictionary for region iter.key()
 //                    const dictionary& regionDict = regionsDict.subDict(key);
 //
-//                    label index = findIndex(localNames, key);
+//                    label index = localNames.find(key);
 //
 //                    if (index == -1)
 //                    {
@@ -251,7 +251,7 @@ Foam::searchableSurfaces::searchableSurfaces
                     // Get the dictionary for region iter.keyword()
                     const dictionary& regionDict = regionsDict.subDict(key);
 
-                    label index = findIndex(localNames, key);
+                    label index = localNames.find(key);
 
                     if (index == -1)
                     {
@@ -285,7 +285,7 @@ Foam::label Foam::searchableSurfaces::findSurfaceID
     const word& wantedName
 ) const
 {
-    return findIndex(names_, wantedName);
+    return names_.find(wantedName);
 }
 
 
@@ -295,9 +295,9 @@ Foam::label Foam::searchableSurfaces::findSurfaceRegionID
     const word& regionName
 ) const
 {
-    label surfaceIndex = findSurfaceID(surfaceName);
+    const label surfaceIndex = findSurfaceID(surfaceName);
 
-    return findIndex(this->operator[](surfaceIndex).regions(), regionName);
+    return this->operator[](surfaceIndex).regions().find(regionName);
 }
 
 
diff --git a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H
index 404bb857759bb93645380acdd005e8cce27e5f3d..bf863e96cf471fec51db6aafee0c000247220d7f 100644
--- a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H
+++ b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.H
@@ -138,7 +138,7 @@ public:
 
             //- Find nearest points that are on all supplied surfaces
             //  (nearest point if single surface; nearest intersection by
-            //   steepst descent if on multiple surfaces). Returns current
+            //   steepest descent if on multiple surfaces). Returns current
             //   best guess). Wip.
             static void findNearest
             (
diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
index 2aff7124af2ad811bbd49150d9c12a8a44a6a453..279c75caba8dee399b83391c995eaf05637822d7 100644
--- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
+++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
@@ -175,7 +175,7 @@ bool Foam::triSurfaceMesh::isSurfaceClosed() const
         forAll(pFaces, i)
         {
             const triSurface::FaceType& f = triSurface::operator[](pFaces[i]);
-            label fp = findIndex(f, pointi);
+            label fp = f.find(pointi);
 
             // Something weird: if I expand the code of addFaceToEdge in both
             // below instances it gives a segmentation violation on some
diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H
index 110ee7944b29bb1a71696612e4899bd58b5a15d1..54af373a33dc3ffab6be29320c76232cf2faf997 100644
--- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H
+++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H
@@ -131,7 +131,7 @@ class triSurfaceMesh
             const point& start,
             const point& end,
             const vector& smallVec,
-            DynamicList<pointIndexHit, 1, 1>& hits
+            DynamicList<pointIndexHit>& hits
         );
 
         //- Disallow default bitwise copy construct
diff --git a/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C b/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C
index fd9c7a9fd0903ddd6ad3fe449678ce1b976daa06..a142a37ee6be4e4ad58b7d09d8e6b35c5a275e7e 100644
--- a/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C
+++ b/src/meshTools/triSurface/booleanOps/intersectedSurface/intersectedSurface.C
@@ -212,7 +212,7 @@ bool Foam::intersectedSurface::sameEdgeOrder
 {
     forAll(fA, fpA)
     {
-        label fpB = findIndex(fB, fA[fpA]);
+        label fpB = fB.find(fA[fpA]);
 
         if (fpB != -1)
         {
diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C
index 8da032518b1ed182c9021b5df8ff35d6d01c50e6..d9ea3c2b8d9c34fff07c36e58d7d8a68708f99ec 100644
--- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C
+++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C
@@ -243,12 +243,16 @@ void Foam::surfaceFeatures::calcFeatPoints
 
                 if (edgeStat[edgeI] != NONE)
                 {
-                    edgeVecs.append(edges[edgeI].vec(localPoints));
-                    edgeVecs.last() /= mag(edgeVecs.last());
+                    vector vec = edges[edgeI].vec(localPoints);
+                    scalar magVec = mag(vec);
+                    if (magVec > SMALL)
+                    {
+                        edgeVecs.append(vec/magVec);
+                    }
                 }
             }
 
-            if (mag(edgeVecs[0] & edgeVecs[1]) < minCos)
+            if (edgeVecs.size() == 2 && mag(edgeVecs[0] & edgeVecs[1]) < minCos)
             {
                 featurePoints.append(pointi);
             }
@@ -388,7 +392,7 @@ Foam::surfaceFeatures::labelScalar Foam::surfaceFeatures::walkSegment
 
     label nVisited = 0;
 
-    if (findIndex(featurePoints_, startPointi) >= 0)
+    if (featurePoints_.found(startPointi))
     {
         // Do not walk across feature points
 
@@ -619,7 +623,7 @@ Foam::surfaceFeatures::surfaceFeatures::checkFlatRegionEdge
 
             regionAndNormal1[i] = myRegionAndNormal;
 
-            label index = findIndex(regionAndNormal, -myRegionAndNormal);
+            label index = regionAndNormal.find(-myRegionAndNormal);
             if (index == -1)
             {
                 // Not found.
diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C
index f8fd6c096eb1566f50cfcbf9773a21c68dc70d59..13ba83fb954dcdd74af21fdca06ec754ade8ec60 100644
--- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C
+++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceRegionSearch.C
@@ -205,7 +205,7 @@ void Foam::triSurfaceRegionSearch::findNearest
 
         forAll(octrees, treeI)
         {
-            if (findIndex(regionIndices, treeI) == -1)
+            if (!regionIndices.found(treeI))
             {
                 continue;
             }
diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C
index 40edce3f2c34a62d0e49af9ac6251ebf0e6dcf70..fe6990565473bd13b3833e96afac497523d2b2bd 100644
--- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C
+++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C
@@ -33,7 +33,7 @@ License
 bool Foam::triSurfaceSearch::checkUniqueHit
 (
     const pointIndexHit& currHit,
-    const DynamicList<pointIndexHit, 1, 1>& hits,
+    const UList<pointIndexHit>& hits,
     const vector& lineVec
 ) const
 {
@@ -387,7 +387,7 @@ void Foam::triSurfaceSearch::findLineAll
     indexedOctree<treeDataTriSurface>::perturbTol() = tolerance();
 
     // Work array
-    DynamicList<pointIndexHit, 1, 1> hits;
+    DynamicList<pointIndexHit> hits;
 
     DynamicList<label> shapeMask;
 
diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H
index b46e758985789b1233e6f671510238cf1ad52f81..d42806a563932ac684a64bb1bfce84af32c8adc9 100644
--- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H
+++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.H
@@ -80,7 +80,7 @@ class triSurfaceSearch
         bool checkUniqueHit
         (
             const pointIndexHit& currHit,
-            const DynamicList<pointIndexHit, 1, 1>& hits,
+            const UList<pointIndexHit>& hits,
             const vector& lineVec
         ) const;
 
diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C
index 2518b095164eb5ce909e82503aeee76c6d0ecf60..f64cb0eea2bf2d992f70eac5a851dd9cb3c7babd 100644
--- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C
+++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCurvature.C
@@ -45,7 +45,7 @@ Foam::scalar Foam::triSurfaceTools::vertexNormalWeight
     const UList<point>& points
 )
 {
-    label index = findIndex(f, pI);
+    label index = f.find(pI);
 
     if (index == -1)
     {
diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C
index d1da45a001c11739382289a15d395b2b1d19b6e1..4f0745a18461cc70b41632a19c2721769d075a33 100644
--- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C
+++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C
@@ -101,7 +101,7 @@ void Foam::triSurfaceTools::greenRefine
 
     // Find index of edge in face.
 
-    label fp0 = findIndex(f, e[0]);
+    label fp0 = f.find(e[0]);
     label fp1 = f.fcIndex(fp0);
     label fp2 = f.fcIndex(fp1);
 
@@ -881,7 +881,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
     {
         // Excluded point. Test only opposite edge.
 
-        label fp0 = findIndex(s.localFaces()[triI], excludePointi);
+        label fp0 = s.localFaces()[triI].find(excludePointi);
 
         if (fp0 == -1)
         {
@@ -1062,7 +1062,7 @@ void Foam::triSurfaceTools::snapToEnd
             // endpoint on edge; current on triangle
             const labelList& fEdges = s.faceEdges()[current.index()];
 
-            if (findIndex(fEdges, end.index()) != -1)
+            if (fEdges.found(end.index()))
             {
                 //if (debug)
                 //{
@@ -1111,7 +1111,7 @@ void Foam::triSurfaceTools::snapToEnd
             // endpoint on point; current on triangle
             const triSurface::FaceType& f = s.localFaces()[current.index()];
 
-            if (findIndex(f, end.index()) != -1)
+            if (f.found(end.index()))
             {
                 //if (debug)
                 //{
@@ -1415,7 +1415,7 @@ void Foam::triSurfaceTools::otherEdges
 {
     const labelList& eFaces = surf.faceEdges()[facei];
 
-    label i0 = findIndex(eFaces, edgeI);
+    label i0 = eFaces.find(edgeI);
 
     if (i0 == -1)
     {
diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C
index 8eb4dca33007eb6e061b7479ec4fb364b50cee28..9a2851870d5b682fd916a6d179efb2986f2f1d6b 100644
--- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C
+++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C
@@ -256,7 +256,7 @@ void Foam::cellCellStencil::globalCellCells
             }
 
             SubList<label> current(stencil, compacti);
-            if (findIndex(current, nbrCelli) == -1)
+            if (!current.found(nbrCelli))
             {
                 stencil[compacti] = nbrCelli;
                 stencilPoints[compacti++] = nbrCc;
diff --git a/src/overset/oversetPolyPatch/oversetPolyPatch.C b/src/overset/oversetPolyPatch/oversetPolyPatch.C
index ddce16ae7c6da92d6376496a64b22beab877f919..1b6e411baf2a35cb01cb08933741bce317cb6c06 100644
--- a/src/overset/oversetPolyPatch/oversetPolyPatch.C
+++ b/src/overset/oversetPolyPatch/oversetPolyPatch.C
@@ -54,7 +54,7 @@ Foam::oversetPolyPatch::oversetPolyPatch
     masterPatchID_(-1)
 {
     //  'overset' is not constraint type so add to group explicitly
-    if (findIndex(inGroups(), typeName) == -1)
+    if (!inGroups().found(typeName))
     {
         inGroups().append(typeName);
     }
@@ -74,7 +74,7 @@ Foam::oversetPolyPatch::oversetPolyPatch
     masterPatchID_(-1)
 {
     //  'overset' is not constraint type so add to group explicitly
-    if (findIndex(inGroups(), typeName) == -1)
+    if (!inGroups().found(typeName))
     {
         inGroups().append(typeName);
     }
diff --git a/src/parallel/decompose/Allwclean b/src/parallel/decompose/Allwclean
index 88c606b523c26c7b8eefe57107d0c6937ab4568d..5fd3b3d4991b846d541dbd59bd78bc7f489655aa 100755
--- a/src/parallel/decompose/Allwclean
+++ b/src/parallel/decompose/Allwclean
@@ -17,8 +17,9 @@ wcleanMpiLib()
 }
 
 
-wclean scotchDecomp
 wclean metisDecomp
+wclean kahipDecomp
+wclean scotchDecomp
 wclean decompositionMethods
 wclean decompose
 wcleanMpiLib ptscotchDecomp
diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake
index a90f705601ba1a0848ea2bdd0ba49862f1d525e4..f3711333487103d6732d1f8f6b22a5864ee12645 100755
--- a/src/parallel/decompose/Allwmake
+++ b/src/parallel/decompose/Allwmake
@@ -25,6 +25,56 @@ findFirstFile()
 }
 
 
+# Test for kahip.
+# - return 0 and export KAHIP_ARCH_PATH on success
+hasKahip()
+{
+    local warning="==> skip kahip"
+    local header label settings
+
+    unset KAHIP_ARCH_PATH KAHIP_VERSION
+    settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip) || {
+        echo "$warning (no config.sh/kahip settings)"
+        return 1
+    }
+
+    . $settings
+    if [ -z "$KAHIP_ARCH_PATH" -o "${KAHIP_ARCH_PATH##*-}" = none ]
+    then
+        echo "$warning (not available)"
+        return 1
+    fi
+
+    # Header
+    header=$(findFirstFile \
+        $KAHIP_ARCH_PATH/include/kaHIP_interface.h \
+        /usr/include/kaHIP_interface.h \
+    ) || {
+        echo "$warning (no header)"
+        return 2  # file not found
+    }
+
+    # Library
+    [ "${KAHIP_ARCH_PATH##*-}" = system ] || \
+    findFirstFile \
+        $FOAM_EXT_LIBBIN/libkahip.so \
+        $KAHIP_ARCH_PATH/lib/libkahip.a  \
+        $KAHIP_ARCH_PATH/lib/libkahip.so \
+        $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.a \
+        $KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.so \
+    > /dev/null || {
+        echo "$warning (missing library)"
+        return 2
+    }
+
+    # kahip itself is 32-bit int, but our interface itself handles some
+    # 64-bit conversion (mesh size).
+
+    export KAHIP_ARCH_PATH
+    echo "kahip (label=32) - $KAHIP_ARCH_PATH"
+}
+
+
 # Test for metis.
 # - return 0 and export METIS_ARCH_PATH on success
 hasMetis()
@@ -208,6 +258,11 @@ then
     wmake $targetType metisDecomp
 fi
 
+if hasKahip
+then
+    wmake $targetType kahipDecomp
+fi
+
 wmake $targetType decompositionMethods
 wmake $targetType decompose
 
diff --git a/src/parallel/decompose/AllwmakeLnInclude b/src/parallel/decompose/AllwmakeLnInclude
index 8aa65506c9551a89224757467d5b891db0969f5e..6041217fec096f659c7392de575bebdeb23910d8 100755
--- a/src/parallel/decompose/AllwmakeLnInclude
+++ b/src/parallel/decompose/AllwmakeLnInclude
@@ -2,6 +2,7 @@
 cd ${0%/*} || exit 1    # Run from this directory
 
 wmakeLnInclude -u decompositionMethods
+wmakeLnInclude -u kahipDecomp
 wmakeLnInclude -u metisDecomp
 wmakeLnInclude -u scotchDecomp
 wmakeLnInclude -u ptscotchDecomp
diff --git a/src/parallel/decompose/decompose/Make/files b/src/parallel/decompose/decompose/Make/files
index 5fabd38ccef57caf31d6d495eb45184fa8bb9fa9..225a27dfad890ce4248954ff1be2aca2c4dfbf16 100644
--- a/src/parallel/decompose/decompose/Make/files
+++ b/src/parallel/decompose/decompose/Make/files
@@ -1,3 +1,4 @@
+decompositionInformation.C
 decompositionModel.C
 fvFieldDecomposer.C
 
diff --git a/src/parallel/decompose/decompose/decompositionInformation.C b/src/parallel/decompose/decompose/decompositionInformation.C
new file mode 100644
index 0000000000000000000000000000000000000000..08f80d2cad774423df1c9696e17b66b067249d01
--- /dev/null
+++ b/src/parallel/decompose/decompose/decompositionInformation.C
@@ -0,0 +1,236 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "decompositionInformation.H"
+#include "ListOps.H"
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+void Foam::decompositionInformation::populate
+(
+    const labelUList& adjncy,
+    const labelUList& xadj,
+    const labelUList& decomp,
+    const label nDomain
+)
+{
+    nDomains_ = nDomain;
+
+    distrib_.clear();
+    distrib_.setSize(nDomain);
+
+    for (labelList& subdist : distrib_)
+    {
+        subdist.clear();
+        subdist.setSize(nDomain, Zero);
+    }
+
+    const label nCells = xadj.size()-1;
+    for (label celli = 0; celli < nCells; ++celli)
+    {
+        const label ownProc = decomp[celli];
+
+        labelList& subdist = distrib_[ownProc];
+
+        // Number of cells
+        ++subdist[ownProc];
+
+        for (label i = xadj[celli]; i < xadj[celli+1]; ++i)
+        {
+            const label neiProc = decomp[adjncy[i]];
+
+            if (neiProc != ownProc)
+            {
+                // Number of processor faces
+                ++subdist[neiProc];
+            }
+        }
+    }
+
+    // Build summary
+
+    labelList cellsCount(nDomains_, Zero);
+    labelList neighCount(nDomains_, Zero);
+    labelList facesCount(nDomains_, Zero);
+
+    forAll(distrib_, ownProc)
+    {
+        const labelList& subdist = distrib_[ownProc];
+
+        cellsCount[ownProc] = subdist[ownProc];
+
+        forAll(subdist, neiProc)
+        {
+            const label n = subdist[neiProc];
+
+            if (n && ownProc != neiProc)
+            {
+                ++neighCount[ownProc];
+                facesCount[ownProc] += n;
+            }
+        }
+    }
+
+    const label n2 = (nDomains_ / 2);
+
+    sort(cellsCount);
+    cellsInfo_.min    = cellsCount.first();
+    cellsInfo_.max    = cellsCount.last();
+    cellsInfo_.median = cellsCount[n2];
+
+    sort(neighCount);
+    neighInfo_.min    = neighCount.first();
+    neighInfo_.max    = neighCount.last();
+    neighInfo_.median = neighCount[n2];
+
+    sort(facesCount);
+    facesInfo_.min    = facesCount.first();
+    facesInfo_.max    = facesCount.last();
+    facesInfo_.median = facesCount[n2];
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::decompositionInformation::decompositionInformation
+(
+    const labelUList& adjncy,
+    const labelUList& xadj,
+    const labelUList& decomp,
+    const label nDomains
+)
+:
+    distrib_(),
+    nDomains_(0)
+{
+    populate(adjncy, xadj, decomp, nDomains);
+}
+
+
+Foam::decompositionInformation::decompositionInformation
+(
+    const CompactListList<label>& cellCells,
+    const labelUList& decomp,
+    const label nDomains
+)
+:
+    distrib_(),
+    nDomains_(0)
+{
+    populate(cellCells.m(), cellCells.offsets(), decomp, nDomains);
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+void Foam::decompositionInformation::clear()
+{
+    distrib_.clear();
+    cellsInfo_.clear();
+    neighInfo_.clear();
+    facesInfo_.clear();
+}
+
+
+void Foam::decompositionInformation::printSummary(Ostream& os) const
+{
+    os  << "Cells "; cellsInfo_.print(os) << nl;
+    os  << "Neigh "; neighInfo_.print(os)<< nl;
+    os  << "Faces "; facesInfo_.print(os)<< nl;
+}
+
+
+void Foam::decompositionInformation::printDetails(Ostream& os) const
+{
+    forAll(distrib_, ownProc)
+    {
+        const labelList& subdist = distrib_[ownProc];
+
+        // First pass:
+        label neighCount = 0;
+        label facesCount = 0;
+
+        forAll(subdist, neiProc)
+        {
+            const label n = subdist[neiProc];
+
+            if (n && ownProc != neiProc)
+            {
+                ++neighCount;
+                facesCount += n;
+            }
+        }
+
+        os  << "Part[" << ownProc << "] cells:" << subdist[ownProc]
+            << " neigh:" << neighCount
+            << " faces:" << facesCount;
+
+        // Second pass with details:
+        if (facesCount)
+        {
+            Info<< " ";
+
+            forAll(subdist, neiProc)
+            {
+                const label n = subdist[neiProc];
+
+                if (n && ownProc != neiProc)
+                {
+                    os  << " (" << neiProc << " " << n << ")";
+                }
+            }
+        }
+
+        os  << nl;
+    }
+}
+
+
+void Foam::decompositionInformation::printAll(Ostream& os) const
+{
+    printDetails(os);
+    printSummary(os);
+}
+
+
+// * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
+
+
+Foam::Ostream& Foam::decompositionInformation::stats::print(Ostream& os) const
+{
+    os  << "max/median/min: "
+        << this->max << " / " << this->median << " / " << this->min;
+
+    if (this->median)
+    {
+        const scalar ratio = scalar(100*this->max)/this->median;
+
+        os  << " (" << ratio << "%)";
+    }
+
+    return os;
+}
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompose/decompositionInformation.H b/src/parallel/decompose/decompose/decompositionInformation.H
new file mode 100644
index 0000000000000000000000000000000000000000..c0f24bb2cf38429c394198273b7e932761eb9741
--- /dev/null
+++ b/src/parallel/decompose/decompose/decompositionInformation.H
@@ -0,0 +1,149 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::decompositionInformation
+
+Description
+    Abstract base class for decomposition
+
+SourceFiles
+    decompositionInformation.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef decompositionInformation_H
+#define decompositionInformation_H
+
+#include "polyMesh.H"
+#include "CompactListList.H"
+#include "IOstreams.H"
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                  Class decompositionInformation Declaration
+\*---------------------------------------------------------------------------*/
+
+class decompositionInformation
+{
+    //- Simple storage for organizing min/max/median quantities
+    struct stats
+    {
+        label min;
+        label max;
+        label median;
+
+        stats() : min(0), max(0), median(0) {}
+
+        void clear()
+        {
+            min = 0;
+            max = 0;
+            median = 0;
+        }
+
+        Ostream& print(Ostream& os) const;
+    };
+
+    // Private data
+
+        labelListList distrib_;
+        label nDomains_;
+
+        stats cellsInfo_;
+        stats neighInfo_;
+        stats facesInfo_;
+
+
+    // Private Member Functions
+
+        //- Populate from cell decomposition list
+        void populate
+        (
+            const labelUList& adjncy,
+            const labelUList& xadj,
+            const labelUList& decomp,
+            const label nDomains
+        );
+
+        //- Disallow default bitwise copy construct and assignment
+        decompositionInformation(const decompositionInformation&) = delete;
+        void operator=(const decompositionInformation&) = delete;
+
+
+public:
+
+    // Constructors
+
+        //- Construct
+        decompositionInformation
+        (
+            const labelUList& adjncy,
+            const labelUList& xadj,
+            const labelUList& decomp,
+            const label nDomains
+        );
+
+        //- Construct
+        decompositionInformation
+        (
+            const CompactListList<label>& cellCells,
+            const labelUList& decomp,
+            const label nDomains
+        );
+
+
+    //- Destructor
+    ~decompositionInformation()
+    {}
+
+
+    // Member Functions
+
+        void clear();
+
+        label nDomains() const
+        {
+            return nDomains_;
+        }
+
+
+        void printSummary(Ostream& os) const;
+
+        void printDetails(Ostream& os) const;
+
+        void printAll(Ostream& os) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/Make/files b/src/parallel/decompose/decompositionMethods/Make/files
index 2aef948ff7a22d15cb43a6f84f1437e200f2edd3..0bae18c40d6bdd40a0b60e042b1625087f1b15a5 100644
--- a/src/parallel/decompose/decompositionMethods/Make/files
+++ b/src/parallel/decompose/decompositionMethods/Make/files
@@ -4,6 +4,7 @@ simpleGeomDecomp/simpleGeomDecomp.C
 hierarchGeomDecomp/hierarchGeomDecomp.C
 manualDecomp/manualDecomp.C
 multiLevelDecomp/multiLevelDecomp.C
+metisLikeDecomp/metisLikeDecomp.C
 structuredDecomp/structuredDecomp.C
 noDecomp/noDecomp.C
 
diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
index a66acf8dbd331f260d3dae05e611261eb531018c..c17958367a31de081796fc24e6795fa7c8604123 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
+++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -21,9 +21,6 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-InClass
-    decompositionMethod
-
 \*---------------------------------------------------------------------------*/
 
 #include "decompositionMethod.H"
@@ -49,6 +46,7 @@ namespace Foam
     defineRunTimeSelectionTable(decompositionMethod, dictionary);
 }
 
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::decompositionMethod::decompositionMethod
@@ -98,11 +96,10 @@ Foam::decompositionMethod::decompositionMethod
     if
     (
         decompositionDict_.found("preserveBaffles")
-     && findIndex
+     && !constraintTypes_.found
         (
-            constraintTypes_,
             decompositionConstraints::preserveBafflesConstraint::typeName
-        ) == -1
+        )
     )
     {
         constraints_.append
@@ -114,11 +111,10 @@ Foam::decompositionMethod::decompositionMethod
     if
     (
         decompositionDict_.found("preservePatches")
-     && findIndex
+     && !constraintTypes_.found
         (
-            constraintTypes_,
             decompositionConstraints::preservePatchesConstraint::typeName
-        ) == -1
+        )
     )
     {
         const wordReList pNames(decompositionDict_.lookup("preservePatches"));
@@ -132,11 +128,10 @@ Foam::decompositionMethod::decompositionMethod
     if
     (
         decompositionDict_.found("preserveFaceZones")
-     && findIndex
+     && !constraintTypes_.found
         (
-            constraintTypes_,
             decompositionConstraints::preserveFaceZonesConstraint::typeName
-        ) == -1
+        )
     )
     {
         const wordReList zNames(decompositionDict_.lookup("preserveFaceZones"));
@@ -150,11 +145,10 @@ Foam::decompositionMethod::decompositionMethod
     if
     (
         decompositionDict_.found("singleProcessorFaceSets")
-     && findIndex
+     && !constraintTypes_.found
         (
-            constraintTypes_,
             decompositionConstraints::preserveFaceZonesConstraint::typeName
-        ) == -1
+        )
     )
     {
         const List<Tuple2<word, label>> zNameAndProcs
@@ -349,8 +343,8 @@ void Foam::decompositionMethod::calcCellCells
 
     for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
     {
-        label own = agglom[faceOwner[facei]];
-        label nei = agglom[faceNeighbour[facei]];
+        const label own = agglom[faceOwner[facei]];
+        const label nei = agglom[faceNeighbour[facei]];
 
         nFacesPerCell[own]++;
         nFacesPerCell[nei]++;
@@ -367,7 +361,7 @@ void Foam::decompositionMethod::calcCellCells
 
             forAll(pp, i)
             {
-                label own = agglom[faceOwner[facei]];
+                const label own = agglom[faceOwner[facei]];
 
                 label globalNei = globalNeighbour[bFacei];
                 if
@@ -399,8 +393,8 @@ void Foam::decompositionMethod::calcCellCells
     // For internal faces is just offsetted owner and neighbour
     for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
     {
-        label own = agglom[faceOwner[facei]];
-        label nei = agglom[faceNeighbour[facei]];
+        const label own = agglom[faceOwner[facei]];
+        const label nei = agglom[faceNeighbour[facei]];
 
         m[offsets[own] + nFacesPerCell[own]++] = globalAgglom.toGlobal(nei);
         m[offsets[nei] + nFacesPerCell[nei]++] = globalAgglom.toGlobal(own);
@@ -418,9 +412,9 @@ void Foam::decompositionMethod::calcCellCells
 
             forAll(pp, i)
             {
-                label own = agglom[faceOwner[facei]];
+                const label own = agglom[faceOwner[facei]];
 
-                label globalNei = globalNeighbour[bFacei];
+                const label globalNei = globalNeighbour[bFacei];
 
                 if
                 (
@@ -457,7 +451,7 @@ void Foam::decompositionMethod::calcCellCells
         nbrCells.clear();
         nbrCells.insert(globalAgglom.toGlobal(celli));
 
-        label endIndex = cellCells.offsets()[celli+1];
+        const label endIndex = cellCells.offsets()[celli+1];
 
         for (label i = startIndex; i < endIndex; i++)
         {
@@ -555,8 +549,8 @@ void Foam::decompositionMethod::calcCellCells
 
     for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
     {
-        label own = agglom[faceOwner[faceI]];
-        label nei = agglom[faceNeighbour[faceI]];
+        const label own = agglom[faceOwner[faceI]];
+        const label nei = agglom[faceNeighbour[faceI]];
 
         nFacesPerCell[own]++;
         nFacesPerCell[nei]++;
@@ -573,9 +567,9 @@ void Foam::decompositionMethod::calcCellCells
 
             forAll(pp, i)
             {
-                label own = agglom[faceOwner[faceI]];
+                const label own = agglom[faceOwner[faceI]];
 
-                label globalNei = globalNeighbour[bFaceI];
+                const label globalNei = globalNeighbour[bFaceI];
                 if
                 (
                    !globalAgglom.isLocal(globalNei)
@@ -607,11 +601,11 @@ void Foam::decompositionMethod::calcCellCells
     // For internal faces is just offsetted owner and neighbour
     for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
     {
-        label own = agglom[faceOwner[faceI]];
-        label nei = agglom[faceNeighbour[faceI]];
+        const label own = agglom[faceOwner[faceI]];
+        const label nei = agglom[faceNeighbour[faceI]];
 
-        label ownIndex = offsets[own] + nFacesPerCell[own]++;
-        label neiIndex = offsets[nei] + nFacesPerCell[nei]++;
+        const label ownIndex = offsets[own] + nFacesPerCell[own]++;
+        const label neiIndex = offsets[nei] + nFacesPerCell[nei]++;
 
         m[ownIndex] = globalAgglom.toGlobal(nei);
         w[ownIndex] = mag(mesh.faceAreas()[faceI]);
@@ -631,9 +625,9 @@ void Foam::decompositionMethod::calcCellCells
 
             forAll(pp, i)
             {
-                label own = agglom[faceOwner[faceI]];
+                const label own = agglom[faceOwner[faceI]];
 
-                label globalNei = globalNeighbour[bFaceI];
+                const label globalNei = globalNeighbour[bFaceI];
 
                 if
                 (
@@ -672,7 +666,7 @@ void Foam::decompositionMethod::calcCellCells
         nbrCells.clear();
         nbrCells.insert(globalAgglom.toGlobal(cellI));
 
-        label endIndex = cellCells.offsets()[cellI+1];
+        const label endIndex = cellCells.offsets()[cellI+1];
 
         for (label i = startIndex; i < endIndex; i++)
         {
@@ -1350,7 +1344,15 @@ Foam::labelList Foam::decompositionMethod::decompose
             {
                 // If no processor specified use the one from the
                 // 0th element
-                proci = finalDecomp[mesh.faceOwner()[set[0]]];
+                if (set.size())
+                {
+                    proci = finalDecomp[mesh.faceOwner()[set[0]]];
+                }
+                else
+                {
+                    // Zero-sized processor (e.g. from redistributePar)
+                    proci = 0;
+                }
             }
 
             forAll(set, fI)
diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H
index 9a8a3a1f1cef9098a83cd7b8230936bbdea7d72f..75a797e1aeeb4a9965959f3816ac9ba802221087 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H
+++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C
new file mode 100644
index 0000000000000000000000000000000000000000..232a351f5966e0cac4d11079c0ff61789e549805
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C
@@ -0,0 +1,271 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "metisLikeDecomp.H"
+#include "Time.H"
+#include "globalIndex.H"
+
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
+
+Foam::label Foam::metisLikeDecomp::decomposeGeneral
+(
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cWeights,
+    List<label>& decomp
+)
+{
+    if (!Pstream::parRun())
+    {
+        return decomposeSerial
+        (
+            adjncy,
+            xadj,
+            cWeights,
+            decomp
+        );
+    }
+
+    if (debug)
+    {
+        Info<< type() << "Decomp : running in parallel."
+            << " Decomposing all of graph on master processor." << endl;
+    }
+    globalIndex globalCells(xadj.size()-1);
+    label nTotalConnections = returnReduce(adjncy.size(), sumOp<label>());
+
+    // Send all to master. Use scheduled to save some storage.
+    if (Pstream::master())
+    {
+        List<label> allAdjncy(nTotalConnections);
+        List<label> allXadj(globalCells.size()+1);
+        List<scalar> allWeights(globalCells.size());
+
+        // Insert my own
+        label nTotalCells = 0;
+        forAll(cWeights, celli)
+        {
+            allXadj[nTotalCells] = xadj[celli];
+            allWeights[nTotalCells++] = cWeights[celli];
+        }
+        nTotalConnections = 0;
+        forAll(adjncy, i)
+        {
+            allAdjncy[nTotalConnections++] = adjncy[i];
+        }
+
+        for (int slave=1; slave<Pstream::nProcs(); ++slave)
+        {
+            IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
+            List<label> nbrAdjncy(fromSlave);
+            List<label> nbrXadj(fromSlave);
+            List<scalar> nbrWeights(fromSlave);
+
+            // Append.
+            forAll(nbrXadj, celli)
+            {
+                allXadj[nTotalCells] = nTotalConnections+nbrXadj[celli];
+                allWeights[nTotalCells++] = nbrWeights[celli];
+            }
+            // No need to renumber xadj since already global.
+            forAll(nbrAdjncy, i)
+            {
+                allAdjncy[nTotalConnections++] = nbrAdjncy[i];
+            }
+        }
+        allXadj[nTotalCells] = nTotalConnections;
+
+        labelList allDecomp;
+        decomposeSerial
+        (
+            allAdjncy,
+            allXadj,
+            allWeights,
+            allDecomp
+        );
+
+
+        // Send allFinalDecomp back
+        for (int slave=1; slave<Pstream::nProcs(); ++slave)
+        {
+            OPstream toSlave(Pstream::commsTypes::scheduled, slave);
+            toSlave << SubList<label>
+            (
+                allDecomp,
+                globalCells.localSize(slave),
+                globalCells.offset(slave)
+            );
+        }
+
+        // Get my own part (always first)
+        decomp = SubList<label>(allDecomp, globalCells.localSize());
+    }
+    else
+    {
+        // Send my part of the graph (already in global numbering)
+        {
+            OPstream toMaster
+            (
+                Pstream::commsTypes::scheduled,
+                Pstream::masterNo()
+            );
+            toMaster<< adjncy << SubList<label>(xadj, xadj.size()-1)
+                << cWeights;
+        }
+
+        // Receive back decomposition
+        IPstream fromMaster
+        (
+            Pstream::commsTypes::scheduled,
+            Pstream::masterNo()
+        );
+        fromMaster >> decomp;
+    }
+
+    return 0;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::metisLikeDecomp::metisLikeDecomp(const dictionary& decompositionDict)
+:
+    decompositionMethod(decompositionDict)
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+Foam::labelList Foam::metisLikeDecomp::decompose
+(
+    const polyMesh& mesh,
+    const pointField& points,
+    const scalarField& pointWeights
+)
+{
+    if (points.size() != mesh.nCells())
+    {
+        FatalErrorInFunction
+            << "Can use this decomposition method only for entire mesh" << nl
+            << "and supply one coordinate (cellCentre) for every cell." << nl
+            << "The number of coordinates " << points.size() << nl
+            << "The number of cells in the mesh " << mesh.nCells()
+            << exit(FatalError);
+    }
+
+    CompactListList<label> cellCells;
+    calcCellCells
+    (
+        mesh,
+        identity(mesh.nCells()),
+        mesh.nCells(),
+        true,
+        cellCells
+    );
+
+    // Decompose using default weights
+    labelList decomp;
+    decomposeGeneral(cellCells.m(), cellCells.offsets(), pointWeights, decomp);
+
+    return decomp;
+}
+
+
+Foam::labelList Foam::metisLikeDecomp::decompose
+(
+    const polyMesh& mesh,
+    const labelList& agglom,
+    const pointField& agglomPoints,
+    const scalarField& agglomWeights
+)
+{
+    if (agglom.size() != mesh.nCells())
+    {
+        FatalErrorInFunction
+            << "Size of cell-to-coarse map " << agglom.size()
+            << " differs from number of cells in mesh " << mesh.nCells()
+            << exit(FatalError);
+    }
+
+    // Make Metis CSR (Compressed Storage Format) storage
+    //   adjncy      : contains neighbours (= edges in graph)
+    //   xadj(celli) : start of information in adjncy for celli
+
+    CompactListList<label> cellCells;
+    calcCellCells
+    (
+        mesh,
+        agglom,
+        agglomPoints.size(),
+        true,
+        cellCells
+    );
+
+    // Decompose using default weights
+    labelList decomp;
+    decomposeGeneral(cellCells.m(), cellCells.offsets(), agglomWeights, decomp);
+
+
+    // Rework back into decomposition for original mesh
+    labelList fineDistribution(agglom.size());
+
+    forAll(fineDistribution, i)
+    {
+        fineDistribution[i] = decomp[agglom[i]];
+    }
+
+    return fineDistribution;
+}
+
+
+Foam::labelList Foam::metisLikeDecomp::decompose
+(
+    const labelListList& globalCellCells,
+    const pointField& cellCentres,
+    const scalarField& cellWeights
+)
+{
+    if (cellCentres.size() != globalCellCells.size())
+    {
+        FatalErrorInFunction
+            << "Inconsistent number of cells (" << globalCellCells.size()
+            << ") and number of cell centres (" << cellCentres.size()
+            << ")." << exit(FatalError);
+    }
+
+    // Make Metis CSR (Compressed Storage Format) storage
+    //   adjncy      : contains neighbours (= edges in graph)
+    //   xadj(celli) : start of information in adjncy for celli
+
+    CompactListList<label> cellCells(globalCellCells);
+
+    // Decompose using default weights
+    labelList decomp;
+    decomposeGeneral(cellCells.m(), cellCells.offsets(), cellWeights, decomp);
+
+    return decomp;
+}
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H
new file mode 100644
index 0000000000000000000000000000000000000000..8c8a6c9e87f12fda6e78d7732645eb901450c97c
--- /dev/null
+++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.H
@@ -0,0 +1,151 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::metisLikeDecomp
+
+Description
+    Domain decomposition using METIS-like data structures.
+
+    When run in parallel will collect the entire graph on to the master,
+    decompose and send back.
+
+SourceFiles
+    metisLikeDecomp.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef metisLikeDecomp_H
+#define metisLikeDecomp_H
+
+#include "decompositionMethod.H"
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                       Class metisLikeDecomp Declaration
+\*---------------------------------------------------------------------------*/
+
+class metisLikeDecomp
+:
+    public decompositionMethod
+{
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct and assignment
+        void operator=(const metisLikeDecomp&) = delete;
+        metisLikeDecomp(const metisLikeDecomp&) = delete;
+
+
+protected:
+
+    // Protected Member Functions
+
+        //- Serial and/or collect/distribute for parallel operation
+        virtual label decomposeGeneral
+        (
+            const UList<label>& adjncy,
+            const UList<label>& xadj,
+            const UList<scalar>& cellWeights,
+            List<label>& decomp
+        );
+
+        //- Decomposition with metis-like parameters
+        virtual label decomposeSerial
+        (
+            const UList<label>& adjncy,
+            const UList<label>& xadj,
+            const UList<scalar>& cellWeights,
+            List<label>& decomp
+        ) = 0;
+
+public:
+
+    // Constructors
+
+        //- Construct given the decomposition dictionary
+        metisLikeDecomp(const dictionary& decompositionDict);
+
+
+    //- Destructor
+    virtual ~metisLikeDecomp()
+    {}
+
+
+    // Member Functions
+
+        //- Inherit decompose from decompositionMethod
+        using decompositionMethod::decompose;
+
+        //- Return for every coordinate the wanted processor number.
+        //  Uses the mesh connectivity (if needed).
+        //  Weights get normalised so the minimum value is 1 before truncation
+        //  to an integer so the weights should be multiples of the minimum
+        //  value. The overall sum of weights might otherwise overflow.
+        virtual labelList decompose
+        (
+            const polyMesh& mesh,
+            const pointField& points,
+            const scalarField& pointWeights
+        );
+
+        //- Return for every coordinate the wanted processor number.
+        //  Gets passed agglomeration map (from fine to coarse cells) and coarse
+        //  cell location. Can be overridden by decomposers that provide this
+        //  functionality natively.
+        //  See note on weights above.
+        virtual labelList decompose
+        (
+            const polyMesh& mesh,
+            const labelList& agglom,
+            const pointField& regionPoints,
+            const scalarField& regionWeights
+        );
+
+        //- Return for every coordinate the wanted processor number.
+        //  Explicitly provided mesh connectivity.
+        //  The connectivity is equal to mesh.cellCells() except for
+        //  - in parallel the cell numbers are global cell numbers (starting
+        //    from 0 at processor0 and then incrementing all through the
+        //    processors)
+        //  - the connections are across coupled patches
+        //  See note on weights above.
+        virtual labelList decompose
+        (
+            const labelListList& globalCellCells,
+            const pointField& cellCentres,
+            const scalarField& cellWeights
+        );
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C
index 3ab449d3d3ffae022c3622b8cfdfb64b54f436ea..e90406009c96e2319bd7cd636fa069f996ef99c3 100644
--- a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C
+++ b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -99,7 +99,7 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells
         forAll(cCells, i)
         {
             // Get locally-compact cell index of neighbouring cell
-            label nbrCelli = oldToNew[cCells[i]];
+            const label nbrCelli = oldToNew[cCells[i]];
             if (nbrCelli == -1)
             {
                 cutConnections[allDist[cCells[i]]]++;
@@ -109,10 +109,10 @@ void Foam::multiLevelDecomp::subsetGlobalCellCells
                 // Reconvert local cell index into global one
 
                 // Get original neighbour
-                label celli = set[subCelli];
-                label oldNbrCelli = cellCells[celli][i];
+                const label celli = set[subCelli];
+                const label oldNbrCelli = cellCells[celli][i];
                 // Get processor from original neighbour
-                label proci = globalCells.whichProcID(oldNbrCelli);
+                const label proci = globalCells.whichProcID(oldNbrCelli);
                 // Convert into global compact numbering
                 cCells[newI++] = globalSubCells.toGlobal(proci, nbrCelli);
             }
@@ -127,15 +127,16 @@ void Foam::multiLevelDecomp::decompose
     const labelListList& pointPoints,
     const pointField& points,
     const scalarField& pointWeights,
-    const labelList& pointMap,      // map back to original points
-    const label levelI,
+    const labelUList& pointMap,     // map back to original points
+    const label currLevel,
+    const label leafOffset,
 
-    labelField& finalDecomp
+    labelList& finalDecomp
 )
 {
     labelList dist
     (
-        methods_[levelI].decompose
+        methods_[currLevel].decompose
         (
             pointPoints,
             points,
@@ -143,30 +144,62 @@ void Foam::multiLevelDecomp::decompose
         )
     );
 
+    // The next recursion level
+    const label nextLevel = currLevel+1;
+
+    // Number of domains at this current level
+    const label nCurrDomains = methods_[currLevel].nDomains();
+
+    // Calculate the domain remapping.
+    // The decompose() method delivers a distribution of [0..nDomains-1]
+    // which we map to the final location according to the decomposition
+    // leaf we are on.
+
+    labelList domainLookup(nCurrDomains);
+    {
+        label sizes = 1;  // Cumulative number of domains
+        for (label i = 0; i <= currLevel; ++i)
+        {
+            sizes *= methods_[i].nDomains();
+        }
+
+        // Distribution of domains at this level
+        sizes = this->nDomains() / sizes;
+
+        forAll(domainLookup, i)
+        {
+            domainLookup[i] = i * sizes + leafOffset;
+        }
+    }
+
+    if (debug)
+    {
+        Info<< "Distribute at level " << currLevel
+            << " to domains" << nl
+            << flatOutput(domainLookup) << endl;
+    }
+
+    // Extract processor+local index from point-point addressing
     forAll(pointMap, i)
     {
-        label orig = pointMap[i];
-        finalDecomp[orig] += dist[i];
+        const label orig = pointMap[i];
+        finalDecomp[orig] = domainLookup[dist[i]];
     }
 
-    if (levelI != methods_.size()-1)
+    if (nextLevel < methods_.size())
     {
         // Recurse
 
         // Determine points per domain
-        label n = methods_[levelI].nDomains();
-        labelListList domainToPoints(invertOneToMany(n, dist));
-
-        // 'Make space' for new levels of decomposition
-        finalDecomp *= methods_[levelI+1].nDomains();
+        labelListList domainToPoints(invertOneToMany(nCurrDomains, dist));
 
         // Extract processor+local index from point-point addressing
         if (debug && Pstream::master())
         {
-            Pout<< "Decomposition at level " << levelI << " :" << endl;
+            Pout<< "Decomposition at level " << currLevel << " :" << endl;
         }
 
-        for (label domainI = 0; domainI < n; domainI++)
+        for (label domainI = 0; domainI < nCurrDomains; domainI++)
         {
             // Extract elements for current domain
             const labelList domainPoints(findIndices(dist, domainI));
@@ -180,7 +213,7 @@ void Foam::multiLevelDecomp::decompose
             labelList nOutsideConnections;
             subsetGlobalCellCells
             (
-                n,
+                nCurrDomains,
                 domainI,
                 dist,
 
@@ -196,12 +229,12 @@ void Foam::multiLevelDecomp::decompose
             Pstream::listCombineScatter(nOutsideConnections);
             label nPatches = 0;
             label nFaces = 0;
-            forAll(nOutsideConnections, i)
+            for (const label nConnect : nOutsideConnections)
             {
-                if (nOutsideConnections[i] > 0)
+                if (nConnect > 0)
                 {
-                    nPatches++;
-                    nFaces += nOutsideConnections[i];
+                    ++nPatches;
+                    nFaces += nConnect;
                 }
             }
 
@@ -224,7 +257,8 @@ void Foam::multiLevelDecomp::decompose
                 subPoints,
                 subWeights,
                 subPointMap,
-                levelI+1,
+                nextLevel,
+                domainLookup[domainI], // The offset for this level and leaf
 
                 finalDecomp
             );
@@ -238,24 +272,30 @@ void Foam::multiLevelDecomp::decompose
         if (debug)
         {
             // Do straight decompose of two levels
-            label nNext = methods_[levelI+1].nDomains();
-            label nTotal = n*nNext;
+            const label nNext = methods_[nextLevel].nDomains();
+            const label nTotal = nCurrDomains * nNext;
 
-            // Retrieve original level0 dictionary and modify number of domains
-            dictionary::const_iterator iter =
-                decompositionDict_.optionalSubDict(typeName + "Coeffs").begin();
-            dictionary myDict = iter().dict();
-            myDict.set("numberOfSubdomains", nTotal);
+            // Get original level0 dictionary and modify numberOfSubdomains
+            dictionary level0Dict;
+            forAllConstIter(dictionary, methodsDict_, iter)
+            {
+                if (iter().isDict())
+                {
+                    level0Dict = iter().dict();
+                    break;
+                }
+            }
+            level0Dict.set("numberOfSubdomains", nTotal);
 
             if (debug && Pstream::master())
             {
-                Pout<< "Reference decomposition with " << myDict << " :"
+                Pout<< "Reference decomposition with " << level0Dict << " :"
                     << endl;
             }
 
             autoPtr<decompositionMethod> method0 = decompositionMethod::New
             (
-                myDict
+                level0Dict
             );
             labelList dist
             (
@@ -267,12 +307,12 @@ void Foam::multiLevelDecomp::decompose
                 )
             );
 
-            for (label blockI = 0; blockI < n; blockI++)
+            for (label blockI = 0; blockI < nCurrDomains; blockI++)
             {
                 // Count the number inbetween blocks of nNext size
 
                 label nPoints = 0;
-                labelList nOutsideConnections(n, 0);
+                labelList nOutsideConnections(nCurrDomains, 0);
                 forAll(pointPoints, pointi)
                 {
                     if ((dist[pointi] / nNext) == blockI)
@@ -283,7 +323,7 @@ void Foam::multiLevelDecomp::decompose
 
                         forAll(pPoints, i)
                         {
-                            label distBlockI = dist[pPoints[i]] / nNext;
+                            const label distBlockI = dist[pPoints[i]] / nNext;
                             if (distBlockI != blockI)
                             {
                                 nOutsideConnections[distBlockI]++;
@@ -301,12 +341,12 @@ void Foam::multiLevelDecomp::decompose
                 Pstream::listCombineScatter(nOutsideConnections);
                 label nPatches = 0;
                 label nFaces = 0;
-                forAll(nOutsideConnections, i)
+                for (const label nConnect : nOutsideConnections)
                 {
-                    if (nOutsideConnections[i] > 0)
+                    if (nConnect > 0)
                     {
-                        nPatches++;
-                        nFaces += nOutsideConnections[i];
+                        ++nPatches;
+                        nFaces += nConnect;
                     }
                 }
 
@@ -330,31 +370,37 @@ void Foam::multiLevelDecomp::decompose
 Foam::multiLevelDecomp::multiLevelDecomp(const dictionary& decompositionDict)
 :
     decompositionMethod(decompositionDict),
-    methodsDict_(decompositionDict_.optionalSubDict(typeName + "Coeffs"))
+    methodsDict_(decompositionDict_.subDict(typeName + "Coeffs"))
 {
     methods_.setSize(methodsDict_.size());
-    label i = 0;
+    label nLevels = 0;
     forAllConstIter(dictionary, methodsDict_, iter)
     {
-        methods_.set(i++, decompositionMethod::New(iter().dict()));
+        // Ignore primitive entries which may be there for additional control
+        if (iter().isDict())
+        {
+            methods_.set(nLevels++, decompositionMethod::New(iter().dict()));
+        }
     }
 
-    label n = 1;
+    methods_.setSize(nLevels);
+
+    label nTot = 1;
     Info<< "decompositionMethod " << type() << " :" << endl;
     forAll(methods_, i)
     {
         Info<< "    level " << i << " decomposing with " << methods_[i].type()
             << " into " << methods_[i].nDomains() << " subdomains." << endl;
 
-        n *= methods_[i].nDomains();
+        nTot *= methods_[i].nDomains();
     }
 
-    if (n != nDomains())
+    if (nTot != nDomains())
     {
         FatalErrorInFunction
             << "Top level decomposition specifies " << nDomains()
             << " domains which is not equal to the product of"
-            << " all sub domains " << n
+            << " all sub domains " << nTot
             << exit(FatalError);
     }
 }
@@ -385,7 +431,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
     CompactListList<label> cellCells;
     calcCellCells(mesh, identity(cc.size()), cc.size(), true, cellCells);
 
-    labelField finalDecomp(cc.size(), 0);
+    labelList finalDecomp(cc.size(), 0);
     labelList cellMap(identity(cc.size()));
 
     decompose
@@ -395,6 +441,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
         cWeights,
         cellMap,      // map back to original cells
         0,
+        0,
 
         finalDecomp
     );
@@ -410,7 +457,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
     const scalarField& pointWeights
 )
 {
-    labelField finalDecomp(points.size(), 0);
+    labelList finalDecomp(points.size(), 0);
     labelList pointMap(identity(points.size()));
 
     decompose
@@ -420,6 +467,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
         pointWeights,
         pointMap,       // map back to original points
         0,
+        0,
 
         finalDecomp
     );
diff --git a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H
index dbdd582295c9bf660d36de424f137d530dc00a2b..d11f14280b050f3914c5ea8d0b133876e3203710 100644
--- a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H
+++ b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -71,21 +71,22 @@ class multiLevelDecomp
             labelList& cutConnections
         ) const;
 
-        //- Decompose level methodI without addressing
+        //- Decompose at 'currLevel' without addressing
         void decompose
         (
             const labelListList& pointPoints,
             const pointField& points,
             const scalarField& pointWeights,
-            const labelList& pointMap,  // map back to original points
-            const label levelI,
+            const labelUList& pointMap,  // map back to original points
+            const label currLevel,
+            const label leafOffset,
 
-            labelField& finalDecomp
+            labelList& finalDecomp
         );
 
         //- Disallow default bitwise copy construct and assignment
-        void operator=(const multiLevelDecomp&);
-        multiLevelDecomp(const multiLevelDecomp&);
+        void operator=(const multiLevelDecomp&) = delete;
+        multiLevelDecomp(const multiLevelDecomp&) = delete;
 
 
 public:
diff --git a/src/parallel/decompose/kahipDecomp/Make/files b/src/parallel/decompose/kahipDecomp/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..eb01da59a368268784cc0c2cde796efc3c71c0b7
--- /dev/null
+++ b/src/parallel/decompose/kahipDecomp/Make/files
@@ -0,0 +1,3 @@
+kahipDecomp.C
+
+LIB = $(FOAM_LIBBIN)/libkahipDecomp
diff --git a/src/parallel/decompose/kahipDecomp/Make/options b/src/parallel/decompose/kahipDecomp/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..fcd1c5d268a78ceb44ffc5090876d9dc47b52581
--- /dev/null
+++ b/src/parallel/decompose/kahipDecomp/Make/options
@@ -0,0 +1,15 @@
+EXE_INC = \
+    -I$(KAHIP_ARCH_PATH)/include \
+    -I../decompositionMethods/lnInclude
+
+/*
+ * The $(KAHIP_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided
+ * to support central, non-thirdparty installations.
+ *
+ * KaHIP is often compiled with openmp, but may be missing the
+ * link dependency for openmp.
+ */
+LIB_LIBS = \
+    -L$(KAHIP_ARCH_PATH)/lib \
+    -L$(KAHIP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
+    -L$(FOAM_EXT_LIBBIN) $(LINK_OPENMP) -lkahip
diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.C b/src/parallel/decompose/kahipDecomp/kahipDecomp.C
new file mode 100644
index 0000000000000000000000000000000000000000..55cba9cfc38406e1b44a49f8cfb30949cf5b2f47
--- /dev/null
+++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.C
@@ -0,0 +1,331 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "kahipDecomp.H"
+#include "addToRunTimeSelectionTable.H"
+#include "Time.H"
+
+#include "kaHIP_interface.h"
+
+#include <string>
+#include <map>
+#include <vector>
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+    defineTypeNameAndDebug(kahipDecomp, 0);
+    addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary);
+}
+
+
+const Foam::Enum
+<
+    Foam::kahipDecomp::configs
+>
+Foam::kahipDecomp::configNames
+{
+    { kahipDecomp::configs::FAST, "fast" },
+    { kahipDecomp::configs::ECO, "eco" },
+    { kahipDecomp::configs::STRONG, "strong" },
+    { kahipDecomp::configs::FASTSOCIAL, "fast-social" },
+    { kahipDecomp::configs::ECOSOCIAL, "eco-social" },
+    { kahipDecomp::configs::STRONGSOCIAL, "strong-social" },
+};
+
+
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+Foam::label Foam::kahipDecomp::decomposeSerial
+(
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cWeights,
+    List<label>& decomp
+)
+{
+    // Default setup
+    enum configs kahipConfig = configs::FAST;
+    double imbalance = 0.01;
+    int seed = 0;
+    bool verbose = false;
+
+    const dictionary* coeffsDictPtr =
+        decompositionDict_.subDictPtr("kahipCoeffs");
+
+    #if WM_LABEL_SIZE == 64
+    if (xadj.size()-1 > INT_MAX)
+    {
+        FatalErrorInFunction
+            << "Cannot decompose " << (xadj.size()-1) << " cells," << nl
+            << "Exceeded integer limit of " << INT_MAX << nl
+            << exit(FatalError);
+    }
+    #endif
+
+    int numCells = xadj.size()-1;
+
+    // Cell weights (so on the vertices of the dual)
+    List<int> cellWeights;
+
+    // Check for externally provided cellweights and if so initialise weights
+    // Note: min, not gMin since routine runs on master only.
+    const scalar minWeights = min(cWeights);
+
+    if (!cWeights.empty())
+    {
+        if (minWeights <= 0)
+        {
+            WarningInFunction
+                << "Illegal minimum weight " << minWeights
+                << endl;
+        }
+
+        if (cWeights.size() != numCells)
+        {
+            FatalErrorInFunction
+                << "Number of cell weights " << cWeights.size()
+                << " does not equal number of cells " << numCells
+                << exit(FatalError);
+        }
+
+        // Convert to integers.
+        cellWeights.setSize(cWeights.size());
+        forAll(cellWeights, i)
+        {
+            cellWeights[i] = int(cWeights[i]/minWeights);
+        }
+    }
+
+    // Additional sizing parameters (testing only)
+    std::map<std::string, std::vector<int>> sizingParams;
+
+    // Check for user supplied weights and decomp options
+    if (coeffsDictPtr)
+    {
+        const dictionary& coeffDict = *coeffsDictPtr;
+
+        //- Find the key in the dictionary and return the corresponding
+        //  enumeration element based on its name.
+        //  Return the default value if the key was not found in the dictionary.
+        //  Fatal if the enumerated name was incorrect.
+
+        kahipConfig =
+            configNames.lookupOrDefault("config", coeffDict, kahipConfig);
+
+        coeffDict.readIfPresent("imbalance", imbalance);
+        coeffDict.readIfPresent("verbose", verbose);
+
+        Info<< "kahipDecomp :"
+            << " config=" << configNames[kahipConfig]
+            << " imbalance=" << imbalance;
+
+        List<int> labels;
+        if
+        (
+            coeffDict.readIfPresent("hierarchy", labels)
+         && !labels.empty()
+        )
+        {
+            std::vector<int> vec;
+            vec.reserve(labels.size()+1);
+
+            // Verify sizing
+
+            int n = 1;
+            for (auto val : labels)
+            {
+                n *= val;
+                vec.push_back(val);
+            }
+
+            if (n != nProcessors_)
+            {
+                // Size mismatch. Try to correct.
+
+                if (nProcessors_ % n)
+                {
+                    WarningInFunction
+                        << "Mismatch in number of processors and "
+                        << "hierarchy specified" << flatOutput(labels) << endl;
+
+                    vec.clear();
+                }
+                else
+                {
+                    // Evenly divisible, add extra hierarchy level
+                    vec.push_back(nProcessors_ / n);
+                }
+            }
+
+            if (!vec.empty())
+            {
+                sizingParams["hierarchy"] = std::move(vec);
+
+                Info<< " hierarchy=" << flatOutput(labels);
+            }
+        }
+
+        if
+        (
+            coeffDict.readIfPresent("distance", labels)
+         && !labels.empty()
+        )
+        {
+            std::vector<int> vec(labels.size());
+
+            forAll(labels, i)
+            {
+                vec[i] = labels[i];
+            }
+
+            sizingParams["distance"] = std::move(vec);
+
+            Info<< " distance=" << flatOutput(labels);
+        }
+
+        if (coeffDict.readIfPresent("seed", seed))
+        {
+            Info<< " seed=" << seed;
+        }
+
+        Info<< endl;
+    }
+    else
+    {
+        Info<< "kahipDecomp :"
+            << " config=" << configNames[kahipConfig]
+            << " imbalance=" << imbalance << endl;
+    }
+
+    // Number of partitions
+    int nParts = nProcessors_;
+
+    // Output: number of cut edges
+    int edgeCut = 0;
+
+    #if WM_LABEL_SIZE == 32
+
+    // Input:
+    int* xadjPtr   = const_cast<UList<int>&>(xadj).begin();
+    int* adjncyPtr = const_cast<UList<int>&>(adjncy).begin();
+
+    // Output: cell -> processor addressing
+    decomp.setSize(numCells);
+    int* decompPtr = decomp.begin();
+
+    #elif WM_LABEL_SIZE == 64
+
+    // input (copy)
+    List<int> xadjCopy(xadj.size());
+    List<int> adjncyCopy(adjncy.size());
+
+    forAll(xadj,i)
+    {
+        xadjCopy[i] = xadj[i];
+    }
+    forAll(adjncy,i)
+    {
+        adjncyCopy[i] = adjncy[i];
+    }
+
+    int* xadjPtr   = xadjCopy.begin();
+    int* adjncyPtr = adjncyCopy.begin();
+
+    if (decomp.size() != numCells)
+    {
+        decomp.clear();
+    }
+
+    // Output: cell -> processor addressing
+    List<int> decompCopy(numCells);
+    int* decompPtr = decompCopy.begin();
+    #endif
+
+#if 0 // WIP: #ifdef KAFFPA_CPP_INTERFACE
+    kaffpa_cpp
+    (
+        &numCells,          // num vertices in graph
+        (cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts
+        xadjPtr,            // indexing into adjncy
+        nullptr,            // edge wts
+        adjncyPtr,          // neighbour info
+        &nParts,            // nparts
+        &imbalance,         // amount of imbalance allowed
+        !verbose,           // suppress output
+        seed,               // for random
+        int(kahipConfig),
+        &edgeCut,           // [output]
+        decompPtr,          // [output]
+        sizingParams
+    );
+#else
+    kaffpa
+    (
+        &numCells,          // num vertices in graph
+        (cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts
+        xadjPtr,            // indexing into adjncy
+        nullptr,            // edge wts
+        adjncyPtr,          // neighbour info
+        &nParts,            // nparts
+        &imbalance,         // amount of imbalance allowed
+        !verbose,           // suppress output
+        seed,               // for random
+        int(kahipConfig),
+        &edgeCut,           // [output]
+        decompPtr           // [output]
+    );
+#endif
+
+    #if WM_LABEL_SIZE == 64
+
+    // Drop input copy
+    xadjCopy.clear();
+    adjncyCopy.clear();
+
+    // Copy back to List<label>
+    decomp.setSize(numCells);
+    forAll(decompCopy, i)
+    {
+        decomp[i] = decompCopy[i];
+    }
+
+    decompCopy.clear();
+    #endif
+
+    return edgeCut;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::kahipDecomp::kahipDecomp(const dictionary& decompositionDict)
+:
+    metisLikeDecomp(decompositionDict)
+{}
+
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.H b/src/parallel/decompose/kahipDecomp/kahipDecomp.H
new file mode 100644
index 0000000000000000000000000000000000000000..37cd4b574c6c168dd12b3a8ee50baa4fce83190d
--- /dev/null
+++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.H
@@ -0,0 +1,143 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::kahipDecomp
+
+Description
+    Domain decomposition using KaHIP
+    http://algo2.iti.kit.edu/documents/kahip/
+
+    When run in parallel will collect the entire graph on to the master,
+    decompose and send back.
+
+    \verbatim
+    numberOfSubdomains   N;
+    method               kahip;
+
+    kahipCoeffs
+    {
+        config          fast;
+        imbalance       0.01;
+    }
+    \endverbatim
+
+    Where the coefficients dictionary is optional, as are all its entries:
+    \table
+        Property  | Description                                 | Default value
+        config    | fast / eco / strong                         | fast
+        imbalance | imbalance on cells between domains          | 0.01
+        seed      | initial value for random number generator   | 0
+    \endtable
+
+SourceFiles
+    kahipDecomp.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef kahipDecomp_H
+#define kahipDecomp_H
+
+#include "metisLikeDecomp.H"
+#include "Enum.H"
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                         Class kahipDecomp Declaration
+\*---------------------------------------------------------------------------*/
+
+class kahipDecomp
+:
+    public metisLikeDecomp
+{
+
+    // Private Member Functions
+
+        //- Call kahip with options from dictionary.
+        virtual label decomposeSerial
+        (
+            const UList<label>& adjncy,
+            const UList<label>& xadj,
+            const UList<scalar>& cellWeights,
+            List<label>& decomp
+        );
+
+        //- Disallow default bitwise copy construct and assignment
+        void operator=(const kahipDecomp&) = delete;
+        kahipDecomp(const kahipDecomp&) = delete;
+
+
+public:
+
+    //- The predefined KaHIP configuration types
+    enum class configs
+    {
+        FAST = 0, //!< default
+        ECO = 1,
+        STRONG = 2,
+        FASTSOCIAL = 3,
+        ECOSOCIAL = 4,
+        STRONGSOCIAL = 5,
+    };
+
+
+    //- The selection names for predefined KaHIP configurations
+    static const Enum<configs> configNames;
+
+
+    //- Runtime type information
+    TypeName("kahip");
+
+
+    // Constructors
+
+        //- Construct given the decomposition dictionary
+        kahipDecomp(const dictionary& decompositionDict);
+
+
+    //- Destructor
+    virtual ~kahipDecomp()
+    {}
+
+
+    // Member Functions
+
+        virtual bool parallelAware() const
+        {
+            return true;
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.C b/src/parallel/decompose/metisDecomp/metisDecomp.C
index 2cb09cbb77cbc672438f9d0954f2616435d16b82..3822a0a31e25c092fdc5cbdab0525683b64f37bd 100644
--- a/src/parallel/decompose/metisDecomp/metisDecomp.C
+++ b/src/parallel/decompose/metisDecomp/metisDecomp.C
@@ -45,13 +45,12 @@ namespace Foam
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-Foam::label Foam::metisDecomp::decompose
+Foam::label Foam::metisDecomp::decomposeSerial
 (
-    const List<label>& adjncy,
-    const List<label>& xadj,
-    const scalarField& cWeights,
-
-    List<label>& finalDecomp
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cWeights,
+    List<label>& decomp
 )
 {
     // Method of decomposition
@@ -59,6 +58,9 @@ Foam::label Foam::metisDecomp::decompose
     // k-way: multi-level k-way
     word method("recursive");
 
+    const dictionary* coeffsDictPtr =
+        decompositionDict_.subDictPtr("metisCoeffs");
+
     label numCells = xadj.size()-1;
 
     // Decomposition options
@@ -75,10 +77,11 @@ Foam::label Foam::metisDecomp::decompose
     // Face weights (so on the edges of the dual)
     List<label> faceWeights;
 
-
     // Check for externally provided cellweights and if so initialise weights
-    scalar minWeights = gMin(cWeights);
-    if (cWeights.size() > 0)
+    // Note: min, not gMin since routine runs on master only.
+    const scalar minWeights = min(cWeights);
+
+    if (!cWeights.empty())
     {
         if (minWeights <= 0)
         {
@@ -105,14 +108,13 @@ Foam::label Foam::metisDecomp::decompose
 
 
     // Check for user supplied weights and decomp options
-    if (decompositionDict_.found("metisCoeffs"))
+    if (coeffsDictPtr)
     {
-        const dictionary& metisCoeffs =
-            decompositionDict_.subDict("metisCoeffs");
+        const dictionary& coeffDict = *coeffsDictPtr;
 
         word weightsFile;
 
-        if (metisCoeffs.readIfPresent("method", method))
+        if (coeffDict.readIfPresent("method", method))
         {
             if (method != "recursive" && method != "k-way")
             {
@@ -127,7 +129,7 @@ Foam::label Foam::metisDecomp::decompose
                 << nl << endl;
         }
 
-        if (metisCoeffs.readIfPresent("options", options))
+        if (coeffDict.readIfPresent("options", options))
         {
             if (options.size() != METIS_NOPTIONS)
             {
@@ -142,7 +144,7 @@ Foam::label Foam::metisDecomp::decompose
                 << nl << endl;
         }
 
-        if (metisCoeffs.readIfPresent("processorWeights", processorWeights))
+        if (coeffDict.readIfPresent("processorWeights", processorWeights))
         {
             processorWeights /= sum(processorWeights);
 
@@ -161,7 +163,7 @@ Foam::label Foam::metisDecomp::decompose
     label nProcs = nProcessors_;
 
     // Output: cell -> processor addressing
-    finalDecomp.setSize(numCells);
+    decomp.setSize(numCells);
 
     // Output: number of cut edges
     label edgeCut = 0;
@@ -172,17 +174,17 @@ Foam::label Foam::metisDecomp::decompose
         (
             &numCells,          // num vertices in graph
             &ncon,              // num balancing constraints
-            const_cast<List<label>&>(xadj).begin(),   // indexing into adjncy
-            const_cast<List<label>&>(adjncy).begin(), // neighbour info
-            cellWeights.begin(),// vertexweights
+            const_cast<UList<label>&>(xadj).begin(),   // indexing into adjncy
+            const_cast<UList<label>&>(adjncy).begin(), // neighbour info
+            cellWeights.begin(),// vertex wts
             nullptr,               // vsize: total communication vol
-            faceWeights.begin(),// edgeweights
+            faceWeights.begin(),// edge wts
             &nProcs,            // nParts
             processorWeights.begin(),   // tpwgts
             nullptr,               // ubvec: processor imbalance (default)
             options.begin(),
             &edgeCut,
-            finalDecomp.begin()
+            decomp.begin()
         );
     }
     else
@@ -191,17 +193,17 @@ Foam::label Foam::metisDecomp::decompose
         (
             &numCells,          // num vertices in graph
             &ncon,              // num balancing constraints
-            const_cast<List<label>&>(xadj).begin(),   // indexing into adjncy
-            const_cast<List<label>&>(adjncy).begin(), // neighbour info
-            cellWeights.begin(),// vertexweights
+            const_cast<UList<label>&>(xadj).begin(),   // indexing into adjncy
+            const_cast<UList<label>&>(adjncy).begin(), // neighbour info
+            cellWeights.begin(),// vertex wts
             nullptr,               // vsize: total communication vol
-            faceWeights.begin(),// edgeweights
+            faceWeights.begin(),// edge wts
             &nProcs,            // nParts
             processorWeights.begin(),   // tpwgts
             nullptr,               // ubvec: processor imbalance (default)
             options.begin(),
             &edgeCut,
-            finalDecomp.begin()
+            decomp.begin()
         );
     }
 
@@ -213,116 +215,8 @@ Foam::label Foam::metisDecomp::decompose
 
 Foam::metisDecomp::metisDecomp(const dictionary& decompositionDict)
 :
-    decompositionMethod(decompositionDict)
+    metisLikeDecomp(decompositionDict)
 {}
 
 
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-Foam::labelList Foam::metisDecomp::decompose
-(
-    const polyMesh& mesh,
-    const pointField& points,
-    const scalarField& pointWeights
-)
-{
-    if (points.size() != mesh.nCells())
-    {
-        FatalErrorInFunction
-            << "Can use this decomposition method only for the whole mesh"
-            << endl
-            << "and supply one coordinate (cellCentre) for every cell." << endl
-            << "The number of coordinates " << points.size() << endl
-            << "The number of cells in the mesh " << mesh.nCells()
-            << exit(FatalError);
-    }
-
-    CompactListList<label> cellCells;
-    calcCellCells
-    (
-        mesh,
-        identity(mesh.nCells()),
-        mesh.nCells(),
-        false,
-        cellCells
-    );
-
-    // Decompose using default weights
-    labelList decomp;
-    decompose(cellCells.m(), cellCells.offsets(), pointWeights, decomp);
-
-    return decomp;
-}
-
-
-Foam::labelList Foam::metisDecomp::decompose
-(
-    const polyMesh& mesh,
-    const labelList& agglom,
-    const pointField& agglomPoints,
-    const scalarField& agglomWeights
-)
-{
-    if (agglom.size() != mesh.nCells())
-    {
-        FatalErrorInFunction
-            << "Size of cell-to-coarse map " << agglom.size()
-            << " differs from number of cells in mesh " << mesh.nCells()
-            << exit(FatalError);
-    }
-
-    // Make Metis CSR (Compressed Storage Format) storage
-    //   adjncy      : contains neighbours (= edges in graph)
-    //   xadj(celli) : start of information in adjncy for celli
-
-    CompactListList<label> cellCells;
-    calcCellCells(mesh, agglom, agglomPoints.size(), false, cellCells);
-
-    // Decompose using default weights
-    labelList finalDecomp;
-    decompose(cellCells.m(), cellCells.offsets(), agglomWeights, finalDecomp);
-
-
-    // Rework back into decomposition for original mesh
-    labelList fineDistribution(agglom.size());
-
-    forAll(fineDistribution, i)
-    {
-        fineDistribution[i] = finalDecomp[agglom[i]];
-    }
-
-    return fineDistribution;
-}
-
-
-Foam::labelList Foam::metisDecomp::decompose
-(
-    const labelListList& globalCellCells,
-    const pointField& cellCentres,
-    const scalarField& cellWeights
-)
-{
-    if (cellCentres.size() != globalCellCells.size())
-    {
-        FatalErrorInFunction
-            << "Inconsistent number of cells (" << globalCellCells.size()
-            << ") and number of cell centres (" << cellCentres.size()
-            << ")." << exit(FatalError);
-    }
-
-
-    // Make Metis CSR (Compressed Storage Format) storage
-    //   adjncy      : contains neighbours (= edges in graph)
-    //   xadj(celli) : start of information in adjncy for celli
-
-    CompactListList<label> cellCells(globalCellCells);
-
-    // Decompose using default weights
-    labelList decomp;
-    decompose(cellCells.m(), cellCells.offsets(), cellWeights, decomp);
-
-    return decomp;
-}
-
-
 // ************************************************************************* //
diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.H b/src/parallel/decompose/metisDecomp/metisDecomp.H
index 84dc04bd938d48ac0cb5c46ebed4ff1024741fbb..a851b0496b5cb6d937f94060e43e45128c64b784 100644
--- a/src/parallel/decompose/metisDecomp/metisDecomp.H
+++ b/src/parallel/decompose/metisDecomp/metisDecomp.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -27,6 +27,29 @@ Class
 Description
     Metis domain decomposition
 
+    When run in parallel will collect the entire graph on to the master,
+    decompose and send back.
+
+    \verbatim
+    numberOfSubdomains   N;
+    method               metis;
+
+    metisCoeffs
+    {
+        method          recursive;  // k-way
+        options          ( ...);
+        processorWeights (   ... );
+    }
+    \endverbatim
+
+    Where the coefficients dictionary is optional, as are all its entries:
+    \table
+        Property  | Description                             | Default value
+        method    | recursive / k-way                       | recursive
+        options   | metis options                           |
+        processorWeights | list of weighting per partition  |
+    \endtable
+
 SourceFiles
     metisDecomp.C
 
@@ -35,7 +58,7 @@ SourceFiles
 #ifndef metisDecomp_H
 #define metisDecomp_H
 
-#include "decompositionMethod.H"
+#include "metisLikeDecomp.H"
 
 namespace Foam
 {
@@ -46,23 +69,23 @@ namespace Foam
 
 class metisDecomp
 :
-    public decompositionMethod
+    public metisLikeDecomp
 {
 
     // Private Member Functions
 
         //- Call Metis with options from dictionary.
-        label decompose
+        virtual label decomposeSerial
         (
-            const List<label>& adjncy,
-            const List<label>& xadj,
-            const scalarField& cellWeights,
-            List<label>& finalDecomp
+            const UList<label>& adjncy,
+            const UList<label>& xadj,
+            const UList<scalar>& cellWeights,
+            List<label>& decomp
         );
 
         //- Disallow default bitwise copy construct and assignment
-        void operator=(const metisDecomp&);
-        metisDecomp(const metisDecomp&);
+        void operator=(const metisDecomp&) = delete;
+        metisDecomp(const metisDecomp&) = delete;
 
 
 public:
@@ -74,7 +97,7 @@ public:
     // Constructors
 
         //- Construct given the decomposition dictionary
-        metisDecomp(const dictionary&);
+        metisDecomp(const dictionary& decompositionDict);
 
 
     //- Destructor
@@ -86,52 +109,9 @@ public:
 
         virtual bool parallelAware() const
         {
-            // Metis does not know about proc boundaries
-            return false;
+            return true;
         }
 
-        //- Inherit decompose from decompositionMethod
-        using decompositionMethod::decompose;
-
-        //- Return for every coordinate the wanted processor number. Use the
-        //  mesh connectivity (if needed)
-        //  Weights get normalised so the minimum value is 1 before truncation
-        //  to an integer so the weights should be multiples of the minimum
-        //  value. The overall sum of weights might otherwise overflow.
-        virtual labelList decompose
-        (
-            const polyMesh& mesh,
-            const pointField& points,
-            const scalarField& pointWeights
-        );
-
-        //- Return for every coordinate the wanted processor number. Gets
-        //  passed agglomeration map (from fine to coarse cells) and coarse cell
-        //  location. Can be overridden by decomposers that provide this
-        //  functionality natively.
-        //  See note on weights above.
-        virtual labelList decompose
-        (
-            const polyMesh& mesh,
-            const labelList& agglom,
-            const pointField& regionPoints,
-            const scalarField& regionWeights
-        );
-
-        //- Return for every coordinate the wanted processor number. Explicitly
-        //  provided mesh connectivity.
-        //  The connectivity is equal to mesh.cellCells() except for
-        //  - in parallel the cell numbers are global cell numbers (starting
-        //    from 0 at processor0 and then incrementing all through the
-        //    processors)
-        //  - the connections are across coupled patches
-        //  See note on weights above.
-        virtual labelList decompose
-        (
-            const labelListList& globalCellCells,
-            const pointField& cc,
-            const scalarField& cWeights
-        );
 };
 
 
diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
index d0035de8d8b1e337e22000a97b4cabcc5568e023..0f6d6a05560ed36955e4f5a51f0dc5c9ae997cf6 100644
--- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
+++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -228,12 +228,17 @@ License
 namespace Foam
 {
     defineTypeNameAndDebug(ptscotchDecomp, 0);
-
     addToRunTimeSelectionTable(decompositionMethod, ptscotchDecomp, dictionary);
 }
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+void Foam::ptscotchDecomp::graphPath(const polyMesh& mesh)
+{
+    graphPath_ = mesh.time().path()/mesh.name();
+}
+
+
 void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 {
     if (retVal)
@@ -248,11 +253,9 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 ////- Does prevention of 0 cell domains and calls ptscotch.
 //Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
 //(
-//    const fileName& meshPath,
-//    const List<label>& initadjncy,
-//    const List<label>& initxadj,
-//    const scalarField& initcWeights,
-//
+//    const UList<label>& initadjncy,
+//    const UList<label>& initxadj,
+//    const UList<scalar>& initcWeights,
 //    List<label>& finalDecomp
 //) const
 //{
@@ -272,7 +275,6 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 //    {
 //        return decompose
 //        (
-//            meshPath,
 //            initadjncy,
 //            initxadj,
 //            initcWeights,
@@ -381,7 +383,7 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 //
 //
 //    // Do decomposition as normal. Sets finalDecomp.
-//    label result = decompose(meshPath, adjncy, xadj, cWeights, finalDecomp);
+//    label result = decompose(adjncy, xadj, cWeights, finalDecomp);
 //
 //
 //    if (debug)
@@ -437,23 +439,19 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
 //}
 
 
-// Call scotch with options from dictionary.
 Foam::label Foam::ptscotchDecomp::decompose
 (
-    const fileName& meshPath,
-    const List<label>& adjncy,
-    const List<label>& xadj,
-    const scalarField& cWeights,
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cWeights,
     List<label>& finalDecomp
 ) const
 {
-    List<label> dummyAdjncy(1);
-    List<label> dummyXadj(1);
-    dummyXadj[0] = 0;
+    List<label> dummyAdjncy { 0 };
+    List<label> dummyXadj { 0 };
 
     return decompose
     (
-        meshPath,
         adjncy.size(),
         (adjncy.size() ? adjncy.begin() : dummyAdjncy.begin()),
         xadj.size(),
@@ -464,16 +462,13 @@ Foam::label Foam::ptscotchDecomp::decompose
 }
 
 
-// Call scotch with options from dictionary.
 Foam::label Foam::ptscotchDecomp::decompose
 (
-    const fileName& meshPath,
     const label adjncySize,
     const label adjncy[],
     const label xadjSize,
     const label xadj[],
-    const scalarField& cWeights,
-
+    const UList<scalar>& cWeights,
     List<label>& finalDecomp
 ) const
 {
@@ -492,7 +487,7 @@ Foam::label Foam::ptscotchDecomp::decompose
         {
             OFstream str
             (
-               meshPath + "_" + Foam::name(Pstream::myProcNo()) + ".dgr"
+               graphPath_ + "_" + Foam::name(Pstream::myProcNo()) + ".dgr"
             );
 
             Pout<< "Dumping Scotch graph file to " << str.name() << endl
@@ -572,8 +567,8 @@ Foam::label Foam::ptscotchDecomp::decompose
 
     // Check for externally provided cellweights and if so initialise weights
 
-    scalar minWeights = gMin(cWeights);
-    scalar maxWeights = gMax(cWeights);
+    const scalar minWeights = gMin(cWeights);
+    const scalar maxWeights = gMax(cWeights);
 
     if (maxWeights > minWeights)
     {
@@ -719,7 +714,10 @@ Foam::label Foam::ptscotchDecomp::decompose
         }
         check
         (
-            SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
+            SCOTCH_archCmpltw
+            (
+                &archdat, nProcessors_, processorWeights.begin()
+            ),
             "SCOTCH_archCmpltw"
         );
     }
@@ -772,9 +770,9 @@ Foam::label Foam::ptscotchDecomp::decompose
     feenableexcept(oldExcepts);
     #endif
 
+    // See above note to have size 1. Undo.
+    finalDecomp.setSize(xadjSize-1);
 
-
-    //finalDecomp.setSize(xadjSize-1);
     //check
     //(
     //    SCOTCH_dgraphPart
@@ -819,6 +817,9 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     const scalarField& pointWeights
 )
 {
+    // Where to write graph
+    graphPath(mesh);
+
     if (points.size() != mesh.nCells())
     {
         FatalErrorInFunction
@@ -835,7 +836,6 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     //   adjncy      : contains neighbours (= edges in graph)
     //   xadj(celli) : start of information in adjncy for celli
 
-
     CompactListList<label> cellCells;
     calcCellCells
     (
@@ -847,22 +847,15 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     );
 
     // Decompose using default weights
-    List<label> finalDecomp;
+    labelList decomp;
     decompose
     (
-        mesh.time().path()/mesh.name(),
         cellCells.m(),
         cellCells.offsets(),
         pointWeights,
-        finalDecomp
+        decomp
     );
 
-    // Copy back to labelList
-    labelList decomp(points.size());
-    forAll(decomp, i)
-    {
-        decomp[i] = finalDecomp[i];
-    }
     return decomp;
 }
 
@@ -875,6 +868,9 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     const scalarField& pointWeights
 )
 {
+    // Where to write graph
+    graphPath(mesh);
+
     if (agglom.size() != mesh.nCells())
     {
         FatalErrorInFunction
@@ -898,14 +894,13 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     );
 
     // Decompose using weights
-    List<label> finalDecomp;
+    labelList decomp;
     decompose
     (
-        mesh.time().path()/mesh.name(),
         cellCells.m(),
         cellCells.offsets(),
         pointWeights,
-        finalDecomp
+        decomp
     );
 
     // Rework back into decomposition for original mesh
@@ -913,7 +908,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
 
     forAll(fineDistribution, i)
     {
-        fineDistribution[i] = finalDecomp[agglom[i]];
+        fineDistribution[i] = decomp[agglom[i]];
     }
 
     return fineDistribution;
@@ -927,6 +922,9 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     const scalarField& cWeights
 )
 {
+    // Where to write graph
+    graphPath_ = "ptscotch";
+
     if (cellCentres.size() != globalCellCells.size())
     {
         FatalErrorInFunction
@@ -943,22 +941,15 @@ Foam::labelList Foam::ptscotchDecomp::decompose
     CompactListList<label> cellCells(globalCellCells);
 
     // Decompose using weights
-    List<label> finalDecomp;
+    labelList decomp;
     decompose
     (
-        "ptscotch",
         cellCells.m(),
         cellCells.offsets(),
         cWeights,
-        finalDecomp
+        decomp
     );
 
-    // Copy back to labelList
-    labelList decomp(cellCentres.size());
-    forAll(decomp, i)
-    {
-        decomp[i] = finalDecomp[i];
-    }
     return decomp;
 }
 
diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H
index 5ff4d47e8471927c5a6876ad2b990c1183052c26..039dd511d01baae1da7f6c67fcee572e3b64493e 100644
--- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H
+++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.H
@@ -64,36 +64,43 @@ class ptscotchDecomp
 :
     public decompositionMethod
 {
+    // Private data
+
+        //- Output path and name for optional grf file.
+        fileName graphPath_;
+
+
     // Private Member Functions
 
+        //- Set graph path and name
+        void graphPath(const polyMesh& mesh);
+
         //- Check and print error message
         static void check(const int, const char*);
 
         //- Decompose. Handles size 0 arrays
         label decompose
         (
-            const fileName& meshPath,
-            const List<label>& adjncy,
-            const List<label>& xadj,
-            const scalarField& cWeights,
+            const UList<label>& adjncy,
+            const UList<label>& xadj,
+            const UList<scalar>& cWeights,
             List<label>& finalDecomp
         ) const;
 
         //- Low level decompose
         label decompose
         (
-            const fileName& meshPath,
             const label adjncySize,
             const label adjncy[],
             const label xadjSize,
             const label xadj[],
-            const scalarField& cWeights,
+            const UList<scalar>& cWeights,
             List<label>& finalDecomp
         ) const;
 
         //- Disallow default bitwise copy construct and assignment
-        void operator=(const ptscotchDecomp&);
-        ptscotchDecomp(const ptscotchDecomp&);
+        void operator=(const ptscotchDecomp&) = delete;
+        ptscotchDecomp(const ptscotchDecomp&) = delete;
 
 
 public:
diff --git a/src/parallel/decompose/scotchDecomp/scotchDecomp.C b/src/parallel/decompose/scotchDecomp/scotchDecomp.C
index 45af4fa1e64b1661ca0989899f632e8e608c4f1c..faea40b866832bcc6d139c3f400a4d2d3f3781b5 100644
--- a/src/parallel/decompose/scotchDecomp/scotchDecomp.C
+++ b/src/parallel/decompose/scotchDecomp/scotchDecomp.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -126,8 +126,6 @@ License
 #include "floatScalar.H"
 #include "Time.H"
 #include "OFstream.H"
-#include "globalIndex.H"
-#include "SubField.H"
 
 extern "C"
 {
@@ -161,6 +159,12 @@ namespace Foam
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+void Foam::scotchDecomp::graphPath(const polyMesh& mesh)
+{
+    graphPath_ = mesh.time().path()/mesh.name() + ".grf";
+}
+
+
 void Foam::scotchDecomp::check(const int retVal, const char* str)
 {
     if (retVal)
@@ -172,186 +176,53 @@ void Foam::scotchDecomp::check(const int retVal, const char* str)
 }
 
 
-Foam::label Foam::scotchDecomp::decompose
+Foam::label Foam::scotchDecomp::decomposeSerial
 (
-    const fileName& meshPath,
-    const List<label>& adjncy,
-    const List<label>& xadj,
-    const scalarField& cWeights,
-
-    List<label>& finalDecomp
+    const UList<label>& adjncy,
+    const UList<label>& xadj,
+    const UList<scalar>& cWeights,
+    List<label>& decomp
 )
 {
-    if (!Pstream::parRun())
-    {
-        decomposeOneProc
-        (
-            meshPath,
-            adjncy,
-            xadj,
-            cWeights,
-            finalDecomp
-        );
-    }
-    else
-    {
-        if (debug)
-        {
-            Info<< "scotchDecomp : running in parallel."
-                << " Decomposing all of graph on master processor." << endl;
-        }
-        globalIndex globalCells(xadj.size()-1);
-        label nTotalConnections = returnReduce(adjncy.size(), sumOp<label>());
-
-        // Send all to master. Use scheduled to save some storage.
-        if (Pstream::master())
-        {
-            Field<label> allAdjncy(nTotalConnections);
-            Field<label> allXadj(globalCells.size()+1);
-            scalarField allWeights(globalCells.size());
-
-            // Insert my own
-            label nTotalCells = 0;
-            forAll(cWeights, celli)
-            {
-                allXadj[nTotalCells] = xadj[celli];
-                allWeights[nTotalCells++] = cWeights[celli];
-            }
-            nTotalConnections = 0;
-            forAll(adjncy, i)
-            {
-                allAdjncy[nTotalConnections++] = adjncy[i];
-            }
+    const dictionary* coeffsDictPtr =
+        decompositionDict_.subDictPtr("scotchCoeffs");
 
-            for (int slave=1; slave<Pstream::nProcs(); slave++)
-            {
-                IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
-                Field<label> nbrAdjncy(fromSlave);
-                Field<label> nbrXadj(fromSlave);
-                scalarField nbrWeights(fromSlave);
-
-                // Append.
-                //label procStart = nTotalCells;
-                forAll(nbrXadj, celli)
-                {
-                    allXadj[nTotalCells] = nTotalConnections+nbrXadj[celli];
-                    allWeights[nTotalCells++] = nbrWeights[celli];
-                }
-                // No need to renumber xadj since already global.
-                forAll(nbrAdjncy, i)
-                {
-                    allAdjncy[nTotalConnections++] = nbrAdjncy[i];
-                }
-            }
-            allXadj[nTotalCells] = nTotalConnections;
+    // Dump graph
+    if (coeffsDictPtr && coeffsDictPtr->lookupOrDefault("writeGraph", false))
+    {
+        OFstream str(graphPath_);
 
+        Info<< "Dumping Scotch graph file to " << str.name() << endl
+            << "Use this in combination with gpart." << endl;
 
-            Field<label> allFinalDecomp;
-            decomposeOneProc
-            (
-                meshPath,
-                allAdjncy,
-                allXadj,
-                allWeights,
-                allFinalDecomp
-            );
+        const label version = 0;
+        str << version << nl;
+        // Numer of vertices
+        str << xadj.size()-1 << ' ' << adjncy.size() << nl;
 
+        // Numbering starts from 0
+        const label baseval = 0;
+        // Has weights?
+        const label hasEdgeWeights = 0;
+        const label hasVertexWeights = 0;
+        const label numericflag = 10*hasEdgeWeights+hasVertexWeights;
+        str << baseval << ' ' << numericflag << nl;
 
-            // Send allFinalDecomp back
-            for (int slave=1; slave<Pstream::nProcs(); slave++)
-            {
-                OPstream toSlave(Pstream::commsTypes::scheduled, slave);
-                toSlave << SubField<label>
-                (
-                    allFinalDecomp,
-                    globalCells.localSize(slave),
-                    globalCells.offset(slave)
-                );
-            }
-            // Get my own part (always first)
-            finalDecomp = SubField<label>
-            (
-                allFinalDecomp,
-                globalCells.localSize()
-            );
-        }
-        else
+        for (label celli = 0; celli < xadj.size()-1; ++celli)
         {
-            // Send my part of the graph (already in global numbering)
-            {
-                OPstream toMaster
-                (
-                    Pstream::commsTypes::scheduled,
-                    Pstream::masterNo()
-                );
-                toMaster<< adjncy << SubField<label>(xadj, xadj.size()-1)
-                    << cWeights;
-            }
-
-            // Receive back decomposition
-            IPstream fromMaster
-            (
-                Pstream::commsTypes::scheduled,
-                Pstream::masterNo()
-            );
-            fromMaster >> finalDecomp;
-        }
-    }
-    return 0;
-}
+            const label start = xadj[celli];
+            const label end = xadj[celli+1];
 
+            str << end-start; // size
 
-// Call scotch with options from dictionary.
-Foam::label Foam::scotchDecomp::decomposeOneProc
-(
-    const fileName& meshPath,
-    const List<label>& adjncy,
-    const List<label>& xadj,
-    const scalarField& cWeights,
-
-    List<label>& finalDecomp
-)
-{
-    // Dump graph
-    if (decompositionDict_.found("scotchCoeffs"))
-    {
-        const dictionary& scotchCoeffs =
-            decompositionDict_.subDict("scotchCoeffs");
-
-        if (scotchCoeffs.lookupOrDefault("writeGraph", false))
-        {
-            OFstream str(meshPath + ".grf");
-
-            Info<< "Dumping Scotch graph file to " << str.name() << endl
-                << "Use this in combination with gpart." << endl;
-
-            label version = 0;
-            str << version << nl;
-            // Numer of vertices
-            str << xadj.size()-1 << ' ' << adjncy.size() << nl;
-            // Numbering starts from 0
-            label baseval = 0;
-            // Has weights?
-            label hasEdgeWeights = 0;
-            label hasVertexWeights = 0;
-            label numericflag = 10*hasEdgeWeights+hasVertexWeights;
-            str << baseval << ' ' << numericflag << nl;
-            for (label celli = 0; celli < xadj.size()-1; celli++)
+            for (label i = start; i < end; ++i)
             {
-                label start = xadj[celli];
-                label end = xadj[celli+1];
-                str << end-start;
-
-                for (label i = start; i < end; i++)
-                {
-                    str << ' ' << adjncy[i];
-                }
-                str << nl;
+                str << ' ' << adjncy[i];
             }
+            str << nl;
         }
     }
 
-
     // Strategy
     // ~~~~~~~~
 
@@ -359,13 +230,10 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
     SCOTCH_Strat stradat;
     check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit");
 
-    if (decompositionDict_.found("scotchCoeffs"))
+    if (coeffsDictPtr)
     {
-        const dictionary& scotchCoeffs =
-            decompositionDict_.subDict("scotchCoeffs");
-
         string strategy;
-        if (scotchCoeffs.readIfPresent("strategy", strategy))
+        if (coeffsDictPtr->readIfPresent("strategy", strategy))
         {
             if (debug)
             {
@@ -384,10 +252,9 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
 
     List<label> velotab;
 
-
     // Check for externally provided cellweights and if so initialise weights
     // Note: min, not gMin since routine runs on master only.
-    scalar minWeights = min(cWeights);
+    const scalar minWeights = min(cWeights);
     if (!cWeights.empty())
     {
         if (minWeights <= 0)
@@ -431,7 +298,6 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
     }
 
 
-
     SCOTCH_Graph grafdat;
     check(SCOTCH_graphInit(&grafdat), "SCOTCH_graphInit");
     check
@@ -462,14 +328,12 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
     check(SCOTCH_archInit(&archdat), "SCOTCH_archInit");
 
     List<label> processorWeights;
-    if (decompositionDict_.found("scotchCoeffs"))
-    {
-        const dictionary& scotchCoeffs =
-            decompositionDict_.subDict("scotchCoeffs");
-
-        scotchCoeffs.readIfPresent("processorWeights", processorWeights);
-    }
-    if (processorWeights.size())
+    if
+    (
+        coeffsDictPtr
+     && coeffsDictPtr->readIfPresent("processorWeights", processorWeights)
+     && processorWeights.size()
+    )
     {
         if (debug)
         {
@@ -478,7 +342,10 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
         }
         check
         (
-            SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
+            SCOTCH_archCmpltw
+            (
+                &archdat, nProcessors_, processorWeights.begin()
+            ),
             "SCOTCH_archCmpltw"
         );
     }
@@ -491,7 +358,7 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
         );
 
 
-        //- Hack to test clustering. Note that finalDecomp is non-compact
+        //- Hack to test clustering. Note that decomp is non-compact
         //  numbers!
         //
         ////- Set up variable sizes architecture
@@ -542,16 +409,16 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
     );
     #endif
 
-    finalDecomp.setSize(xadj.size()-1);
-    finalDecomp = 0;
+    decomp.setSize(xadj.size()-1);
+    decomp = 0;
     check
     (
         SCOTCH_graphMap
         (
             &grafdat,
             &archdat,
-            &stradat,           // const SCOTCH_Strat *
-            finalDecomp.begin() // parttab
+            &stradat,       // const SCOTCH_Strat *
+            decomp.begin()  // parttab
         ),
         "SCOTCH_graphMap"
     );
@@ -560,17 +427,15 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
     feenableexcept(oldExcepts);
     #endif
 
-
-
-    //finalDecomp.setSize(xadj.size()-1);
+    //decomp.setSize(xadj.size()-1);
     //check
     //(
     //    SCOTCH_graphPart
     //    (
     //        &grafdat,
-    //        nProcessors_,       // partnbr
-    //        &stradat,           // const SCOTCH_Strat *
-    //        finalDecomp.begin() // parttab
+    //        nProcessors_,   // partnbr
+    //        &stradat,       // const SCOTCH_Strat *
+    //        decomp.begin()  // parttab
     //    ),
     //    "SCOTCH_graphPart"
     //);
@@ -590,7 +455,7 @@ Foam::label Foam::scotchDecomp::decomposeOneProc
 
 Foam::scotchDecomp::scotchDecomp(const dictionary& decompositionDict)
 :
-    decompositionMethod(decompositionDict)
+    metisLikeDecomp(decompositionDict)
 {}
 
 
@@ -603,46 +468,15 @@ Foam::labelList Foam::scotchDecomp::decompose
     const scalarField& pointWeights
 )
 {
-    if (points.size() != mesh.nCells())
-    {
-        FatalErrorInFunction
-            << "Can use this decomposition method only for the whole mesh"
-            << endl
-            << "and supply one coordinate (cellCentre) for every cell." << endl
-            << "The number of coordinates " << points.size() << endl
-            << "The number of cells in the mesh " << mesh.nCells()
-            << exit(FatalError);
-    }
+    // Where to write graph
+    graphPath(mesh);
 
-    // Calculate local or global (if Pstream::parRun()) connectivity
-    CompactListList<label> cellCells;
-    calcCellCells
+    return metisLikeDecomp::decompose
     (
         mesh,
-        identity(mesh.nCells()),
-        mesh.nCells(),
-        true,
-        cellCells
-    );
-
-    // Decompose using default weights
-    List<label> finalDecomp;
-    decompose
-    (
-        mesh.time().path()/mesh.name(),
-        cellCells.m(),
-        cellCells.offsets(),
-        pointWeights,
-        finalDecomp
+        points,
+        pointWeights
     );
-
-    // Copy back to labelList
-    labelList decomp(finalDecomp.size());
-    forAll(decomp, i)
-    {
-        decomp[i] = finalDecomp[i];
-    }
-    return decomp;
 }
 
 
@@ -654,45 +488,16 @@ Foam::labelList Foam::scotchDecomp::decompose
     const scalarField& pointWeights
 )
 {
-    if (agglom.size() != mesh.nCells())
-    {
-        FatalErrorInFunction
-            << "Size of cell-to-coarse map " << agglom.size()
-            << " differs from number of cells in mesh " << mesh.nCells()
-            << exit(FatalError);
-    }
+    // Where to write graph
+    graphPath(mesh);
 
-    // Calculate local or global (if Pstream::parRun()) connectivity
-    CompactListList<label> cellCells;
-    calcCellCells
+    return metisLikeDecomp::decompose
     (
         mesh,
         agglom,
-        agglomPoints.size(),
-        true,
-        cellCells
+        agglomPoints,
+        pointWeights
     );
-
-    // Decompose using weights
-    List<label> finalDecomp;
-    decompose
-    (
-        mesh.time().path()/mesh.name(),
-        cellCells.m(),
-        cellCells.offsets(),
-        pointWeights,
-        finalDecomp
-    );
-
-    // Rework back into decomposition for original mesh_
-    labelList fineDistribution(agglom.size());
-
-    forAll(fineDistribution, i)
-    {
-        fineDistribution[i] = finalDecomp[agglom[i]];
-    }
-
-    return fineDistribution;
 }
 
 
@@ -703,39 +508,15 @@ Foam::labelList Foam::scotchDecomp::decompose
     const scalarField& cWeights
 )
 {
-    if (cellCentres.size() != globalCellCells.size())
-    {
-        FatalErrorInFunction
-            << "Inconsistent number of cells (" << globalCellCells.size()
-            << ") and number of cell centres (" << cellCentres.size()
-            << ")." << exit(FatalError);
-    }
-
+    // Where to write graph
+    graphPath_ = "scotch.grf";
 
-    // Make Metis CSR (Compressed Storage Format) storage
-    //   adjncy      : contains neighbours (= edges in graph)
-    //   xadj(celli) : start of information in adjncy for celli
-
-    CompactListList<label> cellCells(globalCellCells);
-
-    // Decompose using weights
-    List<label> finalDecomp;
-    decompose
+    return metisLikeDecomp::decompose
     (
-        "scotch",
-        cellCells.m(),
-        cellCells.offsets(),
-        cWeights,
-        finalDecomp
+        globalCellCells,
+        cellCentres,
+        cWeights
     );
-
-    // Copy back to labelList
-    labelList decomp(finalDecomp.size());
-    forAll(decomp, i)
-    {
-        decomp[i] = finalDecomp[i];
-    }
-    return decomp;
 }
 
 
diff --git a/src/parallel/decompose/scotchDecomp/scotchDecomp.H b/src/parallel/decompose/scotchDecomp/scotchDecomp.H
index a2a2a298ca17549e45d2472483943b6827627d1b..7a44f095f27376f31e492fa31bf6ecf9369e999d 100644
--- a/src/parallel/decompose/scotchDecomp/scotchDecomp.H
+++ b/src/parallel/decompose/scotchDecomp/scotchDecomp.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -213,7 +213,7 @@ SourceFiles
 #ifndef scotchDecomp_H
 #define scotchDecomp_H
 
-#include "decompositionMethod.H"
+#include "metisLikeDecomp.H"
 
 namespace Foam
 {
@@ -224,35 +224,34 @@ namespace Foam
 
 class scotchDecomp
 :
-    public decompositionMethod
+    public metisLikeDecomp
 {
+    // Private data
+
+        //- Output path and name for optional grf file.
+        fileName graphPath_;
+
+
     // Private Member Functions
 
+        //- Set graph path and name
+        void graphPath(const polyMesh& mesh);
+
         //- Check and print error message
         static void check(const int, const char*);
 
-        label decompose
-        (
-            const fileName& meshPath,
-            const List<label>& adjncy,
-            const List<label>& xadj,
-            const scalarField& cWeights,
-            List<label>& finalDecomp
-        );
-
         //- Decompose non-parallel
-        label decomposeOneProc
+        virtual label decomposeSerial
         (
-            const fileName& meshPath,
-            const List<label>& adjncy,
-            const List<label>& xadj,
-            const scalarField& cWeights,
-            List<label>& finalDecomp
+            const UList<label>& adjncy,
+            const UList<label>& xadj,
+            const UList<scalar>& cWeights,
+            List<label>& decomp
         );
 
         //- Disallow default bitwise copy construct and assignment
-        void operator=(const scotchDecomp&);
-        scotchDecomp(const scotchDecomp&);
+        void operator=(const scotchDecomp&) = delete;
+        scotchDecomp(const scotchDecomp&) = delete;
 
 
 public:
@@ -280,14 +279,10 @@ public:
             return true;
         }
 
-        //- Inherit decompose from decompositionMethod
+        //- Inherit all decompose methods
         using decompositionMethod::decompose;
 
-        //- Return for every coordinate the wanted processor number. Use the
-        //  mesh connectivity (if needed)
-        //  Weights get normalised with minimum weight and truncated to
-        //  convert into integer so e.g. 3.5 is seen as 3. The overall sum
-        //  of weights might otherwise overflow.
+        //- Return for every coordinate the wanted processor number.
         virtual labelList decompose
         (
             const polyMesh& mesh,
@@ -295,11 +290,7 @@ public:
             const scalarField& pointWeights
         );
 
-        //- Return for every coordinate the wanted processor number. Gets
-        //  passed agglomeration map (from fine to coarse cells) and coarse cell
-        //  location. Can be overridden by decomposers that provide this
-        //  functionality natively.
-        //  See note on weights above.
+        //- Return for every coordinate the wanted processor number.
         virtual labelList decompose
         (
             const polyMesh& mesh,
@@ -308,14 +299,7 @@ public:
             const scalarField& regionWeights
         );
 
-        //- Return for every coordinate the wanted processor number. Explicitly
-        //  provided mesh connectivity.
-        //  The connectivity is equal to mesh.cellCells() except for
-        //  - in parallel the cell numbers are global cell numbers (starting
-        //    from 0 at processor0 and then incrementing all through the
-        //    processors)
-        //  - the connections are across coupled patches
-        //  See note on weights above.
+        //- Return for every coordinate the wanted processor number.
         virtual labelList decompose
         (
             const labelListList& globalCellCells,
diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C
index fc7aa24aef37f8b88f38b805dbb425a208ff4c85..60ff416676c827c40421cc9a6bc31ce972b7980f 100644
--- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C
+++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C
@@ -1147,7 +1147,7 @@ Foam::label Foam::distributedTriSurfaceMesh::findTriangle
         if (f.region() == otherF.region())
         {
             // Find index of otherF[0]
-            label fp0 = findIndex(f, otherF[0]);
+            label fp0 = f.find(otherF[0]);
             // Check rest of triangle in same order
             label fp1 = f.fcIndex(fp0);
             label fp2 = f.fcIndex(fp1);
diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C
index bc8f2a9c4525025a06a25b6a35d5d9e1f46d8a99..367459ce47f2f126494fbabc7fad513d0181b011 100644
--- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C
+++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C
@@ -58,7 +58,7 @@ void surfaceNoise::initialise(const fileName& fName)
 
         // Find the index of the pressure data
         const List<word> fieldNames(readerPtr_->fieldNames(0));
-        pIndex_ = findIndex(fieldNames, pName_);
+        pIndex_ = fieldNames.find(pName_);
         if (pIndex_ == -1)
         {
             FatalErrorInFunction
diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C
index dac63860b81a145b358556159c3197f0d0c28135..86680da8d99fa0f866bd82cea11b1d74a401a5d5 100644
--- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C
+++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C
@@ -384,28 +384,23 @@ void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::write
 ) const
 {
     mixedFvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
     );
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "pyrolysisRegion",
         "pyrolysisProperties",
         pyrolysisRegionName_
     );
-    os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("qr")<< qrName_ << token::END_STATEMENT << nl;
-    os.writeKeyword("convectiveScaling") << convectiveScaling_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("filmDeltaDry") << filmDeltaDry_
-        << token::END_STATEMENT << nl;
-    os.writeKeyword("filmDeltaWet") << filmDeltaWet_
-        << token::END_STATEMENT << endl;
+    os.writeEntry("Tnbr", TnbrName_);
+    os.writeEntry("qr", qrName_);
+    os.writeEntry("convectiveScaling", convectiveScaling_);
+    os.writeEntry("filmDeltaDry", filmDeltaDry_);
+    os.writeEntry("filmDeltaWet", filmDeltaWet_);
     temperatureCoupledBase::write(os);
 }
 
diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C
index 3616268333ec686a9de755347975c484a0c08f18..6b1aee1745296c3292ac448791044f563c824861 100644
--- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C
+++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C
@@ -186,22 +186,20 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::write
 ) const
 {
     fvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
     );
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "pyrolysisRegion",
         "pyrolysisProperties",
         pyrolysisRegionName_
     );
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C
index c5507e06a22385b35f803aff68434ad3a9e8d7c8..f4b4d4455524d90776857e78a1a4bb1f68088de4 100644
--- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C
+++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C
@@ -212,22 +212,20 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
     );
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "pyrolysisRegion",
         "pyrolysisProperties",
         pyrolysisRegionName_
     );
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
     writeEntry("value", os);
 }
 
diff --git a/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H b/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H
index f4709bb62e66b008a88867432a357270fc51019b..cb3185cbad68e577df66d051338b38044419e8ef 100644
--- a/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H
+++ b/src/regionModels/regionModel/derivedFvPatches/mappedVariableThicknessWall/mappedVariableThicknessWallFvPatch.H
@@ -37,8 +37,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef mappedWallFvPatch_H
-#define mappedWallFvPatch_H
+#ifndef mappedVariableThicknessWallFvPatch_H
+#define mappedVariableThicknessWallFvPatch_H
 
 #include "wallFvPatch.H"
 #include "mappedVariableThicknessWallPolyPatch.H"
diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C
index 6ab4eb18db4f69d7907da433bf43cb0cc8602989..d4bda62d8b29d7f297456c6b0fd94d4f0d72bab1 100644
--- a/src/regionModels/regionModel/regionModel/regionModel.C
+++ b/src/regionModels/regionModel/regionModel/regionModel.C
@@ -194,7 +194,7 @@ Foam::regionModels::regionModel::interRegionAMI
     const bool flip
 ) const
 {
-    label nbrRegionID = findIndex(interRegionAMINames_, nbrRegion.name());
+    label nbrRegionID = interRegionAMINames_.find(nbrRegion.name());
 
     const fvMesh& nbrRegionMesh = nbrRegion.regionMesh();
 
diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C
index 18a0bc751eb1c76ff064f228d6d7d2755564959d..a4c48dfb13314ed73c42ce59b1ce2ae213e30038 100644
--- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C
+++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C
@@ -132,9 +132,9 @@ void Foam::filmHeightInletVelocityFvPatchVectorField::updateCoeffs()
 void Foam::filmHeightInletVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    writeEntryIfDifferent<word>(os, "deltaf", "deltaf", deltafName_);
+    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("deltaf", "deltaf", deltafName_);
     writeEntry("value", os);
 }
 
diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C
index e34296a1079af6776289a5143c179427ce56e24b..c2f1c552a5b99d8c13415d84774cceae456b8474 100644
--- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C
+++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C
@@ -192,9 +192,8 @@ void Foam::inclinedFilmNusseltHeightFvPatchScalarField::write
 ) const
 {
     fixedValueFvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C
index 3bbc164e0afde210eb400da47d4c0321bf5bc22f..084e4ad6dfd3bd2c8b87c00e08277746f18e28f9 100644
--- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C
+++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C
@@ -191,9 +191,8 @@ void Foam::inclinedFilmNusseltInletVelocityFvPatchVectorField::write
 ) const
 {
     fvPatchVectorField::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C
index 09e76db86e9367bfddafbad1a8ae539fdd48e4b7..f468aff4c6b603b75ae3a9dc12aae64d9c4c41c8 100644
--- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C
+++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/alphatFilmWallFunction/alphatFilmWallFunctionFvPatchScalarField.C
@@ -237,18 +237,17 @@ void alphatFilmWallFunctionFvPatchScalarField::updateCoeffs()
 void alphatFilmWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
     );
-    os.writeKeyword("B") << B_ << token::END_STATEMENT << nl;
-    os.writeKeyword("yPlusCrit") << yPlusCrit_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
-    os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Prt") << Prt_ << token::END_STATEMENT << nl;
+    os.writeEntry("B", B_);
+    os.writeEntry("yPlusCrit", yPlusCrit_);
+    os.writeEntry("Cmu", Cmu_);
+    os.writeEntry("kappa", kappa_);
+    os.writeEntry("Prt", Prt_);
     writeEntry("value", os);
 }
 
diff --git a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C
index b35804673e4428ced356ea4720822686323987cd..4b733d82680bc8559d721b6ac296d57b2f2e9289 100644
--- a/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C
+++ b/src/regionModels/surfaceFilmModels/derivedFvPatchFields/wallFunctions/nutkFilmWallFunction/nutkFilmWallFunctionFvPatchScalarField.C
@@ -247,16 +247,15 @@ tmp<scalarField> nutkFilmWallFunctionFvPatchScalarField::yPlus() const
 void nutkFilmWallFunctionFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
-    writeEntryIfDifferent<word>
+    os.writeEntryIfDifferent<word>
     (
-        os,
         "filmRegion",
         "surfaceFilmProperties",
         filmRegionName_
     );
     writeLocalEntries(os);
-    os.writeKeyword("B") << B_ << token::END_STATEMENT << nl;
-    os.writeKeyword("yPlusCrit") << yPlusCrit_ << token::END_STATEMENT << nl;
+    os.writeEntry("B", B_);
+    os.writeEntry("yPlusCrit", yPlusCrit_);
     writeEntry("value", os);
 }
 
diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C
index 58f784039858c581f13fbfeebec3995cdaae8c55..9895f146bc1ed4d190c3e09ee96a7096b1a378fd 100644
--- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C
+++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C
@@ -285,11 +285,10 @@ void thermalBaffleFvPatchScalarField::write(Ostream& os) const
         os << dict_.subDict(extrudeModel) << nl;
 
         word regionName = dict_.lookup("region");
-        os.writeKeyword("region") << regionName << token::END_STATEMENT << nl;
+        os.writeEntry("region", regionName);
 
         bool active = readBool(dict_.lookup("active"));
-        os.writeKeyword("active") <<  active
-            << token::END_STATEMENT << nl;
+        os.writeEntry("active", active);
 
         os.writeKeyword("thermoType");
         os << dict_.subDict("thermoType") << nl;
diff --git a/src/rigidBodyDynamics/bodies/cuboid/cuboid.C b/src/rigidBodyDynamics/bodies/cuboid/cuboid.C
index 5309ae50b48f280a508e683830d5a09ae3eba8d8..36f4cc4c1b182ef4f91fd2d6836c2cc6066c5856 100644
--- a/src/rigidBodyDynamics/bodies/cuboid/cuboid.C
+++ b/src/rigidBodyDynamics/bodies/cuboid/cuboid.C
@@ -62,14 +62,9 @@ Foam::RBD::cuboid::~cuboid()
 
 void Foam::RBD::cuboid::write(Ostream& os) const
 {
-    os.writeKeyword("type")
-        << type() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("mass")
-        << m() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("L")
-        << L() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
+    os.writeEntry("mass", m());
+    os.writeEntry("L", L());
 }
 
 
diff --git a/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C b/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C
index 61e5b4bc757fcab95d598047ca31c08537744463..ad5c7ed99a1f2b0a9d27bd7417bfd09afc570005 100644
--- a/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C
+++ b/src/rigidBodyDynamics/bodies/masslessBody/masslessBody.C
@@ -68,8 +68,7 @@ bool Foam::RBD::masslessBody::massless() const
 
 void Foam::RBD::masslessBody::write(Ostream& os) const
 {
-    os.writeKeyword("type")
-        << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
 }
 
 
diff --git a/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C b/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C
index d13772c1000f56a71cc1d7d080624df1c0c95651..51831470059432141750aa2c2ead1b7caa027edd 100644
--- a/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C
+++ b/src/rigidBodyDynamics/bodies/rigidBody/rigidBody.C
@@ -118,17 +118,10 @@ void Foam::RBD::rigidBody::merge(const subBody& subBody)
 
 void Foam::RBD::rigidBody::write(Ostream& os) const
 {
-    os.writeKeyword("type")
-        << type() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("mass")
-        << m() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("centreOfMass")
-        << c() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("inertia")
-        << Ic() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
+    os.writeEntry("mass", m());
+    os.writeEntry("centreOfMass", c());
+    os.writeEntry("inertia", Ic());
 }
 
 
diff --git a/src/rigidBodyDynamics/bodies/sphere/sphere.C b/src/rigidBodyDynamics/bodies/sphere/sphere.C
index ea4d13653e7d94875b9ffedb119967e624f8cd11..6e1c6b9b31078070b523d1565d67bf74c6b906fb 100644
--- a/src/rigidBodyDynamics/bodies/sphere/sphere.C
+++ b/src/rigidBodyDynamics/bodies/sphere/sphere.C
@@ -62,14 +62,9 @@ Foam::RBD::sphere::~sphere()
 
 void Foam::RBD::sphere::write(Ostream& os) const
 {
-    os.writeKeyword("type")
-        << type() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("mass")
-        << m() << token::END_STATEMENT << nl;
-
-    os.writeKeyword("radius")
-        << r() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
+    os.writeEntry("mass", m());
+    os.writeEntry("radius", r());
 }
 
 
diff --git a/src/rigidBodyDynamics/bodies/subBody/subBody.C b/src/rigidBodyDynamics/bodies/subBody/subBody.C
index 96924506beb583f3322763af08343cadd206131d..06586248ac823a59e23db83ba64db04f6f9d424e 100644
--- a/src/rigidBodyDynamics/bodies/subBody/subBody.C
+++ b/src/rigidBodyDynamics/bodies/subBody/subBody.C
@@ -29,11 +29,8 @@ License
 
 void Foam::RBD::subBody::write(Ostream& os) const
 {
-    os.writeKeyword("master")
-        << masterName_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("transform")
-        << masterXT_ << token::END_STATEMENT << nl;
+    os.writeEntry("master", masterName_);
+    os.writeEntry("transform", masterXT_);
 }
 
 
diff --git a/src/rigidBodyDynamics/joints/Pa/Pa.C b/src/rigidBodyDynamics/joints/Pa/Pa.C
index b30997acadfce95a2adca9c549c6a6e621bc9588..30cc3711e30fe9742c0ab61f7559a57a07738fb5 100644
--- a/src/rigidBodyDynamics/joints/Pa/Pa.C
+++ b/src/rigidBodyDynamics/joints/Pa/Pa.C
@@ -98,8 +98,7 @@ void Foam::RBD::joints::Pa::jcalc
 void Foam::RBD::joints::Pa::write(Ostream& os) const
 {
     joint::write(os);
-    os.writeKeyword("axis")
-        << S_[0].l() << token::END_STATEMENT << nl;
+    os.writeEntry("axis", S_[0].l());
 }
 
 
diff --git a/src/rigidBodyDynamics/joints/Ra/Ra.C b/src/rigidBodyDynamics/joints/Ra/Ra.C
index 468985ea67c39da7bc9882f5682767d5c253dca0..df4f9048d65df7460f871340f55e55b7fbad62a8 100644
--- a/src/rigidBodyDynamics/joints/Ra/Ra.C
+++ b/src/rigidBodyDynamics/joints/Ra/Ra.C
@@ -98,8 +98,7 @@ void Foam::RBD::joints::Ra::jcalc
 void Foam::RBD::joints::Ra::write(Ostream& os) const
 {
     joint::write(os);
-    os.writeKeyword("axis")
-        << S_[0].w() << token::END_STATEMENT << nl;
+    os.writeEntry("axis", S_[0].w());
 }
 
 
diff --git a/src/rigidBodyDynamics/joints/joint/joint.C b/src/rigidBodyDynamics/joints/joint/joint.C
index 92204ffebd87a192ca78ab91d833632a768123b2..6448bb6f8b88f63032488678f7eb1a646d428af9 100644
--- a/src/rigidBodyDynamics/joints/joint/joint.C
+++ b/src/rigidBodyDynamics/joints/joint/joint.C
@@ -79,7 +79,7 @@ Foam::RBD::joint::~joint()
 
 void Foam::RBD::joint::write(Ostream& os) const
 {
-    os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
 }
 
 
diff --git a/src/rigidBodyDynamics/joints/joint/jointI.H b/src/rigidBodyDynamics/joints/joint/jointI.H
index eb6e36a2ca8408c1505eaad0a46f1a752cafa2bc..de655ff6c558097afb0d2cc62eb94ad3eaa4511b 100644
--- a/src/rigidBodyDynamics/joints/joint/jointI.H
+++ b/src/rigidBodyDynamics/joints/joint/jointI.H
@@ -112,9 +112,9 @@ Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::iNew::operator()
 
 inline Foam::Ostream& Foam::RBD::operator<<(Ostream& os, const joint& j)
 {
-    os  << indent << token::BEGIN_BLOCK << incrIndent << endl;
+    os.beginBlock();
     j.write(os);
-    os  << decrIndent << indent << token::END_BLOCK;
+    os.endBlock();
 
     return os;
 }
diff --git a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
index 8f0b6143e5cea8844309f5cf2be741667a626f77..379a69c4f4e327cae14197fe759f0847bfea8d46 100644
--- a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
+++ b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
@@ -184,17 +184,10 @@ void Foam::RBD::restraints::linearAxialAngularSpring::write
 {
     restraint::write(os);
 
-    os.writeKeyword("referenceOrientation")
-        << refQ_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("axis")
-        << axis_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("stiffness")
-        << stiffness_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("damping")
-        << damping_ << token::END_STATEMENT << nl;
+    os.writeEntry("referenceOrientation", refQ_);
+    os.writeEntry("axis", axis_);
+    os.writeEntry("stiffness", stiffness_);
+    os.writeEntry("damping", damping_);
 }
 
 
diff --git a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C
index d3e4e063da47e91283415b6ee135ea4076c597b0..b15c39cb4dc8ed646e717605611086bf6aac93a8 100644
--- a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C
+++ b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C
@@ -109,8 +109,7 @@ void Foam::RBD::restraints::linearDamper::write
 {
     restraint::write(os);
 
-    os.writeKeyword("coeff")
-        << coeff_ << token::END_STATEMENT << nl;
+    os.writeEntry("coeff", coeff_);
 }
 
 
diff --git a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C
index 9449d60042d059fc05731bf72efee029df292ebb..189a7e9a9b40b134a28136cc9e2ec2b0f328ffac 100644
--- a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C
+++ b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C
@@ -134,20 +134,11 @@ void Foam::RBD::restraints::linearSpring::write
 {
     restraint::write(os);
 
-    os.writeKeyword("anchor")
-        << anchor_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("refAttachmentPt")
-        << refAttachmentPt_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("stiffness")
-        << stiffness_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("damping")
-        << damping_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("restLength")
-        << restLength_ << token::END_STATEMENT << nl;
+    os.writeEntry("anchor", anchor_);
+    os.writeEntry("refAttachmentPt", refAttachmentPt_);
+    os.writeEntry("stiffness", stiffness_);
+    os.writeEntry("damping", damping_);
+    os.writeEntry("restLength", restLength_);
 }
 
 
diff --git a/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C b/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C
index be56e7b08428123362d065ccf0eb7cd4c343bf14..229e64ae3f5a654a93c5d6b2765987efa3cf0e4e 100644
--- a/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C
+++ b/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.C
@@ -78,10 +78,8 @@ bool Foam::RBD::restraint::read(const dictionary& dict)
 
 void Foam::RBD::restraint::write(Ostream& os) const
 {
-    os.writeKeyword("type")
-        << type() << token::END_STATEMENT << nl;
-    os.writeKeyword("body")
-        << model_.name(bodyID_) << token::END_STATEMENT << nl;
+    os.writeEntry("type", type());
+    os.writeEntry("body", model_.name(bodyID_));
 }
 
 
diff --git a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C
index 8ef17486b78232b6b3d104b8a7e3bbf7441c078e..441bfafc1f90530879080a3cc65a9c30eb102953 100644
--- a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C
+++ b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C
@@ -109,7 +109,7 @@ void Foam::RBD::restraints::sphericalAngularDamper::write
 {
     restraint::write(os);
 
-    os.writeKeyword("coeff") << coeff_ << token::END_STATEMENT << nl;
+    os.writeEntry("coeff", coeff_);
 }
 
 
diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C
index 4a8de4eac4d72b0557ff26ed31edc9f7c0f02a8b..1fbe3fc60e982a4905204a6801afd788e9615322 100644
--- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C
+++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C
@@ -377,17 +377,14 @@ Foam::spatialTransform Foam::RBD::rigidBodyModel::X0
         const subBody& mBody = mergedBody(bodyId);
         return mBody.masterXT() & X0_[mBody.masterID()];
     }
-    else
-    {
-        return X0_[bodyId];
-    }
+
+    return X0_[bodyId];
 }
 
 
 void Foam::RBD::rigidBodyModel::write(Ostream& os) const
 {
-    os  << indent << "bodies" << nl
-        << indent << token::BEGIN_BLOCK << incrIndent << nl;
+    os.beginBlock("bodies");
 
     // Write the moving bodies
     for (label i=1; i<nBodies(); i++)
@@ -396,61 +393,52 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const
         // of composite joints
         if (!isType<jointBody>(bodies_[i]))
         {
-            os  << indent << bodies_[i].name() << nl
-                << indent << token::BEGIN_BLOCK << incrIndent << endl;
+            os.beginBlock(bodies_[i].name());
 
             bodies_[i].write(os);
 
-            os.writeKeyword("parent")
-                << bodies_[lambda_[i]].name() << token::END_STATEMENT << nl;
-
-            os.writeKeyword("transform")
-                << XT_[i] << token::END_STATEMENT << nl;
+            os.writeEntry("parent", bodies_[lambda_[i]].name());
+            os.writeEntry("transform", XT_[i]);
 
-            os  << indent << "joint" << nl << joints_[i] << endl;
+            os  << indent << "joint" << nl
+                << joints_[i] << endl;
 
-            os  << decrIndent << indent << token::END_BLOCK << endl;
+            os.endBlock();
         }
     }
 
     // Write the bodies merged into the parent bodies for efficiency
     forAll(mergedBodies_, i)
     {
-        os  << indent << mergedBodies_[i].name() << nl
-            << indent << token::BEGIN_BLOCK << incrIndent << endl;
+        os.beginBlock(mergedBodies_[i].name());
 
         mergedBodies_[i].body().write(os);
 
-        os.writeKeyword("transform")
-            << mergedBodies_[i].masterXT() << token::END_STATEMENT << nl;
-
-        os.writeKeyword("mergeWith")
-            << mergedBodies_[i].masterName() << token::END_STATEMENT << nl;
+        os.writeEntry("transform", mergedBodies_[i].masterXT());
+        os.writeEntry("mergeWith", mergedBodies_[i].masterName());
 
-        os  << decrIndent << indent << token::END_BLOCK << endl;
+        os.endBlock();
     }
 
-    os  << decrIndent << indent << token::END_BLOCK << nl;
+    os.endBlock();
 
 
     if (!restraints_.empty())
     {
-        os  << indent << "restraints" << nl
-            << indent << token::BEGIN_BLOCK << incrIndent << nl;
+        os.beginBlock("restraints");
 
         forAll(restraints_, ri)
         {
-            word restraintType = restraints_[ri].type();
+            const word& restraintType(restraints_[ri].type());
 
-            os  << indent << restraints_[ri].name() << nl
-                << indent << token::BEGIN_BLOCK << incrIndent << endl;
+            os.beginBlock(restraints_[ri].name());
 
             restraints_[ri].write(os);
 
-            os  << decrIndent << indent << token::END_BLOCK << endl;
+            os.endBlock();
         }
 
-        os  << decrIndent << indent << token::END_BLOCK << nl;
+        os.endBlock();
     }
 }
 
diff --git a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C
index 038d42a31a01f62718f15c1b30e3e2ad85006371..66a7418cd51a3de5bce303b6f488bfc608b1d77e 100644
--- a/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C
+++ b/src/rigidBodyDynamics/rigidBodyModelState/rigidBodyModelStateIO.C
@@ -39,10 +39,10 @@ void Foam::RBD::rigidBodyModelState::write(dictionary& dict) const
 
 void Foam::RBD::rigidBodyModelState::write(Ostream& os) const
 {
-    os.writeKeyword("q") << q_ << token::END_STATEMENT << nl;
-    os.writeKeyword("qDot") << qDot_ << token::END_STATEMENT << nl;
-    os.writeKeyword("qDdot") << qDdot_ << token::END_STATEMENT << nl;
-    os.writeKeyword("deltaT") << deltaT_ << token::END_STATEMENT << nl;
+    os.writeEntry("q", q_);
+    os.writeEntry("qDot", qDot_);
+    os.writeEntry("qDdot", qDdot_);
+    os.writeEntry("deltaT", deltaT_);
 }
 
 
diff --git a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C
index 915af7f56f1a5fd3dd467a889f74fdf6709c1f08..eed9c95b468797e2966f011df513fd69fe2372c2 100644
--- a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C
+++ b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotionIO.C
@@ -44,12 +44,9 @@ void Foam::RBD::rigidBodyMotion::write(Ostream& os) const
 {
     rigidBodyModel::write(os);
 
-    os.writeKeyword("accelerationRelaxation")
-        << aRelax_ << token::END_STATEMENT << nl;
-    os.writeKeyword("accelerationDamping")
-        << aDamp_ << token::END_STATEMENT << nl;
-    os.writeKeyword("report")
-        << report_ << token::END_STATEMENT << nl;
+    os.writeEntry("accelerationRelaxation", aRelax_);
+    os.writeEntry("accelerationDamping", aDamp_);
+    os.writeEntry("report", report_);
 }
 
 
diff --git a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C
index cd0f2d193ce8c0fa75fd5ec1e81e7a7409817eb3..267a424952d1dbe3652c0ce1153f585d9fa57fca 100644
--- a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C
+++ b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C
@@ -297,7 +297,7 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell
         // search target tgtCelli neighbours for match with source cell
         label tgtI = testCells.remove();
 
-        if (findIndex(visitedCells, tgtI) == -1)
+        if (!visitedCells.found(tgtI))
         {
             visitedCells.append(tgtI);
 
@@ -311,7 +311,7 @@ Foam::label Foam::mapNearestMethod::findMappedSrcCell
 
                 forAll(nbrCells, i)
                 {
-                    if (findIndex(visitedCells, nbrCells[i]) == -1)
+                    if (!visitedCells.found(nbrCells[i]))
                     {
                         testCells.append(nbrCells[i]);
                     }
diff --git a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C
index 9a99aa04e1c12d5c0a4ab816c0ac985a28902a17..afb6b727dc9d2cc526b468ae17c6be84c1aa5e5d 100644
--- a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C
+++ b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C
@@ -168,14 +168,12 @@ void Foam::meshToMeshMethod::appendNbrCells
     const labelList& nbrCells = mesh.cellCells()[celli];
 
     // filter out cells already visited from cell neighbours
-    forAll(nbrCells, i)
+    for (const label nbrCelli : nbrCells)
     {
-        label nbrCelli = nbrCells[i];
-
         if
         (
-            (findIndex(visitedCells, nbrCelli) == -1)
-         && (findIndex(nbrCellIDs, nbrCelli) == -1)
+            !visitedCells.found(nbrCelli)
+         && !nbrCellIDs.found(nbrCelli)
         )
         {
             nbrCellIDs.append(nbrCelli);
diff --git a/src/sampling/meshToMesh/meshToMeshParallelOps.C b/src/sampling/meshToMesh/meshToMeshParallelOps.C
index d0efb5f4f34b538d64054d86d3c985e031fa23ed..6fe60c58e9316735ae23cc475c8dea30d5e4d842 100644
--- a/src/sampling/meshToMesh/meshToMeshParallelOps.C
+++ b/src/sampling/meshToMesh/meshToMeshParallelOps.C
@@ -70,7 +70,7 @@ Foam::label Foam::meshToMesh::calcDistribution
         }
         else if (nHaveCells == 1)
         {
-            proci = findIndex(cellsPresentOnProc, 1);
+            proci = cellsPresentOnProc.find(1);
             if (debug)
             {
                 InfoInFunction
diff --git a/src/sampling/meshToMesh0/meshToMesh0.H b/src/sampling/meshToMesh0/meshToMesh0.H
index 885d4baeb05bc95508fe593381f27a8464db7228..989173f0738c1ee166488874b40a664681b73105 100644
--- a/src/sampling/meshToMesh0/meshToMesh0.H
+++ b/src/sampling/meshToMesh0/meshToMesh0.H
@@ -38,8 +38,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef meshtoMesh_H
-#define meshtoMesh_H
+#ifndef meshToMesh0_H
+#define meshToMesh0_H
 
 #include "fvMesh.H"
 #include "HashTable.H"
diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C
index 85ef3a9d4f7e828507c5ffdff7212a782492f255..333bb94527f7b90333e02f31937d6e0639ddccb4 100644
--- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C
+++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C
@@ -55,7 +55,7 @@ Foam::sampledPlane::sampledPlane
     triangulate_(triangulate),
     needsUpdate_(true)
 {
-    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
+    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
     {
         Info<< "cellZone " << zoneKey_
             << " not found - using entire mesh" << endl;
@@ -91,7 +91,7 @@ Foam::sampledPlane::sampledPlane
 
     dict.readIfPresent("zone", zoneKey_);
 
-    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
+    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
     {
         Info<< "cellZone " << zoneKey_
             << " not found - using entire mesh" << endl;
diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C
index 6db990686d140bbd64b044b59d7cd20a933e3e3d..84fdfb1f3f78084ae5b2ae9f812ddbeea61662c3 100644
--- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C
+++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C
@@ -70,7 +70,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
     }
 
     // const scalar timeValue = Foam::name(this->mesh().time().timeValue());
-    const scalar timeValue = readScalar(IStringStream(timeDir)());
+    const scalar timeValue = readScalar(timeDir);
 
     OFstream osCase(baseDir/surfName + ".case");
     ensightGeoFile osGeom
@@ -99,9 +99,13 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
         << "model:  1   " << osGeom.name().name() << nl
         << nl
         << "VARIABLE" << nl
-        << ensightPTraits<Type>::typeName << " per "
-        << word(isNodeValues ? "node:" : "element:")
-        << setw(3) << 1
+        << ensightPTraits<Type>::typeName
+        <<
+        (
+            isNodeValues
+          ? " per node:    1  "  // time-set 1
+          : " per element: 1  "  // time-set 1
+        )
         << setw(15) << varName
         << "   " << surfName.c_str() << ".********." << varName << nl
         << nl
@@ -175,7 +179,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
 
     // surfName already validated
     const fileName meshFile(baseDir/surfName + ".000000.mesh");
-    const scalar timeValue = readScalar(IStringStream(timeDir)());
+    const scalar timeValue = readScalar(timeDir);
     label timeIndex = 0;
 
     // Do case file
@@ -190,7 +194,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
             if (is.good() && dict.read(is))
             {
                 dict.lookup("times") >> times;
-                const scalar timeValue = readScalar(IStringStream(timeDir)());
+                const scalar timeValue = readScalar(timeDir);
                 label index = findLower(times, timeValue);
                 timeIndex = index+1;
             }
diff --git a/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C b/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C
index dea10f0fd3159cf30e36b272a6e6e556285ec717..19132b4b9e8e622f952c7b1985af55afc73c0f3f 100644
--- a/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C
+++ b/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C
@@ -73,7 +73,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
     triangulate_(triangulate),
     needsUpdate_(true)
 {
-    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
+    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
     {
         Info<< "cellZone " << zoneKey_
             << " not found - using entire mesh" << endl;
@@ -109,7 +109,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
 
     dict.readIfPresent("zone", zoneKey_);
 
-    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
+    if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) == -1)
     {
         Info<< "cellZone " << zoneKey_
             << " not found - using entire mesh" << endl;
diff --git a/src/sampling/surface/isoSurface/isoSurface.C b/src/sampling/surface/isoSurface/isoSurface.C
index a2041c100edbd33ad1692277ac5ff1440887c9ef..f4e09a4da53545b4f9344f9a82246c0636bb98a0 100644
--- a/src/sampling/surface/isoSurface/isoSurface.C
+++ b/src/sampling/surface/isoSurface/isoSurface.C
@@ -748,7 +748,7 @@ void Foam::isoSurface::calcSnappedPoint
             FixedList<scalar, 4> s;
             FixedList<point, 4> pt;
 
-            label fp = findIndex(f, pointi);
+            label fp = f.find(pointi);
             s[0] = isoFraction(pVals[pointi], cVals[own]);
             pt[0] = (1.0-s[0])*pts[pointi] + s[0]*cc[own];
 
diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C
index 3b22509c38dc994664dfb6e4c4d15b749e03681a..ab1e6bfdd42e51cd3def6208155ab5505d8ace6a 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceCell.C
+++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C
@@ -226,12 +226,12 @@ Foam::labelPair Foam::isoSurfaceCell::findCommonPoints
     labelPair common(-1, -1);
 
     label fp0 = 0;
-    label fp1 = findIndex(tri1, tri0[fp0]);
+    label fp1 = tri1.find(tri0[fp0]);
 
     if (fp1 == -1)
     {
         fp0 = 1;
-        fp1 = findIndex(tri1, tri0[fp0]);
+        fp1 = tri1.find(tri0[fp0]);
     }
 
     if (fp1 != -1)
@@ -553,7 +553,7 @@ void Foam::isoSurfaceCell::genPointTris
         label nextFp = f.fcIndex(fp);
         triFace tri(f[fp0], f[fp], f[nextFp]);
 
-        label index = findIndex(tri, pointi);
+        label index = tri.find(pointi);
 
         if (index == -1)
         {
@@ -631,7 +631,7 @@ void Foam::isoSurfaceCell::genPointTris
         {
             label p1 = f1[fp];
 
-            if (findIndex(f, p1) == -1)
+            if (!f.found(p1))
             {
                 ccPointi = p1;
                 break;
@@ -645,7 +645,7 @@ void Foam::isoSurfaceCell::genPointTris
 
 
     // Tet between index..index-1, index..index+1, index..cc
-    label index = findIndex(f, pointi);
+    label index = f.find(pointi);
     label b = f[f.fcIndex(index)];
     label c = f[f.rcIndex(index)];
 
diff --git a/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C b/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C
index 521ff41871bbb8b939309d72d5abf8ebd2ed9de7..9a2b1834525d1caf45297adb01df81b88bffeffd 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C
+++ b/src/sampling/surface/isoSurface/isoSurfaceCellTemplates.C
@@ -360,7 +360,7 @@ void Foam::isoSurfaceCell::generateTriPoints
                 {
                     oppositeI = f1[fp];
 
-                    if (findIndex(f0, oppositeI) == -1)
+                    if (!f0.found(oppositeI))
                     {
                         break;
                     }
diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
index daeb9adf8d976ad0d9f0e6355842790494cee6d8..e1508439b6e0c4b080f0e52a843f4931e39d2c41 100644
--- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
+++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
@@ -255,16 +255,16 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const
 {
     pointPatchField<vector>::write(os);
 
-    os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
+    os.writeEntry("rho", rhoName_);
 
     if (rhoName_ == "rhoInf")
     {
-        os.writeKeyword("rhoInf") << rhoInf_ << token::END_STATEMENT << nl;
+        os.writeEntry("rhoInf", rhoInf_);
     }
 
     if (lookupGravity_ == 0 || lookupGravity_ == -2)
     {
-        os.writeKeyword("g") << g_ << token::END_STATEMENT << nl;
+        os.writeEntry("g", g_);
     }
 
     motion_.write(os);
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C
index 985d7ae4caad77630c7e69d989bb5bb8202f7cb4..0650986bfd2c0de4d8035a11b833b1dc058f6051 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/axis/sixDoFRigidBodyMotionAxisConstraint.C
@@ -116,8 +116,7 @@ void Foam::sixDoFRigidBodyMotionConstraints::axis::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("axis")
-        << axis_ << token::END_STATEMENT << nl;
+    os.writeEntry("axis", axis_);
 }
 
 // ************************************************************************* //
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C
index 7e7189b0d1d4c271852bd0e6d6315963c03fb9df..6da64ea471bed7d6b636a6a408907f144934f12c 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/line/sixDoFRigidBodyMotionLineConstraint.C
@@ -130,10 +130,8 @@ void Foam::sixDoFRigidBodyMotionConstraints::line::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("centreOfRotation")
-        << centreOfRotation_ << token::END_STATEMENT << nl;
-    os.writeKeyword("direction")
-        << direction_ << token::END_STATEMENT << nl;
+    os.writeEntry("centreOfRotation", centreOfRotation_);
+    os.writeEntry("direction", direction_);
 }
 
 // ************************************************************************* //
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C
index 7c291dee64cb0cf8a4906ecac9a04d4bc0cc6582..90190f2c63f9b36f48cdeef191a652d49b966234 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/plane/sixDoFRigidBodyMotionPlaneConstraint.C
@@ -117,10 +117,8 @@ void Foam::sixDoFRigidBodyMotionConstraints::plane::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("centreOfRotation")
-        << centreOfRotation_ << token::END_STATEMENT << nl;
-    os.writeKeyword("normal")
-        << normal_ << token::END_STATEMENT << nl;
+    os.writeEntry("centreOfRotation", centreOfRotation_);
+    os.writeEntry("normal", normal_);
 }
 
 // ************************************************************************* //
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C
index 32021c0747676d5fdae8a76144358176aa103811..5fc63648f20cbeaf8faf5d843cfa5163e0b5f9d2 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/constraints/point/sixDoFRigidBodyMotionPointConstraint.C
@@ -116,8 +116,7 @@ void Foam::sixDoFRigidBodyMotionConstraints::point::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("centreOfRotation")
-        << centreOfRotation_ << token::END_STATEMENT << nl;
+    os.writeEntry("centreOfRotation", centreOfRotation_);
 }
 
 // ************************************************************************* //
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
index 2237bf6963c3816b7a425782cb99e84718fc3298..8575a52e774d6a6f59681cb634561e65a02f8156 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
@@ -186,17 +186,10 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("referenceOrientation")
-        << refQ_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("axis")
-        << axis_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("stiffness")
-        << stiffness_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("damping")
-        << damping_ << token::END_STATEMENT << nl;
+    os.writeEntry("referenceOrientation", refQ_);
+    os.writeEntry("axis", axis_);
+    os.writeEntry("stiffness", stiffness_);
+    os.writeEntry("damping", damping_);
 }
 
 // ************************************************************************* //
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C
index 5d70d4db1121e71fe4562b337661de087751f805..1e6d31ce8ea39bec9f5aa1ecc22a75bca5c99c92 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearDamper/linearDamper.C
@@ -105,8 +105,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearDamper::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("coeff")
-        << coeff_ << token::END_STATEMENT << nl;
+    os.writeEntry("coeff", coeff_);
 }
 
 
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C
index 40b19b2006cacd0a6cad623eac602e6c464b5147..c993c4d814354eede2c89af0e2abaab0a4ca3683 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpring/linearSpring.C
@@ -125,20 +125,11 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("anchor")
-        << anchor_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("refAttachmentPt")
-        << refAttachmentPt_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("stiffness")
-        << stiffness_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("damping")
-        << damping_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("restLength")
-        << restLength_ << token::END_STATEMENT << nl;
+    os.writeEntry("anchor", anchor_);
+    os.writeEntry("refAttachmentPt", refAttachmentPt_);
+    os.writeEntry("stiffness", stiffness_);
+    os.writeEntry("damping", damping_);
+    os.writeEntry("restLength", restLength_);
 }
 
 // ************************************************************************* //
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C
index f0731256666d03a3d5bb1415f553bac527790598..27f890590a052a9cf0da809e78f8ca0f0d04e37a 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularDamper/sphericalAngularDamper.C
@@ -107,7 +107,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularDamper::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("coeff") << coeff_ << token::END_STATEMENT << nl;
+    os.writeEntry("coeff", coeff_);
 }
 
 
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C
index aa012153ce948e5e75d478ed3f5a8821b6a328d7..35db712d8f4fa784de68dbbbbf53e7be121ab0a5 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/sphericalAngularSpring/sphericalAngularSpring.C
@@ -145,12 +145,9 @@ void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("referenceOrientation")
-        << refQ_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("stiffness") << stiffness_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("damping") << damping_ << token::END_STATEMENT << nl;
+    os.writeEntry("referenceOrientation", refQ_);
+    os.writeEntry("stiffness", stiffness_);
+    os.writeEntry("damping", damping_);
 }
 
 
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C
index 000ca2618f3b27d3a871e7adb0cbe547c33bc2e6..601184e0a5d729f0c0bc76be22c43164ace28d68 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C
@@ -205,27 +205,21 @@ void Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::write
     Ostream& os
 ) const
 {
-    os.writeKeyword("referenceOrientation")
-        << refQ_ << token::END_STATEMENT << nl;
-
-    os.writeKeyword("axis")
-        << axis_ << token::END_STATEMENT << nl;
+    os.writeEntry("referenceOrientation", refQ_);
+    os.writeEntry("axis", axis_);
 
     moment_.write(os);
 
-    os.writeKeyword("angleFormat");
-
     if (convertToDegrees_)
     {
-        os  << "degrees" << token::END_STATEMENT << nl;
+        os.writeEntry("angleFormat", "degrees");
     }
     else
     {
-        os  << "radians" << token::END_STATEMENT << nl;
+        os.writeEntry("angleFormat", "radians");
     }
 
-    os.writeKeyword("damping")
-        << damping_ << token::END_STATEMENT << nl;
+    os.writeEntry("damping", damping_);
 }
 
 
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C
index e04a11d4788b79f8d99f12fc5a5ade050ece1dac..4b54e45b175b5a27f83e819663b85771bf006224 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C
@@ -51,67 +51,54 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
 {
     motionState_.write(os);
 
-    os.writeKeyword("centreOfMass")
-        << initialCentreOfMass_ << token::END_STATEMENT << nl;
-    os.writeKeyword("initialOrientation")
-        << initialQ_ << token::END_STATEMENT << nl;
-    os.writeKeyword("mass")
-        << mass_ << token::END_STATEMENT << nl;
-    os.writeKeyword("momentOfInertia")
-        << momentOfInertia_ << token::END_STATEMENT << nl;
-    os.writeKeyword("accelerationRelaxation")
-        << aRelax_ << token::END_STATEMENT << nl;
-    os.writeKeyword("accelerationDamping")
-        << aDamp_ << token::END_STATEMENT << nl;
-    os.writeKeyword("report")
-        << report_ << token::END_STATEMENT << nl;
+    os.writeEntry("centreOfMass", initialCentreOfMass_);
+    os.writeEntry("initialOrientation", initialQ_);
+    os.writeEntry("mass", mass_);
+    os.writeEntry("momentOfInertia", momentOfInertia_);
+    os.writeEntry("accelerationRelaxation", aRelax_);
+    os.writeEntry("accelerationDamping", aDamp_);
+    os.writeEntry("report", report_);
 
     if (!restraints_.empty())
     {
-        os  << indent << "restraints" << nl
-            << indent << token::BEGIN_BLOCK << incrIndent << nl;
+        os.beginBlock("restraints");
 
         forAll(restraints_, rI)
         {
-            word restraintType = restraints_[rI].type();
+            const word& restraintType(restraints_[rI].type());
 
-            os  << indent << restraints_[rI].name() << nl
-                << indent << token::BEGIN_BLOCK << incrIndent << endl;
+            os.beginBlock(restraints_[rI].name());
 
-            os.writeKeyword("sixDoFRigidBodyMotionRestraint")
-                << restraintType << token::END_STATEMENT << nl;
+            os.writeEntry("sixDoFRigidBodyMotionRestraint", restraintType);
 
             restraints_[rI].write(os);
 
-            os  << decrIndent << indent << token::END_BLOCK << endl;
+            os.endBlock();
         }
 
-        os  << decrIndent << indent << token::END_BLOCK << nl;
+        os.endBlock();
     }
 
     if (!constraints_.empty())
     {
-        os  << indent << "constraints" << nl
-            << indent << token::BEGIN_BLOCK << incrIndent << nl;
+        os.beginBlock("constraints");
 
         forAll(constraints_, rI)
         {
-            word constraintType = constraints_[rI].type();
+            const word& constraintType(constraints_[rI].type());
 
-            os  << indent << constraints_[rI].name() << nl
-                << indent << token::BEGIN_BLOCK << incrIndent << endl;
+            os.beginBlock(constraints_[rI].name());
 
-            os.writeKeyword("sixDoFRigidBodyMotionConstraint")
-                << constraintType << token::END_STATEMENT << nl;
+            os.writeEntry("sixDoFRigidBodyMotionConstraint", constraintType);
 
             constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
 
             constraints_[rI].write(os);
 
-            os  << decrIndent << indent << token::END_BLOCK << endl;
+            os.endBlock();
         }
 
-        os  << decrIndent << indent << token::END_BLOCK << nl;
+        os.endBlock();
     }
 
     if (!solver_.empty())
diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C
index e24f81f448c8383c1ae45da51086b8d681f82b30..3924adde78c62db3ca2fc6f9697c6b25a072e2ab 100644
--- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C
+++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C
@@ -41,18 +41,12 @@ void Foam::sixDoFRigidBodyMotionState::write(dictionary& dict) const
 
 void Foam::sixDoFRigidBodyMotionState::write(Ostream& os) const
 {
-    os.writeKeyword("centreOfRotation")
-        << centreOfRotation_ << token::END_STATEMENT << nl;
-    os.writeKeyword("orientation")
-        << Q_ << token::END_STATEMENT << nl;
-    os.writeKeyword("velocity")
-        << v_ << token::END_STATEMENT << nl;
-    os.writeKeyword("acceleration")
-        << a_ << token::END_STATEMENT << nl;
-    os.writeKeyword("angularMomentum")
-        << pi_ << token::END_STATEMENT << nl;
-    os.writeKeyword("torque")
-        << tau_ << token::END_STATEMENT << nl;
+    os.writeEntry("centreOfRotation", centreOfRotation_);
+    os.writeEntry("orientation", Q_);
+    os.writeEntry("velocity", v_);
+    os.writeEntry("acceleration", a_);
+    os.writeEntry("angularMomentum", pi_);
+    os.writeEntry("torque", tau_);
 }
 
 
diff --git a/src/surfMesh/surfZone/surfZone/surfZone.C b/src/surfMesh/surfZone/surfZone/surfZone.C
index e2699243b5c6f5e3d409392a3a8f92a5bc4360a5..b51cdcf60bf4732fce19d2dc5cc0ef6647e0efc7 100644
--- a/src/surfMesh/surfZone/surfZone/surfZone.C
+++ b/src/surfMesh/surfZone/surfZone/surfZone.C
@@ -112,14 +112,13 @@ void Foam::surfZone::write(Ostream& os) const
 
 void Foam::surfZone::writeDict(Ostream& os) const
 {
-    os  << indent << name() << nl
-        << indent << token::BEGIN_BLOCK << incrIndent << nl;
+    os.beginBlock(name());
 
     surfZoneIdentifier::write(os);
-    os.writeKeyword("nFaces")    << size()  << token::END_STATEMENT << nl;
-    os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
+    os.writeEntry("nFaces", size());
+    os.writeEntry("startFace", start());
 
-    os  << decrIndent << indent << token::END_BLOCK << endl;
+    os.endBlock();
 }
 
 
diff --git a/src/surfMesh/surfaceFormats/obj/OBJstream.C b/src/surfMesh/surfaceFormats/obj/OBJstream.C
index 2fcf7f43052834b2b637f020f9c49e5cb505ce87..2056c51d5a8a1b8df0203fee9e86065b2bde8dcb 100644
--- a/src/surfMesh/surfaceFormats/obj/OBJstream.C
+++ b/src/surfMesh/surfaceFormats/obj/OBJstream.C
@@ -48,9 +48,10 @@ void Foam::OBJstream::writeAndCheck(const char c)
         startOfLine_ = false;
         if (c == 'v')
         {
-            nVertices_++;
+            ++nVertices_;
         }
     }
+
     OFstream::write(c);
 }
 
@@ -88,9 +89,9 @@ Foam::Ostream& Foam::OBJstream::write(const char c)
 
 Foam::Ostream& Foam::OBJstream::write(const char* str)
 {
-    for (const char* p = str; *p != '\0'; ++p)
+    for (const char* iter = str; *iter; ++iter)
     {
-        writeAndCheck(*p);
+        writeAndCheck(*iter);
     }
     return *this;
 }
@@ -114,54 +115,53 @@ Foam::Ostream& Foam::OBJstream::writeQuoted
     const bool quoted
 )
 {
-    if (quoted)
+    if (!quoted)
     {
-        OFstream::write(token::BEGIN_STRING);
-
-        int backslash = 0;
+        // Output unquoted, only advance line number on newline
         for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
         {
-            const char c = *iter;
+            writeAndCheck(*iter);
+        }
+        return *this;
+    }
 
-            if (c == '\\')
-            {
-                backslash++;
-                // suppress output until we know if other characters follow
-                continue;
-            }
-            else if (c == token::NL)
-            {
-                lineNumber_++;
-                backslash++;    // backslash escape for newline
-            }
-            else if (c == token::END_STRING)
-            {
-                backslash++;    // backslash escape for quote
-            }
 
-            // output pending backslashes
-            while (backslash)
-            {
-                OFstream::write('\\');
-                backslash--;
-            }
+    OFstream::write(token::BEGIN_STRING);
 
-            writeAndCheck(c);
+    unsigned backslash = 0;
+    for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
+    {
+        const char c = *iter;
+
+        if (c == '\\')
+        {
+            ++backslash;
+            continue; // only output after escaped character is known
+        }
+        else if (c == token::NL)
+        {
+            ++lineNumber_;
+            ++backslash;    // backslash escape for newline
+        }
+        else if (c == token::END_STRING)
+        {
+            ++backslash;    // backslash escape for quote
         }
 
-        // silently drop any trailing backslashes
-        // they would otherwise appear like an escaped end-quote
-        OFstream::write(token::END_STRING);
-    }
-    else
-    {
-        // output unquoted string, only advance line number on newline
-        for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
+        // output all pending backslashes
+        while (backslash)
         {
-            writeAndCheck(*iter);
+            OFstream::write('\\');
+            --backslash;
         }
+
+        writeAndCheck(c);
     }
 
+    // silently drop any trailing backslashes
+    // they would otherwise appear like an escaped end-quote
+    OFstream::write(token::END_STRING);
+
     return *this;
 }
 
diff --git a/src/surfMesh/triSurface/triSurface.C b/src/surfMesh/triSurface/triSurface.C
index b67da2ec63fd75c6a4cee034b884c3d33f390d0f..6a7b60da3f747c897a904371572277b8e98441e9 100644
--- a/src/surfMesh/triSurface/triSurface.C
+++ b/src/surfMesh/triSurface/triSurface.C
@@ -937,7 +937,7 @@ void Foam::triSurface::triFaceFaces(List<face>& plainFaces) const
 
     forAll(*this, facei)
     {
-        plainFaces[facei] = operator[](facei).triFaceFace();
+        plainFaces[facei] = this->operator[](facei);
     }
 }
 
diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H
index e3bbc0b433101579f1ef64471db28bd4e4b66a2a..cde61c91b725eba46f389a125d886b297c4f3760 100644
--- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H
+++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/noChemistryReduction/noChemistryReduction.H
@@ -31,8 +31,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef none_H
-#define none_H
+#ifndef chemistryReductionMethods_none_H
+#define chemistryReductionMethods_none_H
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H
index 99952a51f68f07547f3ae07f8bd5eed99766f72d..d321fff58044ecca82a6c943399cb8e194b58475 100644
--- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H
+++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/tabulation/ISAT/binaryNode/binaryNode.H
@@ -32,8 +32,8 @@ SourceFile
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef BINARY_NODE_H
-#define BINARY_NODE_H
+#ifndef binaryNode_H
+#define binaryNode_H
 
 #include "chemPointISAT.H"
 
diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H
index e0f5db3f60c114cbb3fcc8d993d72b449a8690d6..d37290e016933d9a4a27d1059ff92c46871a8b58 100644
--- a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H
+++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H
@@ -33,8 +33,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef noChemistySolver_H
-#define noChemistySolver_H
+#ifndef noChemistrySolver_H
+#define noChemistrySolver_H
 
 #include "chemistrySolver.H"
 
diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C
index 751e1ece9e5006251432a1c89a135a50b769241b..f69354958135908ade696c3b4539c8387a12b1a8 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.C
@@ -187,7 +187,7 @@ void Foam::radiation::MarshakRadiationFvPatchScalarField::write
 ) const
 {
     mixedFvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "T", "T", TName_);
+    os.writeEntryIfDifferent<word>("T", "T", TName_);
 }
 
 
diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H
index d175c9e358aa603595361442c8dc9b543ad2df9d..5e9b7a113886f1a0dd6c2f8a313e32f514eab89c 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationFvPatchScalarField.H
@@ -59,8 +59,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef MarshakRadiationMixedFvPatchField_H
-#define MarshakRadiationMixedFvPatchField_H
+#ifndef radiation_MarshakRadiationFvPatchScalarField_H
+#define radiation_MarshakRadiationFvPatchScalarField_H
 
 #include "mixedFvPatchFields.H"
 
diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C
index 70423f1a722fc6adcb5d02356a1aa19f45c26ba8..ca42809813ebe9c02b20e57782ef9e7d3db05808 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C
@@ -248,8 +248,8 @@ void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
 ) const
 {
     mixedFvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "T", "T", TName_);
-    os.writeKeyword("solarLoad") << solarLoad_ << token::END_STATEMENT << nl;
+    os.writeEntryIfDifferent<word>("T", "T", TName_);
+    os.writeEntry("solarLoad", solarLoad_);
 }
 
 
diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
index 44e347f28c94cf2143376623e7e9079fee15dbc3..f7adff2068e942b167f8b9b8566dc3f7d82d6d3c 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
@@ -192,7 +192,7 @@ write
 {
     fixedValueFvPatchScalarField::write(os);
     qro_.writeEntry("qro", os);
-    os.writeKeyword("solarLoad") << solarLoad_ << token::END_STATEMENT << nl;
+    os.writeEntry("solarLoad", solarLoad_);
 }
 
 
diff --git a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H
index e52733e3eae4978c107f123b66ccfbf20922917d..6532f8223c447088dda81fef85e040baef59997a 100644
--- a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H
+++ b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H
@@ -41,8 +41,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationModelP1_H
-#define radiationModelP1_H
+#ifndef radiation_P1_H
+#define radiation_P1_H
 
 #include "radiationModel.H"
 #include "volFields.H"
diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H
index d7f175fc5c6f373ed4e18bddd765d51dbb99e1ec..c22319fc244c2c01c0009b0d7dd8791edc3fad96 100644
--- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H
+++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef blackModyEmission_H
-#define blackModyEmission_H
+#ifndef radiation_blackBodyEmission_H
+#define radiation_blackBodyEmission_H
 
 #include "volFields.H"
 #include "dimensionedScalar.H"
diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C
index b8f959c1568606624d7a2e8995c8ba28bb51f6c8..3250cc66b00d1945bb92872353d51fdbb6cdb00d 100644
--- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C
+++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C
@@ -530,11 +530,11 @@ void Foam::radiation::fvDOM::setRayIdLambdaId
     label& lambdaId
 ) const
 {
-    // assuming name is in the form: CHARS_rayId_lambdaId
+    // Assuming name is in the form: CHARS_rayId_lambdaId
     const auto i1 = name.find('_');
-    const auto i2 = name.rfind('_');
+    const auto i2 = name.find('_', i1+1);
 
-    rayId = readLabel(name.substr(i1+1, i2-1));
+    rayId    = readLabel(name.substr(i1+1, i2-i1-1));
     lambdaId = readLabel(name.substr(i2+1));
 }
 
diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H
index 3c00d3b2872808eb14e16c46ebc35d2ae2b26863..419389c30c3e0ab373da5e815951a8a3ff06799f 100644
--- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H
+++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H
@@ -74,8 +74,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationModelfvDOM_H
-#define radiationModelfvDOM_H
+#ifndef radiation_fvDOM_H
+#define radiation_fvDOM_H
 
 #include "radiativeIntensityRay.H"
 #include "radiationModel.H"
diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C
index 97069ab988c1a9fc628cff168783a4559205e129..0afa37611330eea9672097cb75024c07cfb9cb88 100644
--- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C
+++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C
@@ -457,7 +457,7 @@ void Foam::radiation::solarLoad::calculateQdiff
                 label faceI = fineFaces[j];
                 label globalFaceI = faceI + pp.start();
 
-                if (findIndex(hitFacesId, globalFaceI) != -1)
+                if (hitFacesId.found(globalFaceI))
                 {
                     fullArea += sf[faceI];
                 }
diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H
index 52e2e9a36e2b6ab6f44f77b38cd0f17d6758d3da..be1e993710c8801205a95a39c8b9ea2047ccdb7a 100644
--- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H
+++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H
@@ -59,8 +59,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationModelsolarLoad_H
-#define radiationModelsolarLoad_H
+#ifndef radiation_solarLoad_H
+#define radiation_solarLoad_H
 
 #include "radiationModel.H"
 #include "singleCellFvMesh.H"
diff --git a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H
index 5bd75d92ae65df34b589463ca672bd9347d9e0bd..92ec802b4593bb297d309887bfb316462e8524df 100644
--- a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H
+++ b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.H
@@ -45,8 +45,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationModelviewFactor_H
-#define radiationModelviewFactor_H
+#ifndef radiation_viewFactor_H
+#define radiation_viewFactor_H
 
 #include "radiationModel.H"
 #include "singleCellFvMesh.H"
diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H
index f02d4a079d90a94d30253a366835bfe854c5ea46..8350cba6f7bd87bd42e545b36911a9a0baec1b45 100644
--- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H
+++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.H
@@ -30,8 +30,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationAbsorptionEmissionModel_H
-#define radiationAbsorptionEmissionModel_H
+#ifndef radiation_absorptionEmissionModel_H
+#define radiation_absorptionEmissionModel_H
 
 #include "IOdictionary.H"
 #include "autoPtr.H"
diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H
index 2771f938b613f4e13d9b2bce369bb05a4802c885..cf9397aac5301bcf83fd1a2c8d095301feb9c6ba 100644
--- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H
+++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationBinaryAbsorptionEmission_H
-#define radiationBinaryAbsorptionEmission_H
+#ifndef radiation_binaryAbsorptionEmission_H
+#define radiation_binaryAbsorptionEmission_H
 
 #include "absorptionEmissionModel.H"
 
diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H
index 357a31d2ba42efb65969bd0008df5699b1e13542..18fc7f349e11a408b3f29c8ce01befe6b5a47c73 100644
--- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H
+++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H
@@ -36,8 +36,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationConstantAbsorptionEmission_H
-#define radiationConstantAbsorptionEmission_H
+#ifndef radiation_constantAbsorptionEmission_H
+#define radiation_constantAbsorptionEmission_H
 
 #include "absorptionEmissionModel.H"
 
diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H
index 011df68dbb15782beeb540156a0a75aede6aa0c4..23ab5e9bb345c91c1049de84e5b3fadfcf9d1152 100644
--- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H
+++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationNoAbsorptionEmission_H
-#define radiationNoAbsorptionEmission_H
+#ifndef radiation_noAbsorptionEmission_H
+#define radiation_noAbsorptionEmission_H
 
 #include "absorptionEmissionModel.H"
 
diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H
index ac6357c3554e151e72f86e4c133198c753204e88..ccf024e6b2216eff0231e2ea237ca243fcad9cce 100644
--- a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H
+++ b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationConstantScatter_H
-#define radiationConstantScatter_H
+#ifndef radiation_constantScatter_H
+#define radiation_constantScatter_H
 
 #include "scatterModel.H"
 
diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H
index 095b4d966925e7e2ce20946b6ab19e4247452da5..2fb19569df2179e8b58e53236d8089b48aa84c56 100644
--- a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H
+++ b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationNoScatter_H
-#define radiationNoScatter_H
+#ifndef radiation_noScatter_H
+#define radiation_noScatter_H
 
 #include "scatterModel.H"
 
diff --git a/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H b/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H
index a3c2dee676b6da0676deb15ea6d2c8bdbce17517..2967f4c9595f8f35eff5ef44abc293114c5e6815 100644
--- a/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H
+++ b/src/thermophysicalModels/radiation/submodels/sootModel/sootModel/sootModel.H
@@ -29,8 +29,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationsootModel_H
-#define radiationsootModel_H
+#ifndef radiation_sootModel_H
+#define radiation_sootModel_H
 
 #include "IOdictionary.H"
 #include "autoPtr.H"
diff --git a/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H b/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H
index 44593c42ebe7a871099c59c519e1ccaa1515a342..e06c4e482981cfb3724e79adbb426744a5be7c88 100644
--- a/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H
+++ b/src/thermophysicalModels/radiation/submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationConstantTransmissivity_H
-#define radiationConstantTransmissivity_H
+#ifndef radiation_constantTransmissivity_H
+#define radiation_constantTransmissivity_H
 
 #include "transmissivityModel.H"
 
diff --git a/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H b/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H
index 517bf43771bd34c5c1e840a9b382a10e0c958a1e..9d264f82c6c82ca28058548ee7e832227b2fc1ec 100644
--- a/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H
+++ b/src/thermophysicalModels/radiation/submodels/transmissivityModel/noTransmissivity/noTransmissivity.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef radiationConstantScatter_H
-#define radiationConstantScatter_H
+#ifndef radiation_noTransmissivity_H
+#define radiation_noTransmissivity_H
 
 #include "transmissivityModel.H"
 
diff --git a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H
index 725ce90e3a8aaa568a1ef1a5f3fe390dd5982a52..4506f4cb6ea25bcc7009886524819b21d0c6506f 100644
--- a/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H
+++ b/src/thermophysicalModels/reactionThermo/psiuReactionThermo/heheuPsiThermo.H
@@ -32,8 +32,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef heheuReactionThermo_H
-#define heheuReactionThermo_H
+#ifndef heheuPsiThermo_H
+#define heheuPsiThermo_H
 
 #include "heThermo.H"
 
diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C
index 18d2a9367c88b7156f00416475d4142de400cacb..da945226ce33727cce0d7c576c5a5760b28bdd82 100644
--- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C
+++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReaction.C
@@ -112,8 +112,7 @@ template<class ReactionThermo>
 void Foam::solidReaction<ReactionThermo>::write(Ostream& os) const
 {
     OStringStream reaction;
-    os.writeKeyword("reaction") << solidReactionStr(reaction)
-        << token::END_STATEMENT << nl;
+    os.writeEntry("reaction", solidReactionStr(reaction));
 }
 
 
diff --git a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H
index 9bad3ba77840727756338bb93e87ba9b787388e9..897904f507398e6ea90096bebe875d5b55ce2e86 100644
--- a/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H
+++ b/src/thermophysicalModels/solidSpecie/reaction/Reactions/solidReaction/solidReactionI.H
@@ -40,7 +40,7 @@ inline Ostream& operator<<
 )
 {
     OStringStream reaction;
-    os << r.solidReactionStr(reaction)<< token::END_STATEMENT <<nl;
+    os << r.solidReactionStr(reaction) << token::END_STATEMENT <<nl;
     return os;
 }
 
diff --git a/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H b/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H
index 1ab4bcb50dda0bba6ba25b76dd9043d2ebae95c5..b9e8689047311aa2cfd223cc2c227abde45bca17 100644
--- a/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H
+++ b/src/thermophysicalModels/solidSpecie/reaction/reactionRate/solidArrheniusReactionRate/solidArrheniusReactionRateI.H
@@ -77,9 +77,9 @@ inline Foam::scalar Foam::solidArrheniusReactionRate::operator()
 
 inline void Foam::solidArrheniusReactionRate::write(Ostream& os) const
 {
-    os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Tcrit") << Tcrit_ << token::END_STATEMENT << nl;
+    os.writeEntry("A", A_);
+    os.writeEntry("Ta", Ta_);
+    os.writeEntry("Tcrit", Tcrit_);
 }
 
 
diff --git a/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H b/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H
index b5444f1e59a0ce5727fcb8eac363a58f3c4cbb18..b278c3c4605f747de02c1838e57b1189fd7c575c 100644
--- a/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H
+++ b/src/thermophysicalModels/solidSpecie/reaction/reactions/makeSolidReaction.H
@@ -29,8 +29,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef makeSolidReactionThermo_H
-#define makeSolidReactionThermo_H
+#ifndef makeSolidReaction_H
+#define makeSolidReaction_H
 
 #include "solidReaction.H"
 #include "IrreversibleReaction.H"
diff --git a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C
index 255cf2b93fd9b8c3f249f54c98d12993c466d1a5..2911baca562bfc3bbf3554d710b81a7399298746 100644
--- a/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C
+++ b/src/thermophysicalModels/specie/reaction/Reactions/NonEquilibriumReversibleReaction/NonEquilibriumReversibleReaction.C
@@ -196,19 +196,13 @@ void Foam::NonEquilibriumReversibleReaction
 {
     ReactionType<ReactionThermo>::write(os);
 
-    os  << indent << "forward" << nl;
-    os  << indent << token::BEGIN_BLOCK << nl;
-    os  << incrIndent;
+    os.beginBlock("forward");
     fk_.write(os);
-    os  << decrIndent;
-    os  << indent << token::END_BLOCK << nl;
+    os.endBlock();
 
-    os  << indent << "reverse" << nl;
-    os  << indent << token::BEGIN_BLOCK << nl;
-    os  << incrIndent;
+    os.beginBlock("reverse");
     rk_.write(os);
-    os  << decrIndent;
-    os  << indent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C
index 5da2f878c4b72175943a1a175bb6a3aeee484281..913f11a712beb26dba9b8f711ef347e6c7714482 100644
--- a/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C
+++ b/src/thermophysicalModels/specie/reaction/Reactions/Reaction/Reaction.C
@@ -386,8 +386,7 @@ template<class ReactionThermo>
 void Foam::Reaction<ReactionThermo>::write(Ostream& os) const
 {
     OStringStream reaction;
-    os.writeKeyword("reaction") << reactionStr(reaction)
-        << token::END_STATEMENT << nl;
+    os.writeEntry("reaction", reactionStr(reaction));
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C
index 6d3f2539fc3459496a136072502884797555aa77..f2a1e0c698dcaafaeb1a13ba305d82ffd27d77f2 100644
--- a/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C
+++ b/src/thermophysicalModels/specie/reaction/Reactions/ReactionList/ReactionList.C
@@ -106,20 +106,21 @@ bool Foam::ReactionList<ThermoType>::readReactionDict()
 template<class ThermoType>
 void Foam::ReactionList<ThermoType>::write(Ostream& os) const
 {
-    os  << "reactions" << nl;
-    os  << token::BEGIN_BLOCK << incrIndent << nl;
+    os.beginBlock("reactions");
 
     forAllConstIter(typename SLPtrList<Reaction<ThermoType>>, *this, iter)
     {
         const Reaction<ThermoType>& r = iter();
-        os  << indent << r.name() << nl
-            << indent << token::BEGIN_BLOCK << incrIndent << nl;
-        os.writeKeyword("type") << r.type() << token::END_STATEMENT << nl;
+
+        os.beginBlock(r.name());
+
+        os.writeEntry("type", r.type());
         r.write(os);
-        os  << decrIndent << indent << token::END_BLOCK << nl;
+
+        os.endBlock();
     }
 
-    os << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H
index 49ec48c71e47ae0c3b6b3c049b20be3a9d8c629d..75bed82ef27039299ae3c5db202233f9352bd750 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/ArrheniusReactionRate/ArrheniusReactionRateI.H
@@ -77,9 +77,9 @@ inline Foam::scalar Foam::ArrheniusReactionRate::operator()
 
 inline void Foam::ArrheniusReactionRate::write(Ostream& os) const
 {
-    os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
-    os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
+    os.writeEntry("A", A_);
+    os.writeEntry("beta", beta_);
+    os.writeEntry("Ta", Ta_);
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H
index fff348d4810fac34d746bfba8cfbc66bcd383c86..1ff54cd5f43091bbd59453146ac71442f77e1048 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/FallOffReactionRate/FallOffReactionRateI.H
@@ -68,10 +68,10 @@ Foam::FallOffReactionRate<ReactionRate, FallOffFunction>::operator()
     const scalarField& c
 ) const
 {
-    scalar k0 = k0_(p, T, c);
-    scalar kInf = kInf_(p, T, c);
+    const scalar k0 = k0_(p, T, c);
+    const scalar kInf = kInf_(p, T, c);
 
-    scalar Pr = k0*thirdBodyEfficiencies_.M(c)/kInf;
+    const scalar Pr = k0*thirdBodyEfficiencies_.M(c)/kInf;
 
     return kInf*(Pr/(1 + Pr))*F_(T, Pr);
 }
@@ -83,33 +83,21 @@ inline void Foam::FallOffReactionRate<ReactionRate, FallOffFunction>::write
     Ostream& os
 ) const
 {
-    os  << indent << "k0" << nl;
-    os  << indent << token::BEGIN_BLOCK << nl;
-    os  << incrIndent;
+    os.beginBlock("k0");
     k0_.write(os);
-    os  << decrIndent;
-    os  << indent << token::END_BLOCK << nl;
+    os.endBlock();
 
-    os  << indent << "kInf" << nl;
-    os  << indent << token::BEGIN_BLOCK << nl;
-    os  << incrIndent;
+    os.beginBlock("kInf");
     kInf_.write(os);
-    os  << decrIndent;
-    os  << indent << token::END_BLOCK << nl;
+    os.endBlock();
 
-    os  << indent << "F" << nl;
-    os  << indent << token::BEGIN_BLOCK << nl;
-    os  << incrIndent;
+    os.beginBlock("F");
     F_.write(os);
-    os  << decrIndent;
-    os  << indent << token::END_BLOCK << nl;
+    os.endBlock();
 
-    os  << indent << "thirdBodyEfficiencies" << nl;
-    os  << indent << token::BEGIN_BLOCK << nl;
-    os  << incrIndent;
+    os.beginBlock("thirdBodyEfficiencies");
     thirdBodyEfficiencies_.write(os);
-    os  << decrIndent;
-    os  << indent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H
index 7d2c9ecd791b158a1ae644fdfe4010bddc3bd725..992b3d9ea429023a2eb630867bb6727081fbd1a2 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/LandauTellerReactionRate/LandauTellerReactionRateI.H
@@ -100,11 +100,11 @@ inline Foam::scalar Foam::LandauTellerReactionRate::operator()
 
 inline void Foam::LandauTellerReactionRate::write(Ostream& os) const
 {
-    os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
-    os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("B") << B_ << token::END_STATEMENT << nl;
-    os.writeKeyword("C") << C_ << token::END_STATEMENT << nl;
+    os.writeEntry("A", A_);
+    os.writeEntry("beta", beta_);
+    os.writeEntry("Ta", Ta_);
+    os.writeEntry("B", B_);
+    os.writeEntry("C", C_);
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H
index 68cce0350da547c5abee5108da1bc10e1c319a2a..58975727b4e71f2595973c516edfb6dc284acbdf 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/SRIFallOffFunction/SRIFallOffFunctionI.H
@@ -67,11 +67,11 @@ inline Foam::scalar Foam::SRIFallOffFunction::operator()
 
 inline void Foam::SRIFallOffFunction::write(Ostream& os) const
 {
-    os.writeKeyword("a") << a_ << token::END_STATEMENT << nl;
-    os.writeKeyword("b") << b_ << token::END_STATEMENT << nl;
-    os.writeKeyword("c") << c_ << token::END_STATEMENT << nl;
-    os.writeKeyword("d") << d_ << token::END_STATEMENT << nl;
-    os.writeKeyword("e") << e_ << token::END_STATEMENT << nl;
+    os.writeEntry("a", a_);
+    os.writeEntry("b", b_);
+    os.writeEntry("c", c_);
+    os.writeEntry("d", d_);
+    os.writeEntry("e", e_);
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H
index 1913985c18de2017f72a3e9548f527afe1213b96..ab654e2103e1381f6b056ace13e882e8e828b7b9 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/fallOffFunctions/TroeFallOffFunction/TroeFallOffFunctionI.H
@@ -77,10 +77,10 @@ inline Foam::scalar Foam::TroeFallOffFunction::operator()
 
 inline void Foam::TroeFallOffFunction::write(Ostream& os) const
 {
-    os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Tsss") << Tsss_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Ts") << Ts_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Tss") << Tss_ << token::END_STATEMENT << nl;
+    os.writeEntry("alpha", alpha_);
+    os.writeEntry("Tsss", Tsss_);
+    os.writeEntry("Ts", Ts_);
+    os.writeEntry("Tss", Tss_);
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H b/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H
index fcf9b808c3bcc6c91d6a866aefe02d7523b25825..40dd268003271ec88e817839fa0d2385beeffe75 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/powerSeries/powerSeriesReactionRateI.H
@@ -84,10 +84,10 @@ inline Foam::scalar Foam::powerSeriesReactionRate::operator()
 
 inline void Foam::powerSeriesReactionRate::write(Ostream& os) const
 {
-    os.writeKeyword("A") << A_ << token::END_STATEMENT << nl;
-    os.writeKeyword("beta") << beta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("Ta") << Ta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("coeffs") << coeffs_ << token::END_STATEMENT << nl;
+    os.writeEntry("A", A_);
+    os.writeEntry("beta", beta_);
+    os.writeEntry("Ta", Ta_);
+    os.writeEntry("coeffs", coeffs_);
 }
 
 
diff --git a/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H b/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H
index 97a0e8eeed99e0d17827857c61c1a56c5b7e54a7..bcec76284b9a6918d12f8354a8ad4114ac7cf396 100644
--- a/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H
+++ b/src/thermophysicalModels/specie/reaction/reactionRate/thirdBodyEfficiencies/thirdBodyEfficienciesI.H
@@ -102,7 +102,7 @@ inline void Foam::thirdBodyEfficiencies::write(Ostream& os) const
         coeffs[i].second() = operator[](i);
     }
 
-    os.writeKeyword("coeffs") << coeffs << token::END_STATEMENT << nl;
+    os.writeEntry("coeffs", coeffs);
 }
 
 
diff --git a/src/thermophysicalModels/specie/transport/const/constTransport.C b/src/thermophysicalModels/specie/transport/const/constTransport.C
index 8b709c9c82161a3976341b6c5f1f47f8d987370a..2408dfb9cc6d38f469f112eb91e7a3611922b1c4 100644
--- a/src/thermophysicalModels/specie/transport/const/constTransport.C
+++ b/src/thermophysicalModels/specie/transport/const/constTransport.C
@@ -42,17 +42,19 @@ Foam::constTransport<Thermo>::constTransport(const dictionary& dict)
 template<class Thermo>
 void Foam::constTransport<Thermo>::constTransport::write(Ostream& os) const
 {
-    os  << this->name() << endl;
-    os  << token::BEGIN_BLOCK  << incrIndent << nl;
+    os.beginBlock(this->name());
 
     Thermo::write(os);
 
-    dictionary dict("transport");
-    dict.add("mu", mu_);
-    dict.add("Pr", 1.0/rPr_);
-    os  << indent << dict.dictName() << dict;
+    // Entries in dictionary format
+    {
+        os.beginBlock("transport");
+        os.writeEntry("mu", mu_);
+        os.writeEntry("Pr", scalar(1.0/rPr_));
+        os.endBlock();
+    }
 
-    os  << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C
index 27366f2893142fd005602359a267426b0c8e58c6..b35e2003df6c7da7adc0917b1f93330f3abb50e9 100644
--- a/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C
+++ b/src/thermophysicalModels/specie/transport/logPolynomial/logPolynomialTransport.C
@@ -57,25 +57,27 @@ Foam::logPolynomialTransport<Thermo, PolySize>::logPolynomialTransport
 template<class Thermo, int PolySize>
 void Foam::logPolynomialTransport<Thermo, PolySize>::write(Ostream& os) const
 {
-    os  << this->name() << endl;
-    os  << token::BEGIN_BLOCK << incrIndent << nl;
+    os.beginBlock(this->name());
 
     Thermo::write(os);
 
-    dictionary dict("transport");
-    dict.add
-    (
-        word("muLogCoeffs<" + Foam::name(PolySize) + '>'),
-        muCoeffs_
-    );
-    dict.add
-    (
-        word("kappaLogCoeffs<" + Foam::name(PolySize) + '>'),
-        kappaCoeffs_
-    );
-    os  << indent << dict.dictName() << dict;
+    // Entries in dictionary format
+    {
+        os.beginBlock("transport");
+        os.writeEntry
+        (
+            word("muLogCoeffs<" + Foam::name(PolySize) + '>'),
+            muCoeffs_
+        );
+        os.writeEntry
+        (
+            word("kappaLogCoeffs<" + Foam::name(PolySize) + '>'),
+            kappaCoeffs_
+        );
+        os.endBlock();
+    }
 
-    os  << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C
index cb907dd01d54396cdd818d80b94584c7d2c16338..88331a715ca7c7ade509b2790ddccacf92bb3c99 100644
--- a/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C
+++ b/src/thermophysicalModels/specie/transport/polynomial/polynomialTransport.C
@@ -57,25 +57,27 @@ Foam::polynomialTransport<Thermo, PolySize>::polynomialTransport
 template<class Thermo, int PolySize>
 void Foam::polynomialTransport<Thermo, PolySize>::write(Ostream& os) const
 {
-    os  << this->name() << endl;
-    os  << token::BEGIN_BLOCK << incrIndent << nl;
+    os.beginBlock(this->name());
 
     Thermo::write(os);
 
-    dictionary dict("transport");
-    dict.add
-    (
-        word("muCoeffs<" + Foam::name(PolySize) + '>'),
-        muCoeffs_
-    );
-    dict.add
-    (
-        word("kappaCoeffs<" + Foam::name(PolySize) + '>'),
-        kappaCoeffs_
-    );
-    os  << indent << dict.dictName() << dict;
+    // Entries in dictionary format
+    {
+        os.beginBlock("transport");
+        os.writeEntry
+        (
+            word("muCoeffs<" + Foam::name(PolySize) + '>'),
+            muCoeffs_
+        );
+        os.writeEntry
+        (
+            word("kappaCoeffs<" + Foam::name(PolySize) + '>'),
+            kappaCoeffs_
+        );
+        os.endBlock();
+    }
 
-    os  << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C
index 1fa07890149b1842532843dc6faae2b2c18ffee1..d3576c52ee3d3b95421247e29f74433bfa701714 100644
--- a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C
+++ b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C
@@ -68,17 +68,19 @@ Foam::sutherlandTransport<Thermo>::sutherlandTransport
 template<class Thermo>
 void Foam::sutherlandTransport<Thermo>::write(Ostream& os) const
 {
-    os  << this->specie::name() << endl
-        << token::BEGIN_BLOCK  << incrIndent << nl;
+    os.beginBlock(this->specie::name());
 
     Thermo::write(os);
 
-    dictionary dict("transport");
-    dict.add("As", As_);
-    dict.add("Ts", Ts_);
+    // Entries in dictionary format
+    {
+        os.beginBlock("transport");
+        os.writeEntry("As", As_);
+        os.writeEntry("Ts", Ts_);
+        os.endBlock();
+    }
 
-    os  << indent << dict.dictName() << dict
-        << decrIndent << token::END_BLOCK << nl;
+    os.endBlock();
 }
 
 
diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C
index e12b63b72534ec5048951f78aa98f4c20870fa5b..3f7bf842d0dfa375a7e28fee050fe9c17fa63d1f 100644
--- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C
+++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C
@@ -727,19 +727,19 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::write
 ) const
 {
     mixedFvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "p", "p", pName_);
-    writeEntryIfDifferent<word>(os, "U", "U", UName_);
-    writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
-    writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_);
-    writeEntryIfDifferent<word>(os, "Tnbr", "T", TnbrName_);
-    writeEntryIfDifferent<word>(os, "qrNbr", "none", qrNbrName_);
-    writeEntryIfDifferent<word>(os, "qr", "none", qrName_);
+    os.writeEntryIfDifferent<word>("p", "p", pName_);
+    os.writeEntryIfDifferent<word>("U", "U", UName_);
+    os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
+    os.writeEntryIfDifferent<word>("mu", "thermo:mu", muName_);
+    os.writeEntryIfDifferent<word>("Tnbr", "T", TnbrName_);
+    os.writeEntryIfDifferent<word>("qrNbr", "none", qrNbrName_);
+    os.writeEntryIfDifferent<word>("qr", "none", qrName_);
 
     if (fluid_)
     {
         os.writeEntry("mode", massModeTypeNames_[mode_]);
 
-        writeEntryIfDifferent<word>(os, "specie", "none", specieName_);
+        os.writeEntryIfDifferent<word>("specie", "none", specieName_);
 
         os.writeEntry("carrierMolWeight", Mcomp_);
 
diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H
index 258af191cc49421364394d3088007a36256945d3..f3f7fba5808013d50253d995307b4adc403f8235 100644
--- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H
+++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.H
@@ -217,7 +217,7 @@ private:
             //- Name of the radiative heat flux field
             const word qrName_;
 
-            //- Name of the species on which the mass transfered (default H2O)
+            //- Name of the species on which the mass transferred (default H2O)
             const word specieName_;
 
 
diff --git a/src/transportModels/incompressible/Make/files b/src/transportModels/incompressible/Make/files
index b181820bd83a285a2c20516f97be9c599452ca37..0c349c3bf57258e8cd03984266b08f9b88048155 100644
--- a/src/transportModels/incompressible/Make/files
+++ b/src/transportModels/incompressible/Make/files
@@ -7,6 +7,7 @@ viscosityModels/BirdCarreau/BirdCarreau.C
 viscosityModels/HerschelBulkley/HerschelBulkley.C
 viscosityModels/Casson/Casson.C
 viscosityModels/strainRateFunction/strainRateFunction.C
+viscosityModels/Arrhenius/Arrheniuss.C
 
 transportModel/transportModel.C
 singlePhaseTransportModel/singlePhaseTransportModel.C
diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C
new file mode 100644
index 0000000000000000000000000000000000000000..2e5014f7497b7f8196c532fccb9cb76d8da5b1da
--- /dev/null
+++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.C
@@ -0,0 +1,93 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+
+#include "Arrhenius.H"
+
+// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+
+template<class ViscousModel>
+Foam::tmp<Foam::volScalarField>
+Foam::viscosityModels::Arrhenius<ViscousModel>::calcNu
+(
+    const volScalarField& field
+) const
+{
+    return exp(-alpha_*(field - Talpha_));
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+template<class ViscousModel>
+Foam::viscosityModels::Arrhenius<ViscousModel>::Arrhenius
+(
+    const word& name,
+    const dictionary& viscosityProperties,
+    const volVectorField& U,
+    const surfaceScalarField& phi
+)
+:
+    ViscousModel(name, viscosityProperties, U, phi),
+    ArrheniusCoeffs_
+    (
+        viscosityProperties.optionalSubDict(typeName + "Coeffs")
+    ),
+    alpha_("alpha", inv(dimTemperature), ArrheniusCoeffs_),
+    Talpha_("Talpha", dimTemperature, ArrheniusCoeffs_),
+    fieldName_(ArrheniusCoeffs_.lookupOrDefault<word>("field","T")),
+    mesh_(U.mesh())
+{
+    const volScalarField* fieldPtr =
+        mesh_.lookupObjectPtr<volScalarField>(fieldName_);
+
+    if (fieldPtr)
+    {
+        this->nu_ *= calcNu(*fieldPtr);
+    }
+}
+
+
+// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
+
+template<class ViscousModel>
+bool Foam::viscosityModels::Arrhenius<ViscousModel>::read
+(
+    const dictionary& viscosityProperties
+)
+{
+    viscosityModel::read(viscosityProperties);
+
+    ArrheniusCoeffs_ =
+        viscosityProperties.optionalSubDict(typeName + "Coeffs");
+
+    ArrheniusCoeffs_.lookup("alpha") >> alpha_;
+    ArrheniusCoeffs_.lookup("Talpha") >> Talpha_;
+
+    return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H
new file mode 100644
index 0000000000000000000000000000000000000000..57ed3f2a102ffa6e6c749654d6ea1520e595c939
--- /dev/null
+++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrhenius.H
@@ -0,0 +1,145 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::viscosityModels::Arrhenius
+
+Description
+    Arrhenius type of dependency on a given scalar field name. Most likely
+    temperature. The expression is as follow:
+    \verbatim
+        mu = exp(-alpha_*(T - Talpha_))
+    \endverbatim
+
+SourceFiles
+    Arrhenius.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef Arrhenius_H
+#define Arrhenius_H
+
+#include "viscosityModel.H"
+#include "dimensionedScalar.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace viscosityModels
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class Arrhenius Declaration
+\*---------------------------------------------------------------------------*/
+
+template<class ViscousModel>
+class Arrhenius
+:
+    public ViscousModel
+{
+    // Private data
+
+        dictionary ArrheniusCoeffs_;
+
+        // Model coefficients
+        dimensionedScalar alpha_;
+        dimensionedScalar Talpha_;
+
+        //- Field used for as temperature
+        word fieldName_;
+
+        //- Auto pointer for scalar field
+        autoPtr<volScalarField> field_;
+
+        //- Reference to mesh
+        const fvMesh& mesh_;
+
+
+    // Private Member Functions
+
+        //- Calculate and return the laminar viscosity
+        tmp<volScalarField> calcNu(const volScalarField&) const;
+
+
+public:
+
+    //- Runtime type information
+    TypeName("Arrhenius");
+
+
+    // Constructors
+
+        //- Construct from components
+        Arrhenius
+        (
+            const word& name,
+            const dictionary& viscosityProperties,
+            const volVectorField& U,
+            const surfaceScalarField& phi
+        );
+
+
+    //- Destructor
+    virtual ~Arrhenius()
+    {}
+
+
+    // Member Functions
+
+        //- Correct the laminar viscosity
+        virtual void correct()
+        {
+            ViscousModel::correct();
+
+            const volScalarField* fieldPtr =
+                mesh_.lookupObjectPtr<volScalarField>(fieldName_);
+
+            if (fieldPtr)
+            {
+                this->nu_ *= calcNu(*fieldPtr);
+            }
+        }
+
+        //- Read transportProperties dictionary
+        virtual bool read(const dictionary& viscosityProperties);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace viscosityModels
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+#   include "Arrhenius.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C
new file mode 100644
index 0000000000000000000000000000000000000000..c150706d142403efd41415b9e820f339cdbf9801
--- /dev/null
+++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/Arrheniuss.C
@@ -0,0 +1,45 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "makeArrheniusTypes.H"
+
+#include "Arrhenius.H"
+
+#include "BirdCarreau.H"
+#include "Casson.H"
+#include "CrossPowerLaw.H"
+#include "HerschelBulkley.H"
+#include "Newtonian.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+makeArrheniusTypes(Arrhenius, BirdCarreau);
+makeArrheniusTypes(Arrhenius, Casson);
+makeArrheniusTypes(Arrhenius, CrossPowerLaw);
+makeArrheniusTypes(Arrhenius, HerschelBulkley);
+makeArrheniusTypes(Arrhenius, Newtonian);
+
+
+// ************************************************************************* //
diff --git a/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H b/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H
new file mode 100644
index 0000000000000000000000000000000000000000..242758ec5973addd37cc1c989d82c89fdd293104
--- /dev/null
+++ b/src/transportModels/incompressible/viscosityModels/Arrhenius/makeArrheniusTypes.H
@@ -0,0 +1,63 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef makeArrheniusTypes_H
+#define makeArrheniusTypes_H
+
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#define makeArrheniusTypes(ArrheniusType, visType)                           \
+                                                                             \
+    namespace Foam                                                           \
+    {                                                                        \
+        namespace viscosityModels                                            \
+        {                                                                    \
+            typedef ArrheniusType<visType>  ArrheniusType##visType;          \
+                                                                             \
+            addNamedToRunTimeSelectionTable                                  \
+            (                                                                \
+                viscosityModel,                                              \
+                ArrheniusType##visType,                                      \
+                dictionary,                                                  \
+                ArrheniusType##visType                                       \
+            );                                                               \
+        }                                                                    \
+                                                                             \
+        defineTemplateTypeNameAndDebugWithName                               \
+        (                                                                    \
+            viscosityModels::ArrheniusType##visType,                         \
+            #ArrheniusType"<"#visType">",                                    \
+            0                                                                \
+        );                                                                   \
+    }
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C
index cb486982c67c9442bcea2b7ca01e93f68dc5b186..11c992916ae9a97a5f1def7d4fa4b37877258893 100644
--- a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C
+++ b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -44,7 +44,7 @@ namespace viscosityModels
 }
 
 
-// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
 Foam::tmp<Foam::volScalarField>
 Foam::viscosityModels::BirdCarreau::calcNu() const
@@ -52,7 +52,7 @@ Foam::viscosityModels::BirdCarreau::calcNu() const
     return
         nuInf_
       + (nu0_ - nuInf_)
-       *pow(scalar(1) + pow(k_*strainRate(), a_), (n_ - 1.0)/a_);
+      * pow(scalar(1) + pow(k_*strainRate(), a_), (n_ - 1.0)/a_);
 }
 
 
diff --git a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H
index 1a1db601f75b684efbd937cfc62fba40246e710c..02dc3ebc3c4444c6cee051153b11896c8bc2f706 100644
--- a/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H
+++ b/src/transportModels/incompressible/viscosityModels/BirdCarreau/BirdCarreau.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -67,10 +67,14 @@ class BirdCarreau
         dimensionedScalar n_;
         dimensionedScalar a_;
 
-        volScalarField nu_;
 
+protected:
+
+    // Protected Data
+
+        volScalarField nu_;
 
-    // Private Member Functions
+    // Protected Member Functions
 
         //- Calculate and return the laminar viscosity
         tmp<volScalarField> calcNu() const;
diff --git a/src/transportModels/incompressible/viscosityModels/Casson/Casson.C b/src/transportModels/incompressible/viscosityModels/Casson/Casson.C
index 43e2807f138ec27011c4e7e263539b18e886227e..ff75e828d1db2f926826bb6989918a35219a0bf4 100644
--- a/src/transportModels/incompressible/viscosityModels/Casson/Casson.C
+++ b/src/transportModels/incompressible/viscosityModels/Casson/Casson.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2016-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -44,7 +44,7 @@ namespace viscosityModels
 }
 
 
-// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
 Foam::tmp<Foam::volScalarField>
 Foam::viscosityModels::Casson::calcNu() const
diff --git a/src/transportModels/incompressible/viscosityModels/Casson/Casson.H b/src/transportModels/incompressible/viscosityModels/Casson/Casson.H
index abdfe70bedacd758f6dd3854dffa3f9bfe2e657c..865e11ab7a74cf5bae2fd6abe349443d6c3a8622 100644
--- a/src/transportModels/incompressible/viscosityModels/Casson/Casson.H
+++ b/src/transportModels/incompressible/viscosityModels/Casson/Casson.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -90,10 +90,16 @@ class Casson
         dimensionedScalar nuMin_;
         dimensionedScalar nuMax_;
 
+
+
+protected:
+
+    // Protected data
+
         volScalarField nu_;
 
 
-    // Private Member Functions
+    // Protected Member Functions
 
         //- Calculate and return the laminar viscosity
         tmp<volScalarField> calcNu() const;
diff --git a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C
index 6b9ac760a789770023b98c8f5478623aaa1aecc5..3f7dbb3ff959990483f001105503851e5fe4ce43 100644
--- a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C
+++ b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -45,7 +45,7 @@ namespace viscosityModels
 }
 
 
-// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
 Foam::tmp<Foam::volScalarField>
 Foam::viscosityModels::CrossPowerLaw::calcNu() const
diff --git a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H
index a0f9ffe6baf2567b5454b5f64c22449daf4027fc..5b9bd885c190d0a9c960afd0034c319a7e0b93d2 100644
--- a/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H
+++ b/src/transportModels/incompressible/viscosityModels/CrossPowerLaw/CrossPowerLaw.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -63,9 +63,15 @@ class CrossPowerLaw
         dimensionedScalar m_;
         dimensionedScalar n_;
 
+
+protected:
+
+    // Protected data
+
         volScalarField nu_;
 
-    // Private Member Functions
+
+    // Protected Member Functions
 
         //- Calculate and return the laminar viscosity
         tmp<volScalarField> calcNu() const;
diff --git a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C
index 8f1656df140b167c4397060bcef499229fcfbf78..e6af2ad62bdb1fc84794c8b07e47e8cf57dfe48d 100644
--- a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C
+++ b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -45,7 +45,7 @@ namespace viscosityModels
 }
 
 
-// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
 Foam::tmp<Foam::volScalarField>
 Foam::viscosityModels::HerschelBulkley::calcNu() const
diff --git a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H
index df105b5807c93c597480026198a3e6da2060c462..a48eb988a184877be2c8a534e7651a416f04640b 100644
--- a/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H
+++ b/src/transportModels/incompressible/viscosityModels/HerschelBulkley/HerschelBulkley.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -63,10 +63,15 @@ class HerschelBulkley
         dimensionedScalar tau0_;
         dimensionedScalar nu0_;
 
+
+protected:
+
+    // Protected data
+
         volScalarField nu_;
 
 
-    // Private Member Functions
+    // Protected Member Functions
 
         //- Calculate and return the laminar viscosity
         tmp<volScalarField> calcNu() const;
diff --git a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C
index 2e6fd44423b858a2d624864673d6afbadfbb00d5..b0121ba1c99b35789af6f04effff744cf0db748f 100644
--- a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C
+++ b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H
index 481bbf945ecd40291662fc994048f288b8e53f00..abe6583fa139935e774ea3b3c530af8dfcd47b32 100644
--- a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H
+++ b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -58,11 +58,14 @@ class Newtonian
 
         dimensionedScalar nu0_;
 
-        volScalarField nu_;
-
 
 public:
 
+    // Protected data
+
+        volScalarField nu_;
+
+
     //- Runtime type information
     TypeName("Newtonian");
 
diff --git a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C
index ec84ba202851f1b388a93990d097f5298bde957b..ecdc46cc1bc64397d4d7406d503d15ba91bae86b 100644
--- a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C
+++ b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -45,7 +45,7 @@ namespace viscosityModels
 }
 
 
-// * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
 
 Foam::tmp<Foam::volScalarField>
 Foam::viscosityModels::powerLaw::calcNu() const
diff --git a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H
index e355a319d85eabd83f826d697c081dbfaf8aaeb2..453431785233f26d8713abd00f64d54a6aef8e7c 100644
--- a/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H
+++ b/src/transportModels/incompressible/viscosityModels/powerLaw/powerLaw.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -63,10 +63,15 @@ class powerLaw
         dimensionedScalar nuMin_;
         dimensionedScalar nuMax_;
 
+
+protected:
+
+    // Protected data
+
         volScalarField nu_;
 
 
-    // Private Member Functions
+    // Protected Member Functions
 
         //- Calculate and return the laminar viscosity
         tmp<volScalarField> calcNu() const;
diff --git a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C
index 29e0735bab1c4d3fd13b03664182ec3ad6c73ea3..22f117c55bba4561f82b86a0d27bbfc750e4d480 100644
--- a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C
+++ b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2016-2017 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H
index 90c102e322b02f38576979710785fd78dcade21b..d31099f4d0f46baa301b52661891aa7171d7e054 100644
--- a/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H
+++ b/src/transportModels/incompressible/viscosityModels/strainRateFunction/strainRateFunction.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -76,7 +76,11 @@ class strainRateFunction
         //- Strain-rate function
         autoPtr<Function1<scalar>> strainRateFunction_;
 
-        //- Current viscosity field
+
+protected:
+
+    // Protected data
+
         volScalarField nu_;
 
 
diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C
index 9a19092e0464a865daee7a7c45adea035e859a31..58593465835b45c898a918d26ea7f2effdb1f94e 100644
--- a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C
+++ b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C
@@ -106,10 +106,8 @@ bool Foam::surfaceTensionModels::constant::writeData(Ostream& os) const
         os  << sigma_ << token::END_STATEMENT << nl;
         return os.good();
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C
index 03fb3a106c75cbd13f791b2c9c63a1d37cf68472..0cf8f63b8bf551840f9973448e7486b1c3846501 100644
--- a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C
+++ b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C
@@ -128,10 +128,8 @@ bool Foam::surfaceTensionModels::temperatureDependent::writeData
         os  << sigma_() << token::END_STATEMENT << nl;
         return os.good();
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C
index c94e36ce778adc61ee8581701f93557a4f13134e..4594202d38c2a9dfd5f206e7911de30447fc19f3 100644
--- a/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C
+++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/constantAlphaContactAngle/constantAlphaContactAngleFvPatchScalarField.C
@@ -113,7 +113,7 @@ void Foam::constantAlphaContactAngleFvPatchScalarField::write
 ) const
 {
     alphaContactAngleFvPatchScalarField::write(os);
-    os.writeKeyword("theta0") << theta0_ << token::END_STATEMENT << nl;
+    os.writeEntry("theta0", theta0_);
     writeEntry("value", os);
 }
 
diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C
index b4a9db0062ae45939796add46cf81e95353f9c5a..e488fcd9ebbaa6ffd4c24c074a2ff892e41f1d81 100644
--- a/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C
+++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/dynamicAlphaContactAngle/dynamicAlphaContactAngleFvPatchScalarField.C
@@ -146,10 +146,10 @@ Foam::dynamicAlphaContactAngleFvPatchScalarField::theta
 void Foam::dynamicAlphaContactAngleFvPatchScalarField::write(Ostream& os) const
 {
     alphaContactAngleFvPatchScalarField::write(os);
-    os.writeKeyword("theta0") << theta0_ << token::END_STATEMENT << nl;
-    os.writeKeyword("uTheta") << uTheta_ << token::END_STATEMENT << nl;
-    os.writeKeyword("thetaA") << thetaA_ << token::END_STATEMENT << nl;
-    os.writeKeyword("thetaR") << thetaR_ << token::END_STATEMENT << nl;
+    os.writeEntry("theta0", theta0_);
+    os.writeEntry("uTheta", uTheta_);
+    os.writeEntry("thetaA", thetaA_);
+    os.writeEntry("thetaR", thetaR_);
     writeEntry("value", os);
 }
 
diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C
index 5eba3cc0b6c371746f979128a3aa7fe8e86c456b..8dfa30a477c0447f21f3de954e2e7d0703fe9b70 100644
--- a/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C
+++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/temperatureDependentAlphaContactAngle/temperatureDependentAlphaContactAngleFvPatchScalarField.C
@@ -121,7 +121,7 @@ void Foam::temperatureDependentAlphaContactAngleFvPatchScalarField::write
 ) const
 {
     alphaContactAngleFvPatchScalarField::write(os);
-    writeEntryIfDifferent<word>(os, "T", "T", TName_);
+    os.writeEntryIfDifferent<word>("T", "T", TName_);
     theta0_->writeData(os);
     writeEntry("value", os);
 }
diff --git a/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C b/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C
index d014b1c6fcd997b8f44814186f88da599d7f7fc0..3ed663eb687be76f75352d50d187c54e81ea8715 100644
--- a/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C
+++ b/src/transportModels/twoPhaseProperties/alphaContactAngle/timeVaryingAlphaContactAngle/timeVaryingAlphaContactAngleFvPatchScalarField.C
@@ -131,10 +131,10 @@ void Foam::timeVaryingAlphaContactAngleFvPatchScalarField::write
 ) const
 {
     alphaContactAngleFvPatchScalarField::write(os);
-    os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl;
-    os.writeKeyword("thetaT0") << thetaT0_ << token::END_STATEMENT << nl;
-    os.writeKeyword("te") << te_ << token::END_STATEMENT << nl;
-    os.writeKeyword("thetaTe") << thetaTe_ << token::END_STATEMENT << nl;
+    os.writeEntry("t0", t0_);
+    os.writeEntry("thetaT0", thetaT0_);
+    os.writeEntry("te", te_);
+    os.writeEntry("thetaTe", thetaTe_);
     writeEntry("value", os);
 }
 
diff --git a/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C b/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C
index 6117513bc992aa6ce37ccb7994291e9eb97c3d42..4e57fcba84f47ba8104ffc0a7f511942bb3fbba2 100644
--- a/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C
+++ b/src/waveModels/derivedFvPatchFields/waveAlpha/waveAlphaFvPatchScalarField.C
@@ -120,8 +120,7 @@ void Foam::waveAlphaFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
 
-    os.writeKeyword("waveDictName") << waveDictName_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("waveDictName", waveDictName_);
 
     writeEntry("value", os);
 }
diff --git a/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C b/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C
index a237aabbc1705ebd897bc189ba4766f216af8353..83fa6c64eae9c5bbfa4fc9ff4ea82d340c6b94d3 100644
--- a/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C
+++ b/src/waveModels/derivedFvPatchFields/waveVelocity/waveVelocityFvPatchVectorField.C
@@ -120,8 +120,7 @@ void Foam::waveVelocityFvPatchVectorField::write(Ostream& os) const
 {
     fvPatchField<vector>::write(os);
 
-    os.writeKeyword("waveDictName") << waveDictName_
-        << token::END_STATEMENT << nl;
+    os.writeEntry("waveDictName", waveDictName_);
 
     writeEntry("value", os);
 }
diff --git a/tutorials/Allrun b/tutorials/Allrun
index 28e4fe6a4515830aefbe4cbeff987f465e53a5fd..0a731b3fc90c94adc565338945942191e4f8321f 100755
--- a/tutorials/Allrun
+++ b/tutorials/Allrun
@@ -63,6 +63,9 @@ do
     -collect)
         optCollectOnly=true
         ;;
+    -test)   # Known options that should be passed through
+        break
+        ;;
     -*)
         usage "unknown option: $1"
         ;;
@@ -124,7 +127,7 @@ logReport()
 if [ -z "$optCollectOnly" ]
 then
     # Recursively run all tutorials
-    foamRunTutorials -test -skipFirst
+    foamRunTutorials -skipFirst $*
 fi
 
 
diff --git a/tutorials/Alltest b/tutorials/Alltest
index f192361942572b1e1a56421b8318f99a73779bb9..39da77fb7a6dec96bfaa02ed5ce748a3e5e085d8 100755
--- a/tutorials/Alltest
+++ b/tutorials/Alltest
@@ -244,7 +244,7 @@ fi
 
 
 cp -f $FOAM_TUTORIALS/Allrun .
-./Allrun
+./Allrun -test
 
 sed -e :a -e '/\\$/N; s/\\\n//; ta' Allrun > temp
 APPLICATIONS=\
diff --git a/tutorials/DNS/dnsFoam/boxTurb16/Allclean b/tutorials/DNS/dnsFoam/boxTurb16/Allclean
index d3bb35319566f89a63cf4f7a9b1fba5ec5f1b31d..63c2af729c6aa613d5be9311e404ad84deb088dd 100755
--- a/tutorials/DNS/dnsFoam/boxTurb16/Allclean
+++ b/tutorials/DNS/dnsFoam/boxTurb16/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -f 0/enstrophy
diff --git a/tutorials/DNS/dnsFoam/boxTurb16/Allrun b/tutorials/DNS/dnsFoam/boxTurb16/Allrun
index 125c236a6c74808003188cbb856c8644d66e7455..73fb0ad1aa26a7522b572aa0c4c66a9042feab17 100755
--- a/tutorials/DNS/dnsFoam/boxTurb16/Allrun
+++ b/tutorials/DNS/dnsFoam/boxTurb16/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication boxTurb
diff --git a/tutorials/IO/fileHandler/0/U b/tutorials/IO/fileHandler/0/U
index 75ed42fbdb44afad496e78afbf6667413c48fba6..04b73f9a93593c7d137caa8358b399821487c251 100644
--- a/tutorials/IO/fileHandler/0/U
+++ b/tutorials/IO/fileHandler/0/U
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/Allclean b/tutorials/IO/fileHandler/Allclean
new file mode 100755
index 0000000000000000000000000000000000000000..be7ddb068847225ad69704840909a7b0d05a5466
--- /dev/null
+++ b/tutorials/IO/fileHandler/Allclean
@@ -0,0 +1,7 @@
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/IO/fileHandler/Allrun b/tutorials/IO/fileHandler/Allrun
index d032798abbd2aa188c17a8c24176fa361bded855..1f90a49f6b26bae3fa71d11c7285b159a35ef4e7 100755
--- a/tutorials/IO/fileHandler/Allrun
+++ b/tutorials/IO/fileHandler/Allrun
@@ -1,14 +1,14 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
+application=$(getApplication)
+
 #- Test writing collated format
 runApplication decomposePar -fileHandler collated
-runParallel `getApplication` -fileHandler collated
+runParallel $application -fileHandler collated
 runApplication reconstructPar -latestTime -fileHandler collated
 
 #- Delete collated files
@@ -16,10 +16,10 @@ rm -rf processors
 
 #- Test writing uncollated format
 runApplication -s uncollated decomposePar -fileHandler uncollated
-runParallel -s uncollated `getApplication` -fileHandler uncollated
+runParallel -s uncollated $application -fileHandler uncollated
 
 #- Restart from uncollated
-runParallel -s collated `getApplication` -fileHandler collated
+runParallel -s collated $application -fileHandler collated
 runApplication -s collated reconstructPar -latestTime -fileHandler collated
 
 #- Convert the parallel format to uncollated
diff --git a/tutorials/IO/fileHandler/Alltest b/tutorials/IO/fileHandler/Alltest
new file mode 100755
index 0000000000000000000000000000000000000000..d5416642d47d45ed6574d8e5c7053f87ff97fe57
--- /dev/null
+++ b/tutorials/IO/fileHandler/Alltest
@@ -0,0 +1,14 @@
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+
+# Reset the controlDict
+if [ -f system/controlDict.orig ]
+then
+    echo "$0: restoring the controlDict from controlDict.orig"
+    mv system/controlDict.orig system/controlDict
+fi
+
+./Allrun
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/IO/fileHandler/constant/g b/tutorials/IO/fileHandler/constant/g
index 0cc222ca3457ed24bf9753d0926fbee84359e624..4702e33f63dacbb20139c0fd115011be321b4102 100644
--- a/tutorials/IO/fileHandler/constant/g
+++ b/tutorials/IO/fileHandler/constant/g
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/constant/kinematicCloudPositions b/tutorials/IO/fileHandler/constant/kinematicCloudPositions
index 1e2be4ebc84a21e14d489a9feba3dd9b048060d1..f2d697e58e05e324ff093fa175632d74a2626166 100644
--- a/tutorials/IO/fileHandler/constant/kinematicCloudPositions
+++ b/tutorials/IO/fileHandler/constant/kinematicCloudPositions
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/constant/kinematicCloudProperties b/tutorials/IO/fileHandler/constant/kinematicCloudProperties
index 41b8c64e80dc955344145935f27a2e3d8625b230..a52b7d2a0a443e928a26834bd7ffc5fa831517b6 100644
--- a/tutorials/IO/fileHandler/constant/kinematicCloudProperties
+++ b/tutorials/IO/fileHandler/constant/kinematicCloudProperties
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/constant/transportProperties b/tutorials/IO/fileHandler/constant/transportProperties
index dbbab9e9f0a37e238aae89ea3025bf9c5f8948fa..375de077121c0bacfbd96836b969c71662a2e2cf 100644
--- a/tutorials/IO/fileHandler/constant/transportProperties
+++ b/tutorials/IO/fileHandler/constant/transportProperties
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/constant/turbulenceProperties b/tutorials/IO/fileHandler/constant/turbulenceProperties
index c2c3b28a1b4e8f4a2cae55f58bd61f9b1a67b488..5eec04267266e7fd15e7701a875d683d5e658cd9 100644
--- a/tutorials/IO/fileHandler/constant/turbulenceProperties
+++ b/tutorials/IO/fileHandler/constant/turbulenceProperties
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/system/blockMeshDict b/tutorials/IO/fileHandler/system/blockMeshDict
index 359a48779aa64f4ab175ee53bf963ae6bd891e7f..f67edf5308bf4adb700b0d3b71402b5893aedfc3 100644
--- a/tutorials/IO/fileHandler/system/blockMeshDict
+++ b/tutorials/IO/fileHandler/system/blockMeshDict
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/system/controlDict b/tutorials/IO/fileHandler/system/controlDict
index 2ac8dc578761cff7aac28a19995a59970091e00b..d2090358217d0e658dc748b212bb992b102d9cc6 100644
--- a/tutorials/IO/fileHandler/system/controlDict
+++ b/tutorials/IO/fileHandler/system/controlDict
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/system/decomposeParDict b/tutorials/IO/fileHandler/system/decomposeParDict
index 0f07bb6aa8ba3f26536b73674eecd5e523fc6953..341581df062ab96de94f4c45669795c7a0f8813d 100644
--- a/tutorials/IO/fileHandler/system/decomposeParDict
+++ b/tutorials/IO/fileHandler/system/decomposeParDict
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/system/fvSchemes b/tutorials/IO/fileHandler/system/fvSchemes
index 12c112d4e08c5b98258dc62f526d3b9df7739cb5..2d0375715454f749ece7b803df5173a5247eaf7f 100644
--- a/tutorials/IO/fileHandler/system/fvSchemes
+++ b/tutorials/IO/fileHandler/system/fvSchemes
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/IO/fileHandler/system/fvSolution b/tutorials/IO/fileHandler/system/fvSolution
index 740eb61a4bcb97e64ae0b33558f5c7057e7a6d20..b72ad9583f3c6419780c52cf8f5db3ffb4d4528a 100644
--- a/tutorials/IO/fileHandler/system/fvSolution
+++ b/tutorials/IO/fileHandler/system/fvSolution
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/basic/laplacianFoam/flange/Allclean b/tutorials/basic/laplacianFoam/flange/Allclean
index dc38fab61fdacb0022970913862e87e614c30bb8..1c56b00e18e2767b3c2d27a34ffcb12d72805138 100755
--- a/tutorials/basic/laplacianFoam/flange/Allclean
+++ b/tutorials/basic/laplacianFoam/flange/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf Fieldview > /dev/null 2>&1
diff --git a/tutorials/basic/laplacianFoam/flange/Allrun b/tutorials/basic/laplacianFoam/flange/Allrun
index 59e996ba18f57017cacb2534754c9b3ba3c11d80..53a0f0634acd4bef19b0aa40b4e0c4d32e45a0c5 100755
--- a/tutorials/basic/laplacianFoam/flange/Allrun
+++ b/tutorials/basic/laplacianFoam/flange/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runAnsysToFoam()
 {
diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean
index bd7671dd1e75ac5648712771db49551bd4343e61..fad073e14312c34146bd5c64a803a9c9480e6869 100755
--- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean
+++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allclean
@@ -1,11 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase0
 
-cleanCase
 rm -f constant/polyMesh/boundary
 rm -f constant/polyMesh/zoneID
 
-rm -rf 0
-
 #------------------------------------------------------------------------------
diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun
index 07dafa9e9538a1bc0fff722e8dfea60f6a9f1ede..395446555eb05bf2c5026fb1afa8183c1da815d0 100755
--- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun
+++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre
index 16135b7062abc05e87173d93b3e9b3581ea8d825..baa7887883a881095cc39429a2c4ed0aaa15b0e4 100755
--- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre
+++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict
index 9f766ac272528f245b086c89fda9a36c82c09d6f..c09be9266f53c71458d04d3b062930bc13fa6a38 100644
--- a/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict
+++ b/tutorials/basic/overLaplacianDyMFoam/heatTransfer/constant/dynamicMeshDict
@@ -25,9 +25,4 @@ displacementLaplacianCoeffs
 
 dynamicFvMesh       dynamicOversetFvMesh;
 
-dynamicOversetFvMeshCoeffs
-{
-//    layerRelax 0.3;
-}
-
 // ************************************************************************* //
diff --git a/tutorials/basic/potentialFoam/cylinder/Allclean b/tutorials/basic/potentialFoam/cylinder/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/basic/potentialFoam/cylinder/Allclean
+++ b/tutorials/basic/potentialFoam/cylinder/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/basic/potentialFoam/cylinder/Allrun b/tutorials/basic/potentialFoam/cylinder/Allrun
index 6e5e8f42de9a538b6f6f88ac9f040ad1fbce551d..754c15e58c070452c93b935e0e7d55aa377b8a6a 100755
--- a/tutorials/basic/potentialFoam/cylinder/Allrun
+++ b/tutorials/basic/potentialFoam/cylinder/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/basic/potentialFoam/pitzDaily/Allclean b/tutorials/basic/potentialFoam/pitzDaily/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/basic/potentialFoam/pitzDaily/Allclean
+++ b/tutorials/basic/potentialFoam/pitzDaily/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/basic/potentialFoam/pitzDaily/Allrun b/tutorials/basic/potentialFoam/pitzDaily/Allrun
index b4667497e463182f3b51997d62610e2ab32993a1..6ea7923d16b4d1bcee098b82a26edeba301da388 100755
--- a/tutorials/basic/potentialFoam/pitzDaily/Allrun
+++ b/tutorials/basic/potentialFoam/pitzDaily/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean
index 189dd60ac401acae1a0b835dabe0860cd76d32a6..b6e861cc69cf5bac739cb28b55bfa2241f4dcacc 100755
--- a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean
+++ b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf VTK
 
diff --git a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun
index 312f7aa370c487b73497f6464b0f38f8575d1733..509c9850525e2342b1c3d50971e107df6d568940 100755
--- a/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun
+++ b/tutorials/combustion/PDRFoam/flamePropagationWithObstacles/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean
+++ b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun
index fa51ae65e3c2e62df30538111ca04090a28ff9db..5e6d5291c4c1add0115d5cca9c74794aa8649277 100755
--- a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun
+++ b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.mesh
 
diff --git a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh
index 59a8b9b93db8b8db05b5dcd21271cbfe54fba2ae..28b75a27c1dd50da5e65acf0fddc59c43f684f58 100755
--- a/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh
+++ b/tutorials/combustion/XiDyMFoam/annularCombustorTurbine/Allrun.mesh
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/combustion/XiFoam/RAS/Allclean b/tutorials/combustion/XiFoam/RAS/Allclean
index edc01a252b9678bc3421b20a1717592078019239..39e9b455bf72e7541b306044ee21bdfd1f27270a 100755
--- a/tutorials/combustion/XiFoam/RAS/Allclean
+++ b/tutorials/combustion/XiFoam/RAS/Allclean
@@ -1,19 +1,13 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 keepCases="moriyoshiHomogeneous"
 loseCases="moriyoshiHomogeneousPart2 moriyoshiHomogeneousHydrogen"
 
 for caseName in $keepCases
 do
-(
-    cd $caseName || exit
-
-    foamCleanTutorials
-)
+    ( cd $caseName && foamCleanTutorials )
 done
 
 for caseName in $loseCases
diff --git a/tutorials/combustion/XiFoam/RAS/Allrun b/tutorials/combustion/XiFoam/RAS/Allrun
index b3d0e3bf1d5307f996015d6d5f7b72e1f47437da..213d7e066483e5ce31902fc3ac5de5a7c54714bc 100755
--- a/tutorials/combustion/XiFoam/RAS/Allrun
+++ b/tutorials/combustion/XiFoam/RAS/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 setControlDict()
 {
diff --git a/tutorials/combustion/chemFoam/gri/Allclean b/tutorials/combustion/chemFoam/gri/Allclean
index 6d98f58208e76f0aa4e0aff3d6de550c49b0e268..9bc42acc50cf995413c5d888773ac5fca486d54c 100755
--- a/tutorials/combustion/chemFoam/gri/Allclean
+++ b/tutorials/combustion/chemFoam/gri/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf chemFoam.out constant/reactions constant/thermo \
    validation/OF_vs_CHEMKINII.eps validation/chemkinII
diff --git a/tutorials/combustion/chemFoam/gri/Allrun b/tutorials/combustion/chemFoam/gri/Allrun
index 9f91a1a6ccd1687bb46e465196a6d7615ee700d8..192618695d35623fd02a3adf040de68de371af1a 100755
--- a/tutorials/combustion/chemFoam/gri/Allrun
+++ b/tutorials/combustion/chemFoam/gri/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 runApplication chemkinToFoam \
diff --git a/tutorials/combustion/chemFoam/h2/Allclean b/tutorials/combustion/chemFoam/h2/Allclean
index 5d4bbd8d8453e850056d9668225ca6bf23b7d194..e01a93433e6ae57c05bd13269b7fd8531d3bf1c8 100755
--- a/tutorials/combustion/chemFoam/h2/Allclean
+++ b/tutorials/combustion/chemFoam/h2/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII
 
diff --git a/tutorials/combustion/chemFoam/h2/Allrun b/tutorials/combustion/chemFoam/h2/Allrun
index a90b3d865ce2bdd38cc3bc1255897171006ae8e7..bf06d218a86fce91c7f35af8883679cf4d1267d7 100755
--- a/tutorials/combustion/chemFoam/h2/Allrun
+++ b/tutorials/combustion/chemFoam/h2/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication $(getApplication)
 
diff --git a/tutorials/combustion/chemFoam/ic8h18/Allclean b/tutorials/combustion/chemFoam/ic8h18/Allclean
index 5d4bbd8d8453e850056d9668225ca6bf23b7d194..e01a93433e6ae57c05bd13269b7fd8531d3bf1c8 100755
--- a/tutorials/combustion/chemFoam/ic8h18/Allclean
+++ b/tutorials/combustion/chemFoam/ic8h18/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII
 
diff --git a/tutorials/combustion/chemFoam/ic8h18/Allrun b/tutorials/combustion/chemFoam/ic8h18/Allrun
index a90b3d865ce2bdd38cc3bc1255897171006ae8e7..bf06d218a86fce91c7f35af8883679cf4d1267d7 100755
--- a/tutorials/combustion/chemFoam/ic8h18/Allrun
+++ b/tutorials/combustion/chemFoam/ic8h18/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication $(getApplication)
 
diff --git a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean
index 5d4bbd8d8453e850056d9668225ca6bf23b7d194..e01a93433e6ae57c05bd13269b7fd8531d3bf1c8 100755
--- a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean
+++ b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII
 
diff --git a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun
index a90b3d865ce2bdd38cc3bc1255897171006ae8e7..bf06d218a86fce91c7f35af8883679cf4d1267d7 100755
--- a/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun
+++ b/tutorials/combustion/chemFoam/ic8h18_TDAC/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication $(getApplication)
 
diff --git a/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph b/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph
index 43e3c36e10e910f240ba3fc82ae5174b669e6464..ebb4474dddaa948b04b7b6a913ae37ffc3587ebb 100755
--- a/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph
+++ b/tutorials/combustion/chemFoam/ic8h18_TDAC/validation/createGraph
@@ -21,4 +21,4 @@ gnuplot<<EOF
         "chemkinII" with lines title "Chemkin II" lt -1
 EOF
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/combustion/chemFoam/nc7h16/Allclean b/tutorials/combustion/chemFoam/nc7h16/Allclean
index 5d4bbd8d8453e850056d9668225ca6bf23b7d194..e01a93433e6ae57c05bd13269b7fd8531d3bf1c8 100755
--- a/tutorials/combustion/chemFoam/nc7h16/Allclean
+++ b/tutorials/combustion/chemFoam/nc7h16/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf chemFoam.out validation/OF_vs_CHEMKINII.eps validation/chemkinII
 
diff --git a/tutorials/combustion/chemFoam/nc7h16/Allrun b/tutorials/combustion/chemFoam/nc7h16/Allrun
index a90b3d865ce2bdd38cc3bc1255897171006ae8e7..bf06d218a86fce91c7f35af8883679cf4d1267d7 100755
--- a/tutorials/combustion/chemFoam/nc7h16/Allrun
+++ b/tutorials/combustion/chemFoam/nc7h16/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication $(getApplication)
 
diff --git a/tutorials/combustion/engineFoam/kivaTest/Allclean b/tutorials/combustion/engineFoam/kivaTest/Allclean
index b1fa019711a5844a72090782a6fc7ee413f96646..71df6ecdbb34314289cd609ecfa484a1d1b70890 100755
--- a/tutorials/combustion/engineFoam/kivaTest/Allclean
+++ b/tutorials/combustion/engineFoam/kivaTest/Allclean
@@ -1,13 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 mv ./-180 temp180
 
-cleanCase
-rm -rf 0
+cleanCase0
 
 mv temp180 ./-180
 
diff --git a/tutorials/combustion/engineFoam/kivaTest/Allrun b/tutorials/combustion/engineFoam/kivaTest/Allrun
index d5434dff00792b057defd27be919037c2fc163d6..80677173bdf09b936f93ea7b94722a9a46008dc0 100755
--- a/tutorials/combustion/engineFoam/kivaTest/Allrun
+++ b/tutorials/combustion/engineFoam/kivaTest/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication kivaToFoam -file otape17
 runApplication $(getApplication)
diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean b/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean
index 3ed713392c5bcec015f5dacfb51ed1e491b94209..9ead8681dec50a28f753ceeb57dae59efa309498 100755
--- a/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean
+++ b/tutorials/combustion/fireFoam/LES/compartmentFire/Allclean
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf constant/panelRegion/polyMesh
 rm -f constant/polyMesh/boundary
 rm -f validation/*.eps
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun b/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun
index 1fb613fedb3c671fbddaa847cdef14fba898b88e..c09ed1e6e3efcac7f098e8a97e64df0f7629ef76 100755
--- a/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun
+++ b/tutorials/combustion/fireFoam/LES/compartmentFire/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create the blockMesh file with the parametric one
 m4 system/blockMeshDict.m4 > system/blockMeshDict
@@ -25,4 +23,4 @@ paraFoam -touch -region panelRegion
 
 (cd validation && ./createGraphs)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean
index 615ace08b7634a42abae50e2049a2cdf69c8cb17..b38edacb8971ae89be405fe393a89e387238a4a1 100755
--- a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean
+++ b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun
index b18a484335d8d4fee91263182d1df98c96de8c83..e99924ab9d446177eb24f250e4165f6937a39d5c 100755
--- a/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun
+++ b/tutorials/combustion/fireFoam/LES/flameSpreadWaterSuppressionPanel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create the underlying block mesh
 runApplication blockMesh
diff --git a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean
index f8c61931336992636c285da8b21da0c2148281bf..fcfdc3257786af032eb6251eabfdf9b08f3a5576 100755
--- a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean
+++ b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun
index c46299855a1fe7dc288e8fbc4c884440ff63180f..259ca145a6bd3c14ad190ab831f4e4bede57b4a3 100755
--- a/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun
+++ b/tutorials/combustion/fireFoam/LES/oppositeBurningPanels/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean
index b333961d48f9124298c175446d2196d3676d2e5f..2e8de5d05fc635a9e9306804d73eddb8e3a3da3f 100755
--- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean
+++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allclean
@@ -1,10 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf constant/panelRegion/polyMesh
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun
index ba88bc10f317372bcd9c32c27fadb6ed300ee4a5..dcd2bad0e5abb686bd824b9dc44c92afe5662646 100755
--- a/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun
+++ b/tutorials/combustion/fireFoam/LES/simplePMMApanel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
@@ -11,4 +9,4 @@ runApplication $(getApplication)
 
 paraFoam -touchAll
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean
index 333e5d8d25c956532ffb0fb461942c45435ea576..b75804a65ba7061ab8ad898306b05b412f4ff74c 100755
--- a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean
+++ b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun
index 942f56f2ec95697f5bcb7f25d2559e66d9d71918..39af3c029d819c14b225e594f867b960f05246d3 100755
--- a/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun
+++ b/tutorials/combustion/fireFoam/LES/smallPoolFire2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean
index 333e5d8d25c956532ffb0fb461942c45435ea576..b75804a65ba7061ab8ad898306b05b412f4ff74c 100755
--- a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean
+++ b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun
index 8c42b7a25ef1f2eba1d6c1e537f79c1a4cbc3cf2..de0f52b40bc764fb4eaca0390db2ce80d2cdfc9b 100755
--- a/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun
+++ b/tutorials/combustion/fireFoam/LES/smallPoolFire3D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean
index 79defe511db3961aef05948e2cf327f0554141a2..c81ffab9ed93a3bc624ae31c2b65c57c63e53800 100755
--- a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean
+++ b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun
index 40a38f4eca58a6fc70171b1a5423243ddb598b1a..1476376f4437f3d9c9b5ab545b213f732ef1ec59 100755
--- a/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun
+++ b/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/Allrun
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
-# Set application name
-application=`getApplication`
+# Application name
+application=$(getApplication)
 
 rm -f 0/T
 cp 0/T.orig 0/T
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean
index 9f691c93851e250425529116772e1d82b81075f2..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allclean
@@ -1,11 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun
index ae405888c0b42ff0b3444c42f758f192c23cb30a..6299aedeab7a4c63664f091a4145ba57c73b18d0 100755
--- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun
+++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/Allrun
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
-# Set application name
-application=`getApplication`
+# Application name
+application=$(getApplication)
 
 rm -f 0
 cp -r 0.orig 0
diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean
index a5e65c7d81ba11f5fce4451cefd5d25886c31879..f2d7cca6654b78c6b98a88e7508f8ab445a8a4e7 100755
--- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean
+++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 cleanSamples
diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun
index 1df0a7e3419e9433aed19dde83e8e2d51872a990..544ba54bad5f20703ae9980773cca56e47748666 100755
--- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun
+++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/compressible/rhoCentralFoam/shockTube/Allclean b/tutorials/compressible/rhoCentralFoam/shockTube/Allclean
index b6716d88fb7ded1749f9a99015171afd16e43228..69fe9734a911dd273f314f1a77c9b161d1ecb164 100755
--- a/tutorials/compressible/rhoCentralFoam/shockTube/Allclean
+++ b/tutorials/compressible/rhoCentralFoam/shockTube/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
+cleanCase0
 cleanSamples
-rm -rf 0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/compressible/rhoCentralFoam/shockTube/Allrun b/tutorials/compressible/rhoCentralFoam/shockTube/Allrun
index 4e1c0a9fbc8c39397a0fb6938f290c9b24b6b467..055484463abf8e7f90c4c8def930c4a77e758ec8 100755
--- a/tutorials/compressible/rhoCentralFoam/shockTube/Allrun
+++ b/tutorials/compressible/rhoCentralFoam/shockTube/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean
index f60abaf9c58489fb3f98e795e9de6174113713bc..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean
+++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean
@@ -1,9 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-\rm -rf 0
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun
index 9961aeb245f821f2cda555bec28ce9050f0df6fd..528f1a0404d2c9b3c64f7c308247d32e1bbb74cc 100755
--- a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun
+++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun
@@ -1,11 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
 runApplication -s preProcess $(getApplication) -postProcess -dict system/preProcess
 runApplication decomposePar
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean
index 14de6e88627c50004596ae2063b3c26b5f77355d..794ee1b81e450e08eef569e83f6b4e7069c02877 100755
--- a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean
+++ b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
 
diff --git a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun
index e7b28d6aa52861d4a38cd519dd01d8ef4dc69209..2b52d36edd8d9cd23238cf0baffb8b0d89c9bfe5 100755
--- a/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun
+++ b/tutorials/compressible/rhoPimpleDyMFoam/annularThermalMixer/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication surfaceFeatureExtract
 
diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions b/tutorials/compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions
new file mode 100644
index 0000000000000000000000000000000000000000..ac606224c7e51b7cbf11c5ab8c4688f1d5a69891
--- /dev/null
+++ b/tutorials/compressible/rhoPimpleFoam/RAS/TJunction/constant/fvOptions
@@ -0,0 +1,22 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    location    "constant";
+    object      fvOptions;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+viscousDissipation
+{
+    type            viscousDissipation;
+    enabled         true;
+}
+// ************************************************************************* //
diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun
index ccdfefe5c1ce337739caa5bddd0affe3cfc4aad0..54368cee898fed93435e246ad8a5c58cca03fd25 100755
--- a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun
+++ b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuct/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun
index ccdfefe5c1ce337739caa5bddd0affe3cfc4aad0..54368cee898fed93435e246ad8a5c58cca03fd25 100755
--- a/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun
+++ b/tutorials/compressible/rhoPimpleFoam/RAS/angledDuctLTS/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun
index 52b2a4941d73838617c1741cb20f1d4a5f4acdf5..5db0a1c8e5a022ae01d798031504740b33e1af13 100755
--- a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun
+++ b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh
index aad5edd02d75571bc5e3e6e4f29cd2168d76bf87..6f4a3fffe32ce8d115e55d8dacdf26faabf07ade 100755
--- a/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh
+++ b/tutorials/compressible/rhoPimpleFoam/RAS/mixerVessel2D/makeMesh
@@ -1,8 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 < system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean
index 92ec2e3cea000256ad300a5305b206a7669f8c29..2b124ecf38e9277815a4b8a05a0f1c0010d0bd8a 100755
--- a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean
+++ b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun
index 0e6804513047c17e3a7bcd78fcb4c8d4332a93cc..8143eddba2bb6037fb48813abc8507770373f479 100755
--- a/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun
+++ b/tutorials/compressible/rhoPimpleFoam/laminar/helmholtzResonance/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 # Run function links the appropriate mesh files and clones the case
diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean
+++ b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun
index 8a77ff8076363a01e3fc0e676fcf87e9a5223fd5..e0f9af4df86f647b2876b3684279d5d511b10570 100755
--- a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun
+++ b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean
index 7b7e1442f81b825413c545d22f7806af23753774..0686c27498f37a8e90e1b5a68d7a28933ba0ff1e 100755
--- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean
+++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allclean
@@ -1,12 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
+cleanCase0
 
 # Remove copies of common files
-\rm -rf 0 constant
+\rm -rf constant
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun
index f7891cd4f8df9f1be6a16b6db919eb753c5bfee4..1331199845154dbb44579ed7c6bdc51a40ff4d2f 100755
--- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun
+++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/explicit/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 echo "Use common files for 0/, constant/ and blockMeshDict"
 \rm -rf 0 constant
diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean
index 7b7e1442f81b825413c545d22f7806af23753774..0686c27498f37a8e90e1b5a68d7a28933ba0ff1e 100755
--- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean
+++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allclean
@@ -1,12 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
+cleanCase0
 
 # Remove copies of common files
-\rm -rf 0 constant
+\rm -rf constant
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun
index f7891cd4f8df9f1be6a16b6db919eb753c5bfee4..1331199845154dbb44579ed7c6bdc51a40ff4d2f 100755
--- a/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun
+++ b/tutorials/compressible/rhoPorousSimpleFoam/angledDuct/implicit/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 echo "Use common files for 0/, constant/ and blockMeshDict"
 \rm -rf 0 constant
diff --git a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun
index ccdfefe5c1ce337739caa5bddd0affe3cfc4aad0..54368cee898fed93435e246ad8a5c58cca03fd25 100755
--- a/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun
+++ b/tutorials/compressible/rhoSimpleFoam/angledDuctExplicitFixedCoeff/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean
index deba0577f492b1007b08568e94ac898c202b9646..6eb1457dbc3fa1a25ee448afe5b03a927224a3bd 100755
--- a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean
+++ b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -f  constant/triSurface/*.eMesh*     > /dev/null 2>&1
 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
diff --git a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun
index a8d8e758dd11afa03f784a9f055f32a2209cf75d..ea3d94ccaebdce089acc03bf86bec185a199b080 100755
--- a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun
+++ b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.mesh
 
diff --git a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh
index 4a2c4342d1f85a57e41bd046131ef099e93f3ec9..4c4121816cc6c28aa1f432b34881706a0d44cdb9 100755
--- a/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh
+++ b/tutorials/compressible/rhoSimpleFoam/gasMixing/injectorPipe/Allrun.mesh
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication surfaceFeatureExtract
diff --git a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean
index 1deb20913349eeacef2f946da013700e1da32287..e681fce19f5f780aa6e065603284208f630df410 100755
--- a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean
+++ b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun
index 4b94147c58f8399495b304f17bd32f292000cd9c..8bd01b9e40fc3b339c328ef4f274b6a1c0f5ec46 100755
--- a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun
+++ b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Convert mesh from resources directory
 runApplication star4ToFoam -scale 1 \
diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean b/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean
index b6716d88fb7ded1749f9a99015171afd16e43228..69fe9734a911dd273f314f1a77c9b161d1ecb164 100755
--- a/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean
+++ b/tutorials/compressible/sonicFoam/laminar/shockTube/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
+cleanCase0
 cleanSamples
-rm -rf 0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun b/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun
index 4a38818ccc6299069bae93f5c8f48764be3b9ae1..5ef8615ad95fec2eabc38aff5c930b1c5a395136 100755
--- a/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun
+++ b/tutorials/compressible/sonicFoam/laminar/shockTube/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/compressible/sonicLiquidFoam/Allclean b/tutorials/compressible/sonicLiquidFoam/Allclean
index aa8cb7bc24c358893ca6bc0faa48766d84edc0ec..cbd249f6efbb5b00592ca006a4c38c9f1f4d7b9a 100755
--- a/tutorials/compressible/sonicLiquidFoam/Allclean
+++ b/tutorials/compressible/sonicLiquidFoam/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 removeCase decompressionTankFine
 foamCleanTutorials cases
diff --git a/tutorials/compressible/sonicLiquidFoam/Allrun b/tutorials/compressible/sonicLiquidFoam/Allrun
index deb3e8f4c6ec6c8798de5ea2e8e29f4ed2f9beb1..f7f2c64c0426d3592e1518dc11092579cd0a6ca0 100755
--- a/tutorials/compressible/sonicLiquidFoam/Allrun
+++ b/tutorials/compressible/sonicLiquidFoam/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 setDecompressionTankFine()
 {
diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean
index 36f3cdc151b3fb59017fe01f9688e56f069e4e1f..40d55b2780e1d33ea9c069b8c3fa0d17e7d89466 100755
--- a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean
+++ b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allclean
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
+
 rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun
index d56e57bf75b28c7a2a795908570a5ddeafd88e68..ffa109248bc46fe2a6cfa937c25b89e49e9bcf75 100755
--- a/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun
+++ b/tutorials/discreteMethods/dsmcFoam/freeSpacePeriodic/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication dsmcInitialise
diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean
index 36f3cdc151b3fb59017fe01f9688e56f069e4e1f..40d55b2780e1d33ea9c069b8c3fa0d17e7d89466 100755
--- a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean
+++ b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allclean
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
+
 rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun
index d56e57bf75b28c7a2a795908570a5ddeafd88e68..ffa109248bc46fe2a6cfa937c25b89e49e9bcf75 100755
--- a/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun
+++ b/tutorials/discreteMethods/dsmcFoam/freeSpaceStream/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication dsmcInitialise
diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean
index 36f3cdc151b3fb59017fe01f9688e56f069e4e1f..40d55b2780e1d33ea9c069b8c3fa0d17e7d89466 100755
--- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean
+++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allclean
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
+
 rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun
index d433a8c02696351d94bc86c06d9f46dfe5e8702a..0c110250f64d4e72af0e6430c446a4de84065b11 100755
--- a/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun
+++ b/tutorials/discreteMethods/dsmcFoam/supersonicCorner/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication decomposePar
diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean
index 36f3cdc151b3fb59017fe01f9688e56f069e4e1f..40d55b2780e1d33ea9c069b8c3fa0d17e7d89466 100755
--- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean
+++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allclean
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
+
 rm -rf 0/lagrangian 0/dsmcSigmaTcRMax 0/uniform > /dev/null 2>&1
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun
index d433a8c02696351d94bc86c06d9f46dfe5e8702a..0c110250f64d4e72af0e6430c446a4de84065b11 100755
--- a/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun
+++ b/tutorials/discreteMethods/dsmcFoam/wedge15Ma5/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication decomposePar
diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean
index 194c42b8c6233e8ac32fe9af0a404b0e4c87fec8..2b07ff650e14ce13b21d4fce16b8d80b269eea05 100755
--- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean
+++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun
index 31e783b003a15e72b62176dbfd6a700dc9f98a0a..2ec6f7b07787b67e675e822e53b173d11be5a8b0 100755
--- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun
+++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeArgon/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication mdInitialise
diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean
index d52fe88c714670d852505bca2f7a2809c2ebdf6c..ca2f48ed946d2ff786cc1cad3152a06d475edd6c 100755
--- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean
+++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun
index 31e783b003a15e72b62176dbfd6a700dc9f98a0a..2ec6f7b07787b67e675e822e53b173d11be5a8b0 100755
--- a/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun
+++ b/tutorials/discreteMethods/molecularDynamics/mdEquilibrationFoam/periodicCubeWater/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication mdInitialise
diff --git a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean
index 7fa5428f73ef770d9a80f24404f72379d39aa6c9..bc26045cbdaa72021233f6d9ac711e64d37c1280 100755
--- a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean
+++ b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf processor[0-9]
diff --git a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun
index 66482be7d4b45256508f008b855a253015e35103..cd4b14a1f9b94d4e8bb416b6f30dfdec11f5573e 100755
--- a/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun
+++ b/tutorials/discreteMethods/molecularDynamics/mdFoam/nanoNozzle/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication decomposePar
diff --git a/tutorials/electromagnetics/mhdFoam/hartmann/Allclean b/tutorials/electromagnetics/mhdFoam/hartmann/Allclean
index a5e65c7d81ba11f5fce4451cefd5d25886c31879..f2d7cca6654b78c6b98a88e7508f8ab445a8a4e7 100755
--- a/tutorials/electromagnetics/mhdFoam/hartmann/Allclean
+++ b/tutorials/electromagnetics/mhdFoam/hartmann/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 cleanSamples
diff --git a/tutorials/electromagnetics/mhdFoam/hartmann/Allrun b/tutorials/electromagnetics/mhdFoam/hartmann/Allrun
index 8bf5318684b5cc1c547828577a784fe1666df0cd..23a6711db49b2c65bb7ee5d231411f01e82faf92 100755
--- a/tutorials/electromagnetics/mhdFoam/hartmann/Allrun
+++ b/tutorials/electromagnetics/mhdFoam/hartmann/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean
index be62031288e5a2bff16d8a47a26c833d6cd30e81..01dae1a898f6a90e6513df4c3e0442276e006814 100755
--- a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean
+++ b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -f 0/T
diff --git a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun
index ac13b0642744f9c533dae77ee185700c2bf4536a..f8719a73da30390fa5d245728ada1604136f7956 100755
--- a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun
+++ b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 \cp 0/T.orig 0/T
diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean
index be62031288e5a2bff16d8a47a26c833d6cd30e81..01dae1a898f6a90e6513df4c3e0442276e006814 100755
--- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean
+++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -f 0/T
diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun
index ac13b0642744f9c533dae77ee185700c2bf4536a..f8719a73da30390fa5d245728ada1604136f7956 100755
--- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun
+++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 \cp 0/T.orig 0/T
diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun
index ca4be116d7c1a5e2f696d2f833e87347c1278983..d0102481dad50ff2591db553dc02ed422e7319e2 100755
--- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun
+++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
@@ -20,7 +18,7 @@ runApplication $(getApplication)
 #    foamDictionary "$f" > "../processors/0/$f"; done \
 #)
 #
-#runParallel `getApplication` -fileHandler collated
+#runParallel $(getApplication) -fileHandler collated
 #runApplication reconstructParMesh -constant  -mergeTol 1e-6
 #runApplication reconstructPar
 
diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean
+++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun
index c61e8a418c5e877e323463c94419ef50726b9fd8..1e6177fd59488a4f085a1dbbd61f63bc559c52ca 100755
--- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun
+++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean
+++ b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun
index 8a77ff8076363a01e3fc0e676fcf87e9a5223fd5..e0f9af4df86f647b2876b3684279d5d511b10570 100755
--- a/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun
+++ b/tutorials/heatTransfer/buoyantPimpleFoam/thermocoupleTestCase/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean
index f02ac1a6eb25f412b2cdecb8ec210e1c3aac5244..8ad093a08cd5ec8b5cc86938986490d31c6ea84d 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -f validation/*.eps
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun
index 33dbc86270280e4c0ef95aaab708395760be5f8e..4abae23d19bcb2706da8e2d48864a34acaee5343 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean
index eb1e8dba18a620da99b58b90ac1c5165577bd46e..0e33c8258de7c6fc74ebecf4aecd0404c3a7a7ad 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/baffle3DRegion
 
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun
index 1927ad7c820c406be7273f93293e8e45bbe010ab..357dac9b56c4c67eac6693ff95c47790fe73ff86 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun
index 8a77ff8076363a01e3fc0e676fcf87e9a5223fd5..e0f9af4df86f647b2876b3684279d5d511b10570 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoom/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun
index 8a77ff8076363a01e3fc0e676fcf87e9a5223fd5..e0f9af4df86f647b2876b3684279d5d511b10570 100755
--- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun
+++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRadiationRoomFvDOM/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean
index 757a0f3d6cc04adbbee8dcd12dd23f5ca70a7742..3f7a0cb7a67b96849bf0e2d135638aa63e10c843 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
@@ -23,4 +21,4 @@ rm -rf constant/heater/polyMesh
 rm -rf constant/leftSolid/polyMesh
 rm -rf constant/rightSolid/polyMesh
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun
index 6191f4b7b1278c78c901b2b3ed259fac12e985cf..25b14f2bb7ce56d0986ac0f2526c653f2d10fde8 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -32,4 +30,4 @@ runApplication ./externalSolver
 # Reconstruct
 runApplication reconstructPar -allRegions
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre
index 481deedc7be6350d0f3f0467f200860a7b8efbd4..aebfbaa5aea1395405072ddf5b9d6ff5d0c31de5 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
@@ -29,4 +27,4 @@ echo "creating files for paraview post-processing"
 echo
 paraFoam -touchAll 2>/dev/null
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean
index bd637e1bf9bf48783f850f95185b488d9a85a814..fecea96c55a084361bc1be299b4fb54b18fb2313 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf VTK
 rm -rf constant/cellToRegion
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun
index c20d1cd3be032c37c84cf7c8287e888798bb0096..b1618a81199fddced3cd9fae01475c7b7164037f 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Setup case
 ./Allrun.pre
@@ -12,21 +10,22 @@ cd ${0%/*} || exit 1    # Run from this directory
 # Agglomerate patch faces
 for i in air
 do
-    faceAgglomerate -region $i -dict constant/viewFactorsDict > log.faceAgglomerate.$i 2>&1
+    runApplication -s $i \
+        faceAgglomerate -region $i -dict constant/viewFactorsDict
 done
 
 # Generate view factors
 for i in air
 do
-    viewFactorsGen -region $i > log.viewFactorsGen.$i 2>&1
+    runApplication -s $i \
+        viewFactorsGen -region $i
 done
 
 runApplication $(getApplication)
 
-
 echo
-echo "creating files for paraview post-processing"
+echo "Creating files for paraview post-processing"
 echo
 paraFoam -touchAll
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel
index 32453b285e732ce0ba54d64db44797c0504b6b9c..4fd07828f95918be60e977d351b33f15decee635 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Setup case
 ./Allrun.pre
@@ -15,18 +13,18 @@ runApplication decomposePar -allRegions -constant
 # Agglomerate patch faces
 for i in air
 do
-    runParallel -s $i -np 4 \
+    runParallel -s $i \
         faceAgglomerate -region $i -dict constant/viewFactorsDict
 done
 
 # Generate view factors
 for i in air
 do
-     runParallel -s $i -np 4 \
+    runParallel -s $i \
         viewFactorsGen -region $i
 done
 
-# set the initial fields
+# Set the initial fields
 restore0Dir
 
 runParallel $(getApplication)
@@ -35,8 +33,8 @@ runParallel $(getApplication)
 runApplication reconstructPar -allRegions
 
 echo
-echo "creating files for paraview post-processing"
+echo "Creating files for paraview post-processing"
 echo
 paraFoam -touchAll
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre
index ad4135ab5cbb8a760033d7fa1ae6100416bb2768..35a20b5e48ae2f8e3553decdf92636282ea48976 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalSolarLoad/Allrun.pre
@@ -1,30 +1,27 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
 runApplication splitMeshRegions -cellZones -overwrite
 
 # Remove unwanted region
-rm -r 0/domain3
-rm -r constant/domain3
-rm -r system/domain3
+rm -rf 0/domain3 constant/domain3 system/domain3
 
-# remove fluid fields from solid regions (important for post-processing)
+# Remove fluid fields from solid regions (important for post-processing)
 for i in solid floor
 do
    rm -f 0*/$i/{rho,mut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
 done
 
-# set the initial fields
+# Set the initial fields
 restore0Dir
 
 for i in air solid floor
 do
-    runApplication -s $i changeDictionary -region $i -subDict dictionaryReplacement
+    runApplication -s $i changeDictionary \
+        -region $i -subDict dictionaryReplacement
 done
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean
index 8b0c932d51bf1e3d5fa3801e7a13c54bc84021c4..fad685f8abf315ed9ac069365c04299af5775c56 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun
index 619f8c0af0ac2ab67801be7dfe8a1416e252bb4a..5cf86d4458f6b06da2f0d9f4f5e34acd5faab0d5 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean
index 230730502d4354ca3a067e8ea9101b44c17c6055..0ad9dc9eb83fd688de417304e60614151bf130e8 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun
index e46f721088820fa427c6d6a87de109ea90bc5a30..b3614e73078de5a4f65e9582a38530cd7d783f9e 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 rm -rf constant/polyMesh/sets
 
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean
index c34834dedb650920f607102c964349c37c94b715..d28baddd336296becdaa7a12f229c1e39e08ccee 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/windshield/polyMesh
 rm -rf constant/cabin/polyMesh
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun
index 7704bd9ea5536674fbf75cda78b97da1a051dc20..51e2df24b4fa8f5831cbebccace85216d9e599e9 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create the underlying block mesh
 runApplication blockMesh
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel
index 18fefcf28cfd906ab6422b0a496718bfe8aef2fa..bdd571ebfcdd9152442bf7549ad37f644ce98c9d 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create the underlying block mesh
 runApplication blockMesh
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls
index 63d17474fbe97c7ab7df9608b8e6f3fd22e3992c..0eae3d794b2554776b0a072d847c7c03d1272744 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls
@@ -12,6 +12,4 @@ maxCo           12;
 
 maxDeltaT       1;
 
-#inputMode           merge
-
 // ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0
index f23b6a4f10bd1ddd4a38224a5627fc87e6ac70a2..65697b024218b853d16ea9ab0e6916fca3392031 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.0
@@ -12,6 +12,4 @@ maxCo           2.5;
 
 maxDeltaT       0.3;
 
-#inputMode           merge
-
 // ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20
index c1143ac2dc3ea7f65747cf2808ef4f36d56837ba..56a2dc921ff4efaccc69712b5ced7938f63f54be 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.20
@@ -12,6 +12,4 @@ maxCo           8;
 
 maxDeltaT       1;
 
-#inputMode           merge
-
 // ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5
index be96ad7429858a69eda432c42858e0d48dabb933..9f1c5f5932eb11aecb5a0f56a905a9969232b064 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.5
@@ -12,6 +12,4 @@ maxCo           5;
 
 maxDeltaT       1;
 
-#inputMode           merge
-
 // ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60 b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60
index 63d17474fbe97c7ab7df9608b8e6f3fd22e3992c..0eae3d794b2554776b0a072d847c7c03d1272744 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/system/solverControls.60
@@ -12,6 +12,4 @@ maxCo           12;
 
 maxDeltaT       1;
 
-#inputMode           merge
-
 // ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T
index cb41965f6d01c80f5be714ccfabd3ff3edeee398..210f21c3c2af40aa09191ee474b28dfe7948e60b 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/T
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      T;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U
index 39f76c7d60888d27bd7ae7981d9219cb3036503c..6417f7697723a34a0f7619c13e0023a34ebc262a 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/U
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volVectorField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      U;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat
index 0ae4684ecd1f6d160a500ab46d8ef40e57911e26..619fface6f380d20204b18a09e607a6fb217cc9f 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/alphat
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      alphat;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k
index 7af0caf3efadf7fe5692fcd9a3a52c7607c76ef7..1ec07db6207cfaadee02545ea0cd62a61cc1e055 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/k
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      k;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut
index 5fec8a0f1361283506c78920c706319a454c6136..c058f2003751bf77755b33951d4b60e001c49b42 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/mut
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      mut;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega
index 408dbbd7f50dffbbf15cc85ac6412d554a0f2c12..b139e99405fe7ac35ad362c65979db00b52e4ed7 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/omega
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      omega;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p
index f4e17657dab0bd532fe11e669c232539d252d733..4ff4f2aab2fd5caa86c92b7e96eb14601b8a888d 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      p;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh
index e999538886a97d84518fc89a5e92495e885a18a0..904e2543585fec5f580dce023c3f02991b3a0d06 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/cabin/p_rgh
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/cabin";
+    location    "0/cabin";
     object      p_rgh;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T
index dd56368c3933e47d6e7dec3a91c0e38f10cfa3c9..316d0a4d79dc058eae8b2402a48445a691e18a46 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/T
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      T;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U
index 1dcf7568ed052b52628ff337b6f7efdabb803e8e..798d170bed0a571fb8f4b8fc45337c46f67b4ff6 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/U
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volVectorField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      U;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat
index 90db16eef7bf2e094a6ed7f6e3b6a6f230e6dd9a..8c0ad63614beef9921877d2edd9e9d9ef616557f 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/alphat
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      alphat;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k
index 47032402600599674730d02fc5dd494f2c1c9ff6..fbbe93014d7468f2a94f407c811d40298e67f3c6 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/k
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      k;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega
index a7cca7714ab10683df18a93f74f9eabb1e5b9823..0e0856fe3936954952eca5e3e9faa3e19804710a 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/omega
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      omega;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p
index 764aecbeb415a97cad8b86213d2c138b90003ca4..20ef4a3e5acaf30b64fa3da3c07a60f232eb2fe4 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      p;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh
index d1c78a163b1d424b82496e481dc9d427a547b54e..672028547d3084d42744aba2f02082dfc9384056 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/exterior/p_rgh
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/exterior";
+    location    "0/exterior";
     object      p_rgh;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T
index e48d2b0c5a91beb557bb102866ccc61fc51d4e6b..84ba951a2fec05c8a93f257a72bcb56d6457cd43 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/T
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/ice";
+    location    "0/ice";
     object      T;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U
index ebe245ba29749d208a1827ab068146c2e6782bd4..e3efcba0f63a879f68df158ecf522f35456b96a6 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/U
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volVectorField;
-    location    "0.0001/ice";
+    location    "0/ice";
     object      U;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p
index 8860f98c60c3d0a44ea0b45cf3703ede0c6fd594..9015143ba7179e348c5e66d4bac3bbde8d0b4519 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/ice";
+    location    "0/ice";
     object      p;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh
index 66de1672f5c48669212d235fe542aaf770ac5020..06578deae9a6075686aefbed23a5d151d622002f 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/0.orig/ice/p_rgh
@@ -10,7 +10,7 @@ FoamFile
     version     2.0;
     format      binary;
     class       volScalarField;
-    location    "0.0001/ice";
+    location    "0/ice";
     object      p_rgh;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean
index 92a631d049e9eecb43b4963fd484a99e6949479a..9ce122ce3d9bc54642bfccc020b97d5508de33cb 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/exterior/polyMesh
 rm -rf constant/ice/polyMesh
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun
index f4d82024cdbfa32827ca307c2aaf9f520d0d6b8b..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
 runApplication $(getApplication)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel
index 4ec7e69c221bbfba7f424a3f3d68f44c7a460f39..53e574a9d5adba603af89c15da01429f0e897b7c 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -19,4 +17,4 @@ runApplication -s ice reconstructPar -region ice
 runApplication -s exterior reconstructPar -region exterior
 
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre
index 44fa75f381cc58c4e9a53a1bf2e31c3fbce7f83f..69ef3caa41954217a56e14dd349ee90cc96a6d55 100755
--- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldDefrost/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create the underlying block mesh
 runApplication blockMesh
@@ -19,4 +17,4 @@ runApplication splitMeshRegions -cellZones -overwrite
 # set the initial fields
 restore0Dir
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean
index 5a54eef9a0e647fa7b80e85aca2642079808588c..2d12f3a3ee482bb0104c598983ae9520658e9cf8 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 foamCleanPolyMesh -region air
 foamCleanPolyMesh -region porous
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun
index f4d82024cdbfa32827ca307c2aaf9f520d0d6b8b..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
 runApplication $(getApplication)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel
index 2be2e1edda0235c014544dc9384939cc01922958..2527a2edf58e2acfc12758b67dfac58ef9228507 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -14,4 +12,4 @@ runParallel $(getApplication)
 runApplication -s air    reconstructPar -latestTime -region air
 runApplication -s porous reconstructPar -latestTime -region porous
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre
index 6d3c8f35440a242ddb97b78d39d6f3e979678a24..b3f7c19f36f7e8bec77a2b81f9c20c8543491a88 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 #create meshes
 runApplication -s air    blockMesh -region air
@@ -26,4 +24,4 @@ paraFoam -touch -region air
 
 restore0Dir
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean
index 31c0b764b5a135ceb1891ba7d5dda8123cb51ded..6d4b7f5c83ef249c9951f7bb37d0dd66f5d6cfb0 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 foamCleanPolyMesh -region solid
 
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun
index 98857416a91cbba898dc7c53731e2306b08af098..b7d6fe2a4db20d66ebae6efa4fc99a9de3f95186 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -10,4 +8,4 @@ runApplication $(getApplication)
 
 ./createGraphs
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel
index b48e4c119d991666fbaa5898f239939af8a88f90..26499f2115259a9ad880aa4bcb57621e8ec5577d 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -14,4 +12,4 @@ runApplication -s solid reconstructPar -latestTime -region solid
 
 ./createGraphs
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre
index c8198f9848a5385a6251bd757cbee53fa0ed6398..4197c7f941c38f9f5d2e3ba123a4fec4a1d2cf35 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Create meshe
 runApplication -s solid blockMesh -region solid
@@ -12,4 +10,4 @@ paraFoam -touch -region solid
 
 restore0Dir
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean
index 0df7ec62070aabead25912cd37ee92ce69a840d5..8232cefee71c6b67fce5e87aded27694cb7ffe40 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
+
 rm -rf VTK
 rm -rf constant/cellToRegion
 rm -rf 0/bottomAir
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun
index 50db130fe2389cfd5a6a002daa902ceed5c13239..e726d6fcab9f95a920b386f7da730301ac2080cc 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 # Setup case
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel
index f8131b1da89504f7196bbf0fc05182805ab7d986..42b3aad022758797aa5d338d207bf6da1f60d263 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun-parallel
@@ -1,14 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Setup case
 ./Allrun.pre
 
-
 #-- Run in parallel
 
 # Decompose
@@ -17,14 +13,14 @@ runApplication decomposePar -allRegions
 # Agglomerate patch faces
 for i in bottomAir topAir
 do
-    runParallel -s $i -np 4 \
+    runParallel -s $i \
         faceAgglomerate -region $i -dict constant/viewFactorsDict
 done
 
 # Generate view factors
 for i in bottomAir topAir
 do
-    runParallel -s $i -np 4 \
+    runParallel -s $i \
         viewFactorsGen -region $i
 done
 
@@ -34,9 +30,8 @@ runParallel $(getApplication)
 # Reconstruct
 runApplication reconstructPar -allRegions
 
-
 echo
-echo "creating files for paraview post-processing"
+echo "Creating files for paraview post-processing"
 echo
 paraFoam -touchAll
 
diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre
index 091548c051a2c0002bf7c19c08a3f1e889d97079..b28d6eee4f18f58f922b8effd05f52dc32197886 100755
--- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre
+++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun b/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun
index 52b2a4941d73838617c1741cb20f1d4a5f4acdf5..5db0a1c8e5a022ae01d798031504740b33e1af13 100755
--- a/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun
+++ b/tutorials/incompressible/SRFPimpleFoam/rotor2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean
index 98908744330933baf3c93c4abfb4121ee7cc30b8..53c93d35b810e619696756eb07b4e57745f41f2d 100755
--- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean
+++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun
index 7f68f709137cae5fd9bafbc7b60546e1df7e6251..0a453a027990ba66250504e61c14656e2768e54a 100755
--- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun
+++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/incompressible/icoFoam/cavity/Allclean b/tutorials/incompressible/icoFoam/cavity/Allclean
index 842bb7ced7d3256ae703992120af550e34d5448a..4431913e3bb0e94d5c7918946e9dabc33485f5fc 100755
--- a/tutorials/incompressible/icoFoam/cavity/Allclean
+++ b/tutorials/incompressible/icoFoam/cavity/Allclean
@@ -1,18 +1,13 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 keepCases="cavity cavityGrade cavityClipped"
 loseCases="cavityFine cavityHighRe"
 
 for caseName in $keepCases
 do
-(
-    cd $caseName || exit
-    foamCleanTutorials
-)
+    ( cd $caseName && foamCleanTutorials )
 done
 
 for caseName in $loseCases
diff --git a/tutorials/incompressible/icoFoam/cavity/Allrun b/tutorials/incompressible/icoFoam/cavity/Allrun
index fdeea0d08d27ca384b93046e244cd850ec2e756c..c1454a28614410fcb5949ca101e46c7b3ae55aa1 100755
--- a/tutorials/incompressible/icoFoam/cavity/Allrun
+++ b/tutorials/incompressible/icoFoam/cavity/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 cavityCases="cavity cavityFine cavityGrade cavityHighRe cavityClipped"
 
@@ -55,20 +53,21 @@ setCavityHighRe()
 }
 
 
+unset previousCase
 for caseName in $cavityCases
 do
-    if [ "$caseName" = cavityFine ]
-    then
+    case "$caseName" in
+    cavityFine)
         cloneCase cavity $caseName
         setCavityFine
-    fi
+        ;;
 
-    if [ "$caseName" = cavityHighRe ]
-    then
+    cavityHighRe)
         cloneCase cavity $caseName
         setCavityHighRe
         copySolutionDirs $caseName cavity
-    fi
+        ;;
+    esac
 
     ( cd $caseName && runApplication blockMesh )
 
diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean b/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean
index 3512fe5e6ebf9617c4118087870cc4b589027bec..63145a3803c964a7279001a71d27d86af2705b09 100755
--- a/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean
+++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf constant/coarseMesh
diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun
index 767ff8591ff643fea5b067019b2c2009634b552a..7d2e3238433f143220602390c62137ba8c28d357 100755
--- a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun
+++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse
 
@@ -13,4 +11,4 @@ runApplication -s fine blockMesh -dict system/blockMeshDict.fine
 
 runApplication $(getApplication)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel
index 2577f9c8669aeadd51a325dcdd922808c5506033..524002c6ec5109c727f4cde7b92a8326f668793a 100755
--- a/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel
+++ b/tutorials/incompressible/icoFoam/cavityMappingTest/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication -s coarseMesh blockMesh -dict system/blockMeshDict.coarse
 
@@ -21,4 +19,4 @@ runParallel $(getApplication)
 #
 #runApplication -s coarseMesh reconstructPar -region coarseMesh
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/icoFoam/elbow/Allclean b/tutorials/incompressible/icoFoam/elbow/Allclean
index 400ad856874908800dc2bc9f19a39b55c9637ad9..7238840f835de2ff0295a0c28569724328f58e7d 100755
--- a/tutorials/incompressible/icoFoam/elbow/Allclean
+++ b/tutorials/incompressible/icoFoam/elbow/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf fluentInterface
diff --git a/tutorials/incompressible/icoFoam/elbow/Allrun b/tutorials/incompressible/icoFoam/elbow/Allrun
index d47748719619575f9d7d05f1d11ae001c8297a1f..a42f83926bc7e90df511ba876a78a4a095036f50 100755
--- a/tutorials/incompressible/icoFoam/elbow/Allrun
+++ b/tutorials/incompressible/icoFoam/elbow/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 runApplication fluentMeshToFoam elbow.msh
diff --git a/tutorials/incompressible/lumpedPointMotion/building/Allrun b/tutorials/incompressible/lumpedPointMotion/building/Allrun
index 8aad569cae698791ada14b75fc6433d735db5589..b922844f842c9f61e1a5785cfb993516eba8f008 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/Allrun
+++ b/tutorials/incompressible/lumpedPointMotion/building/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 # 1) First run steady-state to establish a good initial field.
diff --git a/tutorials/incompressible/lumpedPointMotion/building/Allrun.move b/tutorials/incompressible/lumpedPointMotion/building/Allrun.move
index 33b1a80e7b3a3e3c2207411b6e9ee21203d7a53f..bed249580f511756863fdd71d21d85f22fc43e6d 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/Allrun.move
+++ b/tutorials/incompressible/lumpedPointMotion/building/Allrun.move
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # 1) Run meshing
 # 2) Reconstruct
diff --git a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement
index bf69827a2c1cf7a6840b097590de508723e9d0ca..82baeb53be6fedf66042183e0fd17a09a89ddfb3 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement
+++ b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # The 0/ field only
 # runApplication reconstructPar -withZero -time 0
diff --git a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient
index 50047173685ea2cb7cff8029ac56041e594a7cbc..951dd76adbe140b6b1e25bd27ddf20d0aa4db87f 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient
+++ b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Cleanup old junk that may prevent things from starting
 \rm -f comms/OpenFOAM.lock
diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions b/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions
index 8d82530aae28ec150200ca41df6cad508dab68f2..30be52d9723ebb027881caf82287d940ddd2b895 100644
--- a/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions
+++ b/tutorials/incompressible/lumpedPointMotion/building/steady/0.orig/include/initialConditions
@@ -12,6 +12,4 @@ turbulentKE          37;
 turbulentOmega       32;
 turbulentEpsilon     30;
 
-#inputMode           merge
-
 // ************************************************************************* //
diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean b/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean
index 3b8b23422e8fe31825165fd639baa2f51dffd21b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean
+++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allclean
@@ -1,8 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-cleanCase
-\rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun
index 57456db2fd724c5115a9a4404295415e9daaafaf..fd9ff050c42bc3b5b51d1386ffa21b5caca865c1 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun
+++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre
index de42e2de8ce09a2f5097d6c05c5824d20f75eeeb..fb357cee7868a5f083c9a8bdab830f023a91e0a1 100755
--- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre
+++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Copy building from resources directory
 mkdir -p constant/triSurface/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean
index 862ed262d87e660157ae5c8802d3e9dc742b91c5..a916d0755471418253cb46c1d993f21b4fa9ecef 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allclean
@@ -7,4 +7,4 @@ cd ${0%/*} || exit 1    # run from this directory
 # Add background mesh
 (cd cylinderMesh && foamCleanTutorials)
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun
index 7604f9ad35a006852330ed91538222f0bd42f49b..5758f00725125eed6759ad14dae03071a82639a1 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun
@@ -1,8 +1,11 @@
 #!/bin/sh
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Extrude mesh around cylinder
 (cd cylinderMesh && ./Allrun.pre)
 
 # Add background mesh
 (cd cylinderAndBackground && ./Allrun)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre
index 788e9474864bfb14f862151162d52c799047bfb7..d87c892a62451ca186022496833adecbd1ae7ef7 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/Allrun.pre
@@ -1,8 +1,11 @@
 #!/bin/sh
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Extrude mesh around cylinder
 (cd cylinderMesh && ./Allrun.pre)
 
 # Add background mesh
 (cd cylinderAndBackground && ./Allrun.pre)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U
index c14119ee33c329dfcfbfd6b7d4d0fad25b3b6448..1f740ae49d61487a3d4a6c9e82664aefbe8e1ba1 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/U
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon
index 6491f886514e2f2938d40fe70d2aba7758dc3eb1..cf852c72dce49ad5da3870776e6588c655cd3128 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/epsilon
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions
index aaa6bd1c6ff32eaff7dcb39edfae03322f94992f..d2b995d3b551a60854a16da6811cc0b4d387328b 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/include/initialConditions
@@ -10,6 +10,5 @@ flowVelocity         (10 0 0);
 pressure             0;
 turbulentKE          1.5;
 turbulentEpsilon     0.88;
-#inputMode           merge
 
 // ************************************************************************* //
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k
index e264adb202d59773bcc9d0078fbe960898c7d356..ffd3df6c7009d1aad1aa665f706591563c21c59d 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/k
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut
index 9ec55e9f01b28031d2d0ee1433bd8d7d09e6d69b..9200b0098b01258162ed7035a9b606226e3b18d8 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/nut
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p
index f5688d226d757193fb2e2c6489e3be5f0db240d0..e0d247b2fdd8889aba3faaad13f43353c58e2adc 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/p
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement
index 0bcc4e3481f8abf7a83b9cff09d6b3abb40a45c1..14d636e12264c2061d0ee163804ea4e297d09e67 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/pointDisplacement
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID
index 88d3b0af1d5c71c7682c96aa8a17584c9c99bd7c..1a0b8c3b47f3e98d48d6f5f7f16d3a2f1db7cad3 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/0.orig/zoneID
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean
index 6be736ea3ca30d45035f84d87f0514b7dcca76f2..aab71fa2ca4ea5faeb699a7c0497ec6841e7bce5 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allclean
@@ -1,12 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase0
 
-cleanCase
 rm -f constant/polyMesh/boundary
 rm -f constant/polyMesh/zoneID
 rm -f constant/cellInterpolationWeight
 
-rm -rf 0
-
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun
index 50626eed68377d9c8266c8d16ed8cd788c111771..675192355626c531ff90cf1dee41882714fa3ac4 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre
index f4910d875d6b93d1b10ce3ee5439ba32e55b4fe5..fb7e1120bdf6d35eb6ad8e21168824b9d13db9d8 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Create background mesh
 runApplication blockMesh
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict
index 799c4a059b79ae99d6ca60456cdc817429864de3..9f766ac272528f245b086c89fda9a36c82c09d6f 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/dynamicMeshDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties
index 4efbc8b932532edc97f57592c725b47fc68e60dc..312de2197d3c846fdf304843b8ee8eca43c3deef 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/constant/transportProperties
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict
index 21c7adb08ee536245f8181d5e0c3ea4a1c69ef4b..8efb92d61024b852440bc0491e5e1005ffc411f9 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/setFieldsDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict
index 9c6d97678240cf11709cf4be9ff72e4987055c8f..1b24f69a27dc2c1b7c807064025e9f904f4130b1 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderAndBackground/system/topoSetDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre
index ad0801bbb900fe1a425cb5941eb3778df1ec2056..a86d9586601ab97370e670a5a868563c565ee912 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/Allrun.pre
@@ -1,8 +1,11 @@
 #!/bin/sh
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Generate mesh from surface (in constant/triSurface)
 runApplication extrudeMesh
 
 # Make front and back type empty
 runApplication createPatch -overwrite
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict
index 74214eea8634d7de03bbbfcf250bc67b3c28c173..a4e3a644b325959ac6d5e6fa641b7eaf74aae2f8 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/cylinder/cylinderMesh/system/createPatchDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U
index 4d9613a87a0b92cfcd97af62f82bd76054386f4f..4c6e3407fc6550053102d5bc4786f10d39d5ba8a 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/U
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon
index 3fe3a7428cdc64517a8eb43ae00ff69cf8b6fdc3..a5dfa71fb2f2b06d095f8d82f3e2ac59f8294211 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/epsilon
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
@@ -10,7 +10,6 @@ FoamFile
     version     2.0;
     format      ascii;
     class       volScalarField;
-    location    "0";
     object      epsilon;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k
index e3c6782ce058e27971b796618b42fae7c27294ea..2b47f7341beb20f0488a686c39eb0fe5a0927eea 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/k
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda
index 55de8c57bcc82537a9ccfe31457fb48b3044e229..889292d92b60ec2b2fa793e436e4d82746d8f35f 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nuTilda
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut
index b68e974c96db3572fcc14d64f79ca16fc92f560d..db24c1bdad79523fb932c59b6ae2d21ced4a782f 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/nut
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p
index ab7fd5c2877db8b41b07b48f11780b551c1884a1..08a3949e59a32e01a1053e12659c27f6bddc2133 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/p
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement
index fe072121d3596a6fdafc874ab5d3b0602cb2b812..67ac84306f1f59a47699ff7e778887b3bef25aec 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/pointDisplacement
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID
index 84f0d963f3aaceeace01221fe921445562a88930..6dc74df393939b7493da16f4ffef1eee1d7e6714 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/0.orig/zoneID
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean
index 6be736ea3ca30d45035f84d87f0514b7dcca76f2..aab71fa2ca4ea5faeb699a7c0497ec6841e7bce5 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allclean
@@ -1,12 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase0
 
-cleanCase
 rm -f constant/polyMesh/boundary
 rm -f constant/polyMesh/zoneID
 rm -f constant/cellInterpolationWeight
 
-rm -rf 0
-
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun
index d8593e528778e7a1cc1864e00f2dfd8ad34d23dd..2ac685b863be35e06f569f72e5c886c39892268f 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre
index 4eafbde2339d182be7553259d90edb00c1a37394..217161cb95c50467a0ba5b218dd0727e6dea0599 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties
index ec34b4c47c9337ec43bf17be3ed09869d5783bbb..a90687f88c8db8e213926c0516f596902054730e 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/RASProperties
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict
index 951bd08dae553adda1bbe65b1f91e5c0dc0f9a2e..64a310b628fe4a0419dac269337b56d3c336356b 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/dynamicMeshDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties
index 4efbc8b932532edc97f57592c725b47fc68e60dc..312de2197d3c846fdf304843b8ee8eca43c3deef 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/transportProperties
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties
index c1f1b1a8341789b7a044cd077a981fcb02388fb9..59fa7b96ea5e4c0de437837aa6673ed284d57b91 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/constant/turbulenceProperties
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict
index bc0d9c02a8c1818e182f90c0a1a92a38ba1c8efd..aaa029026d1fd350192b7c856c7dce1174d2a913 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/blockMeshDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict
index d9178735a16b72c85c2f437093ffdd7b46528ffa..b2b8647c64e7c0b776dfc704ab412be95c66e169 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/controlDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes
index 067d2aa43b653b92e6a3b56a71762fdf2ead6125..d31d118e8aa254accf6dfed3d899f1794d7e7c0b 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSchemes
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution
index 464100d29a48d92aebc667015044d10bb5012800..925faa16666c9de18ca5f52106303de3c95c35da 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/fvSolution
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict
index 21c7adb08ee536245f8181d5e0c3ea4a1c69ef4b..8efb92d61024b852440bc0491e5e1005ffc411f9 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/setFieldsDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict
index 4b0957e28897ff620f21d7de94d7806bf6cc1930..52a30892d5598c4c82fa5c170736a9d987ec6298 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/simpleRotor/system/topoSetDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U
index 3d7fddaaaaa661659b3187019769063bc8df542a..807ff39559c574f831b284695e1ecd90a7b2c514 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/U
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p
index 363e7193fdeb16a5a7336e1d22627e8abf850ca0..1baa7b03df76c292cabd8c2cab6aa0cbef1e9dd5 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/p
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement
index b218758016cb03dcd23b9ff48dd3a1083382fe09..7252992283e152d7ed13e531cf8598a2756dea1a 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/pointDisplacement
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID
index 88d3b0af1d5c71c7682c96aa8a17584c9c99bd7c..1a0b8c3b47f3e98d48d6f5f7f16d3a2f1db7cad3 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/0.orig/zoneID
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean
index 6be736ea3ca30d45035f84d87f0514b7dcca76f2..aab71fa2ca4ea5faeb699a7c0497ec6841e7bce5 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allclean
@@ -1,12 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase0
 
-cleanCase
 rm -f constant/polyMesh/boundary
 rm -f constant/polyMesh/zoneID
 rm -f constant/cellInterpolationWeight
 
-rm -rf 0
-
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun
index e4b389b8c57524c70544d8978363089daafc585a..10707b2f2cd6e6f7f93215994e02b164f8de426a 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre
index 44fee43b00567805b7e52710b7fc603d1a2e061c..abccd3163c95858a729642290f99bd730f2d248b 100755
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict
index 391eb516eadea7f512c1d2ac86cbd08d32610f02..d84a86685dcf03bac1c458917c7fcd1f299fa308 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/dynamicMeshDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties
index ab4d80f3308998e0e117975999c9c099ea329ee3..d0519e17b40760feca7f7c6666a3aa06ebb15514 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/transportProperties
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties
index 9abf14eeecd195a74b7b95b2cb31c43de9be98fd..3defecdc9116ae66460974e7b64b6e63b0815542 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/constant/turbulenceProperties
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict
index abcbd45e7949729afa2f1856b525581d50f53330..a198025ce9ca50e874d1da6fdd8dae6e3b208de6 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/blockMeshDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict
index 7e93ade3783ba9725c541b0254687b5e58f56b80..6f6e02ca72e2a15ff6f441a16b4d570aff7daa8f 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/controlDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes
index 4e18294c71a39b32cbddff48c54b33a2be3668d7..d849549fd87bf58d00e0394d902664267bf81499 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSchemes
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution
index 464100d29a48d92aebc667015044d10bb5012800..925faa16666c9de18ca5f52106303de3c95c35da 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/fvSolution
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict
index b3f3729fe8b33e85c96623b48846321965e8a632..0a1f69b27715ffea29b523f28bb6c7f39c661ef3 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/setFieldsDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict
index db08fe53b5dcdc5046c157b5bebef64f2f00c6e4..a42ec579e4a56202c1a69f7d9c09b4daf0cdc1e1 100644
--- a/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict
+++ b/tutorials/incompressible/overPimpleDyMFoam/twoSimpleRotors/system/topoSetDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean
index 10394c3ebe5c48d5d04b411bc73f36a004e457d8..b7522e086ba0b9240f835a8a37cce15d6380ee10 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allclean
@@ -1,20 +1,15 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+for caseName in aeroFoil_snappyHexMesh background_snappyHexMesh
+do
+    ( cd $caseName && cleanCase )
+done
 
-cd aeroFoil_snappyHexMesh
-cleanCase
+for caseName in aeroFoil_overset background_overset
+do
+    ( cd $caseName && cleanCase0 )
+done
 
-cd ../aeroFoil_overset
-cleanCase
-rm -rf 0
-
-cd ../background_snappyHexMesh
-cleanCase
-
-
-cd ../background_overset
-cleanCase
-./Allclean
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun
index 728e17019da744562ece4cd5457526eb14e05a03..96bbd15dee0c33df51586074544eda5c1695336e 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun
@@ -1,10 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
-cd background_overset
-./Allrun
+( cd background_overset && ./Allrun )
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre
index 6b300fc25ac75e76329f4f5920b0ef8899f64393..e3784e5ab623bed82fd0bcd579a889800a0908f6 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/Allrun.pre
@@ -1,12 +1,15 @@
 #!/bin/sh
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
-# create aeroFoil mesh using snappyHexMesh
-(cd aeroFoil_snappyHexMesh && ./Allrun.pre)
+# Create aeroFoil mesh using snappyHexMesh
+( cd aeroFoil_snappyHexMesh && ./Allrun.pre )
 
 # Extrude mesh
-(cd aeroFoil_overset && ./Allrun.pre)
+( cd aeroFoil_overset && ./Allrun.pre )
 
-(cd background_snappyHexMesh && ./Allrun.pre)
+( cd background_snappyHexMesh && ./Allrun.pre )
 
-(cd background_overset &&  ./Allrun.pre)
+( cd background_overset && ./Allrun.pre )
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre
index 98a5ce71db08425b6cbc48f990bc0ddb6396ac82..66379c68c14dd714aafd88120f553c4acc7f296b 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_overset/Allrun.pre
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Make a 2D mesh by extruding a patch and solve to steady state.
 runApplication extrudeMesh
 runApplication createPatch -overwrite
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre
index fdfb7e78d160a43240dc6c41147c4f384d6d1167..7525ed4239fabb65cebaf6bee6fb0398e215491c 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/aeroFoil_snappyHexMesh/Allrun.pre
@@ -1,9 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Make 3D mesh in slab of cells.
 runApplication blockMesh
 runApplication snappyHexMesh -overwrite
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions
index e0b2bd996ee6d283f39b70c8b36c1ebbf153f663..14ab8e962cd8654a3e82530df1ebbafd25136e9f 100644
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/0.orig/include/initialConditions
@@ -11,6 +11,5 @@ pressure             0;
 turbulentKE          0.375;
 turbulentOmega       3.6;
 turbulentEpsilon     0.12;
-#inputMode           merge
 
 // ************************************************************************* //
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean
index 6be736ea3ca30d45035f84d87f0514b7dcca76f2..aab71fa2ca4ea5faeb699a7c0497ec6841e7bce5 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allclean
@@ -1,12 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase0
 
-cleanCase
 rm -f constant/polyMesh/boundary
 rm -f constant/polyMesh/zoneID
 rm -f constant/cellInterpolationWeight
 
-rm -rf 0
-
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun
index 488b782585a4ad93a95370556afa0f504c9d8720..c290d0dd5ec6a8e3b0d9fefd21b8966cc1ed8baf 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Serial
 #runApplication $(getApplication)
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre
index 858bba21fe70c1ddaaab16740e7c32689273403a..4ce424d93f8cecc6236b7b7fdb60e6fd2d0937a3 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_overset/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication extrudeMesh
 runApplication createPatch -overwrite
diff --git a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre
index 756120464768b748c11e94e52540b2b0aa539ca2..c221f0abd3cc10986acc08c4e69f355b3e673b7e 100755
--- a/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre
+++ b/tutorials/incompressible/overSimpleFoam/aeroFoil/background_snappyHexMesh/Allrun.pre
@@ -1,10 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
-# Make 3D mesh in slab of cells.
 # Make 3D mesh in slab of cells.
 runApplication blockMesh
 runApplication snappyHexMesh -overwrite
+
+#-------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun
index 162255286a9d87f59b4804ca4571d111e6c160d4..9450e8b3f6e45b2898e02ca807630a896aa02a16 100755
--- a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun
+++ b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./makeMesh
 
diff --git a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh
index bcb12c0e9ac17c9aefbf669bd022c29c97052727..fc56e7be3ced8dddd0d2158adb4b74e5e2d96239 100755
--- a/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh
+++ b/tutorials/incompressible/pimpleDyMFoam/mixerVesselAMI2D/makeMesh
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 < system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean
+++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun
index f4d82024cdbfa32827ca307c2aaf9f520d0d6b8b..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun
+++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
 runApplication $(getApplication)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel
index 51af1fb48a672f04f66ce275bf17d886679b535a..c9e323cdb775fc3db8410f50e44da516a826d07f 100755
--- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel
+++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -10,4 +8,4 @@ runApplication decomposePar
 runParallel $(getApplication)
 runApplication reconstructPar
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre
index c484c19d159ea442346b8edba7f124046dfa09b6..3d4d5ecf6fe738bd57a8995ebe17f2e77dbde468 100755
--- a/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre
+++ b/tutorials/incompressible/pimpleDyMFoam/oscillatingInletACMI2D/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
@@ -13,4 +11,4 @@ runApplication createBaffles -overwrite
 
 restore0Dir
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean b/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean
index 2334d531d334618050cbef53f358707fab5745ed..88ad2ecc84af62529f353d906360cde3e1fc51b3 100755
--- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean
+++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove surfaces and features
 rm -f constant/triSurface/propellerTip.obj.gz > /dev/null 2>&1
diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun
index 51af1fb48a672f04f66ce275bf17d886679b535a..c9e323cdb775fc3db8410f50e44da516a826d07f 100755
--- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun
+++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -10,4 +8,4 @@ runApplication decomposePar
 runParallel $(getApplication)
 runApplication reconstructPar
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre
index fd9adacb88dc892576ce57e5d8dd1ebf2b127e35..78478afc1ea8ff7a9766753c8f0c66e5fad8efdc 100755
--- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre
+++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre
@@ -1,13 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy propeller surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/propellerTip.obj.gz constant/triSurface/
 
-
 # - meshing
 
 runApplication blockMesh
diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean
index ae51d1251b29abd147072ac8ee9dae5c067c81d1..a7438920301df6fa71e73688c6a35534686a6783 100755
--- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean
+++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allclean
@@ -1,24 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+( cd wingMotion_snappyHexMesh && cleanCase )
 
-(
-    cd wingMotion_snappyHexMesh || exit 1
-    cleanCase
-)
+( cd wingMotion2D_simpleFoam && cleanCase0 )
 
-(
-    cd wingMotion2D_simpleFoam || exit 1
-    cleanCase
-    rm -rf 0
-)
-
-(
-    cd wingMotion2D_pimpleDyMFoam || exit 1
-    cleanCase
-    rm -rf 0
-)
+( cd wingMotion2D_pimpleDyMFoam && cleanCase0 )
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun
index 0b5930fddc5c651b82ca29b0f99359baa3948b52..f173a5d46fa4fede6dc48c1d15fdc6aad2751317 100755
--- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun
+++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Make 3D mesh in slab of cells.
 (
diff --git a/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement b/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement
index aa09fbff1b1ac4bf1d143e613a93df4754202ea5..15ba53c5518a7a7dfb51fdf79a5cacc76937eebb 100644
--- a/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement
+++ b/tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_pimpleDyMFoam/0.orig/pointDisplacement
@@ -10,7 +10,6 @@ FoamFile
     version     2.0;
     format      ascii;
     class       pointVectorField;
-    location    "0.01";
     object      pointDisplacement;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun b/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun
index 8d10da5a1f4adbaed4fb15afdb5e474ea5093c05..08e91994a5c843d0a69ba137da519be071a5e2e5 100755
--- a/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun
+++ b/tutorials/incompressible/pimpleFoam/LES/channel395/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 runApplication blockMesh
diff --git a/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun b/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun
index 5d8a22acc0b4cdef500fdfb46bae6776c8de6358..d6690e27eda54fb52c9d89a131855298623c63e2 100755
--- a/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun
+++ b/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
@@ -14,4 +12,4 @@ runApplication decomposePar -cellDist
 runParallel $(getApplication)
 #runApplication reconstructPar -latestTime
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean
index 97f2707db81d7086eac366adedadf01c2a642142..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean
+++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allclean
@@ -1,9 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-
-\rm -rf 0
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun
index 8551f1c7155f5461954c31491dc63739738a5702..89808888c0e2bf0641a249246c122c9eb36fc627 100755
--- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun
+++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 rm -f system/blockMeshDict
 m4 system/blockMeshDict.m4 > system/blockMeshDict
@@ -14,3 +12,10 @@ restore0Dir
 runApplication decomposePar
 
 runParallel $(getApplication)
+
+# Run noise tool for both point and surface
+
+runParallel -s point noise -dict system/noiseDict-point
+
+runParallel -s surface noise -dict system/noiseDict-surface
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/README b/tutorials/incompressible/pimpleFoam/LES/vortexShed/README
new file mode 100644
index 0000000000000000000000000000000000000000..10722d1a6a4818c8f2eed3e771afa2f61390725e
--- /dev/null
+++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/README
@@ -0,0 +1,3 @@
+- Acoustic pressure is calculated based on Curle's analogy.
+- Such field is sampled for point (probe) and surface (cutting plane)
+- noise utility is operated onto these samples to obtain frequency information
diff --git a/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface b/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface
index 7a192df56ee31d6f93d9e465ab1dc1981f731ba8..a1206332108d2ae5b968e302999c171f77598fa4 100644
--- a/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface
+++ b/tutorials/incompressible/pimpleFoam/LES/vortexShed/system/noiseDict-surface
@@ -34,7 +34,7 @@ surfaceNoiseCoeffs
 
 
     // Input file
-    file        "postProcessing/cuttingPlane/yNormal_0.0/yNormal_0.0.case";
+    file        "postProcessing/cuttingPlane/zNormal/zNormal.case";
 
     // Surface reader
     reader      ensight;
@@ -48,7 +48,7 @@ surfaceNoiseCoeffs
         ensight
         {
             collateTimes    1;
-	        format          binary;
+            format          binary;
         }
     }
 
diff --git a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean
+++ b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun
index 1492c40ae0918bb27154ca93a05c2d8dff3711d9..7a41c2156897ae219fc29cbdbb8514016648cb11 100755
--- a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun
+++ b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 runApplication blockMesh
@@ -17,4 +15,4 @@ runApplication createBaffles -overwrite
 
 runApplication $(getApplication)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean
+++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun
index a1f6b6bbb67324d9c378d340aac069f6fa2046f2..097989bcc7b5d48d319468986706cdf7bca7f58d 100755
--- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun
+++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 runApplication blockMesh
diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean
index 78739484071adc3d0fd4dff44d0810a0582f66d5..bb826d2457ae1d765942118a5ccf48f7bc6364b5 100755
--- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean
+++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf *.dat validation/*.eps
diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun
index 1737ee272a0ee93b1f0dcaaaec3d532eddac3144..784b7fab75cf9f672c4f0bcf2368eadb8c37ec53 100755
--- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun
+++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph
index d6402c1b4d24e9841380cf21afb38e0ffb713987..b44450a78333f1542cbee17f7294201024cd2fc5 100755
--- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph
+++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/createGraph
@@ -24,4 +24,4 @@ gnuplot<<EOF
         "../WatersKing.dat" with lines t "Analytical" lt -1
 EOF
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean b/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean
index 5521d49681a3ead981a446f58bdd42d3d9531a8b..507327c90a4e01c8d8539b012759830472386418 100755
--- a/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean
+++ b/tutorials/incompressible/pisoFoam/LES/motorBike/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 (cd motorBike && ./Allclean)
 
diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun
index 65eb7ef78f73caf0467ae0590ce5080928f2ef91..9f48464dc2b658ee9ada8e22ad8461bc4ecedda1 100755
--- a/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun
+++ b/tutorials/incompressible/pisoFoam/LES/motorBike/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Do the Spalart-Allmaras steady-state case
 (cd motorBike && foamRunTutorials)
diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun
index e18982c7e64263d06288f0ea98e38138613df75f..5bd3017bd20a3fd98217bbd60063e4f8c1eef0b4 100755
--- a/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun
+++ b/tutorials/incompressible/pisoFoam/LES/motorBike/lesFiles/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Set-up the LES case
 \cp ../lesFiles/fvS* ../lesFiles/controlDict system/
diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean
index da3e92633310925af6fdd2401853242b6304627b..d4886e92271c8f3459e787ccf2c8f15754a5a880 100755
--- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean
+++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove surface
 rm -f constant/triSurface/motorBike.obj.gz
diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun
index b3fbef329127d00a569f54052794f7f61bff6ce7..ede3cb25c2e7600457ba956cec2f35d7bd46dd60 100755
--- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun
+++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy motorbike surface from resources directory
 \cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/
diff --git a/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun b/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun
index db65453658e3edd89a9ea29fd51553d50eac62e1..f88fe7fd920ea9d58fe18f1f291d777b10debfef 100755
--- a/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun
+++ b/tutorials/incompressible/pisoFoam/laminar/porousBlockage/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean
index 7b7e1442f81b825413c545d22f7806af23753774..0686c27498f37a8e90e1b5a68d7a28933ba0ff1e 100755
--- a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean
+++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allclean
@@ -1,12 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
+cleanCase0
 
 # Remove copies of common files
-\rm -rf 0 constant
+\rm -rf constant
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun
index f7891cd4f8df9f1be6a16b6db919eb753c5bfee4..1331199845154dbb44579ed7c6bdc51a40ff4d2f 100755
--- a/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun
+++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/explicit/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 echo "Use common files for 0/, constant/ and blockMeshDict"
 \rm -rf 0 constant
diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean
index 7b7e1442f81b825413c545d22f7806af23753774..0686c27498f37a8e90e1b5a68d7a28933ba0ff1e 100755
--- a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean
+++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allclean
@@ -1,12 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
+cleanCase0
 
 # Remove copies of common files
-\rm -rf 0 constant
+\rm -rf constant
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun
index f7891cd4f8df9f1be6a16b6db919eb753c5bfee4..1331199845154dbb44579ed7c6bdc51a40ff4d2f 100755
--- a/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun
+++ b/tutorials/incompressible/porousSimpleFoam/angledDuct/implicit/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 echo "Use common files for 0/, constant/ and blockMeshDict"
 \rm -rf 0 constant
diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean
index 4ebf8a1a7ff18db41add5c4532e3005eb2f935fa..d6454c597fc45b377ef83966ef12037c753ebde6 100755
--- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean
+++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun
index dbc0b12711ce8b61d182d0255c0ddd4d0e6a5fd1..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun
+++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre
index 33bf5258ce2169182747d6a11df79d20ee65c23d..d8dd07021445648a35a2a557f0ae2a0ec315eb8e 100755
--- a/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre
+++ b/tutorials/incompressible/porousSimpleFoam/straightDuctImplicit/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication surfaceFeatureExtract
 
diff --git a/tutorials/incompressible/simpleFoam/T3A/Allclean b/tutorials/incompressible/simpleFoam/T3A/Allclean
index f02ac1a6eb25f412b2cdecb8ec210e1c3aac5244..8ad093a08cd5ec8b5cc86938986490d31c6ea84d 100755
--- a/tutorials/incompressible/simpleFoam/T3A/Allclean
+++ b/tutorials/incompressible/simpleFoam/T3A/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -f validation/*.eps
diff --git a/tutorials/incompressible/simpleFoam/T3A/Allrun b/tutorials/incompressible/simpleFoam/T3A/Allrun
index 666bf88e7e4b4b71f1e544af0b93799b0ac1b21b..c43f998573757dbcbd07c45a6e7a4c5dac6a09d2 100755
--- a/tutorials/incompressible/simpleFoam/T3A/Allrun
+++ b/tutorials/incompressible/simpleFoam/T3A/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/incompressible/simpleFoam/airFoil2D/Allrun b/tutorials/incompressible/simpleFoam/airFoil2D/Allrun
index c96f61d7ef3da434a039f14cfd7b4cf93718172d..16a6a8651d6a191fb9ae6b6f7e308f2e7bb4625e 100755
--- a/tutorials/incompressible/simpleFoam/airFoil2D/Allrun
+++ b/tutorials/incompressible/simpleFoam/airFoil2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication $(getApplication)
 
diff --git a/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun b/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun
index 52b2a4941d73838617c1741cb20f1d4a5f4acdf5..5db0a1c8e5a022ae01d798031504740b33e1af13 100755
--- a/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun
+++ b/tutorials/incompressible/simpleFoam/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh b/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh
index 5cd24a55282eac9c5d606be0eed4b95803cfd2d5..0caafbabf9e2e6c94c2640f16d2acdf1eaf5af2a 100755
--- a/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh
+++ b/tutorials/incompressible/simpleFoam/mixerVessel2D/makeMesh
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 < system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/incompressible/simpleFoam/motorBike/Allclean b/tutorials/incompressible/simpleFoam/motorBike/Allclean
index 1dca1e06777e5689add188ca9fe1474f8d53647b..a0bb1b4d393264805bc967260a37c840225fc70e 100755
--- a/tutorials/incompressible/simpleFoam/motorBike/Allclean
+++ b/tutorials/incompressible/simpleFoam/motorBike/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove surface and features
 rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1
diff --git a/tutorials/incompressible/simpleFoam/motorBike/Allrun b/tutorials/incompressible/simpleFoam/motorBike/Allrun
index c110f083ecd737c4e8180e63f5a5b7df9368f9b7..268780fb13c2ffd67bd1ca408a560741123ef0ef 100755
--- a/tutorials/incompressible/simpleFoam/motorBike/Allrun
+++ b/tutorials/incompressible/simpleFoam/motorBike/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Alternative decomposeParDict name:
 decompDict="-decomposeParDict system/decomposeParDict.6"
@@ -15,7 +13,7 @@ runApplication surfaceFeatureExtract
 
 runApplication blockMesh
 
-runApplication decomposePar $decompDict
+runApplication $decompDict decomposePar
 
 # Using distributedTriSurfaceMesh?
 if foamDictionary -entry geometry -value system/snappyHexMeshDict | \
diff --git a/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean b/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean
+++ b/tutorials/incompressible/simpleFoam/pipeCyclic/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun b/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun
index 0cade47aa82d2fabaddb5e1844db8a6d3b89ce97..9b8ed30d971e6dfe38aba17f8ce829f608b3ac91 100755
--- a/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun
+++ b/tutorials/incompressible/simpleFoam/pipeCyclic/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/incompressible/simpleFoam/rotorDisk/Allclean b/tutorials/incompressible/simpleFoam/rotorDisk/Allclean
index 47d0a0c0c111b14a7dbf60677c826c6f7e501436..09925d447d00693cdf322363baa35a0517f582b2 100755
--- a/tutorials/incompressible/simpleFoam/rotorDisk/Allclean
+++ b/tutorials/incompressible/simpleFoam/rotorDisk/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/incompressible/simpleFoam/rotorDisk/Allrun b/tutorials/incompressible/simpleFoam/rotorDisk/Allrun
index f6f1258231271bbe7ef6e65f55c27603b3c0c01e..12d9aa38bfd1d275bb34ed5953cfa05d5fa698be 100755
--- a/tutorials/incompressible/simpleFoam/rotorDisk/Allrun
+++ b/tutorials/incompressible/simpleFoam/rotorDisk/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Meshing
 runApplication blockMesh
diff --git a/tutorials/incompressible/simpleFoam/simpleCar/Allrun b/tutorials/incompressible/simpleFoam/simpleCar/Allrun
index db65453658e3edd89a9ea29fd51553d50eac62e1..f88fe7fd920ea9d58fe18f1f291d777b10debfef 100755
--- a/tutorials/incompressible/simpleFoam/simpleCar/Allrun
+++ b/tutorials/incompressible/simpleFoam/simpleCar/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/Allclean b/tutorials/incompressible/simpleFoam/turbineSiting/Allclean
index abf6e2e700e3eafc368ea14db56dc9fb7f3c6118..c357ba7bfe58cc39d92d6a38559ee2d2b7e645a6 100755
--- a/tutorials/incompressible/simpleFoam/turbineSiting/Allclean
+++ b/tutorials/incompressible/simpleFoam/turbineSiting/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove decomposeParDict
 rm -f system/decomposeParDict
diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/Allrun b/tutorials/incompressible/simpleFoam/turbineSiting/Allrun
index fd62abc0fa7d70c09c1ea7c974d087077af691f8..ef45fe0dd57fb4e5c38fb737c7c7eca77b36ff3f 100755
--- a/tutorials/incompressible/simpleFoam/turbineSiting/Allrun
+++ b/tutorials/incompressible/simpleFoam/turbineSiting/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Make dummy 0 directory
 mkdir 0
diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean
index 8039a7526408603e09e1efaf8ccf07c424296248..53afd7eaead4f95652b0abc5f78451e168a55318 100755
--- a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean
+++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun
index 06dc7a18c55c4ada424c29a13d95eec58b926c8c..cc32f55043deddf9844861ef86ec686d32f75632 100755
--- a/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun
+++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication surfaceFeatureExtract
 
diff --git a/tutorials/lagrangian/MPPICFoam/cyclone/Allclean b/tutorials/lagrangian/MPPICFoam/cyclone/Allclean
index e274cef962b7a59a49bd8aa5d45c2fe7ec18b479..d4f2a95a0e36cb7f45437c4dc2c0a891ce744bdc 100755
--- a/tutorials/lagrangian/MPPICFoam/cyclone/Allclean
+++ b/tutorials/lagrangian/MPPICFoam/cyclone/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/lagrangian/MPPICFoam/cyclone/Allrun b/tutorials/lagrangian/MPPICFoam/cyclone/Allrun
index 8af86abdc32cc5dbcbc5af39dd0018234384fa52..680e22fbc3bd979e006b8cc301d9e02c667d92c9 100755
--- a/tutorials/lagrangian/MPPICFoam/cyclone/Allrun
+++ b/tutorials/lagrangian/MPPICFoam/cyclone/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 cp $FOAM_TUTORIALS/resources/geometry/cyclone.stl.gz constant/triSurface
diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun
index 158fb0bf528573eda64b6b9d98b39b30a07e4386..1c2a7447eb1a13bb49cdc3fc5c801535e5a15e50 100755
--- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun
+++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create mesh
 runApplication blockMesh
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U
index 843a28d50f459c0fa5523b1c701d2f1802df6870..8a3472efb14e104cc0996c642afacab9f2d10b59 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/0/U
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun
index ac4e385790a30145d6fb9fa63432482594c740cf..413155fdb032559c8edf9cec0105eb7f67fc74b8 100755
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/Allrun
@@ -1,11 +1,11 @@
 #!/bin/sh
-
-cd ${0%/*} || exit 1 # Run from this directory
-
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 < system/blockMeshDict.m4 > system/blockMeshDict
 
 runApplication blockMesh
 
 runApplication $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict
index 180fa548d9fb833ca06f285e647f033415b49cfa..098df40ce8591aacba833047c5b570302b15f8b2 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/dynamicMeshDict
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g
index 7db1127c4e7e5a64adc66d523360bc2073f44857..e385acd7d9adc45c5e67561dbec3626797f54fd6 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/g
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions
index 72e44ae6a1c406078ae38b7164431bc4dce85ed4..0e75a13567cdc042fe608d8a5859b3a6b5b5d62f 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudPositions
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties
index d2c439ffa100c4c6da8a07240f8e60a3848b3779..dc1b7a9f5cafa35056eb5da42519d45960a2aa81 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/kinematicCloudProperties
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties
index 3a1bb800c6f9515bac852efbe3d238ea8944284a..104081599aa155327c3cabff49b8bcd115423ba1 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/transportProperties
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties
index c2c3b28a1b4e8f4a2cae55f58bd61f9b1a67b488..5eec04267266e7fd15e7701a875d683d5e658cd9 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/constant/turbulenceProperties
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4 b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4
index d6cc8a50c8c8306defc4f6cdd56bcd30245c2bd0..9b6f8a5e2bcf512bf7433ddb8cc8497e63487fd2 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/blockMeshDict.m4
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict
index 3bf92c6e366091cf1316c2804fc5a2a078f1701f..245a1149e04787422cca7146ba3be4ff2370438d 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/controlDict
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes
index 9c5ef530909d1e963a2fe0827f810d016a52808a..93fc84347871c7adfb431cd35ab91ed9df1fe796 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSchemes
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution
index b0b21145a2b05d920040ee158d69a3f833dedd17..cb6c43877e550400f031a94d663b2cfc0deb94e8 100644
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelDyMFoam/mixerVesselAMI2D/system/fvSolution
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean
index 47cedce61ea4664897f6d1a65785260159fcd9a4..d837e1f76092a3c2bde4816178b9a2c2edca8a6c 100755
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allclean
@@ -1,20 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+( cd hopperInitialState && cleanCase )
 
-(
-    cd hopperInitialState || exit 1
-
-    cleanCase
-)
-
-(
-    cd hopperEmptying || exit 1
-
-    cleanCase
-    rm -rf 0
-)
+( cd hopperEmptying && cleanCase0 )
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun
index 2beb0f035509562c26da5d2964da525345acd898..c8e15ac9446beff24bfe66436c59282a30959fd7 100755
--- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun
+++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 (
     cd hopperInitialState || exit 1
diff --git a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh
index b51753afdff9f98c5738810e93ef1605f1d11c9c..430890dd3cb2801b947e13a15d59e678fae45824 100644
--- a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh
+++ b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/0/p_rgh
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean
index 4d36bb740b17841a65611ab534a65a124b816623..51e9ee16ca91be08f7c5e025e5e96fed73e088f3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/wallFilmRegion
 rm -f *.obj
diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun
index dbc0b12711ce8b61d182d0255c0ddd4d0e6a5fd1..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre
index 1ad7fbb61c727c5cc43766f58d8ecdf9dc4f6996..1f5781ea73a8bce33fa57eda9de43935163ab148 100755
--- a/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre
+++ b/tutorials/lagrangian/reactingParcelFoam/cylinder/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh
index 889e4cf111374c8bbb5eae7cdd4e47156ac8ddcd..42af2c294a220d65ad7bb665f431f0f37b96ab20 100644
--- a/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh
+++ b/tutorials/lagrangian/reactingParcelFoam/filter/0.orig/p_rgh
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/Allclean b/tutorials/lagrangian/reactingParcelFoam/filter/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/filter/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/filter/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/Allrun b/tutorials/lagrangian/reactingParcelFoam/filter/Allrun
index 183ac7a8643884f48d3bb308d7d93c1968dd0543..683c4a31e0ff56184145d4c128e901f9a193ffea 100755
--- a/tutorials/lagrangian/reactingParcelFoam/filter/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/filter/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean
index 6ed9b627a7676e3830a2ad8f16a062df52439156..9b60dae89ea8d8ef04dcce82aefeb060e030397b 100755
--- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf system/wallFilmRegion
 rm -rf constant/wallFilmRegion
diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun
index dbc0b12711ce8b61d182d0255c0ddd4d0e6a5fd1..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel
index 110ea4ef40de603dd9173f9dd29935ef8847ee4b..7598bf2539a741eef3863b52c73dabacbad5865f 100755
--- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel
+++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre
index a9f16e526ad9ab32479ced026b66027c9a713bc1..4a6913188f2d0a8ac3c09af30cf507aff3038bab 100755
--- a/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre
+++ b/tutorials/lagrangian/reactingParcelFoam/hotBoxes/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh
index 14453a396814c902ca16ba512deea3dbb17c06e2..70182381f8133e738c1dddfd1a658d3717f00df5 100644
--- a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh
+++ b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/0/p_rgh
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean
index 4d36bb740b17841a65611ab534a65a124b816623..51e9ee16ca91be08f7c5e025e5e96fed73e088f3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/wallFilmRegion
 rm -f *.obj
diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun
index dbc0b12711ce8b61d182d0255c0ddd4d0e6a5fd1..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre
index 4ff21dad8e0e653a56e5a4447916fd6ac792eb8d..4002157fcf94680b1bec2a0e8bc18b8b76f5f015 100755
--- a/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre
+++ b/tutorials/lagrangian/reactingParcelFoam/rivuletPanel/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean
index 4d36bb740b17841a65611ab534a65a124b816623..51e9ee16ca91be08f7c5e025e5e96fed73e088f3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/wallFilmRegion
 rm -f *.obj
diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun
index dbc0b12711ce8b61d182d0255c0ddd4d0e6a5fd1..4a206678cd0030722f1dd69879ce535e800b17c8 100755
--- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre
index 00eed56aae61f4d1786a3d9ec2cf9510e8b19478..1722219969f42269271017033e897136d125d6ef 100755
--- a/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre
+++ b/tutorials/lagrangian/reactingParcelFoam/splashPanel/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh
index 462a0fa1054c950170c41ea1a898adaff3a6607e..616e1c783f66b6d785e5b4291056807226697e9f 100644
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.orig/p_rgh
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun
index 58c87fca19363c0d55bb112e6e604bb12ac89ea0..9edda44dd8d8341c4dd91009892d95e2bb3cd4d3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create mesh
 runApplication blockMesh
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh
index bab3fe3b901be867037acf4bf692114cdb4fd87d..6d61fe5976209a3bf19d73205375e93011d922e6 100644
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/0.orig/p_rgh
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun
index 58c87fca19363c0d55bb112e6e604bb12ac89ea0..9edda44dd8d8341c4dd91009892d95e2bb3cd4d3 100755
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create mesh
 runApplication blockMesh
diff --git a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean
+++ b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun
index 6be8a2051632b8004293b797d6d23148bae5e06b..c2c258a824163408ada90a4bbb98650b128c9d36 100755
--- a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun
+++ b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/mesh/blockMesh/pipe/Allrun b/tutorials/mesh/blockMesh/pipe/Allrun
index 3c4ef3e7fffd9530e7208b7e0b463a777a3bac00..a33126fcfd5174d8d9088e071a018929df0a673f 100755
--- a/tutorials/mesh/blockMesh/pipe/Allrun
+++ b/tutorials/mesh/blockMesh/pipe/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/mesh/blockMesh/sphere/Allrun b/tutorials/mesh/blockMesh/sphere/Allrun
index 3c4ef3e7fffd9530e7208b7e0b463a777a3bac00..a33126fcfd5174d8d9088e071a018929df0a673f 100755
--- a/tutorials/mesh/blockMesh/sphere/Allrun
+++ b/tutorials/mesh/blockMesh/sphere/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/mesh/blockMesh/sphere7/Allrun b/tutorials/mesh/blockMesh/sphere7/Allrun
index 3c4ef3e7fffd9530e7208b7e0b463a777a3bac00..a33126fcfd5174d8d9088e071a018929df0a673f 100755
--- a/tutorials/mesh/blockMesh/sphere7/Allrun
+++ b/tutorials/mesh/blockMesh/sphere7/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun b/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun
index 3c4ef3e7fffd9530e7208b7e0b463a777a3bac00..a33126fcfd5174d8d9088e071a018929df0a673f 100755
--- a/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun
+++ b/tutorials/mesh/blockMesh/sphere7ProjectedEdges/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/mesh/foamyHexMesh/Allrun b/tutorials/mesh/foamyHexMesh/Allrun
index 93da24214e4b55618418fc256cf2e22006166697..d8d59bb66159e3663563a2ad88e3b102bfdba2ec 100755
--- a/tutorials/mesh/foamyHexMesh/Allrun
+++ b/tutorials/mesh/foamyHexMesh/Allrun
@@ -1,32 +1,18 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Any cases that are links to solver test cases and are run when the Allrun
 # scripts of those solvers are run.  This script avoids meshing these cases
 # twice.
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
-(
-    cd blob || exit
-    ./Allrun $*
-)
-(
-    cd simpleShapes || exit
-    ./Allrun $*
-)
+( cd blob && ./Allrun $* )
+( cd simpleShapes && ./Allrun $* )
 
 if ! isTest $@
 then
-    (
-        cd flange || exit
-        ./Allrun $*
-    )
-    (
-        cd mixerVessel || exit
-        ./Allrun $*
-    )
+    ( cd flange && ./Allrun $* )
+    ( cd mixerVessel && ./Allrun $* )
 fi
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/mesh/foamyHexMesh/blob/Allclean b/tutorials/mesh/foamyHexMesh/blob/Allclean
index f4dcb53f51ae231ae70396df6af873ab45157851..1b3fad50fc9f6095ac06e09123e2b4330da27fda 100755
--- a/tutorials/mesh/foamyHexMesh/blob/Allclean
+++ b/tutorials/mesh/foamyHexMesh/blob/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/triSurface/blob.stl.gz > /dev/null 2>&1
 
diff --git a/tutorials/mesh/foamyHexMesh/blob/Allrun b/tutorials/mesh/foamyHexMesh/blob/Allrun
index a4d7bd61d581785dba4d4d06fadc964ad034441a..b4c8454ee3aafa0da272bee48af3c286ad289a50 100755
--- a/tutorials/mesh/foamyHexMesh/blob/Allrun
+++ b/tutorials/mesh/foamyHexMesh/blob/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy flange surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/blob.stl.gz constant/triSurface/
diff --git a/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel b/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel
index 7947ab35f21ac2bfa5f5fb57ab52ac220e686ef3..32429bd239417cf334b9129517bfc029bfc6c556 100755
--- a/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel
+++ b/tutorials/mesh/foamyHexMesh/blob/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy flange surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/blob.stl.gz constant/triSurface/
diff --git a/tutorials/mesh/foamyHexMesh/flange/Allclean b/tutorials/mesh/foamyHexMesh/flange/Allclean
index 75abafd12bbd62c1b60132289e14316722425a5e..c4e27e7164da79f87541c63a419a0b091cbea7a6 100755
--- a/tutorials/mesh/foamyHexMesh/flange/Allclean
+++ b/tutorials/mesh/foamyHexMesh/flange/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -r constant/triSurface/flange.stl.gz > /dev/null 2>&1
 
diff --git a/tutorials/mesh/foamyHexMesh/flange/Allrun b/tutorials/mesh/foamyHexMesh/flange/Allrun
index 414ca8f4a3d33ece6f2f2ccd74ad9ec861442b43..5487824ca4ba146368b252cb88e6c3af4f254599 100755
--- a/tutorials/mesh/foamyHexMesh/flange/Allrun
+++ b/tutorials/mesh/foamyHexMesh/flange/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy flange surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/
diff --git a/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel b/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel
index fb57faff8e1f3d70a0096bba298baefe06641a83..c9e154a60cf4ee03401847cffefb6b3aa0152a25 100755
--- a/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel
+++ b/tutorials/mesh/foamyHexMesh/flange/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy flange surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/
diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean b/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean
index afee03547e34f0855ee2be1fe2dfe4d12c52a816..7a64d7a6b532d2170b1f9854d113f62794a5fa0d 100755
--- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean
+++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/extendedFeatureEdgeMesh/
 rm -f constant/triSurface/*.eMesh*
diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun
index b66c25a9a4a92ef8f37f9102f5358ba201224309..5aabd4c3eea50264ff935e48ef5b9a1c5a4cac77 100755
--- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun
+++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Generate mesh
 ./Allrun-pre
diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre
index 21c5d3f1998cc8a0369d9a0c33d806327c44e87b..fa89b7f6c32480e5be26cceb09b70ce53d64662b 100755
--- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre
+++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 intersectSurfaces()
 {
@@ -38,7 +36,7 @@ intersectSurfaces stirrer_baffles.stl stirrer.stl -surf1Baffle -perturb
 intersectSurfaces rotating.stl shaft.stl -surf1Baffle -perturb
 
 # Intersect blades with the plate
-for bladeI in $(seq 1 6);
+for bladeI in $(seq 1 6)
 do
     intersectSurfaces \
         stirrer_baffles_$bladeI.obj \
diff --git a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation
index 392878e5d3ad71ad9bbf04b2191238b8722f805e..a7922952e6bd1ebd260cdf5acd96be272e100aeb 100755
--- a/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation
+++ b/tutorials/mesh/foamyHexMesh/mixerVessel/Allrun-simulation
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 cp system/controlDict.flow system/controlDict
 
diff --git a/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean b/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean
index 5ef122ebb30cc640437da46d5fee4c0e6d83489e..42523e30e7b682f3c1c7e0915172539096db2184 100755
--- a/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean
+++ b/tutorials/mesh/foamyHexMesh/simpleShapes/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -r constant/extendedFeatureEdgeMesh constant/internalDelaunayVertices > /dev/null 2>&1
 rm -f constant/triSurface/*.eMesh > /dev/null 2>&1
diff --git a/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun b/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun
index 1535c7a3a825cad38807aee0081c257e63f982f1..482564c8b5de4d9194df2a1a2212b4591e6b2ac8 100755
--- a/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun
+++ b/tutorials/mesh/foamyHexMesh/simpleShapes/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication -s cone \
     surfaceOrient constant/triSurface/cone.stl \
diff --git a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean
index 894a75c4e03255191b0498997bda71b39cd4df3d..26eaea4667ae52bcfc3e3c35e92c25660899ed94 100755
--- a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean
+++ b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
 rm -rf constant/triSurface/*.eMesh > /dev/null 2>&1
diff --git a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun
index cdd750415ca3bfd2f620023ca402fb31bc170efc..f22a5824bb5fb1ab11a1168fc7b7cc8dc34cbba9 100755
--- a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun
+++ b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 # Make sure surface is oriented properly. Since the letters
diff --git a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam
index 56aef09d09bc7fb6ba9811ad4e736e6b713a6781..c4060eedef03238fe49752f748bfd9d667c581d9 100755
--- a/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam
+++ b/tutorials/mesh/foamyQuadMesh/OpenCFD/Allrun-rhoCentralFoam
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 \cp system/controlDict.rhoCentralFoam system/controlDict
 restore0Dir
diff --git a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean
index 1048413963ce7226c94aab7512a8aab6485a010a..429017895d42d1bdd73092d90d188eb8e243f251 100755
--- a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean
+++ b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun
index 5434248652eb11560a5d697f51868be49f046dbb..f559f8204e3fbe829809e79f1d02b981955a3056 100755
--- a/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun
+++ b/tutorials/mesh/foamyQuadMesh/jaggedBoundary/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication surfaceFeatureExtract
 runApplication foamyQuadMesh -overwrite
diff --git a/tutorials/mesh/foamyQuadMesh/square/Allclean b/tutorials/mesh/foamyQuadMesh/square/Allclean
index 8da713f31dc2496b7deb2fa033108085ce7e5ac0..dc764a614a38d6ac908ee0b51c1064b1e8306b3c 100755
--- a/tutorials/mesh/foamyQuadMesh/square/Allclean
+++ b/tutorials/mesh/foamyQuadMesh/square/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/mesh/foamyQuadMesh/square/Allrun b/tutorials/mesh/foamyQuadMesh/square/Allrun
index 87a113fc1262e7e5e906c6c7e6ab3456d6b93ab4..f72c275f01f22d5d677aba73ddd992d86d36280e 100755
--- a/tutorials/mesh/foamyQuadMesh/square/Allrun
+++ b/tutorials/mesh/foamyQuadMesh/square/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication surfaceFeatureExtract
 runApplication foamyQuadMesh -overwrite
diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean
index a94a6172db565dc7dec33e7d6903cbf1a616be47..57317ddb1ffe80008cd1816add372cf204104217 100755
--- a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean
+++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allclean
@@ -1,19 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-(
-    cd box_snappyHexMesh || exit 1
-    cleanCase
-)
-
-(
-    cd box2D_moveDynamicMesh || exit 1
-    cleanCase
-    rm -rf 0
-)
+( cd box_snappyHexMesh && cleanCase )
 
+( cd box2D_moveDynamicMesh && cleanCase0 )
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun
index 456beeaab5f64521f18771c8bbae46c588907244..785ab59cd0b8037302dce9fb995a630eac5031ea 100755
--- a/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun
+++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Make 3D mesh in slab of cells.
 (
diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement
index c542662e7cacf287d80899ee807a695bd4df39a6..422d3dd30443156eadbfb62cf1e846f42b74cf1a 100644
--- a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement
+++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/cellDisplacement
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus-overset                          |
+|  \\    /   O peration     | Version:  plus                                  |
 |   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
@@ -10,7 +10,6 @@ FoamFile
     version     2.0;
     format      ascii;
     class       volVectorField;
-    location    "0.034";
     object      cellDisplacement;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -59,5 +58,4 @@ boundaryField
     }
 }
 
-
 // ************************************************************************* //
diff --git a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement
index 0748b9df8096ca82acc3f77050c113f76102dc85..92758708dee5ca3aecb2c3614aafe677804c3370 100644
--- a/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement
+++ b/tutorials/mesh/moveDynamicMesh/relativeMotion/box2D_moveDynamicMesh/0.orig/pointDisplacement
@@ -10,7 +10,6 @@ FoamFile
     version     2.0;
     format      ascii;
     class       pointVectorField;
-    location    "0";
     object      pointMotionU;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/tutorials/mesh/parallel/cavity/Allclean b/tutorials/mesh/parallel/cavity/Allclean
index 1ddaee91ff1648c391e96c435bdbf076d0f58b87..3bd36a4b0311885416b3bd9ab477700019d25fb4 100755
--- a/tutorials/mesh/parallel/cavity/Allclean
+++ b/tutorials/mesh/parallel/cavity/Allclean
@@ -1,13 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
 # Restore default dictionaries
-cp system/decomposeParDict-2 system/decomposeParDict
 cp system/controlDict-startTime system/controlDict
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/mesh/parallel/cavity/Allrun b/tutorials/mesh/parallel/cavity/Allrun
index 26c8762dcc9ec3dad1ea87d05e4b1d651fbff805..fdb4a734ca7322f2067a80768bcdfdf0078261cd 100755
--- a/tutorials/mesh/parallel/cavity/Allrun
+++ b/tutorials/mesh/parallel/cavity/Allrun
@@ -1,13 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
-#cp system/decomposeParDict-2 system/decomposeParDict
-#runApplication decomposePar
+decompDict5="-decomposeParDict system/decomposeParDict-5"
 
 # redistributePar to do decomposition
 runParallel -s decompose redistributePar -decompose
@@ -25,15 +22,12 @@ runParallel -s random icoFoam
 cp system/controlDict-latestTime system/controlDict
 
 # Redistribute to 5 processors
-runParallel -s 5 -np 5 redistributePar \
-    -decomposeParDict system/decomposeParDict-5 -cellDist
+runParallel -s 5 $decompDict5 redistributePar -cellDist
 
 # Run a bit more
-runParallel -s 5 -np 5 icoFoam \
-    -decomposeParDict system/decomposeParDict-5
+runParallel -s 5 $decompDict5 icoFoam
 
 # Reconstruct mesh and results
-runParallel -s reconstruct  -np 5 redistributePar -reconstruct
-
+runParallel -s reconstruct -np 5 redistributePar -reconstruct
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/mesh/parallel/cavity/system/decomposeParDict b/tutorials/mesh/parallel/cavity/system/decomposeParDict
index 8c054db9bbb955510d8a4f8d176e8bb51a1e9eaf..01c1ede6e175d8b0ac62a46948a0060a2c5ff0b4 100644
--- a/tutorials/mesh/parallel/cavity/system/decomposeParDict
+++ b/tutorials/mesh/parallel/cavity/system/decomposeParDict
@@ -43,13 +43,14 @@ numberOfSubdomains  2;
 //  for a balanced number of particles in a lagrangian simulation.
 // weightField dsmcRhoNMean;
 
-method          scotch;
-//method          hierarchical;
-// method          simple;
-// method          metis;
-// method          manual;
-// method          multiLevel;
-// method          structured;  // does 2D decomposition of structured mesh
+method      scotch;
+// method      kahip;
+// method      metis;
+// method      hierarchical;
+// method      simple;
+// method      manual;
+// method      multiLevel;
+// method      structured;  // does 2D decomposition of structured mesh
 
 multiLevelCoeffs
 {
diff --git a/tutorials/mesh/parallel/cavity/system/decomposeParDict-2 b/tutorials/mesh/parallel/cavity/system/decomposeParDict-2
deleted file mode 100644
index 8c054db9bbb955510d8a4f8d176e8bb51a1e9eaf..0000000000000000000000000000000000000000
--- a/tutorials/mesh/parallel/cavity/system/decomposeParDict-2
+++ /dev/null
@@ -1,143 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| =========                 |                                                 |
-| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus                                  |
-|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
-|    \\/     M anipulation  |                                                 |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
-    version     2.0;
-    format      ascii;
-    class       dictionary;
-    note        "mesh decomposition control dictionary";
-    object      decomposeParDict;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-numberOfSubdomains  2;
-
-//- Keep owner and neighbour on same processor for faces in zones:
-// preserveFaceZones (heater solid1 solid3);
-
-//- Keep owner and neighbour on same processor for faces in patches:
-//  (makes sense only for cyclic patches)
-//preservePatches (cyclic_half0 cyclic_half1);
-
-//- Keep all of faceSet on a single processor. This puts all cells
-//  connected with a point, edge or face on the same processor.
-//  (just having face connected cells might not guarantee a balanced
-//  decomposition)
-// The processor can be -1 (the decompositionMethod chooses the processor
-// for a good load balance) or explicitly provided (upsets balance).
-//singleProcessorFaceSets ((f0 -1));
-
-
-//- Keep owner and neighbour of baffles on same processor (i.e. keep it
-//  detectable as a baffle). Baffles are two boundary face sharing the
-//  same points.
-//preserveBaffles true;
-
-//- Use the volScalarField named here as a weight for each cell in the
-//  decomposition.  For example, use a particle population field to decompose
-//  for a balanced number of particles in a lagrangian simulation.
-// weightField dsmcRhoNMean;
-
-method          scotch;
-//method          hierarchical;
-// method          simple;
-// method          metis;
-// method          manual;
-// method          multiLevel;
-// method          structured;  // does 2D decomposition of structured mesh
-
-multiLevelCoeffs
-{
-    // Decomposition methods to apply in turn. This is like hierarchical but
-    // fully general - every method can be used at every level.
-
-    level0
-    {
-        numberOfSubdomains  64;
-        //method simple;
-        //simpleCoeffs
-        //{
-        //    n           (2 1 1);
-        //    delta       0.001;
-        //}
-        method scotch;
-    }
-    level1
-    {
-        numberOfSubdomains  4;
-        method scotch;
-    }
-}
-
-// Desired output
-
-simpleCoeffs
-{
-    n           (2 1 1);
-    delta       0.001;
-}
-
-hierarchicalCoeffs
-{
-    n           (1 2 1);
-    delta       0.001;
-    order       xyz;
-}
-
-metisCoeffs
-{
- /*
-    processorWeights
-    (
-        1
-        1
-        1
-        1
-    );
-  */
-}
-
-scotchCoeffs
-{
-    //processorWeights
-    //(
-    //    1
-    //    1
-    //    1
-    //    1
-    //);
-    //writeGraph  true;
-    //strategy "b";
-}
-
-manualCoeffs
-{
-    dataFile    "decompositionData";
-}
-
-structuredCoeffs
-{
-    // Patches to do 2D decomposition on. Structured mesh only; cells have
-    // to be in 'columns' on top of patches.
-    patches     (movingWall);
-
-    // Method to use on the 2D subset
-    method      scotch;
-}
-
-//// Is the case distributed? Note: command-line argument -roots takes
-//// precedence
-//distributed     yes;
-//// Per slave (so nProcs-1 entries) the directory above the case.
-//roots
-//(
-//    "/tmp"
-//    "/tmp"
-//);
-
-// ************************************************************************* //
diff --git a/tutorials/mesh/parallel/cavity/system/decomposeParDict-5 b/tutorials/mesh/parallel/cavity/system/decomposeParDict-5
index 0692228c7c8437894a89a99d023d5a0031babb27..00c7e2a0a7599c6ce46a74a3acfb8eebe9dec9e8 100644
--- a/tutorials/mesh/parallel/cavity/system/decomposeParDict-5
+++ b/tutorials/mesh/parallel/cavity/system/decomposeParDict-5
@@ -43,13 +43,14 @@ numberOfSubdomains  5;
 //  for a balanced number of particles in a lagrangian simulation.
 // weightField dsmcRhoNMean;
 
-method          scotch;
-//method          hierarchical;
-// method          simple;
-// method          metis;
-// method          manual;
-// method          multiLevel;
-// method          structured;  // does 2D decomposition of structured mesh
+method      scotch;
+// method      kahip;
+// method      metis;
+// method      hierarchical;
+// method      simple;
+// method      manual;
+// method      multiLevel;
+// method      structured;  // does 2D decomposition of structured mesh
 
 multiLevelCoeffs
 {
diff --git a/tutorials/mesh/parallel/filter/0.orig/p_rgh b/tutorials/mesh/parallel/filter/0.orig/p_rgh
index 889e4cf111374c8bbb5eae7cdd4e47156ac8ddcd..42af2c294a220d65ad7bb665f431f0f37b96ab20 100644
--- a/tutorials/mesh/parallel/filter/0.orig/p_rgh
+++ b/tutorials/mesh/parallel/filter/0.orig/p_rgh
@@ -1,8 +1,8 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
 FoamFile
diff --git a/tutorials/mesh/parallel/filter/Allclean b/tutorials/mesh/parallel/filter/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/mesh/parallel/filter/Allclean
+++ b/tutorials/mesh/parallel/filter/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/mesh/parallel/filter/Allrun b/tutorials/mesh/parallel/filter/Allrun
index 598afe74a52c340d4560f405f629dac43b06000d..5ac013e09f775bef8ef6df6248ceef06b6ccee12 100755
--- a/tutorials/mesh/parallel/filter/Allrun
+++ b/tutorials/mesh/parallel/filter/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 application=$(getApplication)
 
@@ -29,4 +27,4 @@ runParallel -s parallel $application
 #- Reconstruct all times
 runParallel -s 1 redistributePar -reconstruct
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/mesh/refineMesh/refineFieldDirs/Allclean b/tutorials/mesh/refineMesh/refineFieldDirs/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/mesh/refineMesh/refineFieldDirs/Allclean
+++ b/tutorials/mesh/refineMesh/refineFieldDirs/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/mesh/refineMesh/refineFieldDirs/Allrun b/tutorials/mesh/refineMesh/refineFieldDirs/Allrun
index c3bdd39961898d8634201e7418b12ab17fc1b7c4..26cdf66ba12f72a4d3cbf9dbf2df151c08f5079b 100755
--- a/tutorials/mesh/refineMesh/refineFieldDirs/Allrun
+++ b/tutorials/mesh/refineMesh/refineFieldDirs/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 wmake calcRadiusField
 wclean calcRadiusField
diff --git a/tutorials/mesh/snappyHexMesh/Allrun b/tutorials/mesh/snappyHexMesh/Allrun
index f81482f8745bab6d49b428e388a03fb539f5891d..976f75d38cbe6f1125f20be1678b918de4c4f755 100755
--- a/tutorials/mesh/snappyHexMesh/Allrun
+++ b/tutorials/mesh/snappyHexMesh/Allrun
@@ -1,21 +1,9 @@
 #!/bin/sh
 cd ${0%/*} || exit 1    # Run from this directory
 
-
-(
-    cd flange || exit
-    ./Allrun $*
-)
-
-(
-    cd addLayersToFaceZone || exit
-    ./Allrun
-)
-
-(
-    cd gap_detection || exit
-    ./Allrun
-)
+( cd flange && ./Allrun $* )
+( cd addLayersToFaceZone && ./Allrun )
+( cd gap_detection && ./Allrun )
 
 exit 0
 
diff --git a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean
+++ b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun
index 7a0dffe68c369c56281581ff568e976742e369a4..0ee02ee22699bca35b9bf543ab6244d072b96ac8 100755
--- a/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun
+++ b/tutorials/mesh/snappyHexMesh/addLayersToFaceZone/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 
 runApplication blockMesh
diff --git a/tutorials/mesh/snappyHexMesh/flange/Allclean b/tutorials/mesh/snappyHexMesh/flange/Allclean
index e46b494f7bf07f293ef3fe89824b808255d17441..69d183efe5b2bd295903a3b966ac42442fce30b4 100755
--- a/tutorials/mesh/snappyHexMesh/flange/Allclean
+++ b/tutorials/mesh/snappyHexMesh/flange/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -f ./flange ./*.obj > /dev/null 2>&1
 
diff --git a/tutorials/mesh/snappyHexMesh/flange/Allrun b/tutorials/mesh/snappyHexMesh/flange/Allrun
index cae2427078d9cdba6f22a843765b4aa3fba683c8..8e2c10e1edd312a724e8d98eb9386460fa78578a 100755
--- a/tutorials/mesh/snappyHexMesh/flange/Allrun
+++ b/tutorials/mesh/snappyHexMesh/flange/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy flange surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/
diff --git a/tutorials/mesh/snappyHexMesh/gap_detection/Allclean b/tutorials/mesh/snappyHexMesh/gap_detection/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/mesh/snappyHexMesh/gap_detection/Allclean
+++ b/tutorials/mesh/snappyHexMesh/gap_detection/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/mesh/snappyHexMesh/gap_detection/Allrun b/tutorials/mesh/snappyHexMesh/gap_detection/Allrun
index fb62f26883d416529919b7c306c5b57a04092236..afb0ddb7344dabee640d51c81faffadb1d15018b 100755
--- a/tutorials/mesh/snappyHexMesh/gap_detection/Allrun
+++ b/tutorials/mesh/snappyHexMesh/gap_detection/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/Allclean b/tutorials/mesh/stitchMesh/simple-cube1/Allclean
new file mode 100755
index 0000000000000000000000000000000000000000..d6d329b5ff7fc534c3227e47c1746e57f96e53f1
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/Allclean
@@ -0,0 +1,8 @@
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
+
+cleanCase0
+rmdir constant 2> /dev/null
+
+# -----------------------------------------------------------------------------
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/Allmesh b/tutorials/mesh/stitchMesh/simple-cube1/Allmesh
new file mode 100755
index 0000000000000000000000000000000000000000..a3e4e0da1538c0ff0ca2a1bd795257ccc999483d
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/Allmesh
@@ -0,0 +1,19 @@
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+
+runApplication blockMesh
+runApplication topoSet
+
+runApplication subsetMesh final -patch outer -resultTime 0
+
+# Avoid any inconsistencies
+rm -f constant/polyMesh/{cellZones,faceZones,pointZones}
+
+runApplication -s patches topoSet -dict system/topoSetDict.patches
+
+runApplication createPatch -overwrite
+
+# rm -f 0/polyMesh/{cellZones,faceZones,pointZones}
+
+# -----------------------------------------------------------------------------
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/Allrun b/tutorials/mesh/stitchMesh/simple-cube1/Allrun
new file mode 100755
index 0000000000000000000000000000000000000000..1f37298922d81a48dc3c9f69c798b71f5069bb05
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/Allrun
@@ -0,0 +1,12 @@
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+
+runApplication ./Allmesh
+
+for dir in x y z
+do
+    runApplication -s dir-$dir stitchMesh -partial outer$dir inner$dir
+done
+
+# -----------------------------------------------------------------------------
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch b/tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch
new file mode 100755
index 0000000000000000000000000000000000000000..fd63d6d6827e674f8b25a8e2a6f471a6c382a659
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/scripts/stitch
@@ -0,0 +1,50 @@
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
+
+[ "$#" -gt 0 ] || {
+    echo "provide x, y, z or -all directions"
+    exit 1
+}
+
+unset optAll
+for dir
+do
+    case "$dir" in
+    -x | x) rm -rf 1 2 3 ;;
+    -y | y) rm -rf 2 3 ;;
+    -z | z) rm -rf 3 ;;
+    -all | all)
+        optAll=true
+        rm -rf 1 2 3
+        ;;
+    *)
+        echo "provide x, y, z or -all directions"
+        exit 1
+        ;;
+    esac
+done
+
+if [ "$optAll" = true ]
+then
+    set -- x y z
+fi
+
+stitch()
+{
+    local dir=$1
+    stitchMesh -partial outer$dir inner$dir | tee log.stitch-$dir
+}
+
+
+for dir
+do
+    case "$dir" in
+    -x | x) [ -d 1 ] || stitch x;;
+    -y | y) [ -d 2 ] || stitch y;;
+    -z | z) [ -d 3 ] || stitch z;;
+    esac
+done
+
+
+# -----------------------------------------------------------------------------
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict b/tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict
new file mode 100644
index 0000000000000000000000000000000000000000..5c02992369590d3066268a409a9a72aaaa000e71
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/blockMeshDict
@@ -0,0 +1,132 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      blockMeshDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+scale   1;
+
+// Dimensions for outer box
+lo      0;      // outer lower corner
+uo      1;      // outer upper corner
+
+// Dimensions for inner box
+li      -0.1;   // inner lower corner
+
+ui      0.497;  // inner upper corner
+//      ^^^^^ very poorly handled gaps
+
+ui      0.498;  // inner upper corner
+//      ^^^^^ slave patch probably does not project onto master
+
+ui      0.499;  // inner upper corner
+//      ^^^^^ OK
+
+
+vertices
+(
+    ( $lo $lo $lo )
+    ( $uo $lo $lo )
+    ( $uo $uo $lo )
+    ( $lo $uo $lo )
+    ( $lo $lo $uo )
+    ( $uo $lo $uo )
+    ( $uo $uo $uo )
+    ( $lo $uo $uo )
+
+    ( $li $li $li )
+    ( $ui $li $li )
+    ( $ui $ui $li )
+    ( $li $ui $li )
+    ( $li $li $ui )
+    ( $ui $li $ui )
+    ( $ui $ui $ui )
+    ( $li $ui $ui )
+);
+
+blocks
+(
+    hex (0 1 2 3 4 5 6 7)       (6 6 6)    simpleGrading (1 1 1)
+    hex (8 9 10 11 12 13 14 15) (10 10 10) simpleGrading (1 1 1)
+);
+
+edges
+(
+);
+
+boundary
+(
+    wallso
+    {
+        type patch;
+        faces
+        (
+            // Walls of the outside block
+            (0 4 7 3)
+            (1 2 6 5)
+            (0 1 5 4)
+            (3 7 6 2)
+            (0 3 2 1)
+            (4 5 6 7)
+        );
+    }
+    wallsi
+    {
+        type patch;
+        faces
+        (
+            // Walls of the inside block
+            (8 12 15 11)
+            (8 9 13 12)
+            (8 11 10 9)
+        );
+    }
+
+    // Outer faces populated by subsetMesh
+    outer
+    {
+        type patch;
+        faces ();
+    }
+
+    innerx
+    {
+        type patch;
+        inGroups (inner);
+        faces
+        (
+            (9 10 14 13)
+        );
+    }
+    innery
+    {
+        type patch;
+        inGroups (inner);
+        faces
+        (
+            (11 15 14 10)
+        );
+    }
+    innerz
+    {
+        type patch;
+        inGroups (inner);
+        faces
+        (
+            (12 13 14 15)
+        );
+    }
+
+);
+
+// ************************************************************************* //
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/controlDict b/tutorials/mesh/stitchMesh/simple-cube1/system/controlDict
new file mode 100644
index 0000000000000000000000000000000000000000..b0f6027eaddb4a28bf48b1aaee40c9d4caaebbe8
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/controlDict
@@ -0,0 +1,45 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      controlDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+application     simpleFoam;
+
+startFrom       latestTime;
+
+startTime       0;
+
+stopAt          endTime;
+
+endTime         10;
+
+deltaT          1;
+
+writeControl    runTime;
+
+writeInterval   1;
+
+purgeWrite      0;
+
+writeFormat     ascii;
+
+writePrecision  6;
+
+timeFormat      general;
+
+timePrecision   6;
+
+runTimeModifiable true;
+
+// ************************************************************************* //
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U b/tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict
similarity index 67%
rename from tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U
rename to tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict
index 2b8e9315bf5235ed281a96cf922ff2463b94db4e..deae7b1a60cce5e8316d79d554a3fe45f523897f 100644
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/U
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/createPatchDict
@@ -9,35 +9,45 @@ FoamFile
 {
     version     2.0;
     format      ascii;
-    class       volVectorField;
-    location    "0";
-    object      U;
+    class       dictionary;
+    object      createPatchDict;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-dimensions      [0 1 -1 0 0 0 0];
+pointSync   false;
 
-internalField   uniform (0 0 0);
-
-boundaryField
+outerSet
 {
-    rotor
+    patchInfo
     {
-        type            noSlip;
+        type patch;
+        inGroups (outer);
     }
-    stator
+
+    constructFrom set;
+}
+
+
+// Patches to create.
+patches
+(
     {
-        type            noSlip;
+        name outerx;
+        set  outerx;
+        $outerSet;
     }
-    front
+
     {
-        type            empty;
+        name outery;
+        set  outery;
+        $outerSet;
     }
-    back
+
     {
-        type            empty;
+        name outerz;
+        set  outerz;
+        $outerSet;
     }
-}
-
+);
 
 // ************************************************************************* //
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes
new file mode 100644
index 0000000000000000000000000000000000000000..9c127712e79e022e4fde61e8ff008cf959160c3b
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSchemes
@@ -0,0 +1,55 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      fvSchemes;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ddtSchemes
+{
+    default         Euler;
+}
+
+gradSchemes
+{
+    default         Gauss linear;
+}
+
+divSchemes
+{
+    default         none;
+    div(phi,U)      Gauss cubic;
+}
+
+laplacianSchemes
+{
+    default         Gauss linear corrected;
+}
+
+interpolationSchemes
+{
+    default         linear;
+}
+
+snGradSchemes
+{
+    default         corrected;
+}
+
+fluxRequired
+{
+    default         no;
+    p               ;
+}
+
+
+// ************************************************************************* //
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution
new file mode 100644
index 0000000000000000000000000000000000000000..fce1b29ce9e2f06eb6f8c2741fb80540f81ace3f
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/fvSolution
@@ -0,0 +1,43 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      fvSolution;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+solvers
+{
+    p
+    {
+        solver          PCG;
+        preconditioner  DIC;
+        tolerance       1e-06;
+        relTol          0;
+    }
+
+    U
+    {
+        solver          smoothSolver;
+        smoother        symGaussSeidel;
+        tolerance       1e-05;
+        relTol          0;
+    }
+}
+
+PISO
+{
+    nCorrectors     2;
+    nNonOrthogonalCorrectors 0;
+}
+
+
+// ************************************************************************* //
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict
new file mode 100644
index 0000000000000000000000000000000000000000..9602c4e1475b9f37e6b2c70b2404bd0640db735a
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict
@@ -0,0 +1,106 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      topoSetDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+actions
+(
+    // Outer cube
+    {
+        name    outer;
+        type    cellSet;
+        action  new;
+        source  regionToCell;
+        sourceInfo
+        {
+            insidePoints
+            (
+                (0.99 0.99 0.99)
+            );
+        }
+    }
+
+    {
+        name    corner;
+        type    cellSet;
+        action  new;
+        source  boxToCell;
+        sourceInfo
+        {
+            box (-1 -1 -1)(0.5 0.5 0.5);
+        }
+    }
+
+    {
+        name    inner;
+        type    cellSet;
+        action  new;
+        source  cellToCell;
+        sourceInfo
+        {
+            set corner;
+        }
+    }
+
+    {
+        name    inner;
+        type    cellSet;
+        action  delete;
+        source  cellToCell;
+        sourceInfo
+        {
+            set outer;
+        }
+    }
+
+    {
+        name    outer;
+        type    cellSet;
+        action  delete;
+        source  cellToCell;
+        sourceInfo
+        {
+            set corner;
+        }
+    }
+
+    {
+        name    corner;
+        type    cellSet;
+        action  clear;
+    }
+
+    {
+        name    final;
+        type    cellSet;
+        action  new;
+        source  cellToCell;
+        sourceInfo
+        {
+            set outer;
+        }
+    }
+    {
+        name    final;
+        type    cellSet;
+        action  add;
+        source  cellToCell;
+        sourceInfo
+        {
+            set inner;
+        }
+    }
+);
+
+// ************************************************************************* //
diff --git a/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches
new file mode 100644
index 0000000000000000000000000000000000000000..36a415b66be4b85b50d48b365c152383e641e796
--- /dev/null
+++ b/tutorials/mesh/stitchMesh/simple-cube1/system/topoSetDict.patches
@@ -0,0 +1,88 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  plus                                  |
+|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       dictionary;
+    object      topoSetDict;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+newFromPatch
+{
+    type    faceSet;
+    action  new;
+    source  patchToFace;
+    sourceInfo
+    {
+        name outer;
+    }
+}
+
+subsetNormal
+{
+    type    faceSet;
+    action  subset;
+    source  normalToFace;
+    sourceInfo
+    {
+        cos     0.1;
+    }
+}
+
+actions
+(
+    // outerx
+    {
+        name  outerx;
+        $newFromPatch
+    }
+
+    {
+        name  outerx;
+        $subsetNormal;
+        sourceInfo
+        {
+            normal (-1 0 0);
+        }
+    }
+
+    // outery
+    {
+        name  outery;
+        $newFromPatch
+    }
+
+    {
+        name  outery;
+        $subsetNormal;
+        sourceInfo
+        {
+            normal (0 -1 0);
+        }
+    }
+
+    // outerz
+    {
+        name  outerz;
+        $newFromPatch
+    }
+
+    {
+        name  outerz;
+        $subsetNormal;
+        sourceInfo
+        {
+            normal (0 0 -1);
+        }
+    }
+
+);
+
+// ************************************************************************* //
diff --git a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean
index eb6c79aa66377452012b3c76c7b3701ede496beb..8b16e2858e07cb043805998b19117b8d3b4e6e2f 100755
--- a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean
+++ b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allclean
@@ -1,12 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
 rm -f system/blockMeshDict
 rm -f 0/alpha.water
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun
index 73737743f25f2b20cabb5cec8553b69582d99ecc..b2023e2d8f46bfb931e0e7fc330e09e4368194b9 100755
--- a/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun
+++ b/tutorials/multiphase/MPPICInterFoam/twoPhasePachuka/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # create the underlying block mesh
 m4 system/pachuka.m4 > system/blockMeshDict
@@ -29,4 +27,4 @@ runParallel $(getApplication)
 # Reconstruct case
 runApplication reconstructPar
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/cavitatingFoam/LES/Allrun b/tutorials/multiphase/cavitatingFoam/LES/Allrun
index e0ffdffe185953ba18d157f0f9deb4d76a07df2a..153b2506fcb05242bccd535efa76865855ce8de9 100755
--- a/tutorials/multiphase/cavitatingFoam/LES/Allrun
+++ b/tutorials/multiphase/cavitatingFoam/LES/Allrun
@@ -1,14 +1,7 @@
 #!/bin/sh
 cd ${0%/*} || exit 1    # Run from this directory
 
-(
-    cd throttle || exit
-    ./Allrun $*
-)
-
-(
-    cd throttle3D || exit
-    ./Allrun $*
-)
+( cd throttle && ./Allrun $* )
+( cd throttle3D && ./Allrun $* )
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean
index 6bb45f9da9b680c3e27b84f32480c955af2cdc87..7e94847a483cbf4df83508a0f95a3fc916a68ee0 100755
--- a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean
+++ b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun
index d399430e22495622a5d790dc939ef675016fd164..1b1d5e80a04b6b22720786aee857387b41d839d0 100755
--- a/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun
+++ b/tutorials/multiphase/cavitatingFoam/LES/throttle/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 refineMeshByCellSet()
 {
diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean
index 8b8b96fa046507b00e2e1498724d4a5095eb9620..d695acbf073c9fc611f3a021b6e81a5404db57fd 100755
--- a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean
+++ b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm system/topoSetDict > /dev/null 2>&1
 rm -rf processor[0-9] > /dev/null 2>&1
diff --git a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun
index 39816254dd490965cdb4f2f21302d0f771156ac4..15a39575b71bff31211377e3af282ed3b9a5dc3c 100755
--- a/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun
+++ b/tutorials/multiphase/cavitatingFoam/LES/throttle3D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 refineMeshByCellSet()
 {
diff --git a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean
index 6bb45f9da9b680c3e27b84f32480c955af2cdc87..7e94847a483cbf4df83508a0f95a3fc916a68ee0 100755
--- a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean
+++ b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun
index d399430e22495622a5d790dc939ef675016fd164..1b1d5e80a04b6b22720786aee857387b41d839d0 100755
--- a/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun
+++ b/tutorials/multiphase/cavitatingFoam/RAS/throttle/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 refineMeshByCellSet()
 {
diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun
index 31527e6ec22d7448f5b07e8185779d8f25750efa..c63280a960d1163893f5f0dc1ed8a63d3e9fb275 100755
--- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun
+++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sloshingTank2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean
index e49ac35744ede7554645181bba3a8607ee44ba08..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean
+++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allclean
@@ -1,9 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-cleanCase
-
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun
index 7c3704c16857e357ee467d831da14a9c5f06c1a9..55bb318bf3053005636f20295f6c0d9903362a36 100755
--- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun
+++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel
index bdf2b279c78bc9ba866be172a1dc1524ff0825a0..e66ceb6b8f904e71ae7b5aa663b01c40fe1c6aed 100755
--- a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel
+++ b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/Allrun.parallel
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean
+++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun
index fd07af1d46bcabef45db9aad9d1c153f0f39becb..423e9ec8333253c8a4b63faf7af339b443479965 100755
--- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun
+++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 restore0Dir
diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean
index 86d9367383102e275fe026983693dbb638b74aa4..3b8c6e8e2fb2b80437330845ebe5002ef787f4b3 100755
--- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean
+++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 rm -rf processor*
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun
index 6c6dafdea44eef1c91b654482bf3be033f59bc45..bdb96428fab4a09fe5434006ac2651a46362525a 100755
--- a/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun
+++ b/tutorials/multiphase/compressibleInterFoam/laminar/depthCharge3D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 restore0Dir
diff --git a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean
+++ b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun
index 6cfec647c79d18f2504b7408b94bb8ddbe2e3086..efced0038e951e3578e1e804b9642f639e2bce5e 100755
--- a/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun
+++ b/tutorials/multiphase/compressibleMultiphaseInterFoam/laminar/damBreak4phase/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun
index f1273de8e41357a83af0b1253a297acf47413959..6aeae15553237e47ab738d4a985454a979a3ecb5 100755
--- a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..4065edb322f31711cfb3d4f05a3077fd29bb887f 100755
--- a/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/driftFluxFoam/RAS/mixerVessel2D/makeMesh
@@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun b/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun
index c96f61d7ef3da434a039f14cfd7b4cf93718172d..16a6a8651d6a191fb9ae6b6f7e308f2e7bb4625e 100755
--- a/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun
+++ b/tutorials/multiphase/driftFluxFoam/RAS/tank3D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication $(getApplication)
 
diff --git a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean
+++ b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun
index ebc19b3d2a4adff39cf7ca06c6c671b012c42337..5aace967ac4c7f273caf2a3a8ac42a7b8a102d07 100755
--- a/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun
+++ b/tutorials/multiphase/interCondensatingEvaporatingFoam/condensatingVessel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 application=$(getApplication)
 
diff --git a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean
index a0aed574d064249d38e9e5540f488ea190bd8024..6149df2bfa85ab5eb74544c518b32afa9de13f91 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean
+++ b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allclean
@@ -1,11 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-rm -rf 0
 rm system/topoSetDict > /dev/null 2>&1
 
 # Remove surface and features
diff --git a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun
index 99249befa72e6cfcedcc2409fea6a25830f49e38..975e30d65edecb2a920a5e6c905f4e3258b75da8 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun
+++ b/tutorials/multiphase/interDyMFoam/RAS/DTCHull/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy DTC hull surface from resources folder
 cp $FOAM_TUTORIALS/resources/geometry/DTC-scaled.stl.gz constant/triSurface/
diff --git a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean
+++ b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun
index 6a9d0d022934b4f22d4e024107b9d9098409ce4a..7aede960f72d0bda4e22fb29ce417d77fcf026d5 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun
+++ b/tutorials/multiphase/interDyMFoam/RAS/floatingObject/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean
index d3b4c4257f3c7936b982bd6a0126c8e29d346331..9f8dfd78081276e5417cd1115413728c1215172e 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean
+++ b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0 > /dev/null 2>&1
+cleanCase0
 
 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
 rm -f constant/triSurface/*.eMesh* > /dev/null 2>&1
diff --git a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun
index 83e66bcf9ca0b7ea6a39bb60a1ffc265e8ad9410..62fbd9b214111811f2a27a51ff3f10b8f69b4d30 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun
+++ b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre
index 0d993b2ee7d2f2d5e1535ac436220ae73a89bc13..684bc56996100e09003ad7d1d8b3c0270fae7505 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre
+++ b/tutorials/multiphase/interDyMFoam/RAS/mixerVesselAMI/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 \rm -rf 0
 
diff --git a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean
index 5442dc1333e01662575c442766fce5c37b65a40a..a8a5c30fc0f29e6c3b4d999538e533567eecfafc 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean
+++ b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove surface and features
 \rm -f  constant/triSurface/motorBike.obj.gz > /dev/null 2>&1
@@ -14,4 +11,4 @@ rm -rf 0
 
 \cp system/controlDict_run system/controlDict
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun
index af3c3b444d579918e06711244835d4f27592030b..e2641b893488562fb8bcc07479b8bdae0065f169 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun
+++ b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
@@ -16,4 +14,4 @@ FOAM_SIGFPE=false runParallel -s reconstruct redistributePar -reconstruct
 runParallel -s decompose redistributePar -decompose -latestTime
 runParallel -s restart $(getApplication)
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre
index d4a3ff963991b574ceda910717f54f497aa43c45..030f1f8113cc24cd01fa7f5b6fff148a8df31214 100755
--- a/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre
+++ b/tutorials/multiphase/interDyMFoam/RAS/motorBike/Allrun.pre
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy motorbike surface from resources directory
 \cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/
diff --git a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean
index c9e8210d7785ce379488320db64f2ce1e004a3df..dced1dda723237787258bc6840909d194eaea571 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean
+++ b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm system/cellSetDict > /dev/null 2>&1
 
diff --git a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun
index 755d7612a41f9ec2601a9db825e6a7b5901ce999..4c6e367d38828ee1847f074af06109a7217f3c47 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 runApplication blockMesh
diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun
index 44bb710e5102169ea0c3c77357e23b49bd5dbfa8..9fa872e193fb5a401c8715850433d113d6cc200b 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingCylinder/Allrun
@@ -1,13 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication snappyHexMesh -overwrite
 cp 0/alpha.water.orig 0/alpha.water
 runApplication setFields
-runApplication `getApplication`
+runApplication $(getApplication)
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun
index e827b4c66ab5de7072778c2a80bac0f2db7523bc..ae24f74396c61015d61eaa458007ea37005d9e82 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun
index e827b4c66ab5de7072778c2a80bac0f2db7523bc..ae24f74396c61015d61eaa458007ea37005d9e82 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank2D3DoF/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun
index e827b4c66ab5de7072778c2a80bac0f2db7523bc..ae24f74396c61015d61eaa458007ea37005d9e82 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun
index 823b296e60dbaf5092ecb752a3077207902043b3..faada17ac684327d7cfec73fd698cb7d002d0a33 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D3DoF/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
diff --git a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun
index 603304a5ae32ab7377ac84e7e38028913058ab0f..c63280a960d1163893f5f0dc1ed8a63d3e9fb275 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/sloshingTank3D6DoF/Allrun
@@ -1,13 +1,11 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 runApplication blockMesh
 cp 0/alpha.water.orig 0/alpha.water
 runApplication setFields
-runApplication `getApplication`
+runApplication $(getApplication)
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean
index 8c9c9abaac65b9d9450c0295f887e2506b4d4184..e068de2b139eb5f83cab7b3da1a5010b1489443c 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean
+++ b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm -rf 0/alpha.water
diff --git a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun
index 0af06e79fb4e1b1d4fa9ba2328de784ba59c5fba..a96f714b609e72d4bb7b3fc4b4a6803241971e3e 100755
--- a/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun
+++ b/tutorials/multiphase/interDyMFoam/laminar/testTubeMixer/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 cp 0/alpha.water.orig 0/alpha.water
diff --git a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean
index 473383859a0b61c8d197188eebd6978e3610b73e..20ea2353bb177f42db6860107337758b9cfe4e49 100755
--- a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean
+++ b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 rm system/topoSetDict > /dev/null 2>&1
diff --git a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun
index f110e3491b51d6cecaa0ad3e6aa6321cc909fac0..dc59cb1831bcf809955b78362151a493fba74e80 100755
--- a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun
+++ b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean b/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean
index 0086cd47cb0c88353f0f5d331b776065c012843e..9c855955a4ed9f41733f726e8e4fc17989d119aa 100755
--- a/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean
+++ b/tutorials/multiphase/interFoam/RAS/DTCHull/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm system/topoSetDict > /dev/null 2>&1
 
diff --git a/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun b/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun
index 3eddb17d71b5821e9b7a7c99afc39b37f5a06e8f..2bd2c19a2fffdb34473d4642164182bdcd52cdd8 100755
--- a/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/DTCHull/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy DTC hull surface from resources folder
 \cp $FOAM_TUTORIALS/resources/geometry/DTC-scaled.stl.gz constant/triSurface/
diff --git a/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun b/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun
index ccdfefe5c1ce337739caa5bddd0affe3cfc4aad0..54368cee898fed93435e246ad8a5c58cca03fd25 100755
--- a/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/angledDuct/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/Allclean b/tutorials/multiphase/interFoam/RAS/damBreak/Allclean
index efbd66e1c262b22118772c1a716dd26c52db68a6..050c71bde5fa12db36297c4d96cb268799cdcf01 100755
--- a/tutorials/multiphase/interFoam/RAS/damBreak/Allclean
+++ b/tutorials/multiphase/interFoam/RAS/damBreak/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 keepCases="damBreak"
 loseCases="damBreakFine"
diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/Allrun b/tutorials/multiphase/interFoam/RAS/damBreak/Allrun
index 928fc5036d519f71478de55969a71013c54ca7dd..5588e4ecd039e0dbbc6a6ed27464e53074ccc54b 100755
--- a/tutorials/multiphase/interFoam/RAS/damBreak/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/damBreak/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 setDamBreakFine ()
 {
diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean
index 652e15f7215f32885aedfffdb7fd8b4cf51d8c4a..f578727b2fead8d69ef30991ee5b658c29918804 100755
--- a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean
+++ b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 \cp 0/alpha.water.orig 0/alpha.water
diff --git a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun
index ed61ac543538db7d3679847d004086dd7fe3952f..5bd0f99f3039b9d3fa38ab804d7ac71fac5c2992 100755
--- a/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/damBreak/damBreak/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication setFields
diff --git a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean
index 652e15f7215f32885aedfffdb7fd8b4cf51d8c4a..f578727b2fead8d69ef30991ee5b658c29918804 100755
--- a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean
+++ b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 \cp 0/alpha.water.orig 0/alpha.water
diff --git a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun
index 4c6866acbc18f0346e8d9badc6d118f3c6b9f7fd..7d16543244384e89cd334a48c5368980c379f349 100755
--- a/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/damBreakPorousBaffle/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication setFields
diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean b/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean
index e67e3024e8823c4993864eb0c326a34feafe2e51..b5e3d9ce8810b71807ee3d2b6171301230ae4163 100755
--- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean
+++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh b/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh
index 92d09ceaef7d283af701b4c15459f06814ae3ad1..d0b3f7537812896c7c4e2082db74e37f733f321d 100755
--- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh
+++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun b/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun
index 5a86d49dcb6c907ed66851839049b0cf9feef4f5..072b6d2b199dd1331bf4c5bc44eda10220f01b2b 100755
--- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allmesh
 
diff --git a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean
+++ b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun
index e0a3d741250d5d5e5a4c9beb1381e4ca6fbaabc6..c7107259267d9ec3d57107003fcfe6a9e1483ad5 100755
--- a/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun
+++ b/tutorials/multiphase/interFoam/RAS/weirOverflow/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun b/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun
index b52e0c12fd03a792f1d1c15400926fa3143d0460..42050e1779d7533762023958cb4a380ced878d8c 100755
--- a/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/capillaryRise/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 \cp 0/alpha.water.orig 0/alpha.water
diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/Allclean b/tutorials/multiphase/interFoam/laminar/damBreak/Allclean
index efbd66e1c262b22118772c1a716dd26c52db68a6..050c71bde5fa12db36297c4d96cb268799cdcf01 100755
--- a/tutorials/multiphase/interFoam/laminar/damBreak/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/damBreak/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 keepCases="damBreak"
 loseCases="damBreakFine"
diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/Allrun b/tutorials/multiphase/interFoam/laminar/damBreak/Allrun
index 928fc5036d519f71478de55969a71013c54ca7dd..5588e4ecd039e0dbbc6a6ed27464e53074ccc54b 100755
--- a/tutorials/multiphase/interFoam/laminar/damBreak/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/damBreak/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 setDamBreakFine ()
 {
diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean
index 652e15f7215f32885aedfffdb7fd8b4cf51d8c4a..f578727b2fead8d69ef30991ee5b658c29918804 100755
--- a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 \cp 0/alpha.water.orig 0/alpha.water
diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun
index ed61ac543538db7d3679847d004086dd7fe3952f..5bd0f99f3039b9d3fa38ab804d7ac71fac5c2992 100755
--- a/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/damBreak/damBreak/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication setFields
diff --git a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun
index d347ad0a845c463a62cdc2362058f4d7ee7d5745..3aa1e7a9dd9987a2262eb748bd1c0553cf68f4a1 100755
--- a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
 \cp 0/alpha.water.orig 0/alpha.water
diff --git a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..4065edb322f31711cfb3d4f05a3077fd29bb887f 100755
--- a/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/interFoam/laminar/mixerVessel2D/makeMesh
@@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun
index da1575a1aa04e0948a12fc3608a2fd3ed478b518..a9796a5b0f0a4b4944702333aeed5358f80c3299 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/Allrun
@@ -1,9 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 (cd eulerianInjection && ./Allrun)
 (cd lagrangianParticleInjection && ./Allrun)
 (cd lagrangianDistributionInjection && ./Allrun)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean
index 8976b1e90b5a624a6a34bb638aef29620d8ec7d1..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-\rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun
index 8c13891df5ba424c333bc9e7611f5f2772c16cae..bf653b648363a73588da076d87c4199380f5a93c 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/eulerianInjection/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication  -s createBlockage topoSet -dict system/topoSetDict.createBlockage
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean
index c07f861837c4c4e3b2773c073e04f7e5f0ea38e6..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allclean
@@ -1,8 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-\rm -rf 0
-cleanCase
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun
index 8c4e782f63284e659c7c2df6717310b771363525..3dd409fe044d6488c7bf3a4a6c3fce8bd2276cf0 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianDistributionInjection/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 eulerianCase=../eulerianInjection
 
@@ -53,3 +51,5 @@ runApplication decomposePar
 runParallel $(getApplication)
 
 runApplication reconstructPar
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean
index c07f861837c4c4e3b2773c073e04f7e5f0ea38e6..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allclean
@@ -1,8 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-\rm -rf 0
-cleanCase
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun
index 8c4e782f63284e659c7c2df6717310b771363525..3dd409fe044d6488c7bf3a4a6c3fce8bd2276cf0 100755
--- a/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/vofToLagrangian/lagrangianParticleInjection/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 eulerianCase=../eulerianInjection
 
@@ -53,3 +51,5 @@ runApplication decomposePar
 runParallel $(getApplication)
 
 runApplication reconstructPar
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleCnoidal/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitary/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryGrimshaw/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleSolitaryMcCowan/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesI/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesII/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean
index 705f91474c4a86592eb4f9f16b842144f410492f..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-rm -rf 0
-
-cleanCase
+cleanCase0
 
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun
index 9f0c668029a93fea007d22217c227f723d480abe..28bf991e627511713c3b915ac0d9998f068ce030 100755
--- a/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun
+++ b/tutorials/multiphase/interFoam/laminar/waveExampleStokesV/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -13,3 +11,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/damBreak/Allclean b/tutorials/multiphase/interIsoFoam/damBreak/Allclean
index 513c366d4e453d40bf10eae880a1071f3e8bcc48..40363dccf7f6d56bcac00e3d3a0b08e15de8c511 100755
--- a/tutorials/multiphase/interIsoFoam/damBreak/Allclean
+++ b/tutorials/multiphase/interIsoFoam/damBreak/Allclean
@@ -1,9 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
+\rm -rf isoFaces
 
-cleanCase
-
-\rm -rf 0 isoFaces
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/damBreak/Allrun b/tutorials/multiphase/interIsoFoam/damBreak/Allrun
index 73a4aa44fc904dd62d6bb71affb53b394bce85c7..afce7038479ee2219416b800f2166f942669b718 100755
--- a/tutorials/multiphase/interIsoFoam/damBreak/Allrun
+++ b/tutorials/multiphase/interIsoFoam/damBreak/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -10,3 +8,5 @@ runApplication blockMesh
 runApplication setFields
 
 runApplication $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel b/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel
index 729fedf62cb4974d370296dc161b6bc756f728a8..2a2861b7303554bb3d0a6d722f1dfeee4c53fb15 100755
--- a/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel
+++ b/tutorials/multiphase/interIsoFoam/damBreak/Allrun-parallel
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -11,3 +9,5 @@ runApplication decomposePar
 runParallel setFields
 
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean
index 78449efd83660c6911b1e93e950765b750428078..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean
+++ b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allclean
@@ -1,8 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-\rm -rf 0
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun
index 47d57eb4f7754a3c3dff129a5ce08642683e70b6..4abdc78d004e77ad73e64df8234c3033e88cadb5 100755
--- a/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun
+++ b/tutorials/multiphase/interIsoFoam/discInConstantFlow/Allrun
@@ -1,7 +1,6 @@
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -9,3 +8,5 @@ runApplication blockMesh
 runApplication setAlphaField
 
 runApplication $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean
index c11c2183476730adbcb8206b57df5f367f29be34..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean
+++ b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allclean
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-\rm -rf 0
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun
index 474424491f37b168313472d53fd3c819656c1d4c..7e395e78326b16b2a928518363c77ba6bc177374 100755
--- a/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun
+++ b/tutorials/multiphase/interIsoFoam/discInReversedVortexFlow/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -15,3 +13,5 @@ runApplication -s 2 refineMesh -overwrite
 runApplication setAlphaField
 
 runApplication $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean
index 97f2707db81d7086eac366adedadf01c2a642142..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean
+++ b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allclean
@@ -1,9 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-
-\rm -rf 0
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun
index 317234a300a109eef71b899d681e149c68e34df8..a919ed91c4aff89cddfb6c72304fa9ddbc7d651a 100755
--- a/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun
+++ b/tutorials/multiphase/interIsoFoam/notchedDiscInSolidBodyRotation/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 application=$(getApplication)
 
@@ -17,3 +15,5 @@ runApplication setAlphaField
 runApplication setFields
 
 runApplication ${application}
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean
index c11c2183476730adbcb8206b57df5f367f29be34..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean
+++ b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allclean
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-\rm -rf 0
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun
index f21f9b5925b1ad60cf46ff83a8db1bef052efdff..1767cd6b1b386ff4f91d5c7c2fb78dd57003838b 100755
--- a/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun
+++ b/tutorials/multiphase/interIsoFoam/sphereInReversedVortexFlow/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -11,3 +9,5 @@ runApplication blockMesh
 runApplication setAlphaField
 runApplication decomposePar
 runParallel $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/standingWave/Allclean b/tutorials/multiphase/interIsoFoam/standingWave/Allclean
index 9738fda663b36f826c5f2ddb759bda3d4a0510de..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/interIsoFoam/standingWave/Allclean
+++ b/tutorials/multiphase/interIsoFoam/standingWave/Allclean
@@ -1,9 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-cleanCase
-
-\rm -rf 0
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interIsoFoam/standingWave/Allrun b/tutorials/multiphase/interIsoFoam/standingWave/Allrun
index 3f7a4cb538a521d93128f436ef60a8166df90528..d00d2326e7fc81f7766fae01da3cce1292d1891c 100755
--- a/tutorials/multiphase/interIsoFoam/standingWave/Allrun
+++ b/tutorials/multiphase/interIsoFoam/standingWave/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
@@ -15,3 +13,5 @@ runApplication -s 2 refineMesh -dict system/refineMeshDict2 -overwrite
 runApplication setAlphaField
 
 runApplication $(getApplication)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun
index b20c96d45ab7e92abb0e00391b54b0aee91fe4ed..48c2856ca16fb7a968e51479ee9465ead8f49a8f 100755
--- a/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun
+++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 cp 0/alpha.air.orig 0/alpha.air
diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean
index af5bf72167e93bbc40554a13d2fe609f4b060fb2..d31f20c24ddf417248e051822702615987ab54ff 100755
--- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean
+++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0 > /dev/null 2>&1
+cleanCase0
 
 # Remove surface
 rm -f constant/triSurface/propellerTip.obj.gz > /dev/null 2>&1
diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun
index 59aa02e75334f55ae5a577dd73802e70d1397ab1..b44aaf01a37d6bc2134a960c47799426b6dafa6c 100755
--- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun
+++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 
diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre
index b9980dd726d164462fc7aeaadf21dddd874aab43..b39d40fad9cdfee8315f17fb5dfea1a89f51c085 100755
--- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre
+++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/Allrun.pre
@@ -1,13 +1,10 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy propeller surface from resources directory
 \cp $FOAM_TUTORIALS/resources/geometry/propellerTip.obj.gz constant/triSurface/
 
-
 # - meshing
 
 runApplication blockMesh
@@ -18,7 +15,6 @@ runApplication renumberMesh -overwrite
 # force removal of fields generated by snappy
 rm -rf 0
 
-
 # - generate face/cell sets and zones
 
 #runApplication setSet -batch createInletOutletSets.setSet
@@ -28,11 +24,9 @@ runApplication topoSet -dict system/createInletOutletSets.topoSetDict
 
 runApplication createPatch -overwrite
 
-
 # - test by running moveDynamicMesh
 #runApplication moveDynamicMesh -checkAMI
 
-
 # - apply the initial fields
 
 restore0Dir
diff --git a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean
index 05fe1e79a3f91a15ed06385847d37e4424a41eed..24df93fd3d22844891dc5951256878568e6b4d56 100755
--- a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean
+++ b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove surface
 rm -f constant/triSurface/bullet.stl.gz
diff --git a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun
index 4f35a71a264026b0805b9068be7c528b79f53d5f..dd1ff0aa9508e107cb209f859899cca1d44e5999 100755
--- a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun
+++ b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Copy bullet surface from resources directory
 cp $FOAM_TUTORIALS/resources/geometry/bullet.stl.gz constant/triSurface/
diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean
+++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun
index 6cfec647c79d18f2504b7408b94bb8ddbe2e3086..efced0038e951e3578e1e804b9642f639e2bce5e 100755
--- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun
+++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean
+++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun
index fb2c7cf7a737962f3394292d00843d75376f8677..125f3e96ba2fe5b181265f6134420d6ad6b3e244 100755
--- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun
+++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun
index f1273de8e41357a83af0b1253a297acf47413959..6aeae15553237e47ab738d4a985454a979a3ecb5 100755
--- a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..4065edb322f31711cfb3d4f05a3077fd29bb887f 100755
--- a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/makeMesh
@@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun
index cf76c5c4a6c65fdff4a3308d97e24f34e1789b4b..3d69efdb3a2fb01caf6d63c689d3bd0985b33060 100755
--- a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun
+++ b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./makeMesh
 
diff --git a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh
index bcb12c0e9ac17c9aefbf669bd022c29c97052727..fc56e7be3ced8dddd0d2158adb4b74e5e2d96239 100755
--- a/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh
+++ b/tutorials/multiphase/multiphaseInterDyMFoam/laminar/mixerVesselAMI2D/makeMesh
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 m4 < system/blockMeshDict.m4 > system/blockMeshDict
 
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun
index 6cfec647c79d18f2504b7408b94bb8ddbe2e3086..efced0038e951e3578e1e804b9642f639e2bce5e 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun
index fb2c7cf7a737962f3394292d00843d75376f8677..125f3e96ba2fe5b181265f6134420d6ad6b3e244 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/p_rgh b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0.orig/T
similarity index 86%
rename from tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/p_rgh
rename to tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0.orig/T
index 8c6ca7dcf9ada35976248ab77c111e94e9d8b9ff..4362683670bd14fb4525a343fbba703de47ca4ea 100644
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/p_rgh
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0.orig/T
@@ -10,19 +10,20 @@ FoamFile
     version     2.0;
     format      ascii;
     class       volScalarField;
-    object      p_rgh;
+    object      T;
 }
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-dimensions      [1 -1 -2 0 0 0 0];
+dimensions      [0 0 0 1 0 0 0];
 
-internalField   uniform 0;
+internalField   uniform 300;
 
 boundaryField
 {
     rotor
     {
-        type            zeroGradient;
+        type            fixedValue;
+        value           uniform 305;
     }
 
     stator
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air
deleted file mode 100644
index 3e992f20f64008d5a64acce9c8318a64490bcf42..0000000000000000000000000000000000000000
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.air
+++ /dev/null
@@ -1,3119 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| =========                 |                                                 |
-| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus                                  |
-|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
-|    \\/     M anipulation  |                                                 |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
-    version     2.0;
-    format      ascii;
-    class       volScalarField;
-    location    "0";
-    object      alpha.air;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions      [0 0 0 0 0 0 0];
-
-internalField   nonuniform List<scalar>
-3072
-(
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-)
-;
-
-boundaryField
-{
-    rotor
-    {
-        type            zeroGradient;
-    }
-    stator
-    {
-        type            zeroGradient;
-    }
-    front
-    {
-        type            empty;
-    }
-    back
-    {
-        type            empty;
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury
deleted file mode 100644
index dfef5159a137396986773cb7decb8eb09e3b457a..0000000000000000000000000000000000000000
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.mercury
+++ /dev/null
@@ -1,3119 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| =========                 |                                                 |
-| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus                                  |
-|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
-|    \\/     M anipulation  |                                                 |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
-    version     2.0;
-    format      ascii;
-    class       volScalarField;
-    location    "0";
-    object      alpha.mercury;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions      [0 0 0 0 0 0 0];
-
-internalField   nonuniform List<scalar>
-3072
-(
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-)
-;
-
-boundaryField
-{
-    rotor
-    {
-        type            zeroGradient;
-    }
-    stator
-    {
-        type            zeroGradient;
-    }
-    front
-    {
-        type            empty;
-    }
-    back
-    {
-        type            empty;
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil
deleted file mode 100644
index 04a96b44712b8a2532a6222bb8e8ebc83e673742..0000000000000000000000000000000000000000
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.oil
+++ /dev/null
@@ -1,3119 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| =========                 |                                                 |
-| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus                                  |
-|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
-|    \\/     M anipulation  |                                                 |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
-    version     2.0;
-    format      ascii;
-    class       volScalarField;
-    location    "0";
-    object      alpha.oil;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions      [0 0 0 0 0 0 0];
-
-internalField   nonuniform List<scalar>
-3072
-(
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-)
-;
-
-boundaryField
-{
-    rotor
-    {
-        type            zeroGradient;
-    }
-    stator
-    {
-        type            zeroGradient;
-    }
-    front
-    {
-        type            empty;
-    }
-    back
-    {
-        type            empty;
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water
deleted file mode 100644
index a8704851bf1e095c18011c93cc3c3e52b21aaf4e..0000000000000000000000000000000000000000
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/0/alpha.water
+++ /dev/null
@@ -1,3119 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| =========                 |                                                 |
-| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  plus                                  |
-|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
-|    \\/     M anipulation  |                                                 |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
-    version     2.0;
-    format      ascii;
-    class       volScalarField;
-    location    "0";
-    object      alpha.water;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions      [0 0 0 0 0 0 0];
-
-internalField   nonuniform List<scalar>
-3072
-(
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-)
-;
-
-boundaryField
-{
-    rotor
-    {
-        type            zeroGradient;
-    }
-    stator
-    {
-        type            zeroGradient;
-    }
-    front
-    {
-        type            empty;
-    }
-    back
-    {
-        type            empty;
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean
index e62451c67f94ac85bbe86b61e86b12192a0f6982..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm 0/alphas > /dev/null 2>&1
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun
index f1273de8e41357a83af0b1253a297acf47413959..69a4d43b4918725913e35580d1fe82ff6b25ca40 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/Allrun
@@ -1,10 +1,12 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
+restore0Dir
+topoSet
+setFields
+setsToZones -noFlipMap
 runApplication $(getApplication)
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..3cb213572c282625934f8123992e67154cc58b7c 100755
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/makeMesh
@@ -4,3 +4,4 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict
index b36bb2f3081d72cb79b0180dba6deeb9e7885777..e983f69bda2cf7be7e615a28a9178ccdf0c78d9d 100644
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/controlDict
@@ -52,5 +52,62 @@ maxAlphaCo      0.5;
 
 maxDeltaT       1;
 
-
+functions
+{
+    sTransport
+    {
+        type            energyTransport;
+        libs            ("libsolverFunctionObjects.so");
+
+        enabled         true;
+        writeControl    outputTime;
+        writeInterval   1;
+
+        field           T;
+
+        rho             rho;
+        phi             rhoPhi;
+
+        write           true;
+
+        phaseThermos
+        {
+            alpha.air
+            {
+                Cp          1e3;
+                kappa       0.0243;
+            }
+            alpha.mercury
+            {
+                Cp          140;
+                kappa       8.2;
+            }
+            alpha.oil
+            {
+                Cp          2e3;
+                kappa       0.2;
+            }
+            alpha.water
+            {
+                Cp          4e3;
+                kappa       0.6;
+            }
+        }
+
+        fvOptions
+        {
+            viscousDissipation
+            {
+                type            viscousDissipation;
+                enabled         true;
+
+                viscousDissipationCoeffs
+                {
+                    fields          (T);
+                    rho             rho; //rho Field
+                }
+            }
+        }
+    }
+}
 // ************************************************************************* //
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes
index 8cbffcabee232a9150ec306b319f3c2fc2f3099c..d333691a5336d1cc509221d3310cf2e52673a6f3 100644
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSchemes
@@ -31,6 +31,7 @@ divSchemes
     div(phi,alpha)  Gauss vanLeer;
     div(phirb,alpha) Gauss linear;
     div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear;
+    div(phi,T)      Gauss limitedLinear 1;
 }
 
 laplacianSchemes
diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution
index 29361e6795413079f68d1d7e38fde14696cd6b83..c22130bab0d0fb4ad16e624d54602b15cb59959f 100644
--- a/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution
+++ b/tutorials/multiphase/multiphaseInterFoam/laminar/mixerVessel2D/system/fvSolution
@@ -48,7 +48,7 @@ solvers
         relTol          0;
     }
 
-    U
+    "(U|T)"
     {
         solver          smoothSolver;
         smoother        symGaussSeidel;
@@ -71,7 +71,7 @@ relaxationFactors
 {
     equations
     {
-        "U.*"           1;
+        ".*"           1;
     }
 }
 
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean
index e3c5c15e9c9086e649acfb0b94273f289c08cac0..27381f42e7b4e74f29fd4700b5cfc465a2acd3b1 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allclean
@@ -1,10 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 (cd background && ./Allclean)
 (cd floatingBody && ./Allclean)
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun
index 95ffcc4bf4c2eb11eb4de646685f234b2c940bb6..669972445780882fb5793ca9a24a4e7d81a1d1f1 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun
@@ -1,10 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 ./Allrun.pre
 (cd background && runApplication $(getApplication))
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre
index a69774179d3a8170a4828c98c802bb5c9c308f63..ef286ecbfa84214bc11a1024094bb33d044ccc10 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/Allrun.pre
@@ -1,8 +1,11 @@
 #!/bin/sh
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # mesh floating body
 (cd floatingBody && ./Allrun.pre)
 
 # Add background mesh
 (cd background  && ./Allrun.pre)
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean
index e49ac35744ede7554645181bba3a8607ee44ba08..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allclean
@@ -1,9 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-cleanCase
-
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre
index 31eb9edf99df7ab97e62ade8431c01a2510f1e39..9a44881018bbc6aca5b1c80d3a0616a9825acd6a 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/Allrun.pre
@@ -1,6 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # Create background mesh
 runApplication blockMesh
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean
index d16400a94f636d461b62f6f909c2d64d7e29c335..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allclean
@@ -1,11 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cleanCase0
 
-rm -rf 0 > /dev/null 2>&1
-
-cleanCase
-
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre
index 36d051548dfb8388f0e94c2437d803c370ed766c..8142d7c389dab65e7e840c1abeebc8a7b0a18048 100755
--- a/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre
+++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/floatingBody/Allrun.pre
@@ -1,14 +1,9 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
-
-# Set application name
-application=`getApplication`
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
 runApplication subsetMesh -overwrite c0 -patch floatingObject
 
-# ----------------------------------------------------------------- end-of-file
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean
index 5b17237826694a15efc621c2bb2dfb6a91c1d66b..496dfec3c171a98ee630ccb7840e7abfd1d373dd 100755
--- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean
+++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 rm -rf poolHeight poolHeight_vs_time
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun
index 7cdbc56f458c4aa2648d91383024eed3c4c5c2df..40555d56e14fadc79a48c19d9cb94901995fb37c 100755
--- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun
+++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 
diff --git a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData
index b653b581b7af42a156a3e00f90077e4764b1fa61..4f6979a83f0417bb73295472739a102971e1abd5 100755
--- a/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData
+++ b/tutorials/multiphase/potentialFreeSurfaceDyMFoam/oscillatingBox/extractHeightData
@@ -1,2 +1,5 @@
 #!/bin/sh
+
 awk '{print $1 " " $3}' postProcessing/poolHeight/0/surfaceFieldValue.dat > poolHeight_vs_time
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean
index 5b17237826694a15efc621c2bb2dfb6a91c1d66b..496dfec3c171a98ee630ccb7840e7abfd1d373dd 100755
--- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean
+++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 rm -rf poolHeight poolHeight_vs_time
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun
index 03b5ca3948231b2a68cbcaa5bbc2a0d72e5d693b..897dccd0bb71f7f61caa520f9db6b1d3f61ff6a2 100755
--- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun
+++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication topoSet
diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData
index b653b581b7af42a156a3e00f90077e4764b1fa61..4f6979a83f0417bb73295472739a102971e1abd5 100755
--- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData
+++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/extractHeightData
@@ -1,2 +1,5 @@
 #!/bin/sh
+
 awk '{print $1 " " $3}' postProcessing/poolHeight/0/surfaceFieldValue.dat > poolHeight_vs_time
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun
index f1273de8e41357a83af0b1253a297acf47413959..6aeae15553237e47ab738d4a985454a979a3ecb5 100755
--- a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..4065edb322f31711cfb3d4f05a3077fd29bb887f 100755
--- a/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/reactingMultiphaseEulerFoam/laminar/mixerVessel2D/makeMesh
@@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean
index 4d3ae417ce60f091e742856da3d5aeefe43c7c4f..ba5873a4aef4000f5bca4f7c71d1884c0bf99323 100755
--- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean
+++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 cp ./system/controlDict.org ./system/controlDict
diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun
index 59d62c7881fb2c2c8fed84d24def73039b9694a6..001a60c8fddc3f7a0082b3eb5b94b5eac71ecc35 100755
--- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun
+++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoiling/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean
index 4d3ae417ce60f091e742856da3d5aeefe43c7c4f..ba5873a4aef4000f5bca4f7c71d1884c0bf99323 100755
--- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean
+++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 cp ./system/controlDict.org ./system/controlDict
diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun
index 59d62c7881fb2c2c8fed84d24def73039b9694a6..001a60c8fddc3f7a0082b3eb5b94b5eac71ecc35 100755
--- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun
+++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/wallBoilingIATE/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun
index f1273de8e41357a83af0b1253a297acf47413959..6aeae15553237e47ab738d4a985454a979a3ecb5 100755
--- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..4065edb322f31711cfb3d4f05a3077fd29bb887f 100755
--- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh
@@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean
+++ b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun
index 6cfec647c79d18f2504b7408b94bb8ddbe2e3086..efced0038e951e3578e1e804b9642f639e2bce5e 100755
--- a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun
+++ b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 restore0Dir
 
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun
index f1273de8e41357a83af0b1253a297acf47413959..6aeae15553237e47ab738d4a985454a979a3ecb5 100755
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication ./makeMesh
 runApplication $(getApplication)
diff --git a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh
index 4d667956a0a85573c003797a5e2385cba6296964..4065edb322f31711cfb3d4f05a3077fd29bb887f 100755
--- a/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh
+++ b/tutorials/multiphase/twoPhaseEulerFoam/laminar/mixerVessel2D/makeMesh
@@ -4,3 +4,5 @@ m4 < system/blockMeshDict.m4 > system/blockMeshDict
 blockMesh
 topoSet
 setsToZones -noFlipMap
+
+#------------------------------------------------------------------------------
diff --git a/tutorials/preProcessing/createZeroDirectory/cavity/Allclean b/tutorials/preProcessing/createZeroDirectory/cavity/Allclean
index 61edfb303237d95429c1833e5f77dfbfd671288b..e2f275d9fd6e6ba843f14fec57e2987e4c8607b3 100755
--- a/tutorials/preProcessing/createZeroDirectory/cavity/Allclean
+++ b/tutorials/preProcessing/createZeroDirectory/cavity/Allclean
@@ -1,10 +1,7 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 #------------------------------------------------------------------------------
diff --git a/tutorials/preProcessing/createZeroDirectory/cavity/Allrun b/tutorials/preProcessing/createZeroDirectory/cavity/Allrun
index 909a10a372f915ddefeb5bb0c95d8527f13e1111..51286c4dbdaf38231c5e983ae8676362f9dc28ef 100755
--- a/tutorials/preProcessing/createZeroDirectory/cavity/Allrun
+++ b/tutorials/preProcessing/createZeroDirectory/cavity/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication createZeroDirectory
diff --git a/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean b/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean
index 7ba7ddabb3e7e1a730041832e59aa864abfc256b..b52876b699666e4782c85ba0f987a92d4d19cd23 100755
--- a/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean
+++ b/tutorials/preProcessing/createZeroDirectory/motorBike/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 # Remove surface and features
 \rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1
diff --git a/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun b/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun
index bec223b5deefcf242fd633d7c247c9d903ce2b4a..9dce39c17323e3cebf6b71dad03542a71c015139 100755
--- a/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun
+++ b/tutorials/preProcessing/createZeroDirectory/motorBike/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 # copy motorbike surface from resources folder
 cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/
@@ -22,4 +20,4 @@ runParallel $(getApplication)
 runApplication reconstructParMesh -constant
 runApplication reconstructPar -latestTime
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean
index c0d30ba4bfd0ba95d345685e6b55d77537f4345a..b8032f8f34ecc23cda651f7bd10d6cec14d882b0 100755
--- a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean
+++ b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allclean
@@ -1,11 +1,8 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
-
-cleanCase
-rm -rf 0
+cleanCase0
 
 rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
 rm -f constant/triSurface/*.eMesh > /dev/null 2>&1
@@ -17,4 +14,4 @@ rm -rf constant/heater/polyMesh
 rm -rf constant/leftSolid/polyMesh
 rm -rf constant/rightSolid/polyMesh
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun
index 6b946fe298eec30d120a49638c81621b3a281087..15fab73b655f31f2239692e957869f98e3e37e03 100755
--- a/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun
+++ b/tutorials/preProcessing/createZeroDirectory/snappyMultiRegionHeater/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 rm -rf constant/polyMesh/sets
 
@@ -34,4 +32,4 @@ echo "creating files for paraview post-processing"
 echo
 paraFoam -touchAll
 
-# -----------------------------------------------------------------------------
+#------------------------------------------------------------------------------
diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean
index 6b45f82a41b0f9a0739a80a41a680be892e55243..be7ddb068847225ad69704840909a7b0d05a5466 100755
--- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean
+++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allclean
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial clean functions
-. $WM_PROJECT_DIR/bin/tools/CleanFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/CleanFunctions  # Tutorial clean functions
 
 cleanCase
 
diff --git a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun
index 9c5c0bb36eef9868cd2e10bd799961bd051e5a49..e59dad068eeb108b0640655264b810e364bd83e0 100755
--- a/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun
+++ b/tutorials/stressAnalysis/solidDisplacementFoam/plateHole/Allrun
@@ -1,8 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1    # Run from this directory
-
-# Source tutorial run functions
-. $WM_PROJECT_DIR/bin/tools/RunFunctions
+cd ${0%/*} || exit 1                        # Run from this directory
+. $WM_PROJECT_DIR/bin/tools/RunFunctions    # Tutorial run functions
 
 runApplication blockMesh
 runApplication $(getApplication)
diff --git a/wmake/rules/General/mplibCRAY-MPICH b/wmake/rules/General/mplibCRAY-MPICH
new file mode 100644
index 0000000000000000000000000000000000000000..fdb91c13794fcf6f7757f66ba1e6f88f1cd96a75
--- /dev/null
+++ b/wmake/rules/General/mplibCRAY-MPICH
@@ -0,0 +1 @@
+include $(GENERAL_RULES)/mplibMPICH
diff --git a/wmake/rules/linux64Clang/general b/wmake/rules/linux64Clang/general
index 1002cb169b5ba7215e263d07cced90cd3e8e0308..d83a18b000b3bb3e663ccee8efa77439d863c39d 100644
--- a/wmake/rules/linux64Clang/general
+++ b/wmake/rules/linux64Clang/general
@@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64Clang/openmp b/wmake/rules/linux64Clang/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linux64Clang/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linux64Cray/c b/wmake/rules/linux64Cray/c
new file mode 100644
index 0000000000000000000000000000000000000000..d08f44144037dd10701b5adfe4f357fc4c83054f
--- /dev/null
+++ b/wmake/rules/linux64Cray/c
@@ -0,0 +1,16 @@
+SUFFIXES += .c
+
+cWARN        = -Wall
+
+cc          = cc -m64
+
+include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION)
+
+cFLAGS      = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC
+
+ctoo        = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@
+
+LINK_LIBS   = $(cDBUG)
+
+LINKLIBSO   = $(cc) -shared
+LINKEXE     = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs
diff --git a/wmake/rules/linux64Cray/c++ b/wmake/rules/linux64Cray/c++
new file mode 100644
index 0000000000000000000000000000000000000000..30c2bc762e23a9651ba54620c3c955ac31d38e28
--- /dev/null
+++ b/wmake/rules/linux64Cray/c++
@@ -0,0 +1,24 @@
+SUFFIXES += .C
+
+c++WARN     = -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof
+
+# Suppress some warnings for flex++ and CGAL
+c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
+
+CC          = CC -std=c++11 -m64
+
+include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
+
+ptFLAGS     = -DNoRepository -ftemplate-depth-100
+
+c++FLAGS    = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
+
+Ctoo        = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $< -o $@
+cxxtoo      = $(Ctoo)
+cctoo       = $(Ctoo)
+cpptoo      = $(Ctoo)
+
+LINK_LIBS   = $(c++DBUG)
+
+LINKLIBSO   = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
+LINKEXE     = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
diff --git a/wmake/rules/linux64Cray/c++Debug b/wmake/rules/linux64Cray/c++Debug
new file mode 100644
index 0000000000000000000000000000000000000000..19bdb9c3346fc7a69380dfedd6e7911fe220a965
--- /dev/null
+++ b/wmake/rules/linux64Cray/c++Debug
@@ -0,0 +1,2 @@
+c++DBUG    = -ggdb3 -DFULLDEBUG
+c++OPT      = -O0 -fdefault-inline
diff --git a/wmake/rules/linux64Cray/c++Opt b/wmake/rules/linux64Cray/c++Opt
new file mode 100644
index 0000000000000000000000000000000000000000..599e6aba611dab95225e37204a5763288c546893
--- /dev/null
+++ b/wmake/rules/linux64Cray/c++Opt
@@ -0,0 +1,4 @@
+c++DBUG     =
+c++OPT      = -O3
+
+ROUNDING_MATH = -frounding-math
diff --git a/wmake/rules/linux64Cray/c++Prof b/wmake/rules/linux64Cray/c++Prof
new file mode 100644
index 0000000000000000000000000000000000000000..3bda4dad55e898a8198f6e8bfe21e8d829d7230a
--- /dev/null
+++ b/wmake/rules/linux64Cray/c++Prof
@@ -0,0 +1,2 @@
+c++DBUG    = -pg
+c++OPT     = -O2
diff --git a/wmake/rules/linux64Cray/cDebug b/wmake/rules/linux64Cray/cDebug
new file mode 100644
index 0000000000000000000000000000000000000000..72b638f458220e329d52b59e3566a3c807101f9d
--- /dev/null
+++ b/wmake/rules/linux64Cray/cDebug
@@ -0,0 +1,2 @@
+cDBUG       = -ggdb -DFULLDEBUG
+cOPT        = -O1 -fdefault-inline -finline-functions
diff --git a/wmake/rules/linux64Cray/cOpt b/wmake/rules/linux64Cray/cOpt
new file mode 100644
index 0000000000000000000000000000000000000000..17318709f1fa39e6bf89cbe87778bc6fa459de17
--- /dev/null
+++ b/wmake/rules/linux64Cray/cOpt
@@ -0,0 +1,2 @@
+cDBUG       =
+cOPT        = -O3
diff --git a/wmake/rules/linux64Cray/cProf b/wmake/rules/linux64Cray/cProf
new file mode 100644
index 0000000000000000000000000000000000000000..ca3ac9bf5f0cd61fe99e0f05fa1bd4bdf9fa6cf7
--- /dev/null
+++ b/wmake/rules/linux64Cray/cProf
@@ -0,0 +1,2 @@
+cDBUG       = -pg
+cOPT        = -O2
diff --git a/wmake/rules/linux64Cray/general b/wmake/rules/linux64Cray/general
new file mode 100644
index 0000000000000000000000000000000000000000..a0c807e5d8a95848f20457716565c8debe747570
--- /dev/null
+++ b/wmake/rules/linux64Cray/general
@@ -0,0 +1,9 @@
+CPP        = cpp -traditional-cpp $(GFLAGS)
+
+PROJECT_LIBS = -l$(WM_PROJECT) -ldl
+
+include $(GENERAL_RULES)/standard
+
+# include $(DEFAULT_RULES)/openmp
+include $(DEFAULT_RULES)/c
+include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64Cray/mplibINTELMPI b/wmake/rules/linux64Cray/mplibINTELMPI
new file mode 100644
index 0000000000000000000000000000000000000000..278e0b0f22c7c7d6fafc3334cddccb237afe232e
--- /dev/null
+++ b/wmake/rules/linux64Cray/mplibINTELMPI
@@ -0,0 +1,3 @@
+PFLAGS     = -DMPICH_SKIP_MPICXX
+PINC       = -isystem $(MPI_ARCH_PATH)/include64
+PLIBS      = -L$(MPI_ARCH_PATH)/lib64 -lmpi
diff --git a/wmake/rules/linux64Cray/openmp b/wmake/rules/linux64Cray/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linux64Cray/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linux64Gcc/general b/wmake/rules/linux64Gcc/general
index 1002cb169b5ba7215e263d07cced90cd3e8e0308..d83a18b000b3bb3e663ccee8efa77439d863c39d 100644
--- a/wmake/rules/linux64Gcc/general
+++ b/wmake/rules/linux64Gcc/general
@@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64Gcc/openmp b/wmake/rules/linux64Gcc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linux64Gcc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linux64GccKNL/c b/wmake/rules/linux64GccKNL/c
index a1cd9d6613efd2c4ddfe410727baaad07d036a90..d0eb3eab5709d94f814ba8f71aba33eab0757700 100644
--- a/wmake/rules/linux64GccKNL/c
+++ b/wmake/rules/linux64GccKNL/c
@@ -2,7 +2,7 @@ SUFFIXES += .c
 
 cWARN        = -Wall
 
-cc          = gcc -m64 -march=knl -DvectorMachine -DKNL
+cc          = gcc -m64 -march=knl
 
 include $(DEFAULT_RULES)/c$(WM_COMPILE_OPTION)
 
diff --git a/wmake/rules/linux64GccKNL/c++ b/wmake/rules/linux64GccKNL/c++
index cdc820c556896b2f4ba81cd885941e2bf5be424b..199d72c0fdcb490b1508c8751c47d220c6c64cd7 100644
--- a/wmake/rules/linux64GccKNL/c++
+++ b/wmake/rules/linux64GccKNL/c++
@@ -6,7 +6,7 @@ c++WARN     = -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-para
 # Suppress some warnings for flex++ and CGAL
 c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
 
-CC          = g++ -std=c++11 -m64 -march=knl -DvectorMachine
+CC          = g++ -std=c++11 -m64 -march=knl
 
 include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
 
diff --git a/wmake/rules/linux64GccKNL/general b/wmake/rules/linux64GccKNL/general
index 1002cb169b5ba7215e263d07cced90cd3e8e0308..d83a18b000b3bb3e663ccee8efa77439d863c39d 100644
--- a/wmake/rules/linux64GccKNL/general
+++ b/wmake/rules/linux64GccKNL/general
@@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64GccKNL/openmp b/wmake/rules/linux64GccKNL/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linux64GccKNL/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linux64Icc/general b/wmake/rules/linux64Icc/general
index 52b0e177d7afe6ab60761862ae8b9f966fa18f2f..eb3898f709eb247f990ab1c0911dac0742e3b19d 100644
--- a/wmake/rules/linux64Icc/general
+++ b/wmake/rules/linux64Icc/general
@@ -4,5 +4,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linux64Icc/openmp b/wmake/rules/linux64Icc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..154c9e5743dae699e2dc6c25111dbe4846113030
--- /dev/null
+++ b/wmake/rules/linux64Icc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -qopenmp
+LINK_OPENMP = -liomp5
diff --git a/wmake/rules/linux64IccKNL/c++ b/wmake/rules/linux64IccKNL/c++
index f0938a4da25c6cc8fe6dba81a3acf3fdfe3a91bb..9b047d22caf3cfaf543a4bc938d2c2f377a3464b 100644
--- a/wmake/rules/linux64IccKNL/c++
+++ b/wmake/rules/linux64IccKNL/c++
@@ -6,7 +6,7 @@ c++WARN     = -Wall -Wextra -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invali
 # Suppress some warnings for flex++ and CGAL
 c++LESSWARN = -diag-disable 1224,2026,2305
 
-CC          = icpc -std=c++11 -xmic-avx512 -DvectorMachine -fp-trap=common -fp-model precise -fp-speculation=safe
+CC          = icpc -std=c++11 -xmic-avx512 -fp-trap=common -fp-model precise -fp-speculation=safe
 
 include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)
 
diff --git a/wmake/rules/linux64IccKNL/openmp b/wmake/rules/linux64IccKNL/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..154c9e5743dae699e2dc6c25111dbe4846113030
--- /dev/null
+++ b/wmake/rules/linux64IccKNL/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -qopenmp
+LINK_OPENMP = -liomp5
diff --git a/wmake/rules/linuxARM7Gcc/general b/wmake/rules/linuxARM7Gcc/general
index 1e51dcc403ca74c4a15dc7538c09d3bce642bbe5..4fc50267edbaa5c8c846891dc70fe93f09b5944c 100644
--- a/wmake/rules/linuxARM7Gcc/general
+++ b/wmake/rules/linuxARM7Gcc/general
@@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxARM7Gcc/openmp b/wmake/rules/linuxARM7Gcc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linuxARM7Gcc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linuxClang/general b/wmake/rules/linuxClang/general
index e3427c3181a329ec6bf2f64bdefc4f81bf9afde7..eae23e305bdd3331475a0d51ad5fa727144608c0 100644
--- a/wmake/rules/linuxClang/general
+++ b/wmake/rules/linuxClang/general
@@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxClang/openmp b/wmake/rules/linuxClang/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linuxClang/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linuxGcc/general b/wmake/rules/linuxGcc/general
index e3427c3181a329ec6bf2f64bdefc4f81bf9afde7..eae23e305bdd3331475a0d51ad5fa727144608c0 100644
--- a/wmake/rules/linuxGcc/general
+++ b/wmake/rules/linuxGcc/general
@@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxGcc/openmp b/wmake/rules/linuxGcc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linuxGcc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linuxIA64Gcc/general b/wmake/rules/linuxIA64Gcc/general
index 182ee7f9019e4fcffa64e7bf30fef331a656450d..d8fb470836e8d2469fb42414aeecf3dd06c7eda3 100644
--- a/wmake/rules/linuxIA64Gcc/general
+++ b/wmake/rules/linuxIA64Gcc/general
@@ -4,6 +4,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxIA64Gcc/openmp b/wmake/rules/linuxIA64Gcc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linuxIA64Gcc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linuxIA64Icc/general b/wmake/rules/linuxIA64Icc/general
index 09a389665615459359790ebd71c618b28b1eb5bd..c3269860fb89a538b25faeec8ba66c5ea6183a55 100644
--- a/wmake/rules/linuxIA64Icc/general
+++ b/wmake/rules/linuxIA64Icc/general
@@ -4,6 +4,7 @@ GLIBS      =
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxIA64Icc/openmp b/wmake/rules/linuxIA64Icc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..154c9e5743dae699e2dc6c25111dbe4846113030
--- /dev/null
+++ b/wmake/rules/linuxIA64Icc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -qopenmp
+LINK_OPENMP = -liomp5
diff --git a/wmake/rules/linuxIcc/general b/wmake/rules/linuxIcc/general
index 5c94cad44af0463b5bf104df334ff04867a1065d..85f5be51c0992097b1593c56b86310b260fe0ee8 100644
--- a/wmake/rules/linuxIcc/general
+++ b/wmake/rules/linuxIcc/general
@@ -5,5 +5,6 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxPPC64Gcc/general b/wmake/rules/linuxPPC64Gcc/general
index a590cc29c8d143674c2070610efb1fff1027b7ca..712516c2681a53c10d1d3ad26614fd65fe20317f 100644
--- a/wmake/rules/linuxPPC64Gcc/general
+++ b/wmake/rules/linuxPPC64Gcc/general
@@ -5,6 +5,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxPPC64Gcc/openmp b/wmake/rules/linuxPPC64Gcc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linuxPPC64Gcc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/rules/linuxPPC64leGcc/general b/wmake/rules/linuxPPC64leGcc/general
index 7867cbde8f46661b843fc674bd041809705e8f5b..575cadaeee00313894af62de0bd85a1661cf22db 100644
--- a/wmake/rules/linuxPPC64leGcc/general
+++ b/wmake/rules/linuxPPC64leGcc/general
@@ -5,6 +5,7 @@ PROJECT_LIBS = -l$(WM_PROJECT) -ldl
 
 include $(GENERAL_RULES)/standard
 
+include $(DEFAULT_RULES)/openmp
 include $(DEFAULT_RULES)/X
 include $(DEFAULT_RULES)/c
 include $(DEFAULT_RULES)/c++
diff --git a/wmake/rules/linuxPPC64leGcc/openmp b/wmake/rules/linuxPPC64leGcc/openmp
new file mode 100644
index 0000000000000000000000000000000000000000..bcb805f57c6240bc577b1f04208ac09706d0846a
--- /dev/null
+++ b/wmake/rules/linuxPPC64leGcc/openmp
@@ -0,0 +1,4 @@
+# Flags for compiling/linking openmp
+
+COMP_OPENMP = -DUSE_OMP -fopenmp
+LINK_OPENMP = -lgomp
diff --git a/wmake/scripts/wcleanBuild b/wmake/scripts/wcleanBuild
new file mode 100755
index 0000000000000000000000000000000000000000..0c13af7642e31e0a0d044b2f716fd3e7b11e4cad
--- /dev/null
+++ b/wmake/scripts/wcleanBuild
@@ -0,0 +1,185 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# =========                 |
+# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+#  \\    /   O peration     |
+#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
+#    \\/     M anipulation  |
+#-------------------------------------------------------------------------------
+# License
+#     This file is part of OpenFOAM.
+#
+#     OpenFOAM is free software: you can redistribute it and/or modify it
+#     under the terms of the GNU General Public License as published by
+#     the Free Software Foundation, either version 3 of the License, or
+#     (at your option) any later version.
+#
+#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#     for more details.
+#
+#     You should have received a copy of the GNU General Public License
+#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Script
+#     wcleanBuild
+#
+# Usage
+#     wcleanBuild <option | platform> [.. <option | platform>]
+#
+# Description
+#     Deletes the specified 'build/' object files directories from the
+#     the project top-level 'build/' directory $WM_PROJECT_DIR.
+#
+#     special platforms
+#     - 'all' removes all platforms.
+#     - 'compiler' corresponds to $WM_ARCH$WM_COMPILER.
+#     - 'current' corresponds to $WM_OPTIONS.
+#
+#     You must be in the project or the third-party top-level directory
+#     to run this script.
+#
+#     When called as wcleanPlatform, the target directory changes to
+#     'platforms/ and the 'all' target also cleans up lnInclude dirs and
+#     tutorials
+#
+#------------------------------------------------------------------------------
+Script="${0##*/}"
+targetDir=build   # Safe default - override based on script name
+
+case "$Script" in
+(*[Pp]latform*)
+    targetDir=platforms
+    ;;
+esac
+
+usage() {
+    local extraText
+    if [ "$targetDir" = platforms ]
+    then
+        extraText=", lnInclude and clean tutorials"
+    fi
+
+    exec 1>&2
+    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+    cat<<USAGE
+
+Usage: ${0##*/} <option | platform> [.. <option | platform>]
+
+options:
+  -a, -all              Same as 'all'
+  -c, -current          Use \$WM_OPTIONS ($WM_OPTIONS)
+  -comp, -compiler      Use \$WM_ARCH\$WM_COMPILER*  ($WM_ARCH$WM_COMPILER)
+  -compiler=NAME        Use \$WM_ARCH<NAME>*  ($WM_ARCH<NAME>*)
+  -h, -help             Print the usage
+
+
+Deletes the specified $targetDir/ object file directories from the project
+top-level $targetDir/ directory $WM_PROJECT_DIR.
+
+special platforms:
+  all           Remove all platforms$extraText
+  compiler      $WM_ARCH$WM_COMPILER  (ie, \$WM_ARCH\$WM_COMPILER)
+  current       $WM_OPTIONS  (ie, \$WM_OPTIONS)
+
+You must be in the project or the third-party top-level directory
+to run this script.
+
+USAGE
+    exit 1
+}
+
+# Find -help anywhere
+for i
+do
+    case "$i" in (-h | -help) usage ;; esac
+done
+
+#------------------------------------------------------------------------------
+# Run from OPENFOAM or THIRDPARTY top-level directory only
+wmakeCheckPwd -q "$WM_PROJECT_DIR"     2>/dev/null || \
+wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \
+{
+cat<<ERROR
+${0##*/}: Error incorrect top-level directory
+
+  Not in Project:     $WM_PROJECT_DIR
+  Nor in ThirdParty:  $WM_THIRD_PARTY_DIR
+
+ERROR
+    exit 1
+}
+
+if [ "$#" -eq 0 ]
+then
+    usage "No platform specified to clean from $targetDir"
+else
+    echo "$# platform(s) to clean from $targetDir"
+    echo
+fi
+
+
+for name
+do
+    unset compiler
+
+    case "$name" in
+    -a | -all | all)
+        echo "all $targetDir/ ..."
+        rm -rf $targetDir
+        if [ "$targetDir" = platforms ]
+        then
+            wcleanLnIncludeAll .
+            [ -x tutorials/Allclean ] && tutorials/Allclean
+        fi
+        echo
+        break # Removed everything - can stop now
+        ;;
+    -c | -current | current)
+        name="$WM_OPTIONS"
+        ;;
+    -comp | -compiler | compiler)
+        compiler="$WM_COMPILER"
+        unset name
+        ;;
+    -compiler=*)
+        compiler="${name#*=}"
+        unset name
+        ;;
+    esac
+
+    if [ -n "$compiler" ]
+    then
+        name="$WM_ARCH$compiler"
+
+        dirs=$(find $targetDir -maxdepth 1 -name "${name}*")
+        if [ -n "$dirs" ]
+        then
+            for name in $dirs
+            do
+                echo "    '$name'"
+                rm -rf "$name"
+            done
+            echo
+        else
+            echo "    '$name' - not built or already cleaned"
+            echo
+        fi
+    elif [ -n "$name" ]
+    then
+        if [ -d "$targetDir/$name" ]
+        then
+            echo "    '$name'"
+            rm -rf "$targetDir/$name"*
+            echo
+        else
+            echo "    '$name' - not built or already cleaned"
+            echo
+        fi
+    fi
+done
+
+exit 0 # clean exit
+
+#------------------------------------------------------------------------------
diff --git a/wmake/wcleanBuild b/wmake/wcleanBuild
deleted file mode 100755
index 3989b06e0a3fc620cf8c28c7a98f281575b6935b..0000000000000000000000000000000000000000
--- a/wmake/wcleanBuild
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2017 OpenCFD Ltd.
-#    \\/     M anipulation  |
-#-------------------------------------------------------------------------------
-# License
-#     This file is part of OpenFOAM.
-#
-#     OpenFOAM is free software: you can redistribute it and/or modify it
-#     under the terms of the GNU General Public License as published by
-#     the Free Software Foundation, either version 3 of the License, or
-#     (at your option) any later version.
-#
-#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-#     for more details.
-#
-#     You should have received a copy of the GNU General Public License
-#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-#
-# Script
-#     wcleanBuild
-#
-# Usage
-#    wcleanBuild <platform> [.. <platformN>]
-#
-# Description
-#     Deletes the specified 'build/' object files directories from the
-#     the project top-level 'build/' directory $WM_PROJECT_DIR.
-#
-#     special platforms
-#     - 'all' removes all platforms.
-#     - 'compiler' corresponds to $WM_ARCH$WM_COMPILER.
-#     - 'current' corresponds to $WM_OPTIONS.
-#
-#     You must be in the project or the third-party top-level directory
-#     to run this script.
-#
-#------------------------------------------------------------------------------
-Script=${0##*/}
-
-usage() {
-    exec 1>&2
-    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
-    cat<<USAGE
-
-Usage: $Script <platform> [.. <platformN>]
-       $Script -all | -compiler | -current [<platform> [.. <platformN>]]
-
-options:
-  -a, -all          Same as 'all'
-  -comp, -compiler  Same as 'compiler'
-  -c, -current      Same as 'current'
-  -h, -help         Print the usage
-
-
-Deletes the specified build/ object file directories from the project
-top-level build/ directory $WM_PROJECT_DIR.
-
-special platforms:
-  all           Remove all platforms
-  compiler      $WM_ARCH$WM_COMPILER  (ie, \$WM_ARCH\$WM_COMPILER)
-  current       $WM_OPTIONS  (ie, \$WM_OPTIONS)
-
-You must be in the project or the third-party top-level directory
-to run this script.
-
-USAGE
-    exit 1
-}
-
-# Find -help anywhere
-for i
-do
-    case "$i" in (-h | -help) usage ;; esac
-done
-
-#------------------------------------------------------------------------------
-# Run from OPENFOAM or THIRDPARTY top-level directory only
-wmakeCheckPwd -q "$WM_PROJECT_DIR"     2>/dev/null || \
-wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \
-{
-cat<<ERROR
-${0##*/}: Error incorrect top-level directory
-
-  Not in Project:     $WM_PROJECT_DIR
-  Nor in ThirdParty:  $WM_THIRD_PARTY_DIR
-
-ERROR
-    exit 1
-}
-
-if [ "$#" -eq 0 ]
-then
-    usage "No platform specified"
-else
-    echo "$# platform(s) to clean"
-    echo
-fi
-
-for name
-do
-    case "$name" in
-    -comp | -compiler | compiler)
-        name="$WM_ARCH$WM_COMPILER"
-        ;;
-    -c | -current | current)
-        name="$WM_OPTIONS"
-        ;;
-    -a | -all | all)
-        echo "all build/ ..."
-        rm -rf build
-        echo
-        break # Can stop now
-        ;;
-    esac
-
-    if [ -n "$name" -d "build/$name" ]
-    then
-        echo "    '$name'"
-        rm -rf "build/$name"*
-        echo
-    else
-        echo "    '$name' - not built"
-        echo
-    fi
-done
-
-exit 0 # clean exit
-
-#------------------------------------------------------------------------------
diff --git a/wmake/wcleanBuild b/wmake/wcleanBuild
new file mode 120000
index 0000000000000000000000000000000000000000..a0376ef976460fb07a2c3470bd7e10b128cd4911
--- /dev/null
+++ b/wmake/wcleanBuild
@@ -0,0 +1 @@
+scripts/wcleanBuild
\ No newline at end of file
diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform
deleted file mode 100755
index 39c6da0a8605ecd25e53dc3f868b919149c29a04..0000000000000000000000000000000000000000
--- a/wmake/wcleanPlatform
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 2015 OpenFOAM Foundation
-#    \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
-#-------------------------------------------------------------------------------
-# License
-#     This file is part of OpenFOAM.
-#
-#     OpenFOAM is free software: you can redistribute it and/or modify it
-#     under the terms of the GNU General Public License as published by
-#     the Free Software Foundation, either version 3 of the License, or
-#     (at your option) any later version.
-#
-#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-#     for more details.
-#
-#     You should have received a copy of the GNU General Public License
-#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-#
-# Script
-#     wcleanPlatform
-#
-# Usage
-#    wcleanPlatform <platform> [.. <platformN>]
-#
-# Description
-#     Deletes the specified 'platforms/' object files directories from the
-#     the project top-level 'platforms/' directory $WM_PROJECT_DIR.
-#
-#     special platforms
-#     - 'all' removes all platforms, lnInclude directories and cleans tutorials.
-#     - 'compiler' corresponds to $WM_ARCH$WM_COMPILER.
-#     - 'current' corresponds to $WM_OPTIONS.
-#
-#     You must be in the project or the third-party top-level directory
-#     to run this script.
-#
-#------------------------------------------------------------------------------
-Script=${0##*/}
-
-usage() {
-    exec 1>&2
-    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
-    cat<<USAGE
-
-Usage: $Script <platform> [.. <platformN>]
-       $Script -all | -compiler | -current [<platform> [.. <platformN>]]
-
-options:
-  -a, -all          Same as 'all'
-  -comp, -compiler  Same as 'compiler'
-  -c, -current      Same as 'current'
-  -h, -help         Print the usage
-
-
-Deletes the specified platforms/ object file directories from the project
-top-level platforms/ directory $WM_PROJECT_DIR.
-
-special platforms:
-  all           Remove all platforms, lnInclude and clean tutorials
-  compiler      $WM_ARCH$WM_COMPILER  (ie, \$WM_ARCH\$WM_COMPILER)
-  current       $WM_OPTIONS  (ie, \$WM_OPTIONS)
-
-You must be in the project or the third-party top-level directory
-to run this script.
-
-USAGE
-    exit 1
-}
-
-# Find -help anywhere
-for i
-do
-    case "$i" in (-h | -help) usage ;; esac
-done
-
-#------------------------------------------------------------------------------
-# Run from OPENFOAM or THIRDPARTY top-level directory only
-wmakeCheckPwd -q "$WM_PROJECT_DIR"     2>/dev/null || \
-wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \
-{
-cat<<ERROR
-${0##*/}: Error incorrect top-level directory
-
-  Not in Project:     $WM_PROJECT_DIR
-  Nor in ThirdParty:  $WM_THIRD_PARTY_DIR
-
-ERROR
-    exit 1
-}
-
-if [ "$#" -eq 0 ]
-then
-    usage "No platform specified"
-else
-    echo "$# platform(s) to clean"
-    echo
-fi
-
-for name
-do
-    case "$name" in
-    -comp | -compiler | compiler)
-        name="$WM_ARCH$WM_COMPILER"
-        ;;
-    -c | -current | current)
-        name="$WM_OPTIONS"
-        ;;
-    -a | -all | all)
-        echo "all platforms/ ..."
-        rm -rf platforms
-        wcleanLnIncludeAll .
-        [ -x tutorials/Allclean ] && tutorials/Allclean
-        echo
-        break # Can stop now
-        ;;
-    esac
-
-    if [ -n "$name" -d "build/$name" ]
-    then
-        echo "    '$name'"
-        rm -rf "platforms/$name"*
-        echo
-    else
-        echo "    '$name' - not built"
-        echo
-    fi
-done
-
-exit 0 # clean exit
-
-#------------------------------------------------------------------------------
diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform
new file mode 120000
index 0000000000000000000000000000000000000000..a0376ef976460fb07a2c3470bd7e10b128cd4911
--- /dev/null
+++ b/wmake/wcleanPlatform
@@ -0,0 +1 @@
+scripts/wcleanBuild
\ No newline at end of file