diff --git a/Allwmake b/Allwmake
index 515d1cdf9af0dbfd784597a9a095de8509caa2bc..749c60fc89db7731f3098bb8c576b94c12f2f4fb 100755
--- a/Allwmake
+++ b/Allwmake
@@ -1,10 +1,13 @@
 #!/bin/sh
 set -x
 
+# run from this directory only
+cd ${0%/*} || exit 1
+
 # wmake is required for subsequent targets
 (cd wmake/src && make)
 
-(cd $WM_PROJECT_INST_DIR/ThirdParty && ./Allwmake)
+(cd $WM_THIRD_PARTY_DIR && ./Allwmake)
 
 (cd src && ./Allwmake)
 
diff --git a/README b/README
index e698d955a25075698f816344c2207d7a48a22eb7..57b80f5d14fc2212c275a31ffe331293bdfa0bd6 100644
--- a/README
+++ b/README
@@ -29,8 +29,8 @@
 2. System requirements
 ~~~~~~~~~~~~~~~~~~~~~~
   OpenFOAM is developed and tested on Linux, but should work with other
-  Unix style system.  To check your system setup, execute the foamSystemCheck
-  script in the bin directory of the OpenFOAM installation. If no problems
+  Unix style systems.  To check your system setup, execute the foamSystemCheck
+  script in the bin/ directory of the OpenFOAM installation. If no problems
   are reported, proceed to "3. Installation"; otherwise contact your
   system administrator.
 
@@ -40,7 +40,6 @@
 
 3. Installation
 ~~~~~~~~~~~~~~~
-
   Download and unpack the files in the $HOME/OpenFOAM directory as described
   in:  http://www.OpenFOAM.org/download.html
 
@@ -77,10 +76,9 @@
 
   3.1. Installation in alternative locations
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    OpenFOAM may also be installed in an alternative location.
-    However, the installation directory must be network available
-    (eg, NFS) if parallel calculations are planned.
+    OpenFOAM may also be installed in alternative locations. However, the
+    installation directory should be network available (e.g., NFS) if
+    parallel calculations are planned.
 
     The environment variable 'FOAM_INST_DIR' can be used to find and source
     the appropriate resource file. Here is a bash/ksh/sh example:
@@ -89,7 +87,7 @@
         foamDotFile=$FOAM_INST_DIR/OpenFOAM-<VERSION>/etc/bashrc
         [ -f $foamDotFile ] && . $foamDotFile
 
-    and a csh example:
+    and a csh/tcsh example:
 
         setenv FOAM_INST_DIR /data/app/OpenFOAM
         foamDotFile=$FOAM_INST_DIR/OpenFOAM-<VERSION>/etc/bashrc
@@ -102,9 +100,8 @@
 
 4. Building from Sources (Optional)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
   If you cannot find an appropriate binary pack for your platform, you can
-  build the complete OpenFOAM from the source-pack.  First you will need to
+  build the complete OpenFOAM from the source-pack.  You will first need to
   compile or obtain a recent version of gcc (we recomend gcc-4.2.?) for
   your platform, which may be obtained from http://gcc.gnu.org/.
 
@@ -114,29 +111,27 @@
   $WM_PROJECT_DIR/etc/settings.csh appropriately and finally update the
   environment variables as in section 3.
 
-  Now go to the top-level source directory $WM_PROJECT_DIR and type
-  ./Allwmake, which is the name of the top-level build script for building
-  the whole of OpenFOAM.  In principle this will build everything, but
-  sometimes problems occur with the build order and it is necessary to
-  update the environment variables and re-execute Allwmake.  If you
-  experience difficulties with building the source-pack or your platform is
-  not currently supported please contact <enquiries@OpenCFD.co.uk> to
-  negotiate a support contract and we will do the port and maintain it in
+  Now go to the top-level source directory $WM_PROJECT_DIR and execute the
+  top-level build script './Allwmake'.  In principle this will build
+  everything, but if problems occur with the build order it may be necessary
+  to update the environment variables and re-execute 'Allwmake'. If you
+  experience difficulties with building the source-pack, or your platform is
+  not currently supported, please contact <enquiries@OpenCFD.co.uk> to
+  negotiate a support contract and we will do the port and maintain it for
   future releases.
 
 
 5. Testing the installation
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   To check your installation setup, execute the 'foamInstallationTest'
-  script (in the bin directory of the OpenFOAM installation). If no problems
-  are reported, proceed to getting started with OpenFOAM; otherwise, go back
-  and check you have installed the software correctly and/or contact your
-  system administrator.
+  script (in the bin/ directory of the OpenFOAM installation). If no
+  problems are reported, proceed to getting started with OpenFOAM;
+  otherwise, go back and check you have installed the software correctly
+  and/or contact your system administrator.
 
 
 6. Getting Started
 ~~~~~~~~~~~~~~~~~~
-
   Create a project directory within the $HOME/OpenFOAM directory named
   <USER>-<VERSION> (e.g. 'chris-1.5' for user chris and OpenFOAM version 1.5)
   and create a directory named 'run' within it, e.g. by typing:
@@ -144,7 +139,7 @@
       mkdir -p $HOME/OpenFOAM/${USER}-${WM_PROJECT_VERSION}/run
 
   Copy the 'tutorial' examples directory in the OpenFOAM distribution to the
-  'run' directory.  If OpenFOAM environment variables are set correctly,
+  'run' directory.  If the OpenFOAM environment variables are set correctly,
   then the following command will be correct:
 
       cp -r $WM_PROJECT_DIR/tutorials $HOME/OpenFOAM/${USER}-${WM_PROJECT_VERSION}/run
@@ -158,27 +153,27 @@
 
 7. Documentation
 ~~~~~~~~~~~~~~~~
-    http://www.OpenFOAM.org/doc
+  http://www.OpenFOAM.org/doc
 
 
 8. Help
 ~~~~~~~
-    http://www.OpenFOAM.org
-    http://www.OpenFOAM.org/discussion.html
+  http://www.OpenFOAM.org
+  http://www.OpenFOAM.org/discussion.html
 
 
 9. Reporting Bugs in OpenFOAM
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    http://www.OpenFOAM.org/bugs.html
+  http://www.OpenFOAM.org/bugs.html
 
 
 A. Running OpenFOAM in 32-bit mode on 64-bit machines
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-  Those users with an installation of Linux on a 64-bit machine may install
-  either or both of the 32-bit version of OpenFOAM (linux) or the 64-bit
-  version of FOAM (linux64) with 64-bit being the default mode. In order to
-  set up the user to run in 32-bit mode, the user must set the environment
-  variable $WM_32 (to anything, e.g. "on") before sourcing the etc/bashrc
-  (or etc/cshrc) file.  Unsetting $WM_32 and sourcing the bashrc file will
+  Linux users with a 64-bit machine may install either the OpenFOAM 32-bit
+  version (linux) or the OpenFOAM 64-bit version (linux64), or both.
+  The 64-bit is the default mode on a 64-bit machine.  To use an installed
+  32-bit version, the user must set the environment variable $WM_32 (to
+  anything, e.g. "on") before sourcing the etc/bashrc (or etc/cshrc) file.
+  Unsetting WM_32 and re-sourcing the etc/bashrc (or etc/cshrc) file will
   set up the user to run in 64-bit mode.
 
diff --git a/applications/test/dictionary/calcEntry/calcEntry.C b/applications/test/dictionary/calcEntry/calcEntry.C
index 6fb009456bf4b2b79299cc69f9153e83c458b182..d148f5d829efb5c3ed144fc91284d159258d8fb2 100644
--- a/applications/test/dictionary/calcEntry/calcEntry.C
+++ b/applications/test/dictionary/calcEntry/calcEntry.C
@@ -42,24 +42,17 @@ namespace functionEntries
     (
         functionEntry,
         calcEntry,
-        insert,
+        execute,
         primitiveEntryIstream
     );
 
-    addToMemberFunctionSelectionTable
-    (
-        functionEntry,
-        calcEntry,
-        insert,
-        dictionaryIstream
-    );
 }
 }
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::functionEntries::calcEntry::insert
+bool Foam::functionEntries::calcEntry::execute
 (
     const dictionary& parentDict,
     primitiveEntry& entry,
@@ -75,14 +68,4 @@ bool Foam::functionEntries::calcEntry::insert
 }
 
 
-bool Foam::functionEntries::calcEntry::insert
-(
-    dictionary& parentDict,
-    Istream& is
-)
-{
-    return true;
-}
-
-
 // ************************************************************************* //
diff --git a/applications/test/dictionary/calcEntry/calcEntry.H b/applications/test/dictionary/calcEntry/calcEntry.H
index c4c725dfb0ad8380a0fd1b0aced3e4d8b1e30418..157bdc6d02abe8019f77182698e1c597383b4e76 100644
--- a/applications/test/dictionary/calcEntry/calcEntry.H
+++ b/applications/test/dictionary/calcEntry/calcEntry.H
@@ -69,18 +69,13 @@ public:
 
     // Member Functions
 
-        static bool insert
+        static bool execute
         (
             const dictionary& parentDict,
             primitiveEntry& entry,
             Istream& is
         );
 
-        static bool insert
-        (
-            dictionary& parentDict,
-            Istream& is
-        );
 };
 
 
diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict
index 70f6885e7ef345028a910a08c2691d2e7d6a6a82..9bd58c58ae9faf9d61118341ce0d13c85c049946 100644
--- a/applications/test/dictionary/testDict
+++ b/applications/test/dictionary/testDict
@@ -1,17 +1,19 @@
+/*-------------------------------*- C++ -*---------------------------------*\
+|    =========                                                              |
+|    \\      /     OpenFOAM                                                 |
+|     \\    /                                                               |
+|      \\  /       The Open Source CFD Toolbox                              |
+|       \\/                                        http://www.OpenFOAM.org  |
+\*-------------------------------------------------------------------------*/
 FoamFile
 {
     version         2.0;
     format          ascii;
-
-    root            "";
-    case            "";
-    instance        "";
-    local           "";
-
     class           dictionary;
     object          testDict;
 }
-
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+#inputMode  merge
 
 dimensions      [ 0 2 -2 0 0 0 0 ];
 internalField   uniform 1;
@@ -29,7 +31,6 @@ inactive
     type            zeroGradient;
 }
 
-
 boundaryField
 {
     Default_Boundary_Region
@@ -40,6 +41,12 @@ boundaryField
     inlet_1  { $active }
     inlet_2  { $inactive }
     inlet_3  { $inactive }
+    inlet_4  { $inactive }
+    inlet_5  "a primitiveEntry is squashed by a directory entry";
+    inlet_5  { $inactive }
+    inlet_6  { $inactive }
+    inlet_7  { $inactive }
+    inlet_8  { $inactive }
 
     #include "testDictInc"
 
@@ -48,8 +55,44 @@ boundaryField
         type            inletOutlet;
         inletValue      $internalField;
         value           #include "value";
+        // error           #remove self;
         x               5;
         y               6;
         another         #calc{x $x; y $y;};
     }
+
+    // this should have no effect
+    #remove inactive
+
+    inlet_7  { $active }
+    #inputMode overwrite
+    inlet_8  { $active }
+}
+
+// NB: the inputMode has a global scope
+#inputMode merge
+#include "testDict2"
+
+foo
+{
+    $active
 }
+
+bar
+{
+    $active
+}
+
+baz
+{
+    $active
+}
+
+
+// this should work
+#remove active
+
+// this should work too
+#remove ( bar baz )
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/test/dictionary/testDict2 b/applications/test/dictionary/testDict2
new file mode 100644
index 0000000000000000000000000000000000000000..6c55ab384c22c0ce1c1e324306a68594e2afca1e
--- /dev/null
+++ b/applications/test/dictionary/testDict2
@@ -0,0 +1,30 @@
+/*-------------------------------*- C++ -*---------------------------------*\
+|    =========                                                              |
+|    \\      /     OpenFOAM                                                 |
+|     \\    /                                                               |
+|      \\  /       The Open Source CFD Toolbox                              |
+|       \\/                                        http://www.OpenFOAM.org  |
+\*-------------------------------------------------------------------------*/
+FoamFile
+{
+    version         2.0;
+    format          ascii;
+    class           dictionary;
+    object          testDict;
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+boundaryField
+{
+    Default_Boundary_Region
+    {
+        value $internalField;
+        note "actually a noslip wall";
+    }
+
+    inlet_3  "a primitiveEntry squashes directory entry";
+}
+
+#inputMode  overwrite
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/test/dictionary/value b/applications/test/dictionary/value
index 196f9d3d0a639b5120ba76846b0612094b137245..6a860dc353314050925f870b0548c7fc7e3924e0 100644
--- a/applications/test/dictionary/value
+++ b/applications/test/dictionary/value
@@ -1 +1,2 @@
-uniform 2
+// the trailing ';' shouldn't actually be there, but shouldn't cause problems
+uniform 2;
diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake
index 95f041dd612d0864327b5afa3e50f5377f618a03..31617e3b12578fff89727d64fbc924c8fd09a65d 100755
--- a/applications/utilities/mesh/conversion/Optional/Allwmake
+++ b/applications/utilities/mesh/conversion/Optional/Allwmake
@@ -2,6 +2,9 @@
 # Build optional components (eg, may depend on third-party libraries)
 set -x
 
+# run from this directory only
+cd ${0%/*} || exit 1
+
 # build libccmio if required
 if [ ! -e $FOAM_LIBBIN/libccmio.so ]
 then
diff --git a/bin/mpirunDebug b/bin/mpirunDebug
index b0a53cdc63e3e73dccdabd0514a666bb93289860..eec151343913e5d51231b27460339c41203956e2 100755
--- a/bin/mpirunDebug
+++ b/bin/mpirunDebug
@@ -80,27 +80,25 @@ $ECHO "Choose running method: 1)gdb+xterm  2)gdb  3)log  4)xterm+valgrind: \c"
 read method
 if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 ]; then
     printUsage
-    exit 1    
+    exit 1
 fi
 
 $ECHO "Run all processes local or distributed? 1)local  2)remote: \c"
 read spawn
 if [ "$spawn" -ne 1 -a "$spawn" -ne 2 ]; then
     printUsage
-    exit 1    
+    exit 1
 fi
 
-# check ~/.OpenFOAM-VERSION
-# check <site>/etc
-# check <site>/.OpenFOAM-VERSION
+# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
+# check ~/.$WM_PROJECT/
+# check <installedProject>/etc/
 if [ "$WM_PROJECT" ]; then
 
-   : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION}
-
    for i in \
-      $HOME/$FOAM_DOT_DIR \
+      $HOME/.WM_PROJECT/$WM_PROJECT_VERSION \
+      $HOME/.WM_PROJECT \
       $WM_PROJECT_DIR/etc \
-      $WM_PROJECT_DIR/$FOAM_DOT_DIR \
       ;
    do
       if [ -f "$i/bashrc" ]; then
@@ -112,7 +110,12 @@ fi
 
 # Construct test string for remote execution.
 # Source OpenFOAM settings if OpenFOAM environment not set.
-sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam"
+# attempt to preserve the installation directory 'FOAM_INST_DIR'
+if [ "$FOAM_INST_DIR" ]; then
+   sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam"
+else
+   sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam"
+fi
 
 echo "**sourceFoam:$sourceFoam"
 
diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions
index de10e46fc7891a896ec273b6df95aa2626d2ecd2..c9d52c913413d84349170446bddc8fa5efe36237 100644
--- a/bin/tools/CleanFunctions
+++ b/bin/tools/CleanFunctions
@@ -1,5 +1,4 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
+#---------------------------------*- sh -*-------------------------------------
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions
index 64cc1ae4e59c910c49708499b117a6fb81fd5546..8b0208e64e59e515f547dc6e86ce6fd4e0f47e88 100644
--- a/bin/tools/RunFunctions
+++ b/bin/tools/RunFunctions
@@ -1,5 +1,4 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
+#---------------------------------*- sh -*-------------------------------------
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
diff --git a/bin/tools/buildParaViewFunctions b/bin/tools/buildParaViewFunctions
index 6bbd747555b0a319c93b641093173e215f13b753..d5fb1771ec9df6869d5b0942d928c37df8a5e718 100644
--- a/bin/tools/buildParaViewFunctions
+++ b/bin/tools/buildParaViewFunctions
@@ -1,5 +1,4 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
+#---------------------------------*- sh -*-------------------------------------
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
@@ -48,6 +47,7 @@ initialiseVariables ()
     if [ "$VERBOSE" = ON ]; then
         addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE"
     fi
+    addCMakeVariable "VTK_USE_TK=FALSE"
 }
 
 
diff --git a/bin/tools/thirdPartyGetFunctions b/bin/tools/thirdPartyGetFunctions
index a6c92f8a2dec9d957fb4fa6ea2de60bc75446d98..0a79b6f68f2c37540a5ce00380544b649ee383b3 100644
--- a/bin/tools/thirdPartyGetFunctions
+++ b/bin/tools/thirdPartyGetFunctions
@@ -1,5 +1,4 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
+#---------------------------------*- sh -*-------------------------------------
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
diff --git a/etc/aliases.csh b/etc/aliases.csh
index 0239cc8f3b8df40ba4612ff1f1957b3f8a2d498a..6042fc6bd3a2aa257bbe622641c41d99a61eef70 100644
--- a/etc/aliases.csh
+++ b/etc/aliases.csh
@@ -38,6 +38,12 @@ alias wm32 'setenv WM_ARCH_OPTION 32; source $WM_PROJECT_DIR/etc/cshrc'
 alias wmSP 'setenv WM_PRECISION_OPTION SP; source $WM_PROJECT_DIR/etc/cshrc'
 alias wmDP 'setenv WM_PRECISION_OPTION DP; source $WM_PROJECT_DIR/etc/cshrc'
 
+# Toggle wmakeScheduler on/off
+#  - also need to set WM_HOSTS
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+alias wmSchedON 'setenv WM_SCHEDULER $WM_PROJECT_DIR/wmake/wmakeScheduler'
+alias wmSchedOFF 'unsetenv WM_SCHEDULER'
+
 # Change directory aliases
 # ~~~~~~~~~~~~~~~~~~~~~~~~
 alias src 'cd $FOAM_SRC'
diff --git a/etc/aliases.sh b/etc/aliases.sh
index 885568a7340760a2fed82f20c6c2506d07ae093b..1d3367589ed8e14ba6145b57136601f4099f4268 100644
--- a/etc/aliases.sh
+++ b/etc/aliases.sh
@@ -38,6 +38,12 @@ alias wm32='export WM_ARCH_OPTION=32; . $WM_PROJECT_DIR/etc/bashrc'
 alias wmSP='export WM_PRECISION_OPTION=SP; . $WM_PROJECT_DIR/etc/bashrc'
 alias wmDP='export WM_PRECISION_OPTION=DP; . $WM_PROJECT_DIR/etc/bashrc'
 
+# Toggle wmakeScheduler on/off
+#  - also need to set WM_HOSTS
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+alias wmSchedON='export WM_SCHEDULER=$WM_PROJECT_DIR/wmake/wmakeScheduler'
+alias wmSchedOFF='unset WM_SCHEDULER'
+
 # Change directory aliases
 # ~~~~~~~~~~~~~~~~~~~~~~~~
 alias src='cd $FOAM_SRC'
diff --git a/src/OSspecific/Unix/Unix.C b/src/OSspecific/Unix/Unix.C
index e50444a23602ce9f84b69ced0c935e1246755a74..b2c89395e5917eaf355be72b669b2c0e13fc39d9 100644
--- a/src/OSspecific/Unix/Unix.C
+++ b/src/OSspecific/Unix/Unix.C
@@ -213,25 +213,13 @@ bool Foam::chDir(const fileName& dir)
 
 Foam::fileName Foam::dotFoam(const fileName& name)
 {
-    // Search for file 'name' in:
-    // 1) ~/.OpenFOAM-VERSION/, ~/.OpenFOAM/VERSION/ or ~/.OpenFOAM/
-    // 2) $WM_PROJECT_INST_DIR/site/VERSION or $WM_PROJECT_INST_DIR/site/
-    // 3) $WM_PROJECT_DIR/etc/
-
     // Search user files:
     // ~~~~~~~~~~~~~~~~~~
-    // Check for user file in ~/.OpenFOAM-VERSION/
-    fileName fullName  = home()/(word(".OpenFOAM-") + FOAMversion)/name;
-    if (exists(fullName))
-    {
-        return fullName;
-    }
-
     fileName searchDir = home()/".OpenFOAM";
     if (dir(searchDir))
     {
         // Check for user file in ~/.OpenFOAM/VERSION
-        fullName = searchDir/FOAMversion/name;
+        fileName fullName = searchDir/FOAMversion/name;
         if (exists(fullName))
         {
             return fullName;
@@ -252,7 +240,7 @@ Foam::fileName Foam::dotFoam(const fileName& name)
     if (dir(searchDir))
     {
         // Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
-        fullName = searchDir/"site"/FOAMversion/name;
+        fileName fullName = searchDir/"site"/FOAMversion/name;
         if (exists(fullName))
         {
             return fullName;
@@ -272,14 +260,14 @@ Foam::fileName Foam::dotFoam(const fileName& name)
     if (dir(searchDir))
     {
         // Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
-        fullName = searchDir/"etc"/name;
+        fileName fullName = searchDir/"etc"/name;
         if (exists(fullName))
         {
             return fullName;
         }
     }
 
-    // Nothing found
+    // Not found
     return fileName::null;
 }
 
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index c9be7642ba5b3d6dbcd6e20226138f256cd8fabc..7b137dedc036386457c906dff90927cfa2bcf610 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -122,6 +122,7 @@ functionEntries = $(dictionary)/functionEntries
 $(functionEntries)/functionEntry/functionEntry.C
 $(functionEntries)/includeEntry/includeEntry.C
 $(functionEntries)/inputModeEntry/inputModeEntry.C
+$(functionEntries)/removeEntry/removeEntry.C
 
 IOdictionary = db/IOobjects/IOdictionary
 $(IOdictionary)/IOdictionary.C
diff --git a/src/OpenFOAM/Make/options b/src/OpenFOAM/Make/options
index 420d3469ec8582d2aa9c77229dddaa87a550b962..c5c5809076e0947f38c928f4ea3880b13ba60ac0 100644
--- a/src/OpenFOAM/Make/options
+++ b/src/OpenFOAM/Make/options
@@ -1,5 +1,5 @@
 EXE_INC = \
-    -I$(LIB_SRC)/zlib-1.2.3
+    -I$(WM_THIRD_PARTY_DIR)/zlib-1.2.3
 
 LIB_LIBS = \
     $(FOAM_LIBBIN)/libOSspecific.o \
diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H
index 0c35bd7f1a57443893b858766ce2cdc7a1f72972..e08a56a1a870bd83b49a9f999a41f1919afc9312 100644
--- a/src/OpenFOAM/db/IOobject/IOobject.H
+++ b/src/OpenFOAM/db/IOobject/IOobject.H
@@ -329,12 +329,9 @@ public:
         // Writing
 
             //- Write the standard OpenFOAM file/dictionary banner
+            //  Optionally without -*- C++ -*- editor hint (eg, for logs)
             template<class Stream>
-            static inline void writeBanner(Stream& os);
-
-            //- Write the standard OpenFOAM log banner
-            template<class Stream>
-            static inline void writeLogBanner(Stream& os);
+            static inline void writeBanner(Stream& os, bool noHint=false);
 
             //- Write the standard file section divider
             template<class Stream>
diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H
index 09a64ff89649eaa31f6b85b3324616807795aa43..7ffff5ede501c58980ad2ae98e966f70b50e0737 100644
--- a/src/OpenFOAM/db/IOobject/IOobjectI.H
+++ b/src/OpenFOAM/db/IOobject/IOobjectI.H
@@ -29,48 +29,34 @@ License
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Stream>
-inline void Foam::IOobject::writeBanner(Stream& os)
+inline void Foam::IOobject::writeBanner(Stream& os, bool noHint)
 {
     static bool spacesSet = false;
-    static char spaces[80];
+    static char spaces[40];
 
     if (!spacesSet)
     {
-        memset(spaces, ' ', 80);
+        memset(spaces, ' ', 40);
         spaces[38 - strlen(Foam::FOAMversion)] = '\0';
         spacesSet = true;
     }
 
-    os  <<
-        "/*--------------------------------*- C++ -*----------------------------------*\\\n"
-        "| =========                 |                                                 |\n"
-        "| \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |\n"
-        "|  \\\\    /   O peration     | Version:  " << FOAMversion << spaces << "|\n"
-        "|   \\\\  /    A nd           | Web:      http://www.openfoam.org               |\n"
-        "|    \\\\/     M anipulation  |                                                 |\n"
-        "\\*---------------------------------------------------------------------------*/\n";
-}
-
-
-template<class Stream>
-inline void Foam::IOobject::writeLogBanner(Stream& os)
-{
-    static bool spacesSet = false;
-    static char spaces[80];
-
-    if (!spacesSet)
+    if (noHint)
     {
-        memset(spaces, ' ', 80);
-        spaces[38 - strlen(Foam::FOAMversion)] = '\0';
-        spacesSet = true;
+        os  <<
+            "/*---------------------------------------------------------------------------*\\\n";
+    }
+    else
+    {
+        os  <<
+            "/*--------------------------------*- C++ -*----------------------------------*\\\n";
     }
 
     os  <<
-        "/*---------------------------------------------------------------------------*\\\n"
         "| =========                 |                                                 |\n"
         "| \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |\n"
         "|  \\\\    /   O peration     | Version:  " << FOAMversion << spaces << "|\n"
-        "|   \\\\  /    A nd           | Web:      http://www.openfoam.org               |\n"
+        "|   \\\\  /    A nd           | Web:      http://www.OpenFOAM.org               |\n"
         "|    \\\\/     M anipulation  |                                                 |\n"
         "\\*---------------------------------------------------------------------------*/\n";
 }
diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
index 8846dd1d44cfff55f3a6b92f9ba358fd816c0373..6e647c9ca5e9eb47e53195a99ef88c720e62dafa 100644
--- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
+++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C
@@ -37,8 +37,8 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
     if (!os.good())
     {
         Info<< "IOobject::writeHeader(Ostream&) : "
-            << "no stream open for write"
-            << endl << os.info() << endl;
+            << "no stream open for write" << nl
+            << os.info() << endl;
 
         return false;
     }
@@ -49,16 +49,14 @@ bool Foam::IOobject::writeHeader(Ostream& os) const
         << "    format      " << os.format() << ";\n"
         << "    class       " << type() << ";\n";
 
+    // outdent for visibility and more space
     if (note().size())
     {
-        os << "    note        " << note() << ";\n";
+        os  << "    note    " << note() << ";\n";
     }
 
-    // writing without quotes would look nicer
-    os  << "    object      " << name() << ";\n"
-        //<< "    instance    " << instance()/local() << ";\n"
-        //<< "    local       " << local() << ";\n"
-        << "    location    " << instance()/local() << ";\n"
+    os  << "    location    " << instance()/local() << ";\n"
+        << "    object      " << name() << ";\n"
         << "}" << nl;
 
     writeDivider(os);
diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C
index 8dd2263574dffe4baf17d74f30939a5860e3a2d9..4990cfb8dc3241fc7ad3934e9fb16a92bc150b61 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.C
+++ b/src/OpenFOAM/db/dictionary/dictionary.C
@@ -34,74 +34,6 @@ defineTypeNameAndDebug(Foam::dictionary, 0);
 
 const Foam::dictionary Foam::dictionary::null;
 
-#define DICTIONARY_INPLACE_MERGE
-
-// * * * * * * * * * * * * * Private member functions  * * * * * * * * * * * //
-
-bool Foam::dictionary::add(entry* ePtr, bool mergeEntry)
-{
-    HashTable<entry*>::iterator iter = hashedEntries_.find(ePtr->keyword());
-
-    if (mergeEntry && iter != hashedEntries_.end())
-    {
-        // merge dictionary with dictionary
-        if (iter()->isDict() && ePtr->isDict())
-        {
-            iter()->dict().merge(ePtr->dict());
-            delete ePtr;
-
-            return true;
-        }
-        else
-        {
-            // replace existing dictionary with entry or vice versa
-#ifdef DICTIONARY_INPLACE_MERGE
-            IDLList<entry>::replace(iter(), ePtr);
-            delete iter();
-            hashedEntries_.erase(iter);
-
-            if (hashedEntries_.insert(ePtr->keyword(), ePtr))
-            {
-                ePtr->name() = name_ + "::" + ePtr->keyword();
-                return true;
-            }
-            else
-            {
-                IOWarningIn("dictionary::add(entry* ePtr)", (*this))
-                    << "problem replacing entry "<< ePtr->keyword()
-                    << " in dictionary " << name()
-                    << endl;
-
-                IDLList<entry>::remove(ePtr);
-                delete ePtr;
-                return false;
-            }
-#else
-            remove(ePtr->keyword());
-#endif
-        }
-    }
-
-    if (hashedEntries_.insert(ePtr->keyword(), ePtr))
-    {
-        ePtr->name() = name_ + "::" + ePtr->keyword();
-        IDLList<entry>::append(ePtr);
-
-        return true;
-    }
-    else
-    {
-        IOWarningIn("dictionary::add(entry* ePtr)", (*this))
-            << "attempt to add entry "<< ePtr->keyword()
-            << " which already exists in dictionary " << name()
-            << endl;
-
-        delete ePtr;
-        return false;
-    }
-}
-
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::dictionary::dictionary()
@@ -195,15 +127,15 @@ Foam::label Foam::dictionary::endLineNumber() const
 }
 
 
-bool Foam::dictionary::found(const word& keyword, bool recusive) const
+bool Foam::dictionary::found(const word& keyword, bool recursive) const
 {
     if (hashedEntries_.found(keyword))
     {
         return true;
     }
-    else if (recusive && &parent_ != &dictionary::null)
+    else if (recursive && &parent_ != &dictionary::null)
     {
-        return parent_.found(keyword, recusive);
+        return parent_.found(keyword, recursive);
     }
     else
     {
@@ -215,16 +147,16 @@ bool Foam::dictionary::found(const word& keyword, bool recusive) const
 const Foam::entry* Foam::dictionary::lookupEntryPtr
 (
     const word& keyword,
-    bool recusive
+    bool recursive
 ) const
 {
     HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword);
 
     if (iter == hashedEntries_.end())
     {
-        if (recusive && &parent_ != &dictionary::null)
+        if (recursive && &parent_ != &dictionary::null)
         {
-            return parent_.lookupEntryPtr(keyword, recusive);
+            return parent_.lookupEntryPtr(keyword, recursive);
         }
         else
         {
@@ -239,19 +171,19 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
 Foam::entry* Foam::dictionary::lookupEntryPtr
 (
     const word& keyword,
-    bool recusive
+    bool recursive
 )
 {
     HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
 
     if (iter == hashedEntries_.end())
     {
-        if (recusive && &parent_ != &dictionary::null)
+        if (recursive && &parent_ != &dictionary::null)
         {
             return const_cast<dictionary&>(parent_).lookupEntryPtr
             (
                 keyword,
-                recusive
+                recursive
             );
         }
         else
@@ -267,14 +199,13 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
 const Foam::entry& Foam::dictionary::lookupEntry
 (
     const word& keyword,
-    bool recusive
+    bool recursive
 ) const
 {
-    const entry* ePtr = lookupEntryPtr(keyword, recusive);
+    const entry* entryPtr = lookupEntryPtr(keyword, recursive);
 
-    if (ePtr == NULL)
+    if (entryPtr == NULL)
     {
-        // If keyword not found print error message ...
         FatalIOErrorIn
         (
             "dictionary::lookupEntry(const word& keyword) const",
@@ -284,23 +215,25 @@ const Foam::entry& Foam::dictionary::lookupEntry
             << exit(FatalIOError);
     }
 
-    return *ePtr;
+    return *entryPtr;
 }
 
 
 Foam::ITstream& Foam::dictionary::lookup
 (
     const word& keyword,
-    bool recusive
+    bool recursive
 ) const
 {
-    return lookupEntry(keyword, recusive).stream();
+    return lookupEntry(keyword, recursive).stream();
 }
 
 
 bool Foam::dictionary::isDict(const word& keyword) const
 {
-    if (const entry* entryPtr = lookupEntryPtr(keyword))
+    const entry* entryPtr = lookupEntryPtr(keyword);
+
+    if (entryPtr)
     {
         return entryPtr->isDict();
     }
@@ -313,7 +246,9 @@ bool Foam::dictionary::isDict(const word& keyword) const
 
 const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
 {
-    if (const entry* entryPtr = lookupEntryPtr(keyword))
+    const entry* entryPtr = lookupEntryPtr(keyword);
+
+    if (entryPtr)
     {
         return &entryPtr->dict();
     }
@@ -326,13 +261,9 @@ const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
 
 const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
 {
-    if (const entry* entryPtr = lookupEntryPtr(keyword))
+    const entry* entryPtr = lookupEntryPtr(keyword);
+    if (entryPtr == NULL)
     {
-        return entryPtr->dict();
-    }
-    else
-    {
-        // If keyword not found print error message ...
         FatalIOErrorIn
         (
             "dictionary::subDict(const word& keyword) const",
@@ -340,37 +271,31 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
         )   << " keyword " << keyword << " is undefined in dictionary "
             << name()
             << exit(FatalIOError);
-
-        return entryPtr->dict();
     }
+    return entryPtr->dict();
 }
 
 
 Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
 {
-    if (entry* entryPtr = lookupEntryPtr(keyword))
-    {
-        return entryPtr->dict();
-    }
-    else
+    entry* entryPtr = lookupEntryPtr(keyword);
+    if (entryPtr == NULL)
     {
-        // If keyword not found print error message ...
         FatalIOErrorIn
         (
-            "dictionary::subDict(const word& keyword) const",
+            "dictionary::subDict(const word& keyword)",
             *this
         )   << " keyword " << keyword << " is undefined in dictionary "
             << name()
             << exit(FatalIOError);
-
-        return entryPtr->dict();
     }
+    return entryPtr->dict();
 }
 
 
 Foam::wordList Foam::dictionary::toc() const
 {
-    wordList keywords(size());
+    wordList keys(size());
 
     label i = 0;
     for
@@ -380,56 +305,124 @@ Foam::wordList Foam::dictionary::toc() const
         ++iter
     )
     {
-        keywords[i++] = iter().keyword();
+        keys[i++] = iter().keyword();
+    }
+
+    return keys;
+}
+
+
+bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
+{
+    HashTable<entry*>::iterator iter = hashedEntries_.find(entryPtr->keyword());
+
+    if (mergeEntry && iter != hashedEntries_.end())
+    {
+        // merge dictionary with dictionary
+        if (iter()->isDict() && entryPtr->isDict())
+        {
+            iter()->dict().merge(entryPtr->dict());
+            delete entryPtr;
+
+            return true;
+        }
+        else
+        {
+            // replace existing dictionary with entry or vice versa
+            IDLList<entry>::replace(iter(), entryPtr);
+            delete iter();
+            hashedEntries_.erase(iter);
+
+            if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
+            {
+                entryPtr->name() = name_ + "::" + entryPtr->keyword();
+                return true;
+            }
+            else
+            {
+                IOWarningIn("dictionary::add(entry*)", (*this))
+                    << "problem replacing entry "<< entryPtr->keyword()
+                    << " in dictionary " << name() << endl;
+
+                IDLList<entry>::remove(entryPtr);
+                delete entryPtr;
+                return false;
+            }
+        }
+    }
+
+    if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
+    {
+        entryPtr->name() = name_ + "::" + entryPtr->keyword();
+        IDLList<entry>::append(entryPtr);
+
+        return true;
     }
+    else
+    {
+        IOWarningIn("dictionary::add(entry* entryPtr)", (*this))
+            << "attempt to add entry "<< entryPtr->keyword()
+            << " which already exists in dictionary " << name()
+            << endl;
 
-    return keywords;
+        delete entryPtr;
+        return false;
+    }
 }
 
 
-void Foam::dictionary::add(const entry& e)
+void Foam::dictionary::add(const entry& e, bool mergeEntry)
 {
-    add(e.clone(*this).ptr());
+    add(e.clone(*this).ptr(), mergeEntry);
 }
 
-void Foam::dictionary::add(const word& keyword, const token& t)
+void Foam::dictionary::add(const word& k, const word& w, bool overwrite)
 {
-    add(new primitiveEntry(keyword, t));
+    add(new primitiveEntry(k, token(w)), overwrite);
 }
 
-void Foam::dictionary::add(const word& keyword, const word& w)
+void Foam::dictionary::add(const word& k, const Foam::string& s, bool overwrite)
 {
-    add(new primitiveEntry(keyword, token(w)));
+    add(new primitiveEntry(k, token(s)), overwrite);
 }
 
-void Foam::dictionary::add(const word& keyword, const Foam::string& s)
+void Foam::dictionary::add(const word& k, const label l, bool overwrite)
 {
-    add(new primitiveEntry(keyword, token(s)));
+    add(new primitiveEntry(k, token(l)), overwrite);
 }
 
-void Foam::dictionary::add(const word& keyword, const label l)
+void Foam::dictionary::add(const word& k, const scalar s, bool overwrite)
 {
-    add(new primitiveEntry(keyword, token(l)));
+    add(new primitiveEntry(k, token(s)), overwrite);
 }
 
-void Foam::dictionary::add(const word& keyword, const scalar s)
+void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry)
 {
-    add(new primitiveEntry(keyword, token(s)));
+    add(new dictionaryEntry(k, *this, d), mergeEntry);
 }
 
-void Foam::dictionary::add(const word& keyword, const ITstream& tokens)
+
+void Foam::dictionary::set(entry* entryPtr)
 {
-    add(new primitiveEntry(keyword, tokens));
+    entry* existingPtr = lookupEntryPtr(entryPtr->keyword());
+
+    // clear dictionary so merge acts like overwrite
+    if (existingPtr && existingPtr->isDict())
+    {
+        existingPtr->dict().clear();
+    }
+    add(entryPtr, true);
 }
 
-void Foam::dictionary::add(const word& keyword, const tokenList& tokens)
+
+void Foam::dictionary::set(const entry& e)
 {
-    add(new primitiveEntry(keyword, tokens));
+    set(e.clone(*this).ptr());
 }
 
-void Foam::dictionary::add(const word& keyword, const dictionary& dict)
+void Foam::dictionary::set(const word& k, const dictionary& d)
 {
-    add(new dictionaryEntry(keyword, *this, dict));
+    set(new dictionaryEntry(k, *this, d));
 }
 
 
@@ -486,7 +479,10 @@ bool Foam::dictionary::changeKeyword
         }
         else
         {
-            // could issue warning if desired
+            WarningIn("dictionary::changeKeyword(const word& old, const word& new)")
+                << "cannot rename keyword "<< oldKeyword
+                << " to existing keyword " << newKeyword
+                << " in dictionary " << name() << endl;
             return false;
         }
     }
@@ -527,34 +523,24 @@ bool Foam::dictionary::merge(const dictionary& dict)
         if (iter2 != hashedEntries_.end())
         {
             // Recursively merge sub-dictionaries
+            // TODO: merge without copying
             if (iter2()->isDict() && iter().isDict())
             {
-                // without copying and without remove/add?
-                // this certainly looks ugly and doesn't necessarily
-                // retain the original sort order (perhaps nice to have)
-                if
-                (
-                    iter2()->dict().merge(iter().dict())
-                )
+                if (iter2()->dict().merge(iter().dict()))
                 {
                     changed = true;
                 }
             }
             else
             {
-#ifdef DICTIONARY_INPLACE_MERGE
                 add(iter().clone(*this).ptr(), true);
-#else
-                remove(keyword);
-                add(iter().clone(*this)());
-#endif
                 changed = true;
             }
         }
         else
         {
             // not found - just add
-            add(iter().clone(*this)());
+            add(iter().clone(*this).ptr());
             changed = true;
         }
     }
@@ -588,8 +574,8 @@ void Foam::dictionary::operator=(const dictionary& dict)
             << abort(FatalError);
     }
 
-    // Clear the current entries
-    IDLList<entry>::clear();
+    name_ = dict.name();
+    clear();
 
     // Create clones of the entries in the given dictionary
     // resetting the parentDict to this dictionary
@@ -603,10 +589,6 @@ void Foam::dictionary::operator=(const dictionary& dict)
         IDLList<entry>::append(iter().clone(*this).ptr());
     }
 
-    name_ = dict.name();
-
-    hashedEntries_.clear();
-
     for
     (
         IDLList<entry>::iterator iter = begin();
@@ -636,7 +618,7 @@ void Foam::dictionary::operator+=(const dictionary& dict)
         ++iter
     )
     {
-        add(iter().clone(*this)());
+        add(iter().clone(*this).ptr());
     }
 }
 
@@ -660,7 +642,7 @@ void Foam::dictionary::operator|=(const dictionary& dict)
     {
         if (!found(iter().keyword()))
         {
-            add(iter().clone(*this)());
+            add(iter().clone(*this).ptr());
         }
     }
 }
@@ -683,8 +665,7 @@ void Foam::dictionary::operator<<=(const dictionary& dict)
         ++iter
     )
     {
-        remove(iter().keyword());
-        add(iter().clone(*this)());
+        set(iter().clone(*this).ptr());
     }
 }
 
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index 4bb9bc18490814421a612d1d26879d2229c8b1cc..7e89dc82863fed2866a7268546061a088a867a85 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -31,8 +31,12 @@ Description
 
     The dictionary class is the base class for IOdictionary.
     It serves the purpose of a bootstrap dictionary for the objectRegistry
-    data dictionaries, since unlike the IOdictionary class, it does not use a
-    objectRegistry itself to work.
+    data dictionaries, since unlike the IOdictionary class, it does not use
+    a objectRegistry itself to work.
+
+ToDo
+    A merge() member function with a non-const dictionary parameter.
+    This would avoid unnecessary cloning in the add(entry*,bool) method
 
 SourceFiles
     dictionary.C
@@ -171,31 +175,31 @@ public:
         // Search and lookup
 
             //- Search dictionary for given keyword
-            //  If recusive search parent dictionaries
-            bool found(const word& keyword, bool recusive=false) const;
+            //  If recursive search parent dictionaries
+            bool found(const word& keyword, bool recursive=false) const;
 
             //- Find and return an entry data stream pointer if present
             //  otherwise return NULL.
-            //  If recusive search parent dictionaries
-            const entry* lookupEntryPtr(const word&, bool recusive=false) const;
+            //  If recursive search parent dictionaries
+            const entry* lookupEntryPtr(const word&, bool recursive=false) const;
 
             //- Find and return an entry data stream pointer for manipulation
             //  if present otherwise return NULL.
-            //  If recusive search parent dictionaries
-            entry* lookupEntryPtr(const word&, bool recusive=false);
+            //  If recursive search parent dictionaries
+            entry* lookupEntryPtr(const word&, bool recursive=false);
 
             //- Find and return an entry data stream if present otherwise error.
-            //  If recusive search parent dictionaries
-            const entry& lookupEntry(const word&, bool recusive=false) const;
+            //  If recursive search parent dictionaries
+            const entry& lookupEntry(const word&, bool recursive=false) const;
 
             //- Find and return an entry data stream
-            //  If recusive search parent dictionaries
-            ITstream& lookup(const word&, bool recusive=false) const;
+            //  If recursive search parent dictionaries
+            ITstream& lookup(const word&, bool recursive=false) const;
 
             //- Find and return a T, if not found return the given default value
-            //  If recusive search parent dictionaries
+            //  If recursive search parent dictionaries
             template<class T>
-            T lookupOrDefault(const word&, const T&, bool recusive=false) const;
+            T lookupOrDefault(const word&, const T&, bool recursive=false) const;
 
             //- Find and return a T, if not found return the given default value,
             //  and add to dictionary. If recusive search parent dictionaries
@@ -236,38 +240,57 @@ public:
         // Editing
 
             //- Add a new entry
-            bool add(entry*, bool mergeEntry = false);
+            //  With the merge option, dictionaries are interwoven and
+            //  primitive entries are overwritten
+            bool add(entry*, bool mergeEntry=false);
 
             //- Add an entry
-            void add(const entry&);
-
-            //- Add a token entry
-            void add(const word& keyword, const token&);
+            //  With the merge option, dictionaries are interwoven and
+            //  primitive entries are overwritten
+            void add(const entry&, bool mergeEntry=false);
 
             //- Add a word entry
-            void add(const word& keyword, const word&);
+            //  optionally overwrite an existing entry
+            void add(const word& keyword, const word&, bool overwrite=false);
 
             //- Add a string entry
-            void add(const word& keyword, const string&);
+            //  optionally overwrite an existing entry
+            void add(const word& keyword, const string&, bool overwrite=false);
 
             //- Add a label entry
-            void add(const word& keyword, const label);
+            //  optionally overwrite an existing entry
+            void add(const word& keyword, const label, bool overwrite=false);
 
             //- Add a scalar entry
-            void add(const word& keyword, const scalar);
-
-            //- Add an entry constructed from a ITstream
-            void add(const word& keyword, const ITstream&);
+            //  optionally overwrite an existing entry
+            void add (const word& keyword, const scalar, bool overwrite=false);
 
-            //- Add an entry constructed from a tokenList
-            void add(const word& keyword, const tokenList& tokens);
+            //- Add a dictionary entry
+            //  optionally merge with an existing sub-dictionary
+            void add
+            (
+                const word& keyword,
+                const dictionary&,
+                bool mergeEntry=false
+            );
 
             //- Add a T entry
+            //  optionally overwrite an existing entry
             template<class T>
-            void add(const word& keyword, const T&);
+            void add(const word& keyword, const T&, bool overwrite=false);
 
-            //- Add a dictionary entry
-            void add(const word& keyword, const dictionary&);
+            //- Assign a new entry, overwrite any existing entry
+            void set(entry*);
+
+            //- Assign a new entry, overwrite any existing entry
+            void set(const entry&);
+
+            //- Assign a dictionary entry, overwrite any existing entry
+            void set(const word& keyword, const dictionary&);
+
+            //- Assign a T entry, overwrite any existing entry
+            template<class T>
+            void set(const word& keyword, const T&);
 
             //- Remove an entry specified by keyword
             bool remove(const word& keyword);
@@ -326,14 +349,12 @@ public:
 
 // Global Operators
 
-// Combine dictionaries starting from the entries in dict one and then including
-// those from dict2.
-// Warn, but do not overwrite the entries from dict1.
+//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
+//  Warn, but do not overwrite the entries from dict1.
 dictionary operator+(const dictionary& dict1, const dictionary& dict2);
 
-// Combine dictionaries starting from the entries in dict one and then including
-// those from dict2.
-// Do not overwrite the entries from dict1.
+//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
+//  Do not overwrite the entries from dict1.
 dictionary operator|(const dictionary& dict1, const dictionary& dict2);
 
 
diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
index 6c1361ff07d614a1603b89316198178c2abc1ec7..fe06648d5dcf689431a755142ea25a0b042d5369 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
@@ -33,19 +33,19 @@ template<class T>
 T Foam::dictionary::lookupOrDefault
 (
     const word& keyword,
-    const T& deft,
-    bool recusive
+    const T& deflt,
+    bool recursive
 ) const
 {
-    const entry* ePtr = lookupEntryPtr(keyword, recusive);
+    const entry* entryPtr = lookupEntryPtr(keyword, recursive);
 
-    if (ePtr == NULL)
+    if (entryPtr == NULL)
     {
-        return deft;
+        return deflt;
     }
     else
     {
-        return pTraits<T>(ePtr->stream());
+        return pTraits<T>(entryPtr->stream());
     }
 }
 
@@ -93,12 +93,16 @@ void Foam::dictionary::readIfPresent
 
 
 template<class T>
-void Foam::dictionary::add(const word& keyword, const T& t)
+void Foam::dictionary::add(const word& k, const T& t, bool overwrite)
 {
-    entry* ePtr = new primitiveEntry(keyword, t);
-    append(ePtr);
-    hashedEntries_.insert(ePtr->keyword(), ePtr);
+    add(new primitiveEntry(k, t), overwrite);
 }
 
 
+template<class T>
+void Foam::dictionary::set(const word& k, const T& t)
+{
+    set(new primitiveEntry(k, t));
+}
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C
index 1b2b2016c92cf7e4c606fbc864206545328953bd..84efb2bfc2a6ae443a7d6d3e6432114c9c9ea479 100644
--- a/src/OpenFOAM/db/dictionary/entry/entryIO.C
+++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C
@@ -96,7 +96,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
         if (keyword[0] == '#')        // ... Function entry
         {
             word functionName = keyword(1, keyword.size()-1);
-            return functionEntry::insert(functionName, parentDict, is);
+            return functionEntry::execute(functionName, parentDict, is);
         }
         else if (keyword[0] == '$')    // ... Substitution entry
         {
@@ -105,7 +105,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
         }
         else if (keyword == "include") // ... For backward compatibility
         {
-            return functionEntries::includeEntry::insert(parentDict, is);
+            return functionEntries::includeEntry::execute(parentDict, is);
         }
         else                           // ... Data entries
         {
@@ -114,12 +114,18 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
 
             // Deal with duplicate entries
             bool mergeEntry = false;
-            if (parentDict.found(keyword))
+
+            entry* existingPtr = parentDict.lookupEntryPtr(keyword);
+            if (existingPtr)
             {
                 if (functionEntries::inputModeEntry::overwrite())
                 {
-                    // silently drop previous entries
-                    parentDict.remove(keyword);
+                    // clear dictionary so merge acts like overwrite
+                    if (existingPtr->isDict())
+                    {
+                        existingPtr->dict().clear();
+                    }
+                    mergeEntry = true;
                 }
                 else if (functionEntries::inputModeEntry::merge())
                 {
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C
index 7e53591c64243029bc414605b66d581231faf074..3d4b037dfc8aad6541fe734101695b141af37aff 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C
@@ -33,110 +33,109 @@ namespace Foam
     defineMemberFunctionSelectionTable
     (
         functionEntry,
-        insert,
-        primitiveEntryIstream
+        execute,
+        dictionaryIstream
     );
 
     defineMemberFunctionSelectionTable
     (
         functionEntry,
-        insert,
-        dictionaryIstream
+        execute,
+        primitiveEntryIstream
     );
 }
 
 
 // * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * //
 
-bool Foam::functionEntry::insert
+bool Foam::functionEntry::execute
 (
     const word& functionName,
-    const dictionary& parentDict,
-    primitiveEntry& entry,
+    dictionary& parentDict,
     Istream& is
 )
 {
     is.fatalCheck
     (
-        "functionEntry::insert"
-        "(const word& functionName, const dictionary& parentDict, "
-        "primitiveEntry& entry, Istream& is)"
+        "functionEntry::execute"
+        "(const word& functionName, dictionary& parentDict, Istream& is)"
     );
 
-    if (!insertprimitiveEntryIstreamMemberFunctionTablePtr_)
+    if (!executedictionaryIstreamMemberFunctionTablePtr_)
     {
-        cerr<<"functionEntry::insert"
-            << "(const word&, dictionary&, primitiveEntry&, Istream&)"
+        cerr<<"functionEntry::execute"
+            << "(const word&, dictionary&, Istream&)"
             << " not yet initialized, function = "
             << functionName.c_str() << std::endl;
 
-        // return true to keep reading anyhow
+        // Return true to keep reading
         return true;
     }
 
-    insertprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
-        insertprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
+    executedictionaryIstreamMemberFunctionTable::iterator mfIter =
+        executedictionaryIstreamMemberFunctionTablePtr_->find(functionName);
 
-    if (mfIter == insertprimitiveEntryIstreamMemberFunctionTablePtr_->end())
+    if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end())
     {
         FatalErrorIn
         (
-            "functionEntry::insert"
-            "(const word& functionName, const dictionary& parentDict, "
-            "primitiveEntry& entry, Istream& is)"
+            "functionEntry::execute"
+            "(const word& functionName, dictionary& parentDict, Istream&)"
         )   << "Unknown functionEntry " << functionName
             << endl << endl
             << "Valid functionEntries are :" << endl
-            << insertprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
+            << executedictionaryIstreamMemberFunctionTablePtr_->toc()
             << exit(FatalError);
     }
 
-    return mfIter()(parentDict, entry, is);
+    return mfIter()(parentDict, is);
 }
 
 
-bool Foam::functionEntry::insert
+bool Foam::functionEntry::execute
 (
     const word& functionName,
-    dictionary& parentDict,
+    const dictionary& parentDict,
+    primitiveEntry& entry,
     Istream& is
 )
 {
     is.fatalCheck
     (
-        "functionEntry::insert"
-        "(const word& functionName, dictionary& parentDict, Istream& is)"
+        "functionEntry::execute"
+        "(const word& functionName, const dictionary& parentDict, "
+        "primitiveEntry&, Istream&)"
     );
 
-    if (!insertdictionaryIstreamMemberFunctionTablePtr_)
+    if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
     {
-        cerr<<"functionEntry::insert"
-            << "(const word&, dictionary&, Istream&)"
+        cerr<<"functionEntry::execute"
+            << "(const word&, dictionary&, primitiveEntry&, Istream&)"
             << " not yet initialized, function = "
             << functionName.c_str() << std::endl;
 
-        // Return true to keep reading
+        // return true to keep reading anyhow
         return true;
     }
 
-    insertdictionaryIstreamMemberFunctionTable::iterator mfIter =
-        insertdictionaryIstreamMemberFunctionTablePtr_->find(functionName);
+    executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
+        executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
 
-    if (mfIter == insertdictionaryIstreamMemberFunctionTablePtr_->end())
+    if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end())
     {
         FatalErrorIn
         (
-            "functionEntry::insert"
-            "(const word& functionName, dictionary& parentDict, Istream& is)"
+            "functionEntry::execute"
+            "(const word& functionName, const dictionary& parentDict, "
+            "primitiveEntry&, Istream&)"
         )   << "Unknown functionEntry " << functionName
             << endl << endl
             << "Valid functionEntries are :" << endl
-            << insertdictionaryIstreamMemberFunctionTablePtr_->toc()
+            << executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
             << exit(FatalError);
     }
 
-    return mfIter()(parentDict, is);
+    return mfIter()(parentDict, entry, is);
 }
 
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H
index aa579420d2435c35b2c7c5e309bbf659362d6da4..20f1d9b2479d22a73819956f9e3acd7096cd37dd 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H
@@ -33,13 +33,10 @@ Class
     Foam::functionEntry
 
 Description
-    A function entry causes entries to be added/manipulated on the specified
+    A functionEntry causes entries to be added/manipulated on the specified
     dictionary given an input stream.
 
-    In dictionaries, a @c \# sigil is typically used for a functionEntry.
-
-See Also
-    functionEntries::includeEntry and functionEntries::inputModeEntry
+    In dictionaries, a @c '\#' sigil is typically used for a functionEntry.
 
 SourceFiles
     functionEntry.C
@@ -84,44 +81,47 @@ public:
         (
             bool,
             functionEntry,
-            insert,
-            primitiveEntryIstream,
+            execute,
+            dictionaryIstream,
             (
-                const dictionary& parentDict,
-                primitiveEntry& entry,
+                dictionary& parentDict,
                 Istream& is
             ),
-            (parentDict, entry, is)
+            (parentDict, is)
         );
 
-        static bool insert
+        //- Execute the functionEntry in a sub-dict context
+        static bool execute
         (
             const word& functionName,
-            const dictionary& parentDict,
-            primitiveEntry& entry,
+            dictionary& parentDict,
             Istream& is
         );
 
-
         declareMemberFunctionSelectionTable
         (
             bool,
             functionEntry,
-            insert,
-            dictionaryIstream,
+            execute,
+            primitiveEntryIstream,
             (
-                dictionary& parentDict,
+                const dictionary& parentDict,
+                primitiveEntry& entry,
                 Istream& is
             ),
-            (parentDict, is)
+            (parentDict, entry, is)
         );
 
-        static bool insert
+        //- Execute the functionEntry in a primitiveEntry context
+        static bool execute
         (
             const word& functionName,
-            dictionary& parentDict,
+            const dictionary& parentDict,
+            primitiveEntry& entry,
             Istream& is
         );
+
+
 };
 
 
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C
index 81a8c0b23f4b2c1d65a74f3c022958cc67e09045..60af24c58948f25437e05a8025faf05086906c30 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C
@@ -48,16 +48,16 @@ namespace functionEntries
     (
         functionEntry,
         includeEntry,
-        insert,
-        primitiveEntryIstream
+        execute,
+        dictionaryIstream
     );
 
     addToMemberFunctionSelectionTable
     (
         functionEntry,
         includeEntry,
-        insert,
-        dictionaryIstream
+        execute,
+        primitiveEntryIstream
     );
 }
 }
@@ -82,10 +82,9 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
 }
 
 
-bool Foam::functionEntries::includeEntry::insert
+bool Foam::functionEntries::includeEntry::execute
 (
-    const dictionary& parentDict,
-    primitiveEntry& entry,
+    dictionary& parentDict,
     Istream& is
 )
 {
@@ -93,7 +92,7 @@ bool Foam::functionEntries::includeEntry::insert
 
     if (fileStream)
     {
-        entry.read(parentDict, fileStream);
+        parentDict.read(fileStream);
         return true;
     }
     else
@@ -101,7 +100,7 @@ bool Foam::functionEntries::includeEntry::insert
         FatalIOErrorIn
         (
             "functionEntries::includeEntry::includeEntry"
-            "(dictionary& parentDict, primitiveEntry& entry, Istream& is)",
+            "(dictionary& parentDict,Istream& is)",
             is
         )   << "Cannot open include file " << fileStream.name()
             << " while reading dictionary " << parentDict.name()
@@ -111,10 +110,10 @@ bool Foam::functionEntries::includeEntry::insert
     }
 }
 
-
-bool Foam::functionEntries::includeEntry::insert
+bool Foam::functionEntries::includeEntry::execute
 (
-    dictionary& parentDict,
+    const dictionary& parentDict,
+    primitiveEntry& entry,
     Istream& is
 )
 {
@@ -122,7 +121,7 @@ bool Foam::functionEntries::includeEntry::insert
 
     if (fileStream)
     {
-        parentDict.read(fileStream);
+        entry.read(parentDict, fileStream);
         return true;
     }
     else
@@ -130,7 +129,7 @@ bool Foam::functionEntries::includeEntry::insert
         FatalIOErrorIn
         (
             "functionEntries::includeEntry::includeEntry"
-            "(dictionary& parentDict,Istream& is)",
+            "(dictionary& parentDict, primitiveEntry& entry, Istream& is)",
             is
         )   << "Cannot open include file " << fileStream.name()
             << " while reading dictionary " << parentDict.name()
@@ -140,5 +139,4 @@ bool Foam::functionEntries::includeEntry::insert
     }
 }
 
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H
index dfd6de82d70c729dc51081bd63703e5337cc3c51..00e04d60ca8a612b258c668b586e871a34c1d34c 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H
@@ -29,9 +29,9 @@ Description
     Specify an include file when reading dictionaries, expects a
     single string to follow.
 
-    An example of @c \#include directive:
+    An example of the @c \#include directive:
     @verbatim
-        \#include "includefile"
+        #include "includeFile"
     @endverbatim
 
     The usual expansion of environment variables and other constructs (eg,
@@ -85,18 +85,21 @@ public:
 
     // Member Functions
 
-        static bool insert
+        //- Execute the functionEntry in a sub-dict context
+        static bool execute
         (
-            const dictionary& parentDict,
-            primitiveEntry& entry,
+            dictionary& parentDict,
             Istream& is
         );
 
-        static bool insert
+        //- Execute the functionEntry in a primitiveEntry context
+        static bool execute
         (
-            dictionary& parentDict,
+            const dictionary& parentDict,
+            primitiveEntry& entry,
             Istream& is
         );
+
 };
 
 
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C
index 27b1e78f5eb9137e8497288a273dfe7c1482bcff..cdfa9410fdef6a52e151329c82076e9fa43e31a5 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C
@@ -47,15 +47,7 @@ namespace functionEntries
     (
         functionEntry,
         inputModeEntry,
-        insert,
-        primitiveEntryIstream
-    );
-
-    addToMemberFunctionSelectionTable
-    (
-        functionEntry,
-        inputModeEntry,
-        insert,
+        execute,
         dictionaryIstream
     );
 }
@@ -63,10 +55,11 @@ namespace functionEntries
 
 // * * * * * * * * * * * * * * * * Private Data  * * * * * * * * * * * * * * //
 
-Foam::label Foam::functionEntries::inputModeEntry::inputMode_ = imError;
+Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError;
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
+// we could combine this into execute() directly, but leave it here for now
 void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
 {
     clear();
@@ -74,15 +67,15 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
     word mode(is);
     if (mode == "merge")
     {
-        inputMode_ = imMerge;
+        mode_ = imMerge;
     }
     else if (mode == "overwrite")
     {
-        inputMode_ = imOverwrite;
+        mode_ = imOverwrite;
     }
     else if (mode == "error" || mode == "default")
     {
-        inputMode_ = imError;
+        mode_ = imError;
     }
     else
     {
@@ -95,19 +88,7 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool Foam::functionEntries::inputModeEntry::insert
-(
-    const dictionary& parentDict,
-    primitiveEntry& entry,
-    Istream& is
-)
-{
-    setMode(is);
-    return true;
-}
-
-
-bool Foam::functionEntries::inputModeEntry::insert
+bool Foam::functionEntries::inputModeEntry::execute
 (
     dictionary& parentDict,
     Istream& is
@@ -120,13 +101,13 @@ bool Foam::functionEntries::inputModeEntry::insert
 
 void Foam::functionEntries::inputModeEntry::clear()
 {
-    inputMode_ = imError;
+    mode_ = imError;
 }
 
 
 bool Foam::functionEntries::inputModeEntry::merge()
 {
-    if (inputMode_ & imMerge)
+    if (mode_ & imMerge)
     {
         return true;
     }
@@ -139,7 +120,7 @@ bool Foam::functionEntries::inputModeEntry::merge()
 
 bool Foam::functionEntries::inputModeEntry::overwrite()
 {
-    if (inputMode_ & imOverwrite)
+    if (mode_ & imOverwrite)
     {
         return true;
     }
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H
index 10a3761655690bad6d5e25588454dc11dd761938..072465341d3633b1a5c520e05e85e8eff851f85b 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H
@@ -74,11 +74,12 @@ class inputModeEntry
         };
 
         //- current input mode
-        static label inputMode_;
+        static label mode_;
 
 
     // Private Member Functions
 
+        //- Read the mode as a word and set enum appropriately
         static void setMode(Istream&);
 
         //- Disallow default bitwise copy construct
@@ -96,23 +97,20 @@ public:
 
     // Member Functions
 
-        static bool insert
-        (
-            const dictionary& parentDict,
-            primitiveEntry&,
-            Istream&
-        );
-
-        static bool insert
+        //- Execute the functionEntry in a sub-dict context
+        static bool execute
         (
             dictionary& parentDict,
             Istream&
         );
 
+        //- Reset the inputMode to 'default'
         static void clear();
 
+        //- Return true if the inputMode is 'merge'
         static bool merge();
 
+        //- Return true if the inputMode is 'overwrite'
         static bool overwrite();
 
 };
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
new file mode 100644
index 0000000000000000000000000000000000000000..f6b1becdca4b10b69272a4d73ade00b76c685fd5
--- /dev/null
+++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
@@ -0,0 +1,88 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "removeEntry.H"
+#include "dictionary.H"
+#include "IStringStream.H"
+#include "OStringStream.H"
+#include "addToMemberFunctionSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+const Foam::word Foam::functionEntries::removeEntry::typeName
+(
+    Foam::functionEntries::removeEntry::typeName_()
+);
+
+// Don't lookup the debug switch here as the debug switch dictionary
+// might include removeEntry
+int Foam::functionEntries::removeEntry::debug(0);
+
+namespace Foam
+{
+namespace functionEntries
+{
+    addToMemberFunctionSelectionTable
+    (
+        functionEntry,
+        removeEntry,
+        execute,
+        dictionaryIstream
+    );
+}
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+bool Foam::functionEntries::removeEntry::execute
+(
+    dictionary& parentDict,
+    Istream& is
+)
+{
+    token currToken(is);
+    is.putBack(currToken);
+
+    if (currToken == token::BEGIN_LIST)
+    {
+        wordList keys(is);
+
+        forAll(keys, keyI)
+        {
+            parentDict.remove(keys[keyI]);
+        }
+    }
+    else
+    {
+        word key(is);
+        parentDict.remove(key);
+    }
+
+    return true;
+}
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H
new file mode 100644
index 0000000000000000000000000000000000000000..06c409d299bab03307286666eaa726fc1a5c906b
--- /dev/null
+++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H
@@ -0,0 +1,100 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Class
+    Foam::functionEntries::removeEntry
+
+Description
+    Remove a dictionary entry.
+
+    The @c \#remove directive takes a word or a list of words. For example,
+    @verbatim
+        #remove entry0
+        #remove ( entry1 entry2 entry3 )
+    @endverbatim
+
+    The removable only occurs in the current context.
+    Removing sub-entries or parent entries is not supported.
+
+SourceFiles
+    removeEntry.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef removeEntry_H
+#define removeEntry_H
+
+#include "functionEntry.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionEntries
+{
+
+/*---------------------------------------------------------------------------*\
+                           Class removeEntry Declaration
+\*---------------------------------------------------------------------------*/
+
+class removeEntry
+:
+    public functionEntry
+{
+    // Private Member Functions
+
+        //- Disallow default bitwise copy construct
+        removeEntry(const removeEntry&);
+
+        //- Disallow default bitwise assignment
+        void operator=(const removeEntry&);
+
+
+public:
+
+    //- Runtime type information
+    TypeName("remove");
+
+
+    // Member Functions
+
+        //- Execute the functionEntry in a sub-dict context
+        static bool execute
+        (
+            dictionary& parentDict,
+            Istream& is
+        );
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionEntries
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
index 8c5d0dd9c70a6b4ae9a05a55e48092d34e208f4e..511b53117b4a7120051edc428630c680ccce12d2 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
@@ -115,7 +115,7 @@ bool Foam::primitiveEntry::expandFunction
 )
 {
     word functionName = keyword(1, keyword.size()-1);
-    return functionEntry::insert(functionName, parentDict, *this, is);
+    return functionEntry::execute(functionName, parentDict, *this, is);
 }
 
 
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C
index 8e1738a7347980c8962ece5a2b00a951c73ebf4f..59ee6e57b55cb9edab39097c54484c85e14d105c 100644
--- a/src/OpenFOAM/global/argList/argList.C
+++ b/src/OpenFOAM/global/argList/argList.C
@@ -186,7 +186,7 @@ Foam::argList::argList
     // Print the banner once only for parallel runs
     if (Pstream::master())
     {
-        IOobject::writeLogBanner(Info);
+        IOobject::writeBanner(Info, true);
     }
 
     // convert argv -> args_ and capture ( ... ) lists
@@ -252,19 +252,30 @@ Foam::argList::argList
 
     args_.setSize(nArgs);
 
-    // Help options:
-    //   -doc   display the documentation in browser
-    //   -help  print the usage
-    if (options_.found("doc") || options_.found("help"))
+    // Help/documentation options:
+    //   -help    print the usage
+    //   -doc     display application documentation in browser
+    //   -srcDoc  display source code in browser
+    if
+    (
+        options_.found("help")
+     || options_.found("doc")
+     || options_.found("srcDoc")
+    )
     {
         if (options_.found("help"))
         {
             printUsage();
         }
 
-        if (options_.found("doc"))
+        // only display one or the other
+        if (options_.found("srcDoc"))
+        {
+            displayDoc(true);
+        }
+        else if (options_.found("doc"))
         {
-            displayDoc();
+            displayDoc(false);
         }
 
         ::exit(0);
@@ -578,12 +589,9 @@ void Foam::argList::printUsage() const
         ++iter
     )
     {
-        Info<< ' ' << '<' << iter().c_str() << '>';
+        Info<< " <" << iter().c_str() << '>';
     }
 
-    // place -doc and -help up front
-    Info<< " [-doc] [-help]";
-
     for
     (
         HashTable<string>::iterator iter = validOptions.begin();
@@ -601,16 +609,27 @@ void Foam::argList::printUsage() const
         Info<< ']';
     }
 
-    Info<< endl;
+    // place help/doc options of the way at the end,
+    // but with an extra space to separate it a little
+    Info<< "  [-help] [-doc] [-srcDoc]" << endl;
 }
 
 
-void Foam::argList::displayDoc() const
+void Foam::argList::displayDoc(bool source) const
 {
     const dictionary& docDict = debug::controlDict().subDict("Documentation");
     List<fileName> docDirs(docDict.lookup("doxyDocDirs"));
     List<fileName> docExts(docDict.lookup("doxySourceFileExts"));
 
+    // for source code: change foo_8C.html to foo_8C-source.html
+    if (source)
+    {
+        forAll(docExts, extI)
+        {
+            docExts[extI].replace(".", "-source.");
+        }
+    }
+
     fileName docFile;
     bool found = false;
 
@@ -618,7 +637,7 @@ void Foam::argList::displayDoc() const
     {
         forAll(docExts, extI)
         {
-            docFile = docDirs[dirI]/executable() + docExts[extI];
+            docFile = docDirs[dirI]/executable_ + docExts[extI];
             docFile.expand();
 
             if (exists(docFile))
diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H
index 3068e042c90f70c62f835cb016f2122b150304d9..f79d6d5d1712a1369eaf9725a4c79fdd34603179 100644
--- a/src/OpenFOAM/global/argList/argList.H
+++ b/src/OpenFOAM/global/argList/argList.H
@@ -27,18 +27,18 @@ Class
 
 Description
     Extract command arguments and options from the supplied
-    @a argc and @a argv.
+    @a argc and @a argv parameters.
 
     Sequences with "(" ... ")" are transformed into a stringList.
     For example,
     @verbatim
         program -listFiles \( *.txt \)
     @endverbatim
-    in which the backslash-escaping has been used to avoid shell expansions,
     would create a stringList:
     @verbatim
         ( "file1.txt" "file2.txt" ... "fileN.txt" )
     @endverbatim
+    The backslash-escaping has been used to avoid shell expansions.
 
     @par Default command-line options
     @param -case \<dir\> \n
@@ -47,6 +47,8 @@ Description
         specify case as a parallel job
     @param -doc \n
         display the documentation in browser
+    @param -srcDoc \n
+        display the source documentation in browser
     @param -help \n
        print the usage
 
@@ -130,14 +132,14 @@ public:
         //- A list of valid parallel options
         static HashTable<string> validParOptions;
 
-        //! @cond ignore documentation for this class
+        //! @cond ignoreDocumentation
         class initValidTables
         {
         public:
 
             initValidTables();
         };
-        //! @endcond
+        //! @endcond ignoreDocumentation
 
 
     // Constructors
@@ -148,8 +150,8 @@ public:
         (
             int& argc,
             char**& argv,
-            bool checkArgs = true,
-            bool checkOpts = true
+            bool checkArgs=true,
+            bool checkOpts=true
         );
 
 
@@ -196,8 +198,7 @@ public:
                 return globalCase_;
             }
 
-            //- Return case name for parallel run
-            //  or the global case for a serial run
+            //- Return case name for parallel run or the global case for a serial run
             const fileName& caseName() const
             {
                 return case_;
@@ -222,13 +223,14 @@ public:
             void printUsage() const;
 
             //- Display documentation in browser
-            void displayDoc() const;
+            //  Optionally display the application source code
+            void displayDoc(bool source=false) const;
 
 
         // Check
 
             //- Check argument list
-            bool check(bool checkArgs = true, bool checkOpts = true) const;
+            bool check(bool checkArgs=true, bool checkOpts=true) const;
 
             //- Check root path and case path
             bool checkRootCase() const;
diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H
index d071cf6cd07078ecaf6542a2ba8268512751bf85..33e474cdf3aec8c1c6454af89699d0747e33db60 100644
--- a/src/OpenFOAM/include/OSspecific.H
+++ b/src/OpenFOAM/include/OSspecific.H
@@ -89,8 +89,6 @@ bool chDir(const fileName& dir);
 
 //- Search for @em name in the following hierarchy:
 //  -# personal settings:
-//    - ~/.OpenFOAM-\<VERSION\>
-//      <em>(old style)</em>
 //    - ~/.OpenFOAM/\<VERSION\>/
 //      <em>for version-specific files</em>
 //    - ~/.OpenFOAM/
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C
index 2944cb8d84621ef304787d54380a5329595bbab6..59f152e236f83407b1d4e417885a6177a23b9bab 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/processorLduInterfaceTemplates.C
@@ -73,8 +73,7 @@ void Foam::processorLduInterface::send
     else
     {
         FatalErrorIn("processorLduInterface::send")
-            << "Unsuported communications type "
-            << Pstream::commsTypeNames[commsType]
+            << "Unsupported communications type " << commsType
             << exit(FatalError);
     }
 }
@@ -104,8 +103,7 @@ void Foam::processorLduInterface::receive
     else
     {
         FatalErrorIn("processorLduInterface::receive")
-            << "Unsuported communications type "
-            << Pstream::commsTypeNames[commsType]
+            << "Unsupported communications type " << commsType
             << exit(FatalError);
     }
 }
@@ -184,8 +182,7 @@ void Foam::processorLduInterface::compressedSend
         else
         {
             FatalErrorIn("processorLduInterface::compressedSend")
-                << "Unsuported communications type "
-                << Pstream::commsTypeNames[commsType]
+                << "Unsupported communications type " << commsType
                 << exit(FatalError);
         }
     }
@@ -225,8 +222,7 @@ void Foam::processorLduInterface::compressedReceive
         else if (commsType != Pstream::nonBlocking)
         {
             FatalErrorIn("processorLduInterface::compressedReceive")
-                << "Unsuported communications type "
-                << Pstream::commsTypeNames[commsType]
+                << "Unsupported communications type " << commsType
                 << exit(FatalError);
         }
 
diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake
index 0b81eda1085168c941d96dd766a17e28896234f9..eb51ef379ec8087a94f033cd1db472ea98e97ece 100755
--- a/src/Pstream/Allwmake
+++ b/src/Pstream/Allwmake
@@ -6,6 +6,10 @@ wmake libso dummy
 case "$WM_MPLIB" in
 LAM | OPENMPI | MPI | MPICH | MPICH-GM | MPIGAMMA )
    export WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB
+   set +x
+   echo
+   echo "Note: ignore spurious warnings about missing mpicxx.h headers"
+   set -x
    wmake libso mpi
    ;;
 
diff --git a/src/Pstream/dummy/IPread.C b/src/Pstream/dummy/IPread.C
index dd28fd7fef177eea3c43deb5ab39d006a999b1c3..fd4ed46e0fd3277a12d23c30b2644e867c422f3d 100644
--- a/src/Pstream/dummy/IPread.C
+++ b/src/Pstream/dummy/IPread.C
@@ -32,12 +32,9 @@ Description
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
 
-IPstream::IPstream
+Foam::IPstream::IPstream
 (
     const commsTypes commsType,
     const int fromProcNo,
@@ -53,13 +50,12 @@ IPstream::IPstream
 {
      notImplemented
      (
-         "IPstream::IPstream"
+         "IPsream::IPstream"
          "("
-             "const commsTypes commsType,"
-             "const int fromProcNo,"
+             "const commsTypes,"
+             "const int fromProcNo," 
              "const label bufSize,"
-             "streamFormat format,"
-             "versionNumber version"
+             "streamFormat, versionNumber"
          ")"
      );
 }
@@ -67,7 +63,7 @@ IPstream::IPstream
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-int IPstream::read
+int Foam::IPstream::read
 (
     const commsTypes commsType,
     const int fromProcNo,
@@ -75,33 +71,32 @@ int IPstream::read
     const std::streamsize bufSize
 )
 {
-     notImplemented
-     (
-         "IPstream::read"
-         "("
-             "const commsTypes commsType,"
-             "const int fromProcNo,"
-             "char* buf,"
-             "const label bufSize"
-         ")"
+    notImplemented
+    (
+        "IPstream::read"
+        "("
+            "const commsTypes,"
+            "const int fromProcNo,"
+            "char* buf,"
+            "const label bufSize"
+        ")"
      );
 
      return 0;
 }
 
 
-void IPstream::waitRequests()
+void Foam::IPstream::waitRequests()
 {}
 
 
-bool IPstream::finishedRequest(const label)
+bool Foam::IPstream::finishedRequest(const label)
 {
-     notImplemented("IPstream::finishedRequest()");
+    notImplemented("IPstream::finishedRequest()");
+    return false;
 }
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/Pstream/dummy/OPwrite.C b/src/Pstream/dummy/OPwrite.C
index 7166a1ad45a9dad21a441bdc84b3fd4496d8f550..d87f22d7691179331364186c8a05f51ad195306f 100644
--- a/src/Pstream/dummy/OPwrite.C
+++ b/src/Pstream/dummy/OPwrite.C
@@ -32,12 +32,9 @@ Description
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-OPstream::~OPstream()
+Foam::OPstream::~OPstream()
 {
     notImplemented("OPstream::~OPstream()");
 }
@@ -45,7 +42,7 @@ OPstream::~OPstream()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool OPstream::write
+bool Foam::OPstream::write
 (
     const commsTypes commsType,
     const int toProcNo,
@@ -68,11 +65,11 @@ bool OPstream::write
 }
 
 
-void OPstream::waitRequests()
+void Foam::OPstream::waitRequests()
 {}
 
 
-bool OPstream::finishedRequest(const label)
+bool Foam::OPstream::finishedRequest(const label)
 {
     notImplemented("OPstream::finishedRequest()");
     return false;
@@ -81,6 +78,4 @@ bool OPstream::finishedRequest(const label)
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/Pstream/dummy/Pstream.C b/src/Pstream/dummy/Pstream.C
index 22adbe6cf23f6974fac19a74390a9e32e97d09b9..3b1e9752f544733bba8c3ae9bddbccb04f087778 100644
--- a/src/Pstream/dummy/Pstream.C
+++ b/src/Pstream/dummy/Pstream.C
@@ -29,16 +29,13 @@ License
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-void Pstream::addValidParOptions(HashTable<string>& validParOptions)
+void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions)
 {}
 
 
-bool Pstream::init(int& argc, char**& argv)
+bool Foam::Pstream::init(int& argc, char**& argv)
 {
     FatalErrorIn("Pstream::init(int& argc, char**& argv)")
         << "Trying to use the dummy Pstream library." << nl
@@ -49,24 +46,21 @@ bool Pstream::init(int& argc, char**& argv)
 }
 
 
-void Pstream::exit(int errnum)
+void Foam::Pstream::exit(int errnum)
 {
     notImplemented("Pstream::exit(int errnum)");
 }
 
 
-void Pstream::abort()
+void Foam::Pstream::abort()
 {
     notImplemented("Pstream::abort()");
 }
 
 
-void reduce(scalar&, const sumOp<scalar>&)
+void Foam::reduce(scalar&, const sumOp<scalar>&)
 {}
 
-
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/Pstream/gamma/OPwrite.C b/src/Pstream/gamma/OPwrite.C
index ca96d1a1722357702ddd344a4cad63b9ee816e04..3d1529e4bf42a8895edba322f5451eccdbae96ec 100644
--- a/src/Pstream/gamma/OPwrite.C
+++ b/src/Pstream/gamma/OPwrite.C
@@ -23,7 +23,7 @@ License
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 Description
-    Write primitive and binary block from OPstream
+    Write primitive and binary block from OPstream gamma-mpi
 
 \*---------------------------------------------------------------------------*/
 
@@ -46,8 +46,10 @@ namespace Foam
 
 // Largest message sent so far. This tracks the size of the receive
 // buffer on the receiving end. Done so we only send out resize messages
-// if nessecary
+// if necessary
+//! @cond fileScope
 labelList maxSendSize;
+//! @endcond fileScope
 
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
diff --git a/src/Pstream/gamma/PstreamGlobals.H b/src/Pstream/gamma/PstreamGlobals.H
index 9d0807a9b13cef964dca2ae098d38a30104ba850..58941c80be2b0f01714490868238458cb927cc34 100644
--- a/src/Pstream/gamma/PstreamGlobals.H
+++ b/src/Pstream/gamma/PstreamGlobals.H
@@ -26,7 +26,8 @@ Namespace
     Foam::PstreamGlobals
 
 Description
-    Global functions and variables for working with parallel streams.
+    Global functions and variables for working with parallel streams,
+    but principally for gamma/mpi
 
 SourceFiles
     PstreamGlobals.C
diff --git a/src/Pstream/mpi/IPread.C b/src/Pstream/mpi/IPread.C
index 7423dd6b4321f0483a0f2cc3627ef382d9cbb286..f00f322bab2c4f8b638472508006720e8d916470 100644
--- a/src/Pstream/mpi/IPread.C
+++ b/src/Pstream/mpi/IPread.C
@@ -33,18 +33,16 @@ Description
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 // Outstanding non-blocking operations.
-DynamicList<MPI_Request> IPstream_outstandingRequests_;
-
+//! @cond fileScope
+Foam::DynamicList<MPI_Request> IPstream_outstandingRequests_;
+//! @endcond fileScope
 
 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
 
-IPstream::IPstream
+Foam::IPstream::IPstream
 (
     const commsTypes commsType,
     const int fromProcNo,
@@ -89,7 +87,7 @@ IPstream::IPstream
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-label IPstream::read
+Foam::label Foam::IPstream::read
 (
     const commsTypes commsType,
     const int fromProcNo,
@@ -192,7 +190,7 @@ label IPstream::read
 }
 
 
-void IPstream::waitRequests()
+void Foam::IPstream::waitRequests()
 {
     if (IPstream_outstandingRequests_.size() > 0)
     {
@@ -219,7 +217,7 @@ void IPstream::waitRequests()
 }
 
 
-bool IPstream::finishedRequest(const label i)
+bool Foam::IPstream::finishedRequest(const label i)
 {
     if (i >= IPstream_outstandingRequests_.size())
     {
@@ -244,6 +242,4 @@ bool IPstream::finishedRequest(const label i)
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/Pstream/mpi/OPwrite.C b/src/Pstream/mpi/OPwrite.C
index 2a09427b7ccfb6ffb89d919d12680269b7a0d1f6..4f69ef3f759fc2108ee9ed18288260c411b7646b 100644
--- a/src/Pstream/mpi/OPwrite.C
+++ b/src/Pstream/mpi/OPwrite.C
@@ -31,20 +31,16 @@ Description
 
 #include "OPstream.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 // Outstanding non-blocking operations.
-DynamicList<MPI_Request> OPstream_outstandingRequests_;
-
+//! @cond fileScope
+Foam::DynamicList<MPI_Request> OPstream_outstandingRequests_;
+//! @endcond fileScope
 
 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
 
-OPstream::~OPstream()
+Foam::OPstream::~OPstream()
 {
     if
     (
@@ -66,7 +62,7 @@ OPstream::~OPstream()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool OPstream::write
+bool Foam::OPstream::write
 (
     const commsTypes commsType,
     const int toProcNo,
@@ -80,7 +76,7 @@ bool OPstream::write
     {
         transferFailed = MPI_Bsend
         (
-            (char*)buf,
+            const_cast<char*>(buf),
             bufSize,
             MPI_PACKED,
             procID(toProcNo),
@@ -92,7 +88,7 @@ bool OPstream::write
     {
         transferFailed = MPI_Send
         (
-            (char*)buf,
+            const_cast<char*>(buf),
             bufSize,
             MPI_PACKED,
             procID(toProcNo),
@@ -106,7 +102,7 @@ bool OPstream::write
 
         transferFailed = MPI_Isend
         (
-            (char*)buf,
+            const_cast<char*>(buf),
             bufSize,
             MPI_PACKED,
             procID(toProcNo),
@@ -132,7 +128,7 @@ bool OPstream::write
 }
 
 
-void OPstream::waitRequests()
+void Foam::OPstream::waitRequests()
 {
     if (OPstream_outstandingRequests_.size() > 0)
     {
@@ -159,7 +155,7 @@ void OPstream::waitRequests()
 }
 
 
-bool OPstream::finishedRequest(const label i)
+bool Foam::OPstream::finishedRequest(const label i)
 {
     if (i >= OPstream_outstandingRequests_.size())
     {
@@ -184,6 +180,4 @@ bool OPstream::finishedRequest(const label i)
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/Pstream/mpi/Pstream.C b/src/Pstream/mpi/Pstream.C
index a4563413175d27e360d87ebcab2175935cf4291f..ce42db4ea6bf7b7e7cfc261d18bf05934f45d2b1 100644
--- a/src/Pstream/mpi/Pstream.C
+++ b/src/Pstream/mpi/Pstream.C
@@ -42,12 +42,14 @@ License
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-namespace Foam
-{
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-void Pstream::addValidParOptions(HashTable<string>& validParOptions)
+// NOTE:
+// valid parallel options vary between implementations, but flag common ones.
+// if they are not removed by MPI_Init(), the subsequent argument processing
+// will notice that they are wrong
+void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions)
 {
     validParOptions.insert("np", "");
     validParOptions.insert("p4pg", "PI file");
@@ -59,7 +61,7 @@ void Pstream::addValidParOptions(HashTable<string>& validParOptions)
 }
 
 
-bool Pstream::init(int& argc, char**& argv)
+bool Foam::Pstream::init(int& argc, char**& argv)
 {
     MPI_Init(&argc, &argv);
 
@@ -119,7 +121,7 @@ bool Pstream::init(int& argc, char**& argv)
 }
 
 
-void Pstream::exit(int errnum)
+void Foam::Pstream::exit(int errnum)
 {
 #   ifndef SGIMPI
     int size;
@@ -140,13 +142,13 @@ void Pstream::exit(int errnum)
 }
 
 
-void Pstream::abort()
+void Foam::Pstream::abort()
 {
     MPI_Abort(MPI_COMM_WORLD, 1);
 }
 
 
-void reduce(scalar& Value, const sumOp<scalar>& bop)
+void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
 {
     if (!Pstream::parRun())
     {
@@ -426,6 +428,4 @@ void reduce(scalar& Value, const sumOp<scalar>& bop)
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
index bc36491fa74f1cab760a3b4cac922bb1e715be63..0920b5364031ababb221ca57f8b4611b706ec9ce 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutAndRemove/meshCutAndRemove.C
@@ -653,7 +653,7 @@ void Foam::meshCutAndRemove::setRefinement
             const edge& e = mesh().edges()[edgeI];
 
             // Check if there is any cell using this edge.
-            if (debug & findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
+            if (debug && findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
             {
                 FatalErrorIn
                 (
diff --git a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
index a86578e1851851802cb9fac2d3bb5541fd88223e..28e72d224a362720715272b1d266bb3be5c3ff54 100644
--- a/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
+++ b/src/dynamicMesh/meshCut/meshModifiers/meshCutter/meshCutter.C
@@ -601,7 +601,7 @@ void Foam::meshCutter::setRefinement
             const edge& e = mesh().edges()[edgeI];
 
             // Check if there is any cell using this edge.
-            if (debug & findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
+            if (debug && findCutCell(cuts, mesh().edgeCells()[edgeI]) == -1)
             {
                 FatalErrorIn
                 (
diff --git a/src/sampling/sampledSurface/patch/sampledPatch.C b/src/sampling/sampledSurface/patch/sampledPatch.C
index 2b4f636ee792aeb9ec682c08abf333f376680238..8ca36d42f5aa87566b8f8c160640d13c9e9e3879 100644
--- a/src/sampling/sampledSurface/patch/sampledPatch.C
+++ b/src/sampling/sampledSurface/patch/sampledPatch.C
@@ -140,7 +140,7 @@ Foam::sampledPatch::sampledPatch
     patchFaceLabels_(0)
 {
     // default: non-triangulated
-    triangulate() = getBool(dict, "triangulate", false);
+    triangulate() = dict.lookupOrDefault("triangulate", false);
     createGeometry();
 }
 
diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C
index 24ceb62aa6cde8e0dc71ce818f6de2e0010db08f..ef805c864238b8e6b4d07aa0eaf71ee37df974c4 100644
--- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.C
+++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.C
@@ -151,25 +151,6 @@ Foam::sampledSurface::New
     );
 }
 
-
-bool Foam::sampledSurface::getBool
-(
-    const dictionary& dict,
-    const word& key,
-    const bool defaultVal
-)
-{
-    if (dict.found(key))
-    {
-        return readBool(dict.lookup(key));
-    }
-    else
-    {
-        return defaultVal;
-    }
-}
-
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 Foam::sampledSurface::sampledSurface
@@ -200,8 +181,8 @@ Foam::sampledSurface::sampledSurface
 :
     name_(name),
     mesh_(mesh),
-    triangulate_(getBool(dict, "triangulate", true)),
-    interpolate_(getBool(dict, "interpolate", false)),
+    triangulate_(dict.lookupOrDefault("triangulate", true)),
+    interpolate_(dict.lookupOrDefault("interpolate", false)),
     SfPtr_(NULL),
     magSfPtr_(NULL),
     CfPtr_(NULL),
diff --git a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
index d91ff075e2b99d7410a3cb33058734b49da9c0dd..d143ee95aa7acf4387b93e9b94854f61b9dce915 100644
--- a/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
+++ b/src/sampling/sampledSurface/sampledSurface/sampledSurface.H
@@ -128,11 +128,6 @@ class sampledSurface
 
 protected:
 
-    // Protected static functions
-
-        //- Read bool from dictionary. Return provided value if not found
-        static bool getBool(const dictionary&, const word&, const bool);
-
     // Protected Member functions
 
         virtual void clearGeom() const;
diff --git a/wmake/wmake b/wmake/wmake
index 61def5bc6662643989954bf54540b0597a7f0984..1290fd556d49850d3ec5a5c552a643248ee43451 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -89,9 +89,16 @@ done
 
 make="make"
 
+# set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
+if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ]
+then
+   WM_NCOMPPROCS=$(wmakeScheduler -count)
+   [ $? -eq 0 ] || unset WM_NCOMPPROCS
+fi
+
 if [ "$WM_NCOMPPROCS" ]
 then
-    if [ "$WM_NCOMPPROCS" -ne 1 -a ! "$MAKEFLAGS" ]
+    if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
     then
         lockDir=$HOME/.wmakeScheduler
 
diff --git a/wmake/wmakeLockScheduler b/wmake/wmakeLockScheduler
deleted file mode 100755
index b8db7492f7905f8b2b7b265e707ca81594a001c2..0000000000000000000000000000000000000000
--- a/wmake/wmakeLockScheduler
+++ /dev/null
@@ -1,201 +0,0 @@
-#!/bin/bash
-#------------------------------------------------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
-#     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# Script
-#     wmakeScheduler
-#
-# Description
-#     Scheduler for network distributed compilations using wmake.
-#     - WM_HOSTS contains a list of hosts and number of concurrent processes
-#     eg,
-#        export WM_HOSTS="hostA:1 hostB:2 hostC:1"
-#     - WM_COLOURS contains a list of colours to cycle through
-#        export WM_COLOURS="black blue green cyan red magenta yellow"
-#
-#     Sources the relevant cshrc/bashrc if not set.
-#
-#     WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
-#     before calling this routine
-#
-# Usage
-#     wmakeScheduler COMMAND
-#         run 'COMMAND' on one of the slots listed in WM_HOSTS
-#
-#     wmakeScheduler -count
-#         count the total number of slots available in WM_HOSTS
-#         eg,  WM_NCOMPPROCS=$(wmakeScheduler -count)
-#
-#-------------------------------------------------------------------------------
-lockDir=$HOME/.wmakeScheduler
-
-# fallback - 1 core on current host
-: ${WM_HOSTS:=$HOST:1}
-
-# count the total number of slots available and exit
-if [ "$1" = "-count" ]
-then
-    expr $(
-        for slotGroup in $WM_HOSTS
-        do
-            n=${slotGroup##*:}
-            if [ "$n" = "${slotGroup%%:*}" ]; then n=1; fi # missing ':'
-            echo "+ ${n:-1}"
-        done)
-    exit 0
-fi
-
-# where to source WM_PROJECT settings in a remote shell
-# This code tries to figure out which cshrc or bashrc to execute.
-# !! Assumes remote computer running same shell and startup files
-# in same location
-
-sourceFoam=false    # fallback command
-case $SHELL in
-*/csh | */tcsh )    # [t]csh vs bash|ksh|sh
-    shellRc=cshrc
-    ;;
-*)
-    shellRc=bashrc
-    ;;
-esac
-
-# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/
-# check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
-# check ~/.$WM_PROJECT/
-# check <installedProject>/etc/
-# check <installedProject/.$WM_PROJECT-$WM_PROJECT_VERSION/
-if [ "$WM_PROJECT" ]; then
-
-    : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION}
-
-    for i in \
-        $HOME/$FOAM_DOT_DIR \
-        $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
-        $HOME/.$WM_PROJECT \
-        $WM_PROJECT_DIR/etc \
-        $WM_PROJECT_DIR/$FOAM_DOT_DIR \
-        ;
-    do
-        if [ -f "$i/$shellRc" ]; then
-            sourceFoam="$i/$shellRc"
-            break
-        fi
-    done
-fi
-
-# Construct test string for remote execution.
-# Source WM_PROJECT settings if WM_PROJECT environment not set.
-case $sourceFoam in
-    */cshrc)  sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam";;
-    */bashrc) sourceFoam='[ "$WM_PROJECT" ] || . '"$sourceFoam";;
-esac
-
-# quote double-quotes for remote command line
-rcmd=$(echo $* | sed -e s/\"/\'\"\'/g)
-## the same, without forking (not ksh, maybe not /bin/sh either)
-# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done)
-
-
-# Convert WM_COLOURS into an array
-declare colours
-nColours=0
-for col in $WM_COLOURS
-do
-    colours[$nColours]=$col
-    ((nColours = $nColours + 1))
-done
-
-# Bashism: make pipe fail early. This make sure return value of compilation
-# is returned and not of colouring pipe.
-set -o pipefail
-
-# Define function to colour output by argument 1
-colourPipe(){
-    if [ "$1" ]; then
-        (while read line; do setterm -foreground $1; echo "$line" ; done; setterm -foreground default)
-    else
-        cat
-    fi
-}
-
-
-colourIndex=0
-
-while :
-do
-    for slotGroup in $WM_HOSTS
-    do
-        # split 'host:N', but catch 'host:' and 'host' too
-        host=${slotGroup%%:*}
-        n=${slotGroup##*:}
-        if [ "$n" = "$host" ]; then n=1; fi # missing ':'
-        : ${n:=1}
-
-        i=0
-        while [ "$i" -lt "$n" ]
-        do
-            lockFile="$lockDir/$host:$i"
-            if lockfile -r0 "$lockFile" 2>/dev/null; then
-                # Set colour
-                colour=${colours[$colourIndex]}
-                #echo "** host=$host  colourIndex=$colourIndex  colour=$colour"
-
-                if [ "$host" = "$HOST" ]; then
-                    if [ "$colour" ]; then
-                        eval $* 2>&1 | colourPipe $colour
-                    else
-                        eval $*
-                    fi
-                elif [ -n "$JOB_ID" ]; then
-                    qrsh -inherit -v PWD $host "$rcmd"
-                else
-                    if [ "$colour" ]; then
-                        ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe $colour
-                    else
-                        ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd"
-                    fi
-                fi
-                retval=$?
-
-                # Release lock
-                rm -f "$lockFile" 2>/dev/null
-                exit $retval
-            fi
-            i=$(expr $i + 1)
-
-            # Cycle through colours
-            colourIndex=$(expr $colourIndex + 1)
-            if (( $colourIndex >= $nColours )); then
-                colourIndex=0
-            fi
-        done
-    done
-done
-
-if [ "$WM_COLOURS" ]; then
-    setterm -foreground default
-fi
-
-#------------------------------------------------------------------------------
diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler
index 1be15abd87cc87ff74e457ba317271df2ed29d66..14f4d9040284cdcd1b3b4720d3c718cd0c36a4f4 100755
--- a/wmake/wmakeScheduler
+++ b/wmake/wmakeScheduler
@@ -37,7 +37,8 @@
 #     Sources the relevant cshrc/bashrc if not set.
 #
 #     WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
-#     before calling this routine
+#     before calling this routine.
+#     FOAM_INST_DIR may possibly have been set (to find installation)
 #
 # Usage
 #     wmakeScheduler COMMAND
@@ -45,7 +46,7 @@
 #
 #     wmakeScheduler -count
 #         count the total number of slots available in WM_HOSTS
-#         eg,  WM_NCOMPPROCS=$(wmakeScheduler -count)
+#         eg,  export WM_NCOMPPROCS=$(wmakeScheduler -count)
 #
 #-------------------------------------------------------------------------------
 lockDir=$HOME/.wmakeScheduler
@@ -81,21 +82,15 @@ case $SHELL in
     ;;
 esac
 
-# check ~/.$WM_PROJECT-$WM_PROJECT_VERSION/
 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
 # check ~/.$WM_PROJECT/
 # check <installedProject>/etc/
-# check <installedProject/.$WM_PROJECT-$WM_PROJECT_VERSION/
 if [ "$WM_PROJECT" ]; then
 
-   : ${FOAM_DOT_DIR:=.$WM_PROJECT-$WM_PROJECT_VERSION}
-
    for i in \
-      $HOME/$FOAM_DOT_DIR \
       $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
       $HOME/.$WM_PROJECT \
       $WM_PROJECT_DIR/etc \
-      $WM_PROJECT_DIR/$FOAM_DOT_DIR \
       ;
    do
       if [ -f "$i/$shellRc" ]; then
@@ -203,7 +198,7 @@ do
             fi
         done
     done
-    # Not found any free slots. Rest a bit.
+    # Did not find any free slots. Rest a bit.
     sleep 1
 done