diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C
index 65073700ab173bc4caee99792548a0e43f2afd0c..fc8fab51780bbf4d4f36f9cb274ad763fde4ff81 100644
--- a/applications/test/List/Test-List.C
+++ b/applications/test/List/Test-List.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.
@@ -42,7 +42,11 @@ See also
 #include "vector.H"
 #include "ListOps.H"
 
-#include<list>
+#include "labelRange.H"
+#include "ListOps.H"
+#include "SubList.H"
+
+#include <list>
 
 using namespace Foam;
 
@@ -61,6 +65,19 @@ int main(int argc, char *argv[])
 
     #include "setRootCase.H"
 
+    if (false)
+    {
+        labelList intlist(IStringStream("(0 1 2)")());
+        Info<<"construct from Istream: " << intlist << endl;
+
+        IStringStream("(3 4 5)")() >> static_cast<labelUList&>(intlist);
+        Info<<"is >>: " << intlist << endl;
+
+        IStringStream("(6 7 8)")() >> intlist;
+        Info<<"is >>: " << intlist << endl;
+    }
+
+
     List<vector> list1(IStringStream("1 ((0 1 2))")());
     Info<< "list1: " << list1 << endl;
 
diff --git a/applications/test/labelRanges/Test-labelRanges.C b/applications/test/labelRanges/Test-labelRanges.C
index 9f2be334d1a53a67a6227861395ad627571573e2..dec03a06f0d6f0ab283ad6a2a936e9bee6360494 100644
--- a/applications/test/labelRanges/Test-labelRanges.C
+++ b/applications/test/labelRanges/Test-labelRanges.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.
@@ -58,6 +58,7 @@ int main(int argc, char *argv[])
     }
 
 
+    labelRange range;
     labelRanges ranges;
 
     bool removeMode = false;
@@ -74,14 +75,16 @@ int main(int argc, char *argv[])
             continue;
         }
 
-        label start = 0;
-        label size  = 0;
+        {
+            label start = 0;
+            label size  = 0;
 
-        IStringStream(args[argI])() >> start;
-        ++argI;
-        IStringStream(args[argI])() >> size;
+            IStringStream(args[argI])() >> start;
+            ++argI;
+            IStringStream(args[argI])() >> size;
 
-        labelRange range(start, size);
+            range.reset(start, size);
+        }
 
         Info<< "---------------" << nl;
         if (removeMode)
@@ -107,10 +110,11 @@ int main(int argc, char *argv[])
             ranges.add(range);
         }
 
-        Info<< "<list>" << ranges << "</list>" << nl;
-        forAllConstIter(labelRanges, ranges, iter)
+        Info<< "<list>" << ranges << "</list>" << nl
+            << "content:";
+        for (auto i : ranges)
         {
-            Info<< " " << iter();
+            Info<< " " << i;
         }
         Info<< nl;
     }
diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions
index c3c6be894831806843952b5562a15d0feb0b0326..59e1d66194a9db49f00046428d748736a3ab408f 100755
--- a/bin/tools/RunFunctions
+++ b/bin/tools/RunFunctions
@@ -148,8 +148,9 @@ runParallel()
 
     # Store any parsed additional arguments e.g. decomposeParDict
     APP_PARARGS=
-    # Check the default decomposeParDict if available
-    nProcs=$(getNumberOfProcessors system/decomposeParDict)
+
+    # Initialise number of procs to unset value
+    nProcs=-1
 
     # Parse options and executable
     while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
@@ -185,6 +186,8 @@ runParallel()
         shift
     done
 
+    [ "$nProcs" -eq -1 ] && nProcs=$(getNumberOfProcessors system/decomposeParDict)
+
     if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
     then
         echo "$APP_NAME already run on $PWD:" \
@@ -213,7 +216,7 @@ cloneCase()
     else
         echo "Cloning $2 case from $1"
         mkdir $2
-        cpfiles="0 system constant"
+        cpfiles="0.orig 0 system constant"
         for f in $cpfiles
         do
             \cp -r $1/$f $2
diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C
index bbc55ec10dd7a1db58ba92aa9951f3e618a902b5..6229cb94904c4ccf241f1a9325e1b60b1191cda7 100644
--- a/src/OpenFOAM/containers/Lists/List/ListIO.C
+++ b/src/OpenFOAM/containers/Lists/List/ListIO.C
@@ -64,7 +64,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
     }
     else if (firstToken.isLabel())
     {
-        label s = firstToken.labelToken();
+        const label s = firstToken.labelToken();
 
         // Set list length to that read
         L.setSize(s);
diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C
index 52177d79bcb511819537e0a801ad9482f74252c2..320b22f68fe8f354742d80d9d7b6d1a00fa22889 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.C
+++ b/src/OpenFOAM/containers/Lists/UList/UList.C
@@ -183,7 +183,7 @@ bool Foam::UList<T>::operator<(const UList<T>& a) const
     (
         const_iterator vi = begin(), ai = a.begin();
         vi < end() && ai < a.end();
-        vi++, ai++
+        ++vi, ++ai
     )
     {
         if (*vi < *ai)
diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H
index 719df10a0f00cf28afdb2549d7a1e8359510189c..a31416cc7374a5f520a486c099b003c163ea49a6 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.H
+++ b/src/OpenFOAM/containers/Lists/UList/UList.H
@@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
 // \endcode
 // \sa forAllReverse
 #define forAll(list, i) \
-    for (Foam::label i=0; i<(list).size(); i++)
+    for (Foam::label i=0; i<(list).size(); ++i)
 
 //- Reverse loop across all elements in \a list
 //  \par Usage
@@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
 //  \endcode
 //  \sa forAll
 #define forAllReverse(list, i) \
-    for (Foam::label i=(list).size()-1; i>=0; i--)
+    for (Foam::label i=(list).size()-1; i>=0; --i)
 
 //- Iterate across all elements in the \a container object of type
 //  \a Container.
@@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
 #define forAllConstIter(Container,container,iter)                              \
     for                                                                        \
     (                                                                          \
-        Container::const_iterator iter = (container).begin();                  \
-        iter != (container).end();                                             \
+        Container::const_iterator iter = (container).cbegin();                 \
+        iter != (container).cend();                                            \
         ++iter                                                                 \
     )
 
diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H
index 0e4825c79c85f578c3bfcaeedcdcce01ab316712..bd9fe339ebd7697b2924fbeee98390439615958b 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListI.H
+++ b/src/OpenFOAM/containers/Lists/UList/UListI.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.
@@ -33,7 +33,7 @@ template<class T>
 inline Foam::UList<T>::UList()
 :
     size_(0),
-    v_(0)
+    v_(nullptr)
 {}
 
 
@@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
 template<class T>
 inline void Foam::reverse(UList<T>& ul, const label n)
 {
-    for (int i=0; i<n/2; i++)
+    for (int i=0; i<n/2; ++i)
     {
         Swap(ul[i], ul[n-1-i]);
     }
diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C
index a4648137cfc853bb1c882e96ddacfdd575ab9d20..0559a63adce6ca8d37518d09bf3359efa785881c 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListIO.C
+++ b/src/OpenFOAM/containers/Lists/UList/UListIO.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.
@@ -165,7 +165,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
             )
         );
         // Check list length
-        label s = elems.size();
+        const label s = elems.size();
 
         if (s != L.size())
         {
@@ -174,14 +174,14 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
                 << " expected " << L.size()
                 << exit(FatalIOError);
         }
-        for (label i=0; i<s; i++)
+        for (label i=0; i<s; ++i)
         {
             L[i] = elems[i];
         }
     }
     else if (firstToken.isLabel())
     {
-        label s = firstToken.labelToken();
+        const label s = firstToken.labelToken();
 
         // Set list length to that read
         if (s != L.size())
@@ -203,7 +203,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
             {
                 if (delimiter == token::BEGIN_LIST)
                 {
-                    for (label i=0; i<s; i++)
+                    for (label i=0; i<s; ++i)
                     {
                         is >> L[i];
 
@@ -226,7 +226,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<s; ++i)
                     {
                         L[i] = element;
                     }
@@ -281,7 +281,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
         (
             typename SLList<T>::const_iterator iter = sll.begin();
             iter != sll.end();
-            ++iter
+            ++iter, ++i
         )
         {
             L[i] = iter();
diff --git a/src/OpenFOAM/db/IOstreams/hashes/base64Layer.C b/src/OpenFOAM/db/IOstreams/hashes/base64Layer.C
index f1123f7519fc37981d54359bd0fa91dab0926001..5e055c1ca1cfab90240013ad3be4f0a9a77a0249 100644
--- a/src/OpenFOAM/db/IOstreams/hashes/base64Layer.C
+++ b/src/OpenFOAM/db/IOstreams/hashes/base64Layer.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -43,27 +43,35 @@ static const unsigned char base64Chars[64] =
 //! \endcond
 
 
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+std::size_t Foam::base64Layer::encodedLength(std::size_t n)
+{
+    return 4 * ((n / 3) + (n % 3 ? 1 : 0));
+}
+
+
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
-inline unsigned char Foam::base64Layer::encode0()
+inline unsigned char Foam::base64Layer::encode0() const
 {
     // Top 6 bits of char0
     return base64Chars[((group_[0] & 0xFC) >> 2)];
 }
 
-inline unsigned char Foam::base64Layer::encode1()
+inline unsigned char Foam::base64Layer::encode1() const
 {
     // Bottom 2 bits of char0, Top 4 bits of char1
     return base64Chars[((group_[0] & 0x03) << 4) | ((group_[1] & 0xF0) >> 4)];
 }
 
-inline unsigned char Foam::base64Layer::encode2()
+inline unsigned char Foam::base64Layer::encode2() const
 {
     // Bottom 4 bits of char1, Top 2 bits of char2
     return base64Chars[((group_[1] & 0x0F) << 2) | ((group_[2] & 0xC0) >> 6)];
 }
 
-inline unsigned char Foam::base64Layer::encode3()
+inline unsigned char Foam::base64Layer::encode3() const
 {
     // Bottom 6 bits of char2
     return base64Chars[(group_[2] & 0x3F)];
diff --git a/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H b/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H
index 9aa4bc8d7968905e31d7e333beb59ffd737f685f..4eaaf87e83e7848975d6e870b99fc539a96a4336 100644
--- a/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H
+++ b/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -30,7 +30,7 @@ Description
     Base64 encoding accoding to RFC 4648 specification
     (https://tools.ietf.org/html/rfc4648#page-5).
     It is the obligation of the caller to avoid using normal output
-    while the base-64 encoding layer is actively being used.
+    while the base-64 encoding layer is actively used.
 
 SourceFiles
     base64Layer.C
@@ -70,10 +70,10 @@ class base64Layer
 
     // Private Member Functions
 
-        inline unsigned char encode0();
-        inline unsigned char encode1();
-        inline unsigned char encode2();
-        inline unsigned char encode3();
+        inline unsigned char encode0() const;
+        inline unsigned char encode1() const;
+        inline unsigned char encode2() const;
+        inline unsigned char encode3() const;
 
         //- Disallow default bitwise copy construct
         base64Layer(const base64Layer&) = delete;
@@ -95,7 +95,7 @@ public:
     // Constructors
 
         //- Construct and attach to an output stream
-        base64Layer(std::ostream&);
+        base64Layer(std::ostream& os);
 
 
     //- Destructor
@@ -104,6 +104,10 @@ public:
 
     // Member Functions
 
+        //- The encoded length has 4 bytes out for every 3 bytes in.
+        static std::size_t encodedLength(std::size_t n);
+
+
         //- Encode the character sequence, writing when possible.
         void write(const char* s, std::streamsize n);
 
@@ -111,7 +115,7 @@ public:
         void reset();
 
         //- End the encoding sequence, padding the final characters with '='.
-        //  Return false if no encoding layer was actually used.
+        //  Return false if no encoding was actually performed.
         bool close();
 
 };
diff --git a/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H b/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H
index 09cd289b9e010aa986f551c40c2967d27a9a309c..d52304291041a1561bf2d6e805bc0ee627161de1 100644
--- a/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H
+++ b/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H
@@ -32,7 +32,7 @@ Description
     Note: cannot access the state dictionary until after construction of the
     function objects, since the owner container functionObjectList is owned
     by time, and time owns the state dictionary.  I.e. need to wait for time
-    to be fully consttucted.
+    to be fully constructed.
 
 See also
     Foam::functionObject
diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
index c05a1ffe4de3cb0ee3e22552de5a2b8f58fd3ab5..1f7f1edfce343457a18a0445ca3f13fc6b0ac241 100644
--- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
+++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H
@@ -51,7 +51,7 @@ namespace functionObjects
 {
 
 /*---------------------------------------------------------------------------*\
-                     Class functionObjectFile Declaration
+                          Class writeFile Declaration
 \*---------------------------------------------------------------------------*/
 
 class writeFile
diff --git a/src/OpenFOAM/primitives/ranges/labelRange/labelRange.C b/src/OpenFOAM/primitives/ranges/labelRange/labelRange.C
index 11aacf25cb5cb7ea82b6f8b22626506760adb346..2bf9810f6c6178bef8f2972c1a99e9a2d80aa9bf 100644
--- a/src/OpenFOAM/primitives/ranges/labelRange/labelRange.C
+++ b/src/OpenFOAM/primitives/ranges/labelRange/labelRange.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.
@@ -29,8 +29,6 @@ License
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-const Foam::labelRange::const_iterator Foam::labelRange::endIter_;
-
 int Foam::labelRange::debug(::Foam::debug::debugSwitch("labelRange", 0));
 
 
@@ -47,13 +45,24 @@ Foam::labelRange::labelRange(Istream& is)
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::labelRange::intersects
-(
-    const labelRange& range,
-    const bool touches
-) const
+void Foam::labelRange::adjust()
+{
+    if (start_ < 0)
+    {
+        size_ += start_;
+        start_ = 0;
+    }
+
+    if (size_ < 0)
+    {
+        size_ = 0;
+    }
+}
+
+
+bool Foam::labelRange::overlaps(const labelRange& range, bool touches) const
 {
-    label final = touches ? 1 : 0;
+    const label final = touches ? 1 : 0;
 
     return
     (
@@ -97,7 +106,7 @@ Foam::labelRange Foam::labelRange::join(const labelRange& range) const
 
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
-Foam::labelRange& Foam::labelRange::operator+=(const labelRange& rhs)
+void Foam::labelRange::operator+=(const labelRange& rhs)
 {
     if (!size_)
     {
@@ -112,8 +121,6 @@ Foam::labelRange& Foam::labelRange::operator+=(const labelRange& rhs)
         start_ = lower;
         size_  = upper - lower + 1;
     }
-
-    return *this;
 }
 
 
@@ -127,10 +134,10 @@ Foam::Istream& Foam::operator>>(Istream& is, labelRange& range)
 
     is.check("operator>>(Istream&, labelRange&)");
 
-    // disallow invalid sizes
-    if (range.size_ <= 0)
+    // Disallow invalid sizes
+    if (range.size_ < 0)
     {
-        range.clear();
+        range.size_ = 0;
     }
 
     return is;
@@ -139,15 +146,11 @@ Foam::Istream& Foam::operator>>(Istream& is, labelRange& range)
 
 Foam::Ostream& Foam::operator<<(Ostream& os, const labelRange& range)
 {
-    // write ASCII only for now
+    // Write ASCII only for now
     os  << token::BEGIN_LIST
         << range.start_ << token::SPACE << range.size_
         << token::END_LIST;
 
-//    os  << token::BEGIN_BLOCK
-//        << range.start_ << "-" << range.last()
-//        << token::END_BLOCK;
-
     os.check("operator<<(Ostream&, const labelRange&)");
     return os;
 }
diff --git a/src/OpenFOAM/primitives/ranges/labelRange/labelRange.H b/src/OpenFOAM/primitives/ranges/labelRange/labelRange.H
index 24dd33729cb1544845fccb6f1f0079c741dd4c24..3fa69c4ff379f367cedb3848ee395fb642069b9b 100644
--- a/src/OpenFOAM/primitives/ranges/labelRange/labelRange.H
+++ b/src/OpenFOAM/primitives/ranges/labelRange/labelRange.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,7 +25,7 @@ Class
     Foam::labelRange
 
 Description
-    A label range specifier.
+    A range of labels.
 
 SourceFiles
     labelRange.C
@@ -47,8 +47,8 @@ class Ostream;
 
 // Forward declaration of friend functions and operators
 class labelRange;
-Istream& operator>>(Istream&, labelRange&);
-Ostream& operator<<(Ostream&, const labelRange&);
+Istream& operator>>(Istream& is, labelRange& range);
+Ostream& operator<<(Ostream& os, const labelRange& range);
 
 /*---------------------------------------------------------------------------*\
                          Class labelRange Declaration
@@ -63,7 +63,7 @@ class labelRange
 
 public:
 
-        static int debug;
+    static int debug;
 
 
     // Public classes
@@ -75,31 +75,50 @@ public:
 
             bool operator()(const labelRange& a, const labelRange& b)
             {
-                return a.first() < b.first();
+                return a.operator<(b);
             }
         };
 
+
     // Constructors
 
-        //- Construct an empty range
+        //- Construct an empty range with zero as start and size.
         inline labelRange();
 
-        //- Construct a range
-        //  A negative size is autmatically changed to zero.
-        inline labelRange(const label start, const label size);
+        //- Construct a range from start and size.
+        //  Optionally adjust the start to avoid any negative indices.
+        //  Always reduce a negative size to zero.
+        inline labelRange
+        (
+            const label start,
+            const label size,
+            const bool adjustStart = false
+        );
 
         //- Construct from Istream.
-        labelRange(Istream&);
+        labelRange(Istream& is);
 
 
     // Member Functions
 
-        //- Reset to zero size
+        //- Alias for setSize(const label)
+        inline void resize(const label n);
+
+        //- Adjust size
+        inline void setSize(const label n);
+
+        //- Reset to zero start and zero size
         inline void clear();
 
         //- Is the range empty?
         inline bool empty() const;
 
+        //- Adjust the start to avoid any negative indices
+        void adjust();
+
+        //- Is the range valid (non-empty)?
+        inline bool valid() const;
+
         //- Return the effective size of the range
         inline label size() const;
 
@@ -109,32 +128,44 @@ public:
         //- The (inclusive) upper value of the range
         inline label last() const;
 
+        //- Reset start and size.
+        //  Optionally adjust the start to avoid any negative indices.
+        //  Always reduce a negative size to zero.
+        //  Return true if the updated range valid (non-empty).
+        inline bool reset
+        (
+            const label start,
+            const label size,
+            const bool adjustStart = false
+        );
+
         //- Return true if the value is within the range
-        inline bool contains(const label) const;
+        inline bool contains(const label value) const;
 
-        //- Return true if the ranges intersect
+        //- Return true if the ranges overlap.
         //  Optional test for ranges that also just touch each other
-        bool intersects(const labelRange&, const bool touches = false) const;
+        bool overlaps(const labelRange& range, bool touches=false) const;
 
         //- Return a joined range, squashing any gaps in between
-        //  A prior intersects() check can be used to avoid squashing gaps.
-        labelRange join(const labelRange&) const;
+        //  A prior overlaps() check can be used to avoid squashing gaps.
+        labelRange join(const labelRange& range) const;
 
 
     // Member Operators
 
         //- Return element in range, no bounds checking
-        inline label operator[](const label) const;
+        inline label operator[](const label i) const;
 
-        //- Comparison function for sorting, compares the start
+        //- Comparison function for sorting, compares the start.
+        //  If the start values are equal, also compares the size.
         inline bool operator<(const labelRange& rhs) const;
 
         //- Join ranges, squashing any gaps in between
-        //  A prior intersects() check can be used to avoid squashing gaps.
-        labelRange& operator+=(const labelRange&);
+        //  A prior overlaps() check can be used to avoid squashing gaps.
+        void operator+=(const labelRange& rhs);
 
-        inline bool operator==(const labelRange&) const;
-        inline bool operator!=(const labelRange&) const;
+        inline bool operator==(const labelRange& rhs) const;
+        inline bool operator!=(const labelRange& rhs) const;
 
 
     // STL iterator
@@ -142,6 +173,8 @@ public:
         //- An STL const_iterator
         class const_iterator
         {
+            friend class labelRange;
+
             // Private data
 
                 //- Reference to the range for which this is an iterator
@@ -150,54 +183,48 @@ public:
                 //- Current index
                 label index_;
 
-        public:
 
             // Constructors
 
-                //- Construct null - equivalent to an 'end' position
-                inline const_iterator();
-
-                //- Construct from range, moving to its 'begin' position
-                inline explicit const_iterator(const labelRange&);
+                //- Construct from range at 'begin' or 'end' position
+                inline const_iterator
+                (
+                    const labelRange& range,
+                    const bool endIter = false
+                );
 
+        public:
 
             // Member operators
 
-                inline bool operator==(const const_iterator&) const;
-
-                inline bool operator!=(const const_iterator&) const;
+                inline bool operator==(const const_iterator& iter) const;
+                inline bool operator!=(const const_iterator& iter) const;
 
-                inline label operator*();
-                inline label operator()();
+                inline label operator*() const;
+                inline label operator()() const;
 
                 inline const_iterator& operator++();
                 inline const_iterator operator++(int);
         };
 
 
-        //- const_iterator set to the beginning of the range
+        //- A const_iterator set to the beginning of the range
         inline const_iterator cbegin() const;
 
-        //- const_iterator set to beyond the end of the range
-        inline const const_iterator& cend() const;
+        //- A const_iterator set to beyond the end of the range
+        inline const const_iterator cend() const;
 
-        //- const_iterator set to the beginning of the range
+        //- A const_iterator set to the beginning of the range
         inline const_iterator begin() const;
 
-        //- const_iterator set to beyond the end of the range
-        inline const const_iterator& end() const;
+        //- A const_iterator set to beyond the end of the range
+        inline const const_iterator end() const;
 
 
     // IOstream Operators
 
-        friend Istream& operator>>(Istream&, labelRange&);
-        friend Ostream& operator<<(Ostream&, const labelRange&);
-
-
-private:
-
-        //- const_iterator returned by end(), cend()
-        static const const_iterator endIter_;
+        friend Istream& operator>>(Istream& is, labelRange& range);
+        friend Ostream& operator<<(Ostream& os, const labelRange& range);
 
 };
 
diff --git a/src/OpenFOAM/primitives/ranges/labelRange/labelRangeI.H b/src/OpenFOAM/primitives/ranges/labelRange/labelRangeI.H
index 21e839cf3cc44431fc3113fabb3cc413db155a74..927a6f57a083bdd1d1b8ac2b44d61a05d003c9d7 100644
--- a/src/OpenFOAM/primitives/ranges/labelRange/labelRangeI.H
+++ b/src/OpenFOAM/primitives/ranges/labelRange/labelRangeI.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.
@@ -33,32 +33,39 @@ inline Foam::labelRange::labelRange()
 {}
 
 
-inline Foam::labelRange::labelRange(const label start, const label size)
+inline Foam::labelRange::labelRange
+(
+    const label start,
+    const label size,
+    const bool adjustStart
+)
 :
     start_(start),
     size_(size)
 {
-    // disallow invalid sizes
-    if (size_ <= 0)
+    if (adjustStart)
+    {
+        // Disallow invalid indices and sizes
+        adjust();
+    }
+    else if (size_ < 0)
     {
-        this->clear();
+        // Disallow invalid sizes
+        size_ = 0;
     }
 }
 
 
 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
 
-inline Foam::labelRange::const_iterator::const_iterator()
-:
-   range_(*reinterpret_cast<Foam::labelRange* >(0)),
-   index_(-1)
-{}
-
-
-inline Foam::labelRange::const_iterator::const_iterator(const labelRange& range)
+inline Foam::labelRange::const_iterator::const_iterator
+(
+    const labelRange& range,
+    const bool endIter
+)
 :
    range_(range),
-   index_(range_.empty() ? -1 : 0)
+   index_(endIter ? range_.size() : 0)
 {}
 
 
@@ -76,17 +83,17 @@ inline bool Foam::labelRange::const_iterator::operator!=
     const const_iterator& iter
 ) const
 {
-    return !(this->operator==(iter));
+    return (this->index_ != iter.index_);
 }
 
 
-inline Foam::label Foam::labelRange::const_iterator::operator*()
+inline Foam::label Foam::labelRange::const_iterator::operator*() const
 {
     return range_[index_];
 }
 
 
-inline Foam::label Foam::labelRange::const_iterator::operator()()
+inline Foam::label Foam::labelRange::const_iterator::operator()() const
 {
     return range_[index_];
 }
@@ -95,12 +102,7 @@ inline Foam::label Foam::labelRange::const_iterator::operator()()
 inline Foam::labelRange::const_iterator&
 Foam::labelRange::const_iterator::operator++()
 {
-    if (++index_ >= range_.size())
-    {
-        // equivalent to end iterator
-        index_ = -1;
-    }
-
+    ++index_;
     return *this;
 }
 
@@ -109,7 +111,7 @@ inline Foam::labelRange::const_iterator
 Foam::labelRange::const_iterator::operator++(int)
 {
     const_iterator old = *this;
-    this->operator++();
+    ++index_;
     return old;
 }
 
@@ -120,9 +122,9 @@ inline Foam::labelRange::const_iterator Foam::labelRange::cbegin() const
 }
 
 
-inline const Foam::labelRange::const_iterator& Foam::labelRange::cend() const
+inline const Foam::labelRange::const_iterator Foam::labelRange::cend() const
 {
-    return endIter_;
+    return const_iterator(*this, true);
 }
 
 
@@ -132,14 +134,31 @@ inline Foam::labelRange::const_iterator Foam::labelRange::begin() const
 }
 
 
-inline const Foam::labelRange::const_iterator& Foam::labelRange::end() const
+inline const Foam::labelRange::const_iterator Foam::labelRange::end() const
 {
-    return endIter_;
+    return const_iterator(*this, true);
 }
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
+inline void Foam::labelRange::resize(const label n)
+{
+    setSize(n);
+}
+
+
+inline void Foam::labelRange::setSize(const label n)
+{
+    size_ = n;
+
+    if (size_ < 0)
+    {
+        size_ = 0;
+    }
+}
+
+
 inline void Foam::labelRange::clear()
 {
     start_ = size_ = 0;
@@ -152,6 +171,12 @@ inline bool Foam::labelRange::empty() const
 }
 
 
+inline bool Foam::labelRange::valid() const
+{
+    return size_;
+}
+
+
 inline Foam::label Foam::labelRange::size() const
 {
     return size_;
@@ -170,6 +195,31 @@ inline Foam::label Foam::labelRange::last() const
 }
 
 
+inline bool Foam::labelRange::reset
+(
+    const label start,
+    const label size,
+    const bool adjustStart
+)
+{
+    start_ = start;
+    size_  = size;
+
+    if (adjustStart)
+    {
+        // Disallow invalid indices and sizes
+        adjust();
+    }
+    else if (size_ < 0)
+    {
+        // Disallow invalid sizes
+        size_ = 0;
+    }
+
+    return size_;
+}
+
+
 inline bool Foam::labelRange::contains(const label value) const
 {
     return value >= this->first() && value <= this->last();
@@ -186,7 +236,11 @@ inline Foam::label Foam::labelRange::operator[](const label i) const
 
 inline bool Foam::labelRange::operator<(const labelRange& rhs) const
 {
-    return this->first() < rhs.first();
+    return
+    (
+        this->first() < rhs.first()
+     || (this->first() == rhs.first() && this->size() < rhs.size())
+    );
 }
 
 
diff --git a/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.C b/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.C
index 101c2bce983c4acdd6d62568f300fe7e6295e89f..d9edff0e47abf2f07c347bbd74666ccb63beed19 100644
--- a/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.C
+++ b/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.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,11 +26,6 @@ License
 #include "labelRanges.H"
 #include "ListOps.H"
 
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-const Foam::labelRanges::const_iterator Foam::labelRanges::endIter_;
-
-
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
 void Foam::labelRanges::insertBefore
@@ -141,7 +136,7 @@ bool Foam::labelRanges::add(const labelRange& range)
     {
         labelRange& currRange = ParentType::operator[](elemI);
 
-        if (currRange.intersects(range, true))
+        if (currRange.overlaps(range, true))
         {
             // absorb into the existing (adjacent/overlapping) range
             currRange += range;
@@ -150,7 +145,7 @@ bool Foam::labelRanges::add(const labelRange& range)
             for (; elemI < this->size()-1; ++elemI)
             {
                 labelRange& nextRange = ParentType::operator[](elemI+1);
-                if (currRange.intersects(nextRange, true))
+                if (currRange.overlaps(nextRange, true))
                 {
                     currRange += nextRange;
                     nextRange.clear();
diff --git a/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.H b/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.H
index 6fa10b0aac58733e9f2c48bf74d3ce56fc7baca3..134acb048202aeff4d10db35b7ee02ab792c3447 100644
--- a/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.H
+++ b/src/OpenFOAM/primitives/ranges/labelRange/labelRanges.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.
@@ -49,8 +49,8 @@ class Ostream;
 
 // Forward declaration of friend functions and operators
 class labelRanges;
-Istream& operator>>(Istream&, labelRanges&);
-Ostream& operator<<(Ostream&, const labelRanges&);
+Istream& operator>>(Istream& is, labelRanges& ranges);
+Ostream& operator<<(Ostream& is, const labelRanges& ranges);
 
 /*---------------------------------------------------------------------------*\
                          Class labelRanges Declaration
@@ -68,13 +68,13 @@ class labelRanges
     // Private Member Functions
 
         //- Insert range before specified insertion index, by copying up
-        void insertBefore(const label, const labelRange&);
+        void insertBefore(const label insert, const labelRange& range);
 
         //- Purge empty ranges, by copying down
         void purgeEmpty();
 
         //- Print the range for debugging purposes
-        Ostream& printRange(Ostream&, const labelRange&) const;
+        Ostream& printRange(Ostream& os, const labelRange& range) const;
 
 
 public:
@@ -85,10 +85,10 @@ public:
         inline labelRanges();
 
         //- Construct given size
-        inline explicit labelRanges(const label);
+        inline explicit labelRanges(const label nElem);
 
         //- Construct from Istream.
-        labelRanges(Istream&);
+        labelRanges(Istream& is);
 
 
     // Member Functions
@@ -100,19 +100,22 @@ public:
         using DynamicList<labelRange>::empty;
 
         //- Return true if the value is within any of the ranges
-        inline bool contains(const label) const;
+        inline bool contains(const label value) const;
 
         //- Add the range to the list
-        bool add(const labelRange&);
+        bool add(const labelRange& range);
 
         //- Remove the range from the list
-        bool remove(const labelRange&);
+        bool remove(const labelRange& range);
+
 
     // STL iterator
 
         //- An STL const_iterator
         class const_iterator
         {
+            friend class labelRanges;
+
             // Private data
 
                 //- Reference to the list for which this is an iterator
@@ -124,22 +127,21 @@ public:
                 //- Index of current element at listIndex
                 label subIndex_;
 
-        public:
-
             // Constructors
 
-                //- Construct null - equivalent to an 'end' position
-                inline const_iterator();
-
-                //- Construct from list, moving to its 'begin' position
-                inline explicit const_iterator(const labelRanges&);
+                //- Construct from ranges at 'begin' or 'end' position
+                inline const_iterator
+                (
+                    const labelRanges& lst,
+                    const bool endIter = false
+                );
 
+        public:
 
             // Member operators
 
-                inline bool operator==(const const_iterator&) const;
-
-                inline bool operator!=(const const_iterator&) const;
+                inline bool operator==(const const_iterator& iter) const;
+                inline bool operator!=(const const_iterator& iter) const;
 
                 inline label operator*();
                 inline label operator()();
@@ -149,29 +151,23 @@ public:
         };
 
 
-        //- const_iterator set to the beginning of the list
+        //- A const_iterator set to the beginning of the list
         inline const_iterator cbegin() const;
 
-        //- const_iterator set to beyond the end of the list
-        inline const const_iterator& cend() const;
+        //- A const_iterator set to beyond the end of the list
+        inline const const_iterator cend() const;
 
-        //- const_iterator set to the beginning of the list
+        //- A const_iterator set to the beginning of the list
         inline const_iterator begin() const;
 
-        //- const_iterator set to beyond the end of the list
-        inline const const_iterator& end() const;
+        //- A const_iterator set to beyond the end of the list
+        inline const const_iterator end() const;
 
 
     // IOstream Operators
 
-        friend Istream& operator>>(Istream&, labelRanges&);
-        friend Ostream& operator<<(Ostream&, const labelRanges&);
-
-
-private:
-
-        //- const_iterator returned by end(), cend()
-        static const const_iterator endIter_;
+        friend Istream& operator>>(Istream& is, labelRanges& ranges);
+        friend Ostream& operator<<(Ostream& os, const labelRanges& ranges);
 
 };
 
diff --git a/src/OpenFOAM/primitives/ranges/labelRange/labelRangesI.H b/src/OpenFOAM/primitives/ranges/labelRange/labelRangesI.H
index 739d582e9fe39073e963b4aae45a977136b1b73a..9ccad0e300c20cf75dabaf922bdced742ada7374 100644
--- a/src/OpenFOAM/primitives/ranges/labelRange/labelRangesI.H
+++ b/src/OpenFOAM/primitives/ranges/labelRange/labelRangesI.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.
@@ -40,28 +40,18 @@ inline Foam::labelRanges::labelRanges(const label nElem)
 
 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
 
-inline Foam::labelRanges::const_iterator::const_iterator()
+inline Foam::labelRanges::const_iterator::const_iterator
+(
+    const labelRanges& lst,
+    const bool endIter
+)
 :
-   list_(*reinterpret_cast<Foam::labelRanges* >(0)),
-   index_(-1),
-   subIndex_(-1)
+    list_(lst),
+    index_(endIter ? lst.size() : 0),
+    subIndex_(0)
 {}
 
 
-inline Foam::labelRanges::const_iterator::const_iterator(const labelRanges& lst)
-:
-   list_(lst),
-   index_(0),
-   subIndex_(0)
-{
-    if (list_.empty())
-    {
-        // equivalent to end iterator
-        index_ = subIndex_ = -1;
-    }
-}
-
-
 inline bool Foam::labelRanges::const_iterator::operator==
 (
     const const_iterator& iter
@@ -69,7 +59,7 @@ inline bool Foam::labelRanges::const_iterator::operator==
 {
     return
     (
-        this->index_ == iter.index_
+        this->index_    == iter.index_
      && this->subIndex_ == iter.subIndex_
     );
 }
@@ -101,13 +91,9 @@ Foam::labelRanges::const_iterator::operator++()
 {
     if (++subIndex_ >= list_[index_].size())
     {
-        // go to next list entry
+        // Next sub-list
+        ++index_;
         subIndex_ = 0;
-        if (++index_ >= list_.size())
-        {
-            // equivalent to end iterator
-            index_ = subIndex_ = -1;
-        }
     }
 
     return *this;
@@ -129,9 +115,9 @@ inline Foam::labelRanges::const_iterator Foam::labelRanges::cbegin() const
 }
 
 
-inline const Foam::labelRanges::const_iterator& Foam::labelRanges::cend() const
+inline const Foam::labelRanges::const_iterator Foam::labelRanges::cend() const
 {
-    return endIter_;
+    return const_iterator(*this, true);
 }
 
 
@@ -141,9 +127,9 @@ inline Foam::labelRanges::const_iterator Foam::labelRanges::begin() const
 }
 
 
-inline const Foam::labelRanges::const_iterator& Foam::labelRanges::end() const
+inline const Foam::labelRanges::const_iterator Foam::labelRanges::end() const
 {
-    return endIter_;
+    return const_iterator(*this, true);
 }
 
 
diff --git a/src/conversion/vtk/part/foamVtkCells.C b/src/conversion/vtk/part/foamVtkCells.C
index b4c7beacde9d7523af4cd59f61edac03fc6c2590..5846c8442d705359cd54460ce2668b80ca091588 100644
--- a/src/conversion/vtk/part/foamVtkCells.C
+++ b/src/conversion/vtk/part/foamVtkCells.C
@@ -326,7 +326,7 @@ void Foam::foamVtkCells::correct()
                         nAddVerts += 5;
 
                         vertOffset_[celLoc] = nAddVerts;
-                        decompose_.superCells_[nAddCells++] = celLoc;
+                        decompose_.superCells_[nAddCells++] = cellI;
                     }
 
                     cellTypes_[celLoc] = foamVtkCore::VTK_PYRAMID;
@@ -373,7 +373,7 @@ void Foam::foamVtkCells::correct()
                         nAddVerts += 4;
 
                         vertOffset_[celLoc] = nAddVerts;
-                        decompose_.superCells_[nAddCells++] = celLoc;
+                        decompose_.superCells_[nAddCells++] = cellI;
                     }
 
                     cellTypes_[celLoc] = foamVtkCore::VTK_TETRA;
diff --git a/src/fileFormats/Make/files b/src/fileFormats/Make/files
index 87fd35ee22b3c227489cbc79bad227c58ebc1051..ab7fe26dc28d14e0a433dd49fb4a3dc37aab39ab 100644
--- a/src/fileFormats/Make/files
+++ b/src/fileFormats/Make/files
@@ -19,6 +19,7 @@ vtk/format/foamVtkAppendBase64Formatter.C
 vtk/format/foamVtkAppendRawFormatter.C
 vtk/format/foamVtkAsciiFormatter.C
 vtk/format/foamVtkBase64Formatter.C
+vtk/format/foamVtkBase64Layer.C
 vtk/format/foamVtkLegacyFormatter.C
 vtk/format/foamVtkFormatter.C
 vtk/format/foamVtkOutputOptions.C
diff --git a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
index ee8b84200f0aaa5b8d333d2e577b44c2d5289be3..3805b61812e783c4bddd29582c2cc442a45e815f 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
+++ b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -27,8 +27,7 @@ License
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-const char* Foam::foamVtkAppendBase64Formatter::name_     = "append";
-const char* Foam::foamVtkAppendBase64Formatter::encoding_ = "base64";
+const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
@@ -38,14 +37,16 @@ Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
     std::ostream& os
 )
 :
-    foamVtkBase64Formatter(os)
+    foamVtkBase64Layer(os)
 {}
 
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
 Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
-{}
+{
+    base64Layer::close();
+}
 
 
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
@@ -56,10 +57,4 @@ const char* Foam::foamVtkAppendBase64Formatter::name() const
 }
 
 
-const char* Foam::foamVtkAppendBase64Formatter::encoding() const
-{
-    return encoding_;
-}
-
-
 // ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
index b7239ee7c66ffc637441b4504eb69a9a74f52a24..db3e1d6694fffda7c0869e1ae43916bce97dc2fb 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
+++ b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -36,7 +36,7 @@ SourceFiles
 #ifndef foamVtkAppendBase64Formatter_H
 #define foamVtkAppendBase64Formatter_H
 
-#include "foamVtkBase64Formatter.H"
+#include "foamVtkBase64Layer.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -49,12 +49,11 @@ namespace Foam
 
 class foamVtkAppendBase64Formatter
 :
-    public foamVtkBase64Formatter
+    public foamVtkBase64Layer
 {
     // Private Data Members
 
         static const char* name_;
-        static const char* encoding_;
 
 
     // Private Member Functions
@@ -71,7 +70,7 @@ public:
     // Constructors
 
         //- Construct and attach to an output stream
-        foamVtkAppendBase64Formatter(std::ostream&);
+        foamVtkAppendBase64Formatter(std::ostream& os);
 
 
     //- Destructor
@@ -83,9 +82,6 @@ public:
         //- Output name for XML type ("append")
         virtual const char* name() const;
 
-        //- Name for the XML append encoding ("base64").
-        virtual const char* encoding() const;
-
 };
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
index 9933970495ea2e8a920659bf6f61edd680933914..ae565323b8546a93739d9eca782a519a039f8b52 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -71,9 +71,9 @@ const char* Foam::foamVtkAppendRawFormatter::encoding() const
 }
 
 
-void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t val)
+void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t nBytes)
 {
-    write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
+    write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
 }
 
 
@@ -85,28 +85,28 @@ void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
 
 void Foam::foamVtkAppendRawFormatter::write(const label val)
 {
-    // std::cerr<<"label is:" << sizeof(val) << '\n';
+    // std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
     write(reinterpret_cast<const char*>(&val), sizeof(label));
 }
 
 
 void Foam::foamVtkAppendRawFormatter::write(const float val)
 {
-    // std::cerr<<"float is:" << sizeof(val) << '\n';
+    // std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
     write(reinterpret_cast<const char*>(&val), sizeof(float));
 }
 
 
 void Foam::foamVtkAppendRawFormatter::write(const double val)
 {
-    // std::cerr<<"write double as float:" << val << '\n';
+    // std::cerr<<"double as float=" << val << '\n';
     float copy(val);
     write(copy);
 }
 
 
 void Foam::foamVtkAppendRawFormatter::flush()
-{}
+{/*nop*/}
 
 
 // ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
index abc3db09293f7baccc6c1796ef4ba3ffe40d2e1d..1dcb9b8d55c39a2fd3845947c0e2b8915effddbe 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
@@ -77,7 +77,7 @@ public:
     // Constructors
 
         //- Construct and attach to an output stream
-        foamVtkAppendRawFormatter(std::ostream&);
+        foamVtkAppendRawFormatter(std::ostream& os);
 
 
     //- Destructor
@@ -94,12 +94,14 @@ public:
 
 
         //- Write leading size for binary output
-        virtual void writeSize(const uint64_t);
+        virtual void writeSize(const uint64_t nBytes);
 
-        virtual void write(const uint8_t);
-        virtual void write(const label);
-        virtual void write(const float);
-        virtual void write(const double);
+        virtual void write(const uint8_t val);
+        virtual void write(const label val);
+        virtual void write(const float val);
+        virtual void write(const double val);
+
+        //- A no-op for this format
         virtual void flush();
 
 };
diff --git a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
index 6a78f73f53cbf19db657bda92e828c282329d4ab..9ed22db23303d3239a446e6328f435a7f8268c6f 100644
--- a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -47,6 +47,16 @@ inline void Foam::foamVtkAsciiFormatter::next()
 }
 
 
+inline void Foam::foamVtkAsciiFormatter::done()
+{
+    if (pos_)
+    {
+        os()<< '\n';
+    }
+    pos_ = 0;
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter(std::ostream& os)
@@ -73,7 +83,7 @@ Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
 
 Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
 {
-    flush();
+    done();
 }
 
 
@@ -91,7 +101,7 @@ const char* Foam::foamVtkAsciiFormatter::encoding() const
 }
 
 
-void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t)
+void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t ignored)
 {/*nop*/}
 
 
@@ -125,11 +135,14 @@ void Foam::foamVtkAsciiFormatter::write(const double val)
 
 void Foam::foamVtkAsciiFormatter::flush()
 {
-    if (pos_)
-    {
-        os()<< '\n';
-    }
-    pos_ = 0;
+    done();
+}
+
+
+std::size_t
+Foam::foamVtkAsciiFormatter::encodedLength(std::size_t ignored) const
+{
+    return 0;
 }
 
 
diff --git a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
index 009d776f89f1d85cf3cd5335e2feb5cde8695047..8b8e06b2a226c855c2243f89f4675aeb4bc2251c 100644
--- a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -62,9 +62,12 @@ class foamVtkAsciiFormatter
 
     // Private Member Functions
 
-        //- Advance to next position, adding space or newline as required
+        //- Advance to next position, adding space or newline as needed
         inline void next();
 
+        //- Finish an output line, adding newline as needed
+        inline void done();
+
 
         //- Disallow default bitwise copy construct
         foamVtkAsciiFormatter(const foamVtkAsciiFormatter&) = delete;
@@ -78,10 +81,10 @@ public:
     // Constructors
 
         //- Construct and attach to an output stream, use default precision
-        foamVtkAsciiFormatter(std::ostream&);
+        foamVtkAsciiFormatter(std::ostream& os);
 
         //- Construct and attach to an output stream, use specified precision
-        foamVtkAsciiFormatter(std::ostream&, unsigned precision);
+        foamVtkAsciiFormatter(std::ostream& os, unsigned precision);
 
 
     //- Destructor
@@ -95,18 +98,24 @@ public:
         virtual const char* name() const;
 
         //- Name for the XML append encoding - unused.
-        //  Currently simply "ASCII", but this should not be relied upon.
+        //  Currently identical to name(), but do not rely on this.
         virtual const char* encoding() const;
 
 
         //- Write leading size - this is a no-op for ascii output
-        virtual void writeSize(const uint64_t);
+        virtual void writeSize(const uint64_t ignored);
+
+        virtual void write(const uint8_t val);
+        virtual void write(const label val);
+        virtual void write(const float val);
+        virtual void write(const double val);
 
-        virtual void write(const uint8_t);
-        virtual void write(const label);
-        virtual void write(const float);
-        virtual void write(const double);
+        //- Write a newline if needed to finish a line of output.
         virtual void flush();
+
+        //- The encoded length for ascii output is not applicable.
+        virtual std::size_t encodedLength(std::size_t ignored) const;
+
 };
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Formatter.C b/src/fileFormats/vtk/format/foamVtkBase64Formatter.C
index a11d97bd49e573d318700e6e56f66802364daf51..f87efbb19f4972a65dd02f9c40eb56800696e0bb 100644
--- a/src/fileFormats/vtk/format/foamVtkBase64Formatter.C
+++ b/src/fileFormats/vtk/format/foamVtkBase64Formatter.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -27,28 +27,14 @@ License
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
-const char* Foam::foamVtkBase64Formatter::name_     = "binary";
-const char* Foam::foamVtkBase64Formatter::encoding_ = "base64";
-
-
-// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
-
-void Foam::foamVtkBase64Formatter::write
-(
-    const char* s,
-    std::streamsize n
-)
-{
-    base64Layer::write(s, n);
-}
+const char* Foam::foamVtkBase64Formatter::name_ = "binary";
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
 :
-    foamVtkFormatter(os),
-    base64Layer(os)
+    foamVtkBase64Layer(os)
 {}
 
 
@@ -56,7 +42,10 @@ Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
 
 Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
 {
-    flush();
+    if (base64Layer::close())
+    {
+        os().put('\n');
+    }
 }
 
 
@@ -68,46 +57,6 @@ const char* Foam::foamVtkBase64Formatter::name() const
 }
 
 
-const char* Foam::foamVtkBase64Formatter::encoding() const
-{
-    return encoding_;
-}
-
-
-void Foam::foamVtkBase64Formatter::writeSize(const uint64_t val)
-{
-    write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
-}
-
-
-void Foam::foamVtkBase64Formatter::write(const uint8_t val)
-{
-    base64Layer::add(val);
-}
-
-
-void Foam::foamVtkBase64Formatter::write(const label val)
-{
-    // std::cerr<<"label is:" << sizeof(val) << '\n';
-    write(reinterpret_cast<const char*>(&val), sizeof(label));
-}
-
-
-void Foam::foamVtkBase64Formatter::write(const float val)
-{
-    // std::cerr<<"float is:" << sizeof(val) << '\n';
-    write(reinterpret_cast<const char*>(&val), sizeof(float));
-}
-
-
-void Foam::foamVtkBase64Formatter::write(const double val)
-{
-    // std::cerr<<"write double as float:" << val << '\n';
-    float copy(val);
-    write(copy);
-}
-
-
 void Foam::foamVtkBase64Formatter::flush()
 {
     if (base64Layer::close())
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Formatter.H b/src/fileFormats/vtk/format/foamVtkBase64Formatter.H
index f01bec3d9aa343159749834e47cc0f7ff14e62fe..e92fa4f9e374c21c8ead9795234d6c777b8ab381 100644
--- a/src/fileFormats/vtk/format/foamVtkBase64Formatter.H
+++ b/src/fileFormats/vtk/format/foamVtkBase64Formatter.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -33,8 +33,7 @@ Description
 #ifndef foamVtkBase64Formatter_H
 #define foamVtkBase64Formatter_H
 
-#include "foamVtkFormatter.H"
-#include "base64Layer.H"
+#include "foamVtkBase64Layer.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -47,8 +46,7 @@ namespace Foam
 
 class foamVtkBase64Formatter
 :
-    public foamVtkFormatter,
-    private base64Layer
+    public foamVtkBase64Layer
 {
     // Private Data Members
 
@@ -64,20 +62,12 @@ class foamVtkBase64Formatter
         //- Disallow default bitwise assignment
         void operator=(const foamVtkBase64Formatter&) = delete;
 
-protected:
-
-    // Protected Member Functions
-
-        //- Write
-        void write(const char* s, std::streamsize n);
-
-
 public:
 
     // Constructors
 
         //- Construct and attach to an output stream
-        foamVtkBase64Formatter(std::ostream&);
+        foamVtkBase64Formatter(std::ostream& os);
 
 
     //- Destructor
@@ -90,17 +80,9 @@ public:
         //  The lowercase version of the Legacy output type.
         virtual const char* name() const;
 
-        //- Name for the XML append encoding.
-        virtual const char* encoding() const;
-
-
-        //- Write leading size for binary output
-        virtual void writeSize(const uint64_t);
 
-        virtual void write(const uint8_t);
-        virtual void write(const label);
-        virtual void write(const float);
-        virtual void write(const double);
+        //- End the encoding sequence (padding the final characters with '=')
+        //  and write a newline to the output if any encoding was done.
         virtual void flush();
 
 };
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Layer.C b/src/fileFormats/vtk/format/foamVtkBase64Layer.C
new file mode 100644
index 0000000000000000000000000000000000000000..d66970d522b7e356eb03e711557b66985939bcd2
--- /dev/null
+++ b/src/fileFormats/vtk/format/foamVtkBase64Layer.C
@@ -0,0 +1,116 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  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 "foamVtkBase64Layer.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+const char* Foam::foamVtkBase64Layer::encoding_ = "base64";
+
+
+// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
+
+void Foam::foamVtkBase64Layer::write
+(
+    const char* s,
+    std::streamsize n
+)
+{
+    base64Layer::write(s, n);
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
+:
+    foamVtkFormatter(os),
+    base64Layer(os)
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
+{
+    base64Layer::close();
+}
+
+
+// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
+
+const char* Foam::foamVtkBase64Layer::encoding() const
+{
+    return encoding_;
+}
+
+
+void Foam::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
+{
+    write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
+}
+
+
+void Foam::foamVtkBase64Layer::write(const uint8_t val)
+{
+    base64Layer::add(val);
+}
+
+
+void Foam::foamVtkBase64Layer::write(const label val)
+{
+    // std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
+    write(reinterpret_cast<const char*>(&val), sizeof(label));
+}
+
+
+void Foam::foamVtkBase64Layer::write(const float val)
+{
+    // std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
+    write(reinterpret_cast<const char*>(&val), sizeof(float));
+}
+
+
+void Foam::foamVtkBase64Layer::write(const double val)
+{
+    // std::cerr<<"double as float=" << val << '\n';
+    float copy(val);
+    write(copy);
+}
+
+
+void Foam::foamVtkBase64Layer::flush()
+{
+    base64Layer::close();
+}
+
+
+std::size_t Foam::foamVtkBase64Layer::encodedLength(std::size_t n) const
+{
+    return base64Layer::encodedLength(n);
+}
+
+
+// ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Layer.H b/src/fileFormats/vtk/format/foamVtkBase64Layer.H
new file mode 100644
index 0000000000000000000000000000000000000000..61527a11bc02d6047ef6ee8b28bca8e61f978584
--- /dev/null
+++ b/src/fileFormats/vtk/format/foamVtkBase64Layer.H
@@ -0,0 +1,114 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  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
+    foamVtkBase64Layer
+
+Description
+    Base-64 encoded output.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef foamVtkBase64Layer_H
+#define foamVtkBase64Layer_H
+
+#include "foamVtkFormatter.H"
+#include "base64Layer.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                   Class foamVtkBase64Layer Declaration
+\*---------------------------------------------------------------------------*/
+
+class foamVtkBase64Layer
+:
+    public foamVtkFormatter,
+    protected base64Layer
+{
+    // Private Data Members
+
+        static const char* encoding_;
+
+
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
+
+        //- Disallow default bitwise assignment
+        void operator=(const foamVtkBase64Layer&) = delete;
+
+protected:
+
+    // Protected Member Functions
+
+        //- Write
+        void write(const char* s, std::streamsize n);
+
+
+    // Constructors
+
+        //- Construct and attach to an output stream
+        foamVtkBase64Layer(std::ostream& os);
+
+public:
+
+    //- Destructor
+    virtual ~foamVtkBase64Layer();
+
+
+    // Member Functions
+
+        //- Name for the XML append encoding ("base64").
+        virtual const char* encoding() const;
+
+
+        //- Write leading size for binary output
+        virtual void writeSize(const uint64_t nBytes);
+
+        virtual void write(const uint8_t val);
+        virtual void write(const label val);
+        virtual void write(const float val);
+        virtual void write(const double val);
+
+        //- End the encoding sequence (padding the final characters with '=')
+        virtual void flush();
+
+        //- The encoded length for base64 encoded output.
+        virtual std::size_t encodedLength(std::size_t n) const;
+
+};
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkFormatter.C b/src/fileFormats/vtk/format/foamVtkFormatter.C
index 7271dd22f5ebbee7037f5dd1484fd8b67ef5046c..2bc607a78a2684e18ac84cbe33d88deb2b4537b3 100644
--- a/src/fileFormats/vtk/format/foamVtkFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkFormatter.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -52,6 +52,12 @@ Foam::foamVtkFormatter::~foamVtkFormatter()
 
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
+std::size_t Foam::foamVtkFormatter::encodedLength(std::size_t n) const
+{
+    return n;
+}
+
+
 void Foam::foamVtkFormatter::indent()
 {
     label n = xmlTags_.size() * 2;
@@ -149,7 +155,6 @@ Foam::foamVtkFormatter::tag(const word& tag)
 }
 
 
-
 Foam::foamVtkFormatter&
 Foam::foamVtkFormatter::endTag(const word& tag)
 {
@@ -181,7 +186,6 @@ Foam::foamVtkFormatter::endTag(const word& tag)
 }
 
 
-
 Foam::foamVtkFormatter&
 Foam::foamVtkFormatter::xmlAttr
 (
diff --git a/src/fileFormats/vtk/format/foamVtkFormatter.H b/src/fileFormats/vtk/format/foamVtkFormatter.H
index 65519b1955a0265fbd09154100be57124c111d69..5ab0776d6064ccf5c4b8b0be24139713c4d6d002 100644
--- a/src/fileFormats/vtk/format/foamVtkFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkFormatter.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -74,8 +74,8 @@ class foamVtkFormatter
         template<class Type>
         foamVtkFormatter& xmlAttribute
         (
-            const word&,
-            const Type&,
+            const word& k,
+            const Type& v,
             const char quote
         );
 
@@ -120,14 +120,20 @@ public:
 
 
         //- Write leading size for binary output
-        virtual void writeSize(const uint64_t) = 0;
+        virtual void writeSize(const uint64_t nBytes) = 0;
 
-        virtual void write(const uint8_t) = 0;
-        virtual void write(const label)   = 0;
-        virtual void write(const float)   = 0;
-        virtual void write(const double)  = 0;
+        virtual void write(const uint8_t val) = 0;
+        virtual void write(const label val)   = 0;
+        virtual void write(const float val)   = 0;
+        virtual void write(const double val)  = 0;
+
+        //- Flush encoding, write newline etc.
         virtual void flush() = 0;
 
+        //- The encoded length for binary output.
+        //  The default is pass-through.
+        virtual std::size_t encodedLength(std::size_t n) const;
+
 
     // Member Functions
 
@@ -138,7 +144,7 @@ public:
         foamVtkFormatter& xmlHeader();
 
         //- Write XML comment (at the current indentation level)
-        foamVtkFormatter& comment(const std::string&);
+        foamVtkFormatter& comment(const std::string& text);
 
 
         //- Open XML tag
@@ -177,40 +183,40 @@ public:
         //- Write XML attribute
         foamVtkFormatter& xmlAttr
         (
-            const word&,
-            const std::string&,
+            const word& k,
+            const std::string& v,
             const char quote = '\''
         );
 
         //- Write XML attribute
         foamVtkFormatter& xmlAttr
         (
-            const word&,
-            const int32_t,
+            const word& k,
+            const int32_t v,
             const char quote = '\''
         );
 
         //- Write XML attribute
         foamVtkFormatter& xmlAttr
         (
-            const word&,
-            const int64_t,
+            const word& k,
+            const int64_t v,
             const char quote = '\''
         );
 
         //- Write XML attribute
         foamVtkFormatter& xmlAttr
         (
-            const word&,
-            const uint64_t,
+            const word& k,
+            const uint64_t v,
             const char quote = '\''
         );
 
         //- Write XML attribute
         foamVtkFormatter& xmlAttr
         (
-            const word&,
-            const scalar,
+            const word& k,
+            const scalar v,
             const char quote = '\''
         );
 
@@ -219,19 +225,19 @@ public:
     // Member Operators
 
         //- Write XML attribute
-        foamVtkFormatter& operator()(const word&, const std::string&);
+        foamVtkFormatter& operator()(const word& k, const std::string& v);
 
         //- Write XML attribute
-        foamVtkFormatter& operator()(const word&, const int32_t);
+        foamVtkFormatter& operator()(const word& k, const int32_t v);
 
         //- Write XML attribute
-        foamVtkFormatter& operator()(const word&, const int64_t);
+        foamVtkFormatter& operator()(const word& k, const int64_t v);
 
         //- Write XML attribute
-        foamVtkFormatter& operator()(const word&, const uint64_t);
+        foamVtkFormatter& operator()(const word& k, const uint64_t v);
 
         //- Write XML attribute
-        foamVtkFormatter& operator()(const word&, const scalar);
+        foamVtkFormatter& operator()(const word& k, const scalar v);
 
 };
 
diff --git a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.C b/src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
index 89525ab0baa0ebf2555548a517f0fce491d4c259..a3e87264f82fc1bc30977fa0f7dd4ed02f3a86e0 100644
--- a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -71,8 +71,8 @@ const char* Foam::foamVtkLegacyFormatter::encoding() const
 }
 
 
-void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t)
-{}
+void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t ignored)
+{/*nop*/}
 
 
 void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
diff --git a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.H b/src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
index fe2395add4d143085d854c987d040b6ed051caaa..6ec5ba7e8dd37209a9bc92c6b91fa2e479e75eac 100644
--- a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -25,11 +25,10 @@ Class
     foamVtkLegacyFormatter
 
 Description
-    Binary output for the VTK legacy format, always written as big-endian.
+    Binary output for the VTK legacy format, always written as big-endian
+    and with 32-bit integers.
 
-    The legacy files are always written as big endian.
-    Since integers in the legacy format are limited to 32-bit,
-    this format should not be used for OpenFOAM with 64-bit label sizes.
+    This format should never be used for OpenFOAM with 64-bit label sizes.
 
 SourceFiles
     foamVtkLegacyFormatter.C
@@ -81,7 +80,7 @@ public:
     // Constructors
 
         //- Construct and attach to an output stream
-        foamVtkLegacyFormatter(std::ostream&);
+        foamVtkLegacyFormatter(std::ostream& os);
 
 
     //- Destructor
@@ -90,22 +89,25 @@ public:
 
     // Member Functions
 
-        //- Name for the Legacy output type ("BINARY")
+        //- Name for the legacy binary output type ("BINARY")
         virtual const char* name() const;
 
         //- Name for the XML append encoding (unused)
-        //  Currently simply "BINARY", but this should not be relied upon.
+        //  Currently identical to name(), but do not rely on this.
         virtual const char* encoding() const;
 
 
         //- Write leading size - a no-op for legacy binary output
-        virtual void writeSize(const uint64_t);
+        virtual void writeSize(const uint64_t ignored);
 
-        virtual void write(const uint8_t);
-        virtual void write(const label);
-        virtual void write(const float);
-        virtual void write(const double);
+        virtual void write(const uint8_t val);
+        virtual void write(const label val);
+        virtual void write(const float val);
+        virtual void write(const double val);
+
+        //- Write a newline to the output
         virtual void flush();
+
 };
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkOutputOptions.C b/src/fileFormats/vtk/format/foamVtkOutputOptions.C
index 39f11a432e8e65e90660d21cbb7d18af22b56fee..c88d334594d14289c27237b66c66839fb89f5def 100644
--- a/src/fileFormats/vtk/format/foamVtkOutputOptions.C
+++ b/src/fileFormats/vtk/format/foamVtkOutputOptions.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -45,10 +45,8 @@ Foam::foamVtkOutputOptions::foamVtkOutputOptions()
 
 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
 
-Foam::autoPtr<Foam::foamVtkFormatter> Foam::foamVtkOutputOptions::newFormatter
-(
-    std::ostream& os
-) const
+Foam::autoPtr<Foam::foamVtkFormatter>
+Foam::foamVtkOutputOptions::newFormatter(std::ostream& os) const
 {
     switch (type_)
     {
@@ -87,9 +85,9 @@ Foam::autoPtr<Foam::foamVtkFormatter> Foam::foamVtkOutputOptions::newFormatter
 
 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
 
-void Foam::foamVtkOutputOptions::ascii(bool b)
+void Foam::foamVtkOutputOptions::ascii(bool on)
 {
-    if (b)
+    if (on)
     {
         // Force ASCII:
 
@@ -132,9 +130,9 @@ void Foam::foamVtkOutputOptions::ascii(bool b)
 }
 
 
-void Foam::foamVtkOutputOptions::append(bool b)
+void Foam::foamVtkOutputOptions::append(bool on)
 {
-    if (b)
+    if (on)
     {
         if (!(type_ & APPEND))
         {
@@ -153,9 +151,9 @@ void Foam::foamVtkOutputOptions::append(bool b)
 }
 
 
-void Foam::foamVtkOutputOptions::legacy(bool b)
+void Foam::foamVtkOutputOptions::legacy(bool on)
 {
-    if (b)
+    if (on)
     {
         if (type_ & APPEND)
         {
@@ -180,9 +178,9 @@ void Foam::foamVtkOutputOptions::legacy(bool b)
 }
 
 
-void Foam::foamVtkOutputOptions::precision(unsigned val) const
+void Foam::foamVtkOutputOptions::precision(unsigned prec) const
 {
-    precision_ = val;
+    precision_ = prec;
 }
 
 
diff --git a/src/fileFormats/vtk/format/foamVtkOutputOptions.H b/src/fileFormats/vtk/format/foamVtkOutputOptions.H
index a5f59de5144e91e0ec16b296a036d1bbc39fc82e..7e0e89b24be155f760fb45f3d16e97b71b8f57de 100644
--- a/src/fileFormats/vtk/format/foamVtkOutputOptions.H
+++ b/src/fileFormats/vtk/format/foamVtkOutputOptions.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -88,7 +88,7 @@ public:
     // Selectors
 
         //- Return new data formatter based on the writer options
-        autoPtr<foamVtkFormatter> newFormatter(std::ostream&) const;
+        autoPtr<foamVtkFormatter> newFormatter(std::ostream& os) const;
 
 
     // Member Functions
@@ -117,16 +117,16 @@ public:
         //  In append mode, this switches between base64 and raw binary.
         //  In XML mode, this switches between ASCII and base64.
         //  In legacy mode, this switches between ASCII and binary.
-        void ascii(bool);
+        void ascii(bool on);
 
         //- Toggle append mode on/off.
-        void append(bool);
+        void append(bool on);
 
         //- Toggle legacy mode on/off.
-        void legacy(bool);
+        void legacy(bool on);
 
         //- Set the write precision to be used for new ASCII formatters
-        void precision(unsigned val) const;
+        void precision(unsigned prec) const;
 
 
     // Other
diff --git a/src/fileFormats/vtk/type/foamVtkPTraits.C b/src/fileFormats/vtk/type/foamVtkPTraits.C
index 91bf1f3a33b647663c9077245b8252efa4d0c76a..feb5e909c25c5b20d239452ce851f3ea431b18f9 100644
--- a/src/fileFormats/vtk/type/foamVtkPTraits.C
+++ b/src/fileFormats/vtk/type/foamVtkPTraits.C
@@ -59,11 +59,11 @@ Foam::foamVtkPTraits<double>::typeName = "Float64";
 #ifdef WM_LITTLE_ENDIAN
 template<>
 const char* const
-Foam::foamVtkPTraits<::Foam::endian>::typeName = "LittleEndian";
+Foam::foamVtkPTraits<Foam::endian>::typeName = "LittleEndian";
 #else
 template<>
 const char* const
-Foam::foamVtkPTraits<::Foam::endian>::typeName = "BigEndian";
+Foam::foamVtkPTraits<Foam::endian>::typeName = "BigEndian";
 #endif
 
 
diff --git a/src/fileFormats/vtk/type/foamVtkPTraits.H b/src/fileFormats/vtk/type/foamVtkPTraits.H
index ea95c0820d1f61f8190336f0c7dd092013ffd98d..ff77c03b8d9498f97737a2435e5235c9f6bba537 100644
--- a/src/fileFormats/vtk/type/foamVtkPTraits.H
+++ b/src/fileFormats/vtk/type/foamVtkPTraits.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -58,28 +58,28 @@ public:
 
 
 template<>
-const char* const foamVtkPTraits<uint8_t>::typeName;  // = UInt8
+const char* const foamVtkPTraits<uint8_t>::typeName;  // UInt8
 
 template<>
-const char* const foamVtkPTraits<int32_t>::typeName;  // = Int32
+const char* const foamVtkPTraits<int32_t>::typeName;  // Int32
 
 template<>
-const char* const foamVtkPTraits<int32_t>::typeName;  // = UInt32
+const char* const foamVtkPTraits<uint32_t>::typeName; // UInt32
 
 template<>
-const char* const foamVtkPTraits<int32_t>::typeName;  // = Int64
+const char* const foamVtkPTraits<int64_t>::typeName;  // Int64
 
 template<>
-const char* const foamVtkPTraits<int64_t>::typeName;  // = UInt64
+const char* const foamVtkPTraits<uint64_t>::typeName; // UInt64
 
 template<>
-const char* const foamVtkPTraits<float>::typeName;    // = Float32
+const char* const foamVtkPTraits<float>::typeName;    // Float32
 
 template<>
-const char* const foamVtkPTraits<double>::typeName;   // = Float64
+const char* const foamVtkPTraits<double>::typeName;   // Float64
 
 template<>
-const char* const foamVtkPTraits<::Foam::endian>::typeName;
+const char* const foamVtkPTraits<Foam::endian>::typeName; // (Big|Little)Endian
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H
index 52170caa29a6cdab13f452f18320b6a41066f21e..7b4916c136f35a0a5c74bd9025ed173fb2d93d6d 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H
@@ -34,7 +34,7 @@ Description
 Usage
     \table
         Property      | Description             | Required    | Default value
-        valueFraction | fraction od value used for boundary [0-1] | yes |
+        valueFraction | fraction of value used for boundary [0-1] | yes |
     \endtable
 
     Example of the boundary condition specification:
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/slip/slipFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/slip/slipFvPatchField.C
index 83340f3fe56ad4adccd4c5f50b8c5f9de6820354..e2f04b79ead4b2b8c17ebff8f26c7684452f35bf 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/slip/slipFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/slip/slipFvPatchField.C
@@ -34,7 +34,7 @@ Foam::slipFvPatchField<Type>::slipFvPatchField
     const DimensionedField<Type, volMesh>& iF
 )
 :
-   basicSymmetryFvPatchField<Type>(p, iF)
+    basicSymmetryFvPatchField<Type>(p, iF)
 {}
 
 
diff --git a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H
index c531f5070bf390b4cfeb3eb1a44b55966e124483..0f93924c2bdfb5efa4a8ad4abb6cd5e812c9cca0 100644
--- a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H
+++ b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H
@@ -22,7 +22,7 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Class
-    Foam::functionObjects::runTimePostProcessing
+    Foam::functionObjects::runTimePostPro::runTimePostProcessing
 
 Group
     grpGraphicsFunctionObjects
diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C
index 84b68341d8d1325d905127761678be8c9277ffd4..641241b91e6cbb2a7e6fd8c64bf966aa0e53eb28 100644
--- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C
+++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C
@@ -201,7 +201,7 @@ Foam::functionObjects::scalarTransport::scalarTransport
     resetOnStartUp_(false),
     schemesField_("unknown-schemesField"),
     fvOptions_(mesh_),
-    bounded01_(dict.lookupOrDefault<bool>("bounded01", true))
+    bounded01_(dict.lookupOrDefault<Switch>("bounded01", true))
 {
     read(dict);
 
@@ -235,12 +235,7 @@ bool Foam::functionObjects::scalarTransport::read(const dictionary& dict)
     dict.readIfPresent("bounded01", bounded01_);
 
     schemesField_ = dict.lookupOrDefault("schemesField", fieldName_);
-
-    constantD_ = false;
-    if (dict.readIfPresent("D", D_))
-    {
-        constantD_ = true;
-    }
+    constantD_ = dict.readIfPresent("D", D_);
 
     dict.readIfPresent("nCorr", nCorr_);
     dict.readIfPresent("resetOnStartUp", resetOnStartUp_);
@@ -256,11 +251,11 @@ bool Foam::functionObjects::scalarTransport::read(const dictionary& dict)
 
 bool Foam::functionObjects::scalarTransport::execute()
 {
-    Log << type() << " write:" << endl;
-
     volScalarField& s = transportedField();
 
-    const surfaceScalarField& phi = 
+    Log << type() << " execute: " << s.name() << endl;
+
+    const surfaceScalarField& phi =
         mesh_.lookupObject<surfaceScalarField>(phiName_);
 
     // Calculate the diffusivity
diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.H b/src/functionObjects/solvers/scalarTransport/scalarTransport.H
index e2570fc7f9f805ce3b9a3e83f9d7785be928c946..bc743e7eea2601e965340214ae3a7ab71eb125c0 100644
--- a/src/functionObjects/solvers/scalarTransport/scalarTransport.H
+++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.H
@@ -111,17 +111,18 @@ Usage
     \table
         Property     | Description             | Required    | Default value
         type         | Type name: scalarTransport | yes      |
-        phi          | Name of flux field      | yes          |
+        field        | Name of the scalar field | no         | s
+        phi          | Name of flux field      | no          | phi
         rho          | Name of density field   | no          | rho
-        phase        | Name of the phase name  | no          | none
+        phase        | Name of the phase       | no          | none
         nut          | Name of the turbulence viscosity | no | none
         D            | Diffusion coefficient   | no          | auto generated
         nCorr        | Number of correctors    | no          | 0
         resetOnStartUp | Reset scalar to zero on start-up | no | no
-        schemesField | Name of field to specify schemes | no | fieldName
+        schemesField | Name of field to specify schemes | no | field name
         fvOptions    | List of scalar sources  | no          |
-        bounded01    | Bounds scalar between 0-1 for multiphase | no |true
-        phasePhiCompressed |Compressed flux for VOF | no | alphaPhiUn
+        bounded01    | Bounds scalar between 0-1 for multiphase | no | true
+        phasePhiCompressed | Compressed flux for VOF | no | alphaPhiUn
     \endtable
 
 See also
@@ -156,10 +157,10 @@ class scalarTransport
 {
     // Private data
 
-        //- Name of field to process
+        //- Name of the transport field.
         word fieldName_;
 
-        //- Name of flux field
+        //- Name of flux field (optional)
         word phiName_;
 
         //- Name of density field (optional)
@@ -168,10 +169,10 @@ class scalarTransport
         //- Name of turbulent viscosity field (optional)
         word nutName_;
 
-        //- Name of phase field
+        //- Name of phase field (optional)
         word phaseName_;
 
-        //- Name of phase field compressed flux
+        //- Name of phase field compressed flux (optional)
         word phasePhiCompressedName_;
 
         //- Diffusion coefficient (optional)
diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C
index 135338d1fad82c67ec3a453ec823c06b17ad29ad..33ace2cd2c85f7bcbf6962363a852f3786639173 100644
--- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C
+++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C
@@ -27,7 +27,7 @@ License
 #include "dictionary.H"
 #include "polyMesh.H"
 #include "volFields.H"
-
+#include "coordinateSystem.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
index b625675eff24ab7e28d232ba254fd7b64ab15056..f0148f8ca64b2b35f536d8a8705348a0548efeac 100644
--- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
+++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
@@ -63,7 +63,6 @@ SourceFiles
 #include "surfaceFieldsFwd.H"
 #include "surfaceMesh.H"
 #include "polyMesh.H"
-#include "coordinateSystems.H"
 #include "interpolation.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C b/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C
index b01b09a3552e1385d42f3e095321b93ea383c7a6..dea10f0fd3159cf30e36b272a6e6e556285ec717 100644
--- a/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C
+++ b/src/sampling/surfMeshSampler/plane/surfMeshPlaneSampler.C
@@ -27,6 +27,7 @@ License
 #include "dictionary.H"
 #include "polyMesh.H"
 #include "volFields.H"
+#include "coordinateSystem.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
diff --git a/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H b/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H
index 010429e390695e558f84812c2e21af28349fcde4..6cfcee33094645c2efe42bd9d31677a5f3e0a752 100644
--- a/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H
+++ b/src/sampling/surfMeshSampler/surfMeshSampler/surfMeshSampler.H
@@ -52,7 +52,6 @@ SourceFiles
 #include "volFieldsFwd.H"
 #include "surfaceFieldsFwd.H"
 #include "polyMesh.H"
-#include "coordinateSystems.H"
 #include "interpolation.H"
 #include "error.H"
 #include "IOobjectList.H"
diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C
index f976ceb902c356ce6e0554c3ab62fb806a23375b..b522df0e561f703e95a67712f92a8e775cdbe1e7 100644
--- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C
+++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2015 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -264,15 +264,13 @@ void Foam::faceShading::calculate()
                 {
                     includeAllFacesPerPatch[patchI].insert
                     (
-                        faceI //pp.start()
+                        faceI
                     );
                 }
             }
         }
     }
 
-    labelList triSurfaceToAgglom(5*nFaces);
-
     triSurface localSurface = triangulate
     (
         includePatches,
@@ -294,9 +292,10 @@ void Foam::faceShading::calculate()
         dict
     );
 
-    surfacesMesh.searchableSurface::write();
-
-    triSurfaceToAgglom.resize(surfacesMesh.size());
+    if (debug)
+    {
+        surfacesMesh.searchableSurface::write();
+    }
 
     scalar maxBounding = 5.0*mag(mesh_.bounds().max() - mesh_.bounds().min());
 
@@ -324,7 +323,7 @@ void Foam::faceShading::calculate()
 
                 const vector d(direction_*maxBounding);
 
-                start.append(fc - SMALL*d);
+                start.append(fc - 0.001*d);
 
                 startIndex.append(myFaceId);
 
@@ -355,7 +354,7 @@ void Foam::faceShading::calculate()
             (
                 mesh_.time().path()/"allVisibleFaces.obj",
                 end,
-                Cfs
+                start
             );
         }
 
diff --git a/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C b/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C
index caae10e34d3d565472fb74866dff81ffb872c5a5..d887867658482fd608c4b63ded7f47791ec48f1e 100644
--- a/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C
+++ b/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2015 OpenCFD Ltd.
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -26,6 +26,9 @@ License
 #include "solarCalculator.H"
 #include "Time.H"
 #include "unitConversion.H"
+#include "constants.H"
+
+using namespace Foam::constant;
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -104,6 +107,14 @@ void Foam::solarCalculator::calculateBetaTetha()
     beta_ = max(asin(cos(L)*cos(deltaRad)*cos(H) + sin(L)*sin(deltaRad)), 1e-3);
     tetha_ = acos((sin(beta_)*sin(L) - sin(deltaRad))/(cos(beta_)*cos(L)));
 
+    // theta is the angle between the SOUTH axis and the Sun
+    // If the hour angle is lower than zero (morning) the Sun is positioned
+    // on the East side.
+    if (H < 0)
+    {
+        tetha_ += 2*(constant::mathematical::pi - tetha_);
+    }
+
     if (debug)
     {
         Info << tab << "altitude : " << radToDeg(beta_) << endl;
@@ -126,9 +137,10 @@ void Foam::solarCalculator::calculateSunDirection()
         new coordinateSystem("grid", Zero, gridUp_, eastDir_)
     );
 
+    // Assuming 'z' vertical, 'y' North and 'x' East
     direction_.z() = -sin(beta_);
-    direction_.y() =  cos(beta_)*cos(tetha_); //North
-    direction_.x() =  cos(beta_)*sin(tetha_); //East
+    direction_.y() =  cos(beta_)*cos(tetha_); // South axis
+    direction_.x() =  cos(beta_)*sin(tetha_); // West axis
 
     direction_ /= mag(direction_);
 
@@ -137,6 +149,7 @@ void Foam::solarCalculator::calculateSunDirection()
         Info<< "Sun direction in absolute coordinates : " << direction_ <<endl;
     }
 
+    // Transform to actual coordinate system
     direction_ = coord_->R().transform(direction_);
 
     if (debug)
diff --git a/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.C b/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.C
index a0f47ef919478f9a2333b0ce25ed5116ce367ede..1cadfeefa03716ccf1995b7be0af5a61f8c86655 100644
--- a/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.C
+++ b/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -62,7 +62,7 @@ Foam::waveModels::waveAbsorptionModel::waveAbsorptionModel
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -75,9 +75,12 @@ Foam::waveModels::waveAbsorptionModel::~waveAbsorptionModel()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::waveAbsorptionModel::read(const dictionary& overrideDict)
+bool Foam::waveModels::waveAbsorptionModel::readDict
+(
+    const dictionary& overrideDict
+)
 {
-    if (waveModel::read(overrideDict))
+    if (waveModel::readDict(overrideDict))
     {
         // Note: always set to true
         activeAbsorption_ = true;
diff --git a/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.H b/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.H
index 0201aaaab7c94f3dd2671971c51908744fbe0c40..e30b6b5ee7aee3d77db253c19476697fdd361048 100644
--- a/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.H
+++ b/src/waveModels/waveAbsorptionModels/base/waveAbsorptionModel/waveAbsorptionModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -77,7 +77,7 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 };
 
 
diff --git a/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.C b/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.C
index d6c7de6040741090ae545012a9c7f06694444f7c..e4e47820fb2c4e2908313f460b4b7a3c07486452 100644
--- a/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.C
+++ b/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -96,7 +96,7 @@ Foam::waveModels::shallowWaterAbsorption::shallowWaterAbsorption
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -109,12 +109,12 @@ Foam::waveModels::shallowWaterAbsorption::~shallowWaterAbsorption()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::shallowWaterAbsorption::read
+bool Foam::waveModels::shallowWaterAbsorption::readDict
 (
     const dictionary& overrideDict
 )
 {
-    return waveAbsorptionModel::read(overrideDict);
+    return waveAbsorptionModel::readDict(overrideDict);
 }
 
 
diff --git a/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.H b/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.H
index bbc31f78783f87ca856e13755c9f12b6f4d5297f..e390fbfff0cb50a66dc4195f11ab18a285246c8c 100644
--- a/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.H
+++ b/src/waveModels/waveAbsorptionModels/derived/shallowWaterAbsorption/shallowWaterAbsorption.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -94,7 +94,7 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 };
 
 
diff --git a/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.C b/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.C
index efaa83b5524b4a861a4d61795d656e9eb586dd6c..030c590d2a58490b8140d83d83b22b2ec5264526 100644
--- a/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.C
+++ b/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -86,7 +86,7 @@ Foam::waveModels::regularWaveModel::regularWaveModel
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -99,9 +99,12 @@ Foam::waveModels::regularWaveModel::~regularWaveModel()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::regularWaveModel::read(const dictionary& overrideDict)
+bool Foam::waveModels::regularWaveModel::readDict
+(
+    const dictionary& overrideDict
+)
 {
-    if (waveGenerationModel::read(overrideDict))
+    if (waveGenerationModel::readDict(overrideDict))
     {
         lookup("rampTime") >> rampTime_;
 
diff --git a/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.H b/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.H
index 13b6bfda73ef3bd58bae18b6e96c6c6311c83184..43a9a9096f6859dc63168fea33dfb35b2d62a358 100644
--- a/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.H
+++ b/src/waveModels/waveGenerationModels/base/regularWaveModel/regularWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -105,12 +105,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.C b/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.C
index 332d7e0304d011802dd8dd322724ca75b05d515f..d8d6ab34582aa489469c7239b20b33e59062dcea 100644
--- a/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.C
+++ b/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -70,7 +70,7 @@ Foam::waveModels::solitaryWaveModel::solitaryWaveModel
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -83,9 +83,12 @@ Foam::waveModels::solitaryWaveModel::~solitaryWaveModel()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::solitaryWaveModel::read(const dictionary& overrideDict)
+bool Foam::waveModels::solitaryWaveModel::readDict
+(
+    const dictionary& overrideDict
+)
 {
-    if (waveGenerationModel::read(overrideDict))
+    if (waveGenerationModel::readDict(overrideDict))
     {
         return true;
     }
diff --git a/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.H b/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.H
index f01dff404c3d44de7b12377d07619b79a2a8946d..e0724d341371f73beacfc8a37b167384b642582c 100644
--- a/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.H
+++ b/src/waveModels/waveGenerationModels/base/solitaryWaveModel/solitaryWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -87,12 +87,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.C b/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.C
index 44cf01006b305e6123d849dd3f43d17dc8d34268..5e52d9de93234b33a669a54f4fc2d852595f5877 100644
--- a/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.C
+++ b/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -55,7 +55,7 @@ Foam::waveModels::waveGenerationModel::waveGenerationModel
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -68,9 +68,12 @@ Foam::waveModels::waveGenerationModel::~waveGenerationModel()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::waveGenerationModel::read(const dictionary& overrideDict)
+bool Foam::waveModels::waveGenerationModel::readDict
+(
+    const dictionary& overrideDict
+)
 {
-    if (waveModel::read(overrideDict))
+    if (waveModel::readDict(overrideDict))
     {
         lookup("activeAbsorption") >> activeAbsorption_;
 
diff --git a/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.H b/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.H
index c0ed643e7b9467975acfc5c24f90ec696bf9b485..aee9213ed69fd72813e9f03e2aaa357fb7954042 100644
--- a/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.H
+++ b/src/waveModels/waveGenerationModels/base/waveGenerationModel/waveGenerationModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -80,7 +80,7 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
diff --git a/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.C b/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.C
index d7e4dca2fc592d56f394e0730593b00a5c33bab6..a81f32dd8aed5f41d145218db78a845d4f941732 100644
--- a/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.C
+++ b/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -101,7 +101,7 @@ Foam::vector Foam::waveModels::Boussinesq::Deta
 }
 
 
-Foam::vector Foam::waveModels::Boussinesq::U
+Foam::vector Foam::waveModels::Boussinesq::Uf
 (
     const scalar H,
     const scalar h,
@@ -139,6 +139,8 @@ Foam::vector Foam::waveModels::Boussinesq::U
 }
 
 
+// * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
+
 void Foam::waveModels::Boussinesq::setLevel
 (
     const scalar t,
@@ -165,44 +167,6 @@ void Foam::waveModels::Boussinesq::setLevel
 }
 
 
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-Foam::waveModels::Boussinesq::Boussinesq
-(
-    const dictionary& dict,
-    const fvMesh& mesh,
-    const polyPatch& patch,
-    const bool readFields
-)
-:
-    solitaryWaveModel(dict, mesh, patch, false)
-{
-    if (readFields)
-    {
-        read(dict);
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-Foam::waveModels::Boussinesq::~Boussinesq()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-bool Foam::waveModels::Boussinesq::read(const dictionary& overrideDict)
-{
-    if (solitaryWaveModel::read(overrideDict))
-    {
-        return true;
-    }
-
-    return false;
-}
-
-
 void Foam::waveModels::Boussinesq::setVelocity
 (
     const scalar t,
@@ -224,7 +188,7 @@ void Foam::waveModels::Boussinesq::setVelocity
         {
             const label paddlei = faceToPaddle_[facei];
 
-            const vector Uf = U
+            const vector Uf = this->Uf
 	        (
                 waveHeight_,
                 waterDepthRef_,
@@ -242,6 +206,44 @@ void Foam::waveModels::Boussinesq::setVelocity
 }
 
 
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::waveModels::Boussinesq::Boussinesq
+(
+    const dictionary& dict,
+    const fvMesh& mesh,
+    const polyPatch& patch,
+    const bool readFields
+)
+:
+    solitaryWaveModel(dict, mesh, patch, false)
+{
+    if (readFields)
+    {
+        readDict(dict);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::waveModels::Boussinesq::~Boussinesq()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::waveModels::Boussinesq::readDict(const dictionary& overrideDict)
+{
+    if (solitaryWaveModel::readDict(overrideDict))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+
 void Foam::waveModels::Boussinesq::info(Ostream& os) const
 {
     solitaryWaveModel::info(os);
diff --git a/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.H b/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.H
index ff76841a818fcc57b06cedea59b49cb9823d8ac6..b5071d28176fd47e1a9b086578f81b8c773ffde9 100644
--- a/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.H
+++ b/src/waveModels/waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -49,12 +49,12 @@ class Boussinesq
 :
     public solitaryWaveModel
 {
-protected:
+private:
 
-    // Protected Member Functions
+    // Private Member Functions
 
         //- Wave height
-        virtual scalar eta
+        scalar eta
         (
             const scalar H,
             const scalar h,
@@ -66,7 +66,7 @@ protected:
         ) const;
 
         //- Wave
-        virtual vector Deta
+        vector Deta
         (
             const scalar H,
             const scalar h,
@@ -78,7 +78,7 @@ protected:
         ) const;
 
         //- Wave velocity
-        virtual vector U
+        vector Uf
         (
             const scalar H,
             const scalar h,
@@ -90,6 +90,11 @@ protected:
             const scalar z
         ) const;
 
+
+protected:
+
+    // Protected Member Functions
+
         //- Set the water level
         virtual void setLevel
         (
@@ -128,12 +133,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.C b/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.C
index 8a67ea2a2db4ae3349cf47440d211dd4b82f7852..b1609348513de314a6a5d5b79f5d22f5c20e1440 100644
--- a/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.C
+++ b/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -48,6 +48,26 @@ namespace waveModels
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
+Foam::scalar Foam::waveModels::StokesI::eta
+(
+    const scalar H,
+    const scalar Kx,
+    const scalar x,
+    const scalar Ky,
+    const scalar y,
+    const scalar omega,
+    const scalar t,
+    const scalar phase
+) const
+{
+    scalar phaseTot = Kx*x + Ky*y - omega*t + phase;
+
+    return H*0.5*cos(phaseTot);
+}
+
+
+// * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
+
 Foam::scalar Foam::waveModels::StokesI::waveLength
 (
     const scalar h,
@@ -66,24 +86,7 @@ Foam::scalar Foam::waveModels::StokesI::waveLength
 }
 
 
-Foam::scalar Foam::waveModels::StokesI::eta
-(
-    const scalar H,
-    const scalar Kx,
-    const scalar x,
-    const scalar Ky,
-    const scalar y,
-    const scalar omega,
-    const scalar t,
-    const scalar phase
-) const
-{
-    scalar phaseTot = Kx*x + Ky*y - omega*t + phase;
-
-    return H*0.5*cos(phaseTot);
-}
-
-Foam::vector Foam::waveModels::StokesI::U
+Foam::vector Foam::waveModels::StokesI::UfBase
 (
     const scalar H,
     const scalar h,
@@ -141,46 +144,6 @@ void Foam::waveModels::StokesI::setLevel
 }
 
 
-// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
-
-Foam::waveModels::StokesI::StokesI
-(
-    const dictionary& dict,
-    const fvMesh& mesh,
-    const polyPatch& patch,
-    const bool readFields
-)
-:
-    regularWaveModel(dict, mesh, patch, false)
-{
-    if (readFields)
-    {
-        read(dict);
-    }
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-Foam::waveModels::StokesI::~StokesI()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-bool Foam::waveModels::StokesI::read(const dictionary& overrideDict)
-{
-    if (regularWaveModel::read(overrideDict))
-    {
-		waveLength_ = waveLength(waterDepthRef_, wavePeriod_);
-
-        return true;
-    }
-
-    return false;
-}
-
-
 void Foam::waveModels::StokesI::setVelocity
 (
     const scalar t,
@@ -207,7 +170,7 @@ void Foam::waveModels::StokesI::setVelocity
         {
             const label paddlei = faceToPaddle_[facei];
 
-            const vector Uf = U
+            const vector Uf = UfBase
 	        (
                 waveHeight_,
                 waterDepthRef_,
@@ -227,6 +190,46 @@ void Foam::waveModels::StokesI::setVelocity
 }
 
 
+// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
+
+Foam::waveModels::StokesI::StokesI
+(
+    const dictionary& dict,
+    const fvMesh& mesh,
+    const polyPatch& patch,
+    const bool readFields
+)
+:
+    regularWaveModel(dict, mesh, patch, false)
+{
+    if (readFields)
+    {
+        readDict(dict);
+    }
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
+
+Foam::waveModels::StokesI::~StokesI()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::waveModels::StokesI::readDict(const dictionary& overrideDict)
+{
+    if (regularWaveModel::readDict(overrideDict))
+    {
+		waveLength_ = waveLength(waterDepthRef_, wavePeriod_);
+
+        return true;
+    }
+
+    return false;
+}
+
+
 void Foam::waveModels::StokesI::info(Ostream& os) const
 {
     regularWaveModel::info(os);
diff --git a/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.H b/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.H
index 82213261bf8add3c84dec42e4a969471c4fe3983..23a3f67e42881c36d8b004153f028ba276a259d3 100644
--- a/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.H
+++ b/src/waveModels/waveGenerationModels/derived/StokesI/StokesIWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -49,15 +49,12 @@ class StokesI
 :
     public regularWaveModel
 {
-protected:
-
-    // Protected Member Functions
+private:
 
-        //- Return the wavelength
-        virtual scalar waveLength(const scalar h, const scalar T) const;
+    // Private Member Functions
 
         //- Wave height
-        virtual scalar eta
+        scalar eta
         (
             const scalar H,
             const scalar Kx,
@@ -69,8 +66,16 @@ protected:
             const scalar phase
         ) const;
 
+
+protected:
+
+    // Protected Member Functions
+
+        //- Return the wavelength
+        virtual scalar waveLength(const scalar h, const scalar T) const;
+
         //- Wave velocity
-        virtual vector U
+        virtual vector UfBase
         (
             const scalar H,
             const scalar h,
@@ -84,7 +89,6 @@ protected:
             const scalar z
         ) const;
 
-
         //- Set the water level
         virtual void setLevel
         (
@@ -123,12 +127,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.C b/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.C
index b867959f8c91f4bf9dfe82d4a97fa4f37b62f9ca..e77122fd052a85bc140040c378abc144928dd69a 100644
--- a/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.C
+++ b/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -71,7 +71,9 @@ Foam::scalar Foam::waveModels::StokesII::eta
 }
 
 
-Foam::vector Foam::waveModels::StokesII::U
+// * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
+
+Foam::vector Foam::waveModels::StokesII::UfBase
 (
     const scalar H,
     const scalar h,
@@ -148,7 +150,7 @@ Foam::waveModels::StokesII::StokesII
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -161,9 +163,9 @@ Foam::waveModels::StokesII::~StokesII()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::StokesII::read(const dictionary& overrideDict)
+bool Foam::waveModels::StokesII::readDict(const dictionary& overrideDict)
 {
-    if (StokesI::read(overrideDict))
+    if (StokesI::readDict(overrideDict))
     {
         return true;
     }
diff --git a/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.H b/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.H
index 044eba4bc57cb9130e8215ca648212d56869874f..c82325b5f54c5c274832b1e261a98afe4e481dda 100644
--- a/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.H
+++ b/src/waveModels/waveGenerationModels/derived/StokesII/StokesIIWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -49,12 +49,12 @@ class StokesII
 :
     public StokesI
 {
-protected:
+private:
 
-    // Protected Member Functions
+    // Private Member Functions
 
         //- Wave height
-        virtual scalar eta
+        scalar eta
         (
             const scalar H,
             const scalar h,
@@ -67,8 +67,13 @@ protected:
             const scalar phase
         ) const;
 
+
+protected:
+
+    // Protected Member Functions
+
         //- Wave velocity
-        virtual vector U
+        virtual vector UfBase
         (
             const scalar H,
             const scalar h,
@@ -112,12 +117,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.C b/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.C
index 643acedeb24b848de3334929c6e63df9bfbbf003..4ba32ea4450e51a79040722b5314b090bc4ca506 100644
--- a/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.C
+++ b/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -680,7 +680,7 @@ Foam::scalar Foam::waveModels::StokesV::eta
 }
 
 
-Foam::vector Foam::waveModels::StokesV::U
+Foam::vector Foam::waveModels::StokesV::Uf
 (
     const scalar d,
     const scalar kx,
@@ -722,17 +722,17 @@ Foam::vector Foam::waveModels::StokesV::U
 
     scalar u =
         a1u*cosh(k*z)*cos(theta)
-      + a2u*cosh(2.0*k*z)*cos(2.0*(theta))
-      + a3u*cosh(3.0*k*z)*cos(3.0*(theta))
-      + a4u*cosh(4.0*k*z)*cos(4.0*(theta))
-      + a5u*cosh(5.0*k*z)*cos(5.0*(theta));
+      + a2u*cosh(2*k*z)*cos(2*theta)
+      + a3u*cosh(3*k*z)*cos(3*theta)
+      + a4u*cosh(4*k*z)*cos(4*theta)
+      + a5u*cosh(5*k*z)*cos(5*theta);
 
     scalar w =
         a1u*sinh(k*z)*sin(theta)
-      + a2u*sinh(2.0*k*z)*sin(2.0*(theta))
-      + a3u*sinh(3.0*k*z)*sin(3.0*(theta))
-      + a4u*sinh(4.0*k*z)*sin(4.0*(theta))
-      + a5u*sinh(5.0*k*z)*sin(5.0*(theta));
+      + a2u*sinh(2*k*z)*sin(2*theta)
+      + a3u*sinh(3*k*z)*sin(3*theta)
+      + a4u*sinh(4*k*z)*sin(4*theta)
+      + a5u*sinh(5*k*z)*sin(5*theta);
 
     scalar v = u*sin(waveAngle_);
     u *= cos(waveAngle_);
@@ -741,6 +741,8 @@ Foam::vector Foam::waveModels::StokesV::U
 }
 
 
+// * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
+
 void Foam::waveModels::StokesV::setLevel
 (
     const scalar t,
@@ -773,6 +775,51 @@ void Foam::waveModels::StokesV::setLevel
 }
 
 
+void Foam::waveModels::StokesV::setVelocity
+(
+    const scalar t,
+    const scalar tCoeff,
+    const scalarField& level
+)
+{
+    const scalar waveK = mathematical::twoPi/waveLength_;
+    const scalar waveKx = waveK*cos(waveAngle_);
+    const scalar waveKy = waveK*sin(waveAngle_);
+
+    forAll(U_, facei)
+    {
+        // Fraction of geometry represented by paddle - to be set
+        scalar fraction = 1;
+
+        // Height - to be set
+        scalar z = 0;
+
+        setPaddlePropeties(level, facei, fraction, z);
+
+        if (fraction > 0)
+        {
+            const label paddlei = faceToPaddle_[facei];
+
+            const vector Uf = this->Uf
+	        (
+                waterDepthRef_,
+                waveKx,
+                waveKy,
+                lambda_,
+                wavePeriod_,
+                xPaddle_[paddlei],
+                yPaddle_[paddlei],
+                t,
+                wavePhase_,
+                z
+            );
+
+            U_[facei] = fraction*Uf*tCoeff;
+        }
+    }
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::waveModels::StokesV::StokesV
@@ -783,12 +830,12 @@ Foam::waveModels::StokesV::StokesV
     const bool readFields
 )
 :
-    regularWaveModel(dict, mesh, patch, false),
+    StokesI(dict, mesh, patch, false),
     lambda_(0)
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -801,9 +848,9 @@ Foam::waveModels::StokesV::~StokesV()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::StokesV::read(const dictionary& overrideDict)
+bool Foam::waveModels::StokesV::readDict(const dictionary& overrideDict)
 {
-    if (regularWaveModel::read(overrideDict))
+    if (StokesI::readDict(overrideDict))
     {
         scalar f1;
         scalar f2;
@@ -829,8 +876,6 @@ bool Foam::waveModels::StokesV::read(const dictionary& overrideDict)
 	            << exit(FatalError);
         }
 
-        waveLength_ = 2.0*mathematical::pi/waveK;
-
         return true;
     }
 
@@ -838,54 +883,9 @@ bool Foam::waveModels::StokesV::read(const dictionary& overrideDict)
 }
 
 
-void Foam::waveModels::StokesV::setVelocity
-(
-    const scalar t,
-    const scalar tCoeff,
-    const scalarField& level
-)
-{
-    const scalar waveK = mathematical::twoPi/waveLength_;
-    const scalar waveKx = waveK*cos(waveAngle_);
-    const scalar waveKy = waveK*sin(waveAngle_);
-
-    forAll(U_, facei)
-    {
-        // Fraction of geometry represented by paddle - to be set
-        scalar fraction = 1;
-
-        // Height - to be set
-        scalar z = 0;
-
-        setPaddlePropeties(level, facei, fraction, z);
-
-        if (fraction > 0)
-        {
-            const label paddlei = faceToPaddle_[facei];
-
-            const vector Uf = U
-	        (
-                waterDepthRef_,
-                waveKx,
-                waveKy,
-                lambda_,
-                wavePeriod_,
-                xPaddle_[paddlei],
-                yPaddle_[paddlei],
-                t,
-                wavePhase_,
-                z
-            );
-
-            U_[facei] = fraction*Uf*tCoeff;
-        }
-    }
-}
-
-
 void Foam::waveModels::StokesV::info(Ostream& os) const
 {
-    regularWaveModel::info(os);
+    StokesI::info(os);
 
     os  << "    Lambda : " << lambda_ << nl
         << "    Wave type : " << waveType() << nl;
diff --git a/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.H b/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.H
index 225bb9bf1ff3a7f458e9d9434e0eca2226b1d105..1450fca0a0acea8f555ceb1ad10ccfc14d16e977 100644
--- a/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.H
+++ b/src/waveModels/waveGenerationModels/derived/StokesV/StokesVWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -39,7 +39,7 @@ Description
 #ifndef waveModels_StokesV_H
 #define waveModels_StokesV_H
 
-#include "regularWaveModel.H"
+#include "StokesIWaveModel.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -54,71 +54,65 @@ namespace waveModels
 
 class StokesV
 :
-    public regularWaveModel
+    public StokesI
 {
-protected:
-
-    // Proteced Data
-
-        //-
-        scalar lambda_;
-
+private:
 
-    // Protected Member Functions
+    // Private Member Functions
 
         // Model coefficients
 
-            virtual scalar A11(const scalar h, const scalar k) const;
+            scalar A11(const scalar h, const scalar k) const;
 
-            virtual scalar A13(const scalar h, const scalar k) const;
+            scalar A13(const scalar h, const scalar k) const;
 
-            virtual scalar A15(const scalar h, const scalar k) const;
+            scalar A15(const scalar h, const scalar k) const;
 
-            virtual scalar A22(const scalar h, const scalar k) const;
+            scalar A22(const scalar h, const scalar k) const;
 
-            virtual scalar A24(const scalar h, const scalar k) const;
+            scalar A24(const scalar h, const scalar k) const;
 
-            virtual scalar A33(const scalar h, const scalar k) const;
+            scalar A33(const scalar h, const scalar k) const;
 
-            virtual scalar A35(const scalar h, const scalar k) const;
+            scalar A35(const scalar h, const scalar k) const;
 
-            virtual scalar A44(const scalar h, const scalar k) const;
+            scalar A44(const scalar h, const scalar k) const;
 
-            virtual scalar A55(const scalar h, const scalar k) const;
+            scalar A55(const scalar h, const scalar k) const;
 
-            virtual scalar B22(const scalar h, const scalar k) const;
+            scalar B22(const scalar h, const scalar k) const;
 
-            virtual scalar B24(const scalar h, const scalar k) const;
+            scalar B24(const scalar h, const scalar k) const;
 
-            virtual scalar B33(const scalar h, const scalar k) const;
+            scalar B33(const scalar h, const scalar k) const;
 
-            virtual scalar B33k(const scalar h, const scalar k) const;
+            scalar B33k(const scalar h, const scalar k) const;
 
-            virtual scalar B35(const scalar h, const scalar k) const;
+            scalar B35(const scalar h, const scalar k) const;
 
-            virtual scalar B35k(const scalar h, const scalar k) const;
+            scalar B35k(const scalar h, const scalar k) const;
 
-            virtual scalar B44(const scalar h, const scalar k) const;
+            scalar B44(const scalar h, const scalar k) const;
 
-            virtual scalar B55(const scalar h, const scalar k) const;
+            scalar B55(const scalar h, const scalar k) const;
 
-            virtual scalar B55k(const scalar h, const scalar k) const;
+            scalar B55k(const scalar h, const scalar k) const;
 
-            virtual scalar C1(const scalar h, const scalar k) const;
+            scalar C1(const scalar h, const scalar k) const;
 
-            virtual scalar C1k(const scalar h, const scalar k) const;
+            scalar C1k(const scalar h, const scalar k) const;
 
-            virtual scalar C2(const scalar h, const scalar k) const;
+            scalar C2(const scalar h, const scalar k) const;
 
-            virtual scalar C2k(const scalar h, const scalar k) const;
+            scalar C2k(const scalar h, const scalar k) const;
 
-            virtual scalar C3(const scalar h, const scalar k) const;
+            scalar C3(const scalar h, const scalar k) const;
 
-            virtual scalar C4(const scalar h, const scalar k) const;
+            scalar C4(const scalar h, const scalar k) const;
 
 
         //- Model intialisation
-        virtual void initialise
+        void initialise
         (
             const scalar H,
             const scalar d,
@@ -130,7 +124,7 @@ protected:
         ) const;
 
         //- Wave height
-        virtual scalar eta
+        scalar eta
         (
             const scalar h,
             const scalar kx,
@@ -144,7 +138,7 @@ protected:
         ) const;
 
         //- Wave velocity
-        virtual vector U
+        vector Uf
         (
             const scalar d,
             const scalar kx,
@@ -158,6 +152,17 @@ protected:
             const scalar z
         ) const;
 
+
+protected:
+
+    // Proteced Data
+
+        //-
+        scalar lambda_;
+
+
+    // Protected Member Functions
+
         //- Set the water level
         virtual void setLevel
         (
@@ -196,12 +201,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.C b/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.C
index 98c3873451723248f8712a832ec926761c354d52..efa9481f8f85aecb64b427dd1432212f1d324ee1 100644
--- a/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.C
+++ b/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -189,7 +189,7 @@ Foam::vector Foam::waveModels::cnoidal::dEtaDx
 }
 
 
-Foam::vector Foam::waveModels::cnoidal::U
+Foam::vector Foam::waveModels::cnoidal::Uf
 (
     const scalar H,
     const scalar h,
@@ -231,6 +231,8 @@ Foam::vector Foam::waveModels::cnoidal::U
 }
 
 
+// * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
+
 void Foam::waveModels::cnoidal::setLevel
 (
     const scalar t,
@@ -262,6 +264,51 @@ void Foam::waveModels::cnoidal::setLevel
 }
 
 
+void Foam::waveModels::cnoidal::setVelocity
+(
+    const scalar t,
+    const scalar tCoeff,
+    const scalarField& level
+)
+{
+    const scalar waveK = mathematical::twoPi/waveLength_;
+    const scalar waveKx = waveK*cos(waveAngle_);
+    const scalar waveKy = waveK*sin(waveAngle_);
+
+    forAll(U_, facei)
+    {
+        // Fraction of geometry represented by paddle - to be set
+        scalar fraction = 1;
+
+        // Height - to be set
+        scalar z = 0;
+
+        setPaddlePropeties(level, facei, fraction, z);
+
+        if (fraction > 0)
+        {
+            const label paddlei = faceToPaddle_[facei];
+
+            const vector Uf = this->Uf
+	        (
+                waveHeight_,
+                waterDepthRef_,
+                m_,
+                waveKx,
+                waveKy,
+                wavePeriod_,
+                xPaddle_[paddlei],
+                yPaddle_[paddlei],
+                t,
+                z
+            );
+
+            U_[facei] = fraction*Uf*tCoeff;
+        }
+    }
+}
+
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::waveModels::cnoidal::cnoidal
@@ -277,7 +324,7 @@ Foam::waveModels::cnoidal::cnoidal
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -290,9 +337,9 @@ Foam::waveModels::cnoidal::~cnoidal()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModels::cnoidal::read(const dictionary& overrideDict)
+bool Foam::waveModels::cnoidal::readDict(const dictionary& overrideDict)
 {
-    if (regularWaveModel::read(overrideDict))
+    if (regularWaveModel::readDict(overrideDict))
     {
         // Initialise m parameter and wavelength
         initialise
@@ -311,51 +358,6 @@ bool Foam::waveModels::cnoidal::read(const dictionary& overrideDict)
 }
 
 
-void Foam::waveModels::cnoidal::setVelocity
-(
-    const scalar t,
-    const scalar tCoeff,
-    const scalarField& level
-)
-{
-    const scalar waveK = mathematical::twoPi/waveLength_;
-    const scalar waveKx = waveK*cos(waveAngle_);
-    const scalar waveKy = waveK*sin(waveAngle_);
-
-    forAll(U_, facei)
-    {
-        // Fraction of geometry represented by paddle - to be set
-        scalar fraction = 1;
-
-        // Height - to be set
-        scalar z = 0;
-
-        setPaddlePropeties(level, facei, fraction, z);
-
-        if (fraction > 0)
-        {
-            const label paddlei = faceToPaddle_[facei];
-
-            const vector Uf = U
-	        (
-                waveHeight_,
-                waterDepthRef_,
-                m_,
-                waveKx,
-                waveKy,
-                wavePeriod_,
-                xPaddle_[paddlei],
-                yPaddle_[paddlei],
-                t,
-                z
-            );
-
-            U_[facei] = fraction*Uf*tCoeff;
-        }
-    }
-}
-
-
 void Foam::waveModels::cnoidal::info(Ostream& os) const
 {
     regularWaveModel::info(os);
diff --git a/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.H b/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.H
index 3c786581543566cfd87a58a842cf78f53926dba1..5dd6162bf3413b97606a2934dd56ed91a03873ad 100644
--- a/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.H
+++ b/src/waveModels/waveGenerationModels/derived/cnoidal/cnoidalWaveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -49,16 +49,11 @@ class cnoidal
 :
     public regularWaveModel
 {
-protected:
-
-    // Protected data
-
-        //- `m' coefficient
-        scalar m_;
+private:
 
+    // Private Member Functions
 
-    // Protected Member Functions
-
+        //- Initialise
         void initialise
         (
             const scalar H,
@@ -69,7 +64,7 @@ protected:
         ) const;
 
         //- Wave height
-        virtual scalar eta
+        scalar eta
         (
             const scalar H,
             const scalar Kx,
@@ -107,7 +102,7 @@ protected:
         ) const;
 
         //- Wave velocity
-        virtual vector U
+        vector Uf
         (
             const scalar H,
             const scalar h,
@@ -121,6 +116,18 @@ protected:
             const scalar z
         ) const;
 
+
+protected:
+
+    // Protected data
+
+        //- `m' coefficient
+        scalar m_;
+
+
+    // Protected Member Functions
+
+
         //- Set the water level
         virtual void setLevel
         (
@@ -159,12 +166,13 @@ public:
     // Public Member Functions
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Info
         virtual void info(Ostream& os) const;
 };
 
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace waveModels
diff --git a/src/waveModels/waveModel/waveModel.C b/src/waveModels/waveModel/waveModel.C
index bb859aacda8463b83b65db48da9e2f3bca56e50e..1f86780e8863191705e7d42550f90f12b0aa5ce6 100644
--- a/src/waveModels/waveModel/waveModel.C
+++ b/src/waveModels/waveModel/waveModel.C
@@ -277,7 +277,7 @@ Foam::waveModel::waveModel
 {
     if (readFields)
     {
-        read(dict);
+        readDict(dict);
     }
 }
 
@@ -290,7 +290,7 @@ Foam::waveModel::~waveModel()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::waveModel::read(const dictionary& overrideDict)
+bool Foam::waveModel::readDict(const dictionary& overrideDict)
 {
     readOpt() = IOobject::READ_IF_PRESENT;
     if (headerOk())
diff --git a/src/waveModels/waveModel/waveModel.H b/src/waveModels/waveModel/waveModel.H
index 7a0efd457053419ae0d724902c72f05f9556ae41..f7cea6c719d1b664c69ff06637043f70b627f0ba 100644
--- a/src/waveModels/waveModel/waveModel.H
+++ b/src/waveModels/waveModel/waveModel.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.
      \\/     M anipulation  | Copyright (C) 2015 IH-Cantabria
 -------------------------------------------------------------------------------
 License
@@ -231,7 +231,7 @@ public:
         static word modelName(const word& patchName);
 
         //- Read from dictionary
-        virtual bool read(const dictionary& overrideDict);
+        virtual bool readDict(const dictionary& overrideDict);
 
         //- Return the latest wave velocity prediction
         virtual const vectorField& U() const;