From c6520033c9c404d28000acd66d236f6a49ca9c83 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 15 Oct 2018 16:16:12 +0200
Subject: [PATCH] ENH: rationalize dictionary access methods

- use keyType::option enum to consolidate searching options.
  These enumeration names should be more intuitive to use
  and improve code readability.

    Eg,   lookupEntry(key, keyType::REGEX);
    vs    lookupEntry(key, false, true);

  or

    Eg,   lookupEntry(key, keyType::LITERAL_RECURSIVE);
    vs    lookupEntry(key, true, false);

- new findEntry(), findDict(), findScoped() methods with consolidated
  search options for shorter naming and access names more closely
  aligned with other components. Behave simliarly to the
  methods lookupEntryPtr(), subDictPtr(), lookupScopedEntryPtr(),
  respectively. Default search parameters consistent with lookupEntry().

    Eg, const entry* e = dict.findEntry(key);
    vs  const entry* e = dict.lookupEntryPtr(key, false, true);

- added '*' and '->' dereference operators to dictionary searchers.
---
 .../test/dictionary/Test-dictionary.C         |  22 +-
 .../Test-fvSolutionCombine.C                  |  12 +-
 .../cellSizeFunction/cellSizeFunction.C       |   8 +-
 .../conformalVoronoiMeshCalcDualMesh.C        |   2 +-
 .../conformationSurfaces.C                    |   2 +-
 .../generation/snappyHexMesh/snappyHexMesh.C  |   2 +-
 .../foamDictionary/foamDictionary.C           |  28 +-
 .../profilingSummary/profilingSummary.C       |  24 +-
 .../changeDictionary/changeDictionary.C       |  40 +-
 src/OpenFOAM/db/Time/Time.C                   |   4 +-
 src/OpenFOAM/db/Time/TimeIO.C                 |  10 +-
 src/OpenFOAM/db/dictionary/dictionary.C       | 128 ++--
 src/OpenFOAM/db/dictionary/dictionary.H       | 569 +++++++++++-------
 src/OpenFOAM/db/dictionary/dictionaryCompat.C |  31 +-
 src/OpenFOAM/db/dictionary/dictionaryIO.C     |  19 +-
 src/OpenFOAM/db/dictionary/dictionarySearch.C |  97 ++-
 .../db/dictionary/dictionaryTemplates.C       |  60 +-
 src/OpenFOAM/db/dictionary/entry/entryIO.C    |  12 +-
 .../functionEntries/removeEntry/removeEntry.C |   3 +-
 .../primitiveEntry/primitiveEntry.C           |   3 +-
 .../db/dynamicLibrary/codedBase/codedBase.C   |   6 +-
 .../dynamicCode/dynamicCodeContext.C          |  30 +-
 .../functionObjectList/functionObjectList.C   |   8 +-
 src/OpenFOAM/global/debug/debug.C             |  23 +-
 .../fileOperation/fileOperation.C             |   3 +-
 .../lduMatrix/lduMatrixPreconditioner.C       |  13 +-
 .../lduMatrix/lduMatrix/lduMatrixSmoother.C   |  12 +-
 src/OpenFOAM/matrices/solution/solution.C     |  19 +-
 .../Function1/Function1/Function1New.C        |   2 +-
 .../primitives/strings/keyType/keyType.H      |  22 +-
 .../primitives/strings/keyType/keyTypeI.H     |   4 +-
 .../primitives/strings/stringOps/stringOps.C  |  16 +-
 .../primitives/strings/wordRe/wordRe.H        |  16 +-
 .../motionSmoother/motionSmootherAlgoCheck.C  |  67 ++-
 .../solutionControl/loopControl/loopControl.C |   7 +-
 .../codedFunctionObject/codedFunctionObject.C |  37 +-
 .../general/codedSource/CodedSourceIO.C       |  27 +-
 src/lumpedPointMotion/lumpedPointMovement.C   |   4 +-
 .../blockDescriptor/blockDescriptor.C         |   2 +-
 .../blockMesh/blockMesh/blockMeshTopology.C   |   2 +-
 .../blockMesh/blockMeshTools/blockMeshTools.C |  13 +-
 .../blockVertices/blockVertex/blockVertex.C   |   4 +-
 .../blockVertices/namedVertex/namedVertex.C   |   4 +-
 .../blockMesh/blocks/namedBlock/namedBlock.C  |   4 +-
 .../meshRefinementProblemCells.C              |   3 +-
 .../refinementSurfaces/refinementSurfaces.C   |   3 +-
 .../shellSurfaces/shellSurfaces.C             |  23 +-
 .../coordinate/systems/coordinateSystem.C     |   2 +-
 .../coordinate/systems/coordinateSystemNew.C  |   2 +-
 .../triSurfaceMesh/triSurfaceMesh.C           |   6 +-
 .../dynamicOversetFvMesh.C                    |   4 +-
 .../oversetPolyPatch/oversetFvPatchField.C    |   4 +-
 .../decompositionMethod/decompositionMethod.C |   2 +-
 .../multiLevelDecomp/multiLevelDecomp.C       |   8 +-
 .../decompose/metisDecomp/metisDecomp.C       |   2 +-
 .../regionModel/regionModel/regionModel.C     |  20 +-
 56 files changed, 758 insertions(+), 742 deletions(-)

diff --git a/applications/test/dictionary/Test-dictionary.C b/applications/test/dictionary/Test-dictionary.C
index 393aafe4822..bddadce6fe6 100644
--- a/applications/test/dictionary/Test-dictionary.C
+++ b/applications/test/dictionary/Test-dictionary.C
@@ -82,8 +82,8 @@ int main(int argc, char *argv[])
             Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc()
                 << endl;
 
-            dictionary dict3(dict2.subDictPtr("boundaryField"));
-            dictionary dict4(dict2.subDictPtr("NONEXISTENT"));
+            dictionary dict3(dict2.findDict("boundaryField"));
+            dictionary dict4(dict2.findDict("NONEXISTENT"));
 
             Info<< "dictionary construct from pointer" << nl
                 << "ok = " << dict3.name() << " " << dict3.toc() << nl
@@ -105,23 +105,17 @@ int main(int argc, char *argv[])
             Info<< "Pattern find \"abc\" in top directory : "
                 << dict.lookup("abc") << endl;
             Info<< "Pattern find \"abc\" in sub directory : "
-                << dict.subDict("someDict").lookup("abc")
-                    << endl;
+                << dict.subDict("someDict").lookup("abc") << nl;
             Info<< "Recursive pattern find \"def\" in sub directory : "
-                << dict.subDict("someDict").lookup("def", true)
-                    << endl;
+                << dict.subDict("someDict").lookup("def", true) << nl;
             Info<< "Recursive pattern find \"foo\" in sub directory : "
-                << dict.subDict("someDict").lookup("foo", true)
-                    << endl;
+                << dict.subDict("someDict").lookup("foo", true) << nl;
             Info<< "Recursive pattern find \"fooz\" in sub directory : "
-                << dict.subDict("someDict").lookup("fooz", true)
-                    << endl;
+                << dict.subDict("someDict").lookup("fooz", true) << nl;
             Info<< "Recursive pattern find \"bar\" in sub directory : "
-                << dict.subDict("someDict").lookup("bar", true)
-                    << endl;
+                << dict.subDict("someDict").lookup("bar", true) << nl;
             Info<< "Recursive pattern find \"xxx\" in sub directory : "
-                << dict.subDict("someDict").lookup("xxx", true)
-                    << endl;
+                << dict.subDict("someDict").lookup("xxx", true) << nl;
         }
     }
     else
diff --git a/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C b/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
index c844c8286b9..f3ed8436804 100644
--- a/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
+++ b/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C
@@ -52,20 +52,16 @@ bool checkDictionaryContent(const dictionary& dict1, const dictionary& dict2)
 
     forAllConstIter(dictionary, dict1, iter1)
     {
-        const entry* entryPtr = dict2.lookupEntryPtr
-        (
-            iter1().keyword(),
-            false,
-            false
-        );
+        const entry* eptr =
+            dict2.findEntry(iter1().keyword(), keyType::LITERAL);
 
-        if (!entryPtr)
+        if (!eptr)
         {
             return false;
         }
 
         const entry& entry1 = iter1();
-        const entry& entry2 = *entryPtr;
+        const entry& entry2 = *eptr;
 
         bool ok = false;
         if (entry1.isDict())
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C
index 740b807f40b..ca4e3280e39 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C
@@ -63,9 +63,13 @@ Foam::cellSizeFunction::cellSizeFunction
     defaultCellSize_(defaultCellSize),
     regionIndices_(regionIndices),
     sideMode_(),
-    priority_(cellSizeFunctionDict.get<label>("priority", true))
+    priority_
+    (
+        cellSizeFunctionDict.get<label>("priority", keyType::REGEX_RECURSIVE)
+    )
 {
-    const word mode = cellSizeFunctionDict.get<word>("mode", true);
+    const word mode =
+        cellSizeFunctionDict.get<word>("mode", keyType::REGEX_RECURSIVE);
 
     if (surface_.hasVolumeType())
     {
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
index 00bad93cd88..d6f1256074a 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
@@ -837,7 +837,7 @@ void Foam::conformalVoronoiMesh::checkCellSizing()
         = dict.subDict("meshQualityControls");
 
     const scalar maxNonOrtho =
-        meshQualityDict.get<scalar>("maxNonOrtho", true);
+        meshQualityDict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE);
 
     label nWrongFaces = 0;
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C
index bc71e6d0f19..fba263b4643 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C
@@ -339,7 +339,7 @@ Foam::conformationSurfaces::conformationSurfaces
     {
         const word& geomName = allGeometry_.names()[geomI];
 
-        const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
+        const entry* ePtr = surfacesDict.findEntry(geomName, keyType::REGEX);
 
         if (ePtr)
         {
diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C
index 5daa5766fe6..5a7da19bb7b 100644
--- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C
+++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C
@@ -125,7 +125,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
     {
         const word& geomName = allGeometry.names()[geomi];
 
-        const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
+        const entry* ePtr = surfacesDict.findEntry(geomName, keyType::REGEX);
 
         if (ePtr)
         {
diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C
index dee2956e076..ce2e7ae1017 100644
--- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C
+++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C
@@ -170,9 +170,10 @@ class dictAndKeyword
     word key_;
 
 public:
+
     dictAndKeyword(const word& scopedName)
     {
-        string::size_type i = scopedName.rfind('/');
+        auto i = scopedName.rfind('/');
         if (i == string::npos)
         {
             i = scopedName.rfind('.');
@@ -212,7 +213,7 @@ const dictionary& lookupScopedDict
         return dict;
     }
 
-    const entry* eptr = dict.lookupScopedEntryPtr(subDictName, false, false);
+    const entry* eptr = dict.findScoped(subDictName, keyType::LITERAL);
 
     if (!eptr || !eptr->isDict())
     {
@@ -231,7 +232,7 @@ void removeDict(dictionary& dict, const dictionary& dictToRemove)
 {
     for (const entry& refEntry : dictToRemove)
     {
-        auto finder = dict.search(refEntry.keyword(), false, false);
+        auto finder = dict.search(refEntry.keyword(), keyType::LITERAL);
 
         bool purge = false;
 
@@ -357,8 +358,7 @@ int main(int argc, char *argv[])
     bool changed = false;
 
     // Read but preserve headers
-    dictionary dict;
-    dict.read(dictFile(), true);
+    dictionary dict(dictFile(), true);
 
     if (listIncludes)
     {
@@ -455,12 +455,7 @@ int main(int argc, char *argv[])
             changed = true;
 
             // Print the changed entry
-            const auto finder = dict.csearchScoped
-            (
-                scopedName,
-                false,
-                true  // Support wildcards
-            );
+            const auto finder = dict.csearchScoped(scopedName, keyType::REGEX);
 
             if (finder.found())
             {
@@ -489,8 +484,8 @@ int main(int argc, char *argv[])
                 const dictionary& d1(lookupScopedDict(dict, dAk.dict()));
                 const dictionary& d2(lookupScopedDict(diffDict, dAk.dict()));
 
-                const entry* e1Ptr = d1.lookupEntryPtr(dAk.key(), false, true);
-                const entry* e2Ptr = d2.lookupEntryPtr(dAk.key(), false, true);
+                const entry* e1Ptr = d1.findEntry(dAk.key(), keyType::REGEX);
+                const entry* e2Ptr = d2.findEntry(dAk.key(), keyType::REGEX);
 
                 if (e1Ptr && e2Ptr)
                 {
@@ -509,12 +504,7 @@ int main(int argc, char *argv[])
                 }
             }
 
-            const auto finder = dict.csearchScoped
-            (
-                scopedName,
-                false,
-                true  // Support wildcards
-            );
+            const auto finder = dict.csearchScoped(scopedName, keyType::REGEX);
 
             if (!finder.found())
             {
diff --git a/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C b/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C
index 920ba165a57..357c889d8a3 100644
--- a/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C
+++ b/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
 
                 // Assumed to be good if it has 'profiling' sub-dict
 
-                const dictionary* ptr = dict.subDictPtr(blockNameProfiling);
+                const dictionary* ptr = dict.findDict(blockNameProfiling);
                 if (ptr)
                 {
                     ++nDict;
@@ -295,13 +295,12 @@ int main(int argc, char *argv[])
 
                 for (const dictionary& procDict : profiles)
                 {
-                    const dictionary* inDictPtr =
-                        procDict.subDictPtr(level1Name);
+                    const dictionary* inDictPtr = procDict.findDict(level1Name);
 
                     if (inDictPtr && hasDictEntries)
                     {
-                        // descend to the next level as required
-                        inDictPtr = inDictPtr->subDictPtr(level2Name);
+                        // Descend to the next level as required
+                        inDictPtr = inDictPtr->findDict(level2Name);
                     }
 
                     if (!inDictPtr)
@@ -313,16 +312,13 @@ int main(int argc, char *argv[])
 
                     for (const word& tag : tags)
                     {
-                        const entry* eptr = inDictPtr->lookupEntryPtr
-                        (
-                            tag,
-                            false,
-                            false
-                        );
+                        scalar val;
 
-                        if (eptr)
+                        if
+                        (
+                            inDictPtr->readIfPresent(tag, val, keyType::LITERAL)
+                        )
                         {
-                            const scalar val = readScalar(eptr->stream());
                             stats(tag).append(val);
                         }
                     }
@@ -339,7 +335,7 @@ int main(int argc, char *argv[])
                 if (hasDictEntries)
                 {
                     outputDict.add(level2Name, level1Dict.subDict(level2Name));
-                    outDictPtr = outputDict.subDictPtr(level2Name);
+                    outDictPtr = outputDict.findDict(level2Name);
                 }
                 else
                 {
diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
index 8a39925f4fb..4e86ce0af93 100644
--- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
+++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C
@@ -235,10 +235,9 @@ bool merge
     // Save current (non-wildcard) keys before adding items.
     wordHashSet thisKeysSet;
     {
-        List<keyType> keys = thisDict.keys(false);
-        forAll(keys, i)
+        for (const word& k : thisDict.keys(false))
         {
-            thisKeysSet.insert(keys[i]);
+            thisKeysSet.insert(k);
         }
     }
 
@@ -261,25 +260,20 @@ bool merge
         }
         else if (literalRE || !(key.isPattern() || shortcuts.found(key)))
         {
-            entry* entryPtr = thisDict.lookupEntryPtr
-            (
-                key,
-                false,              // recursive
-                false               // patternMatch
-            );
+            entry* eptr = thisDict.findEntry(key, keyType::LITERAL);
 
-            if (entryPtr)
+            if (eptr)
             {
                 // Mark thisDict entry as having been match for wildcard
                 // handling later on.
-                thisKeysSet.erase(entryPtr->keyword());
+                thisKeysSet.erase(eptr->keyword());
 
                 if
                 (
                     addEntry
                     (
                         thisDict,
-                       *entryPtr,
+                       *eptr,
                         mergeIter(),
                         literalRE,
                         shortcuts
@@ -310,7 +304,7 @@ bool merge
 
     // Pass 2. Wildcard or shortcut matches (if any) on any non-match keys.
 
-    if (!literalRE && thisKeysSet.size() > 0)
+    if (!literalRE && thisKeysSet.size())
     {
         // Pick up remaining dictionary entries
         wordList thisKeys(thisKeysSet.toc());
@@ -336,10 +330,10 @@ bool merge
                 );
 
                 // Remove all matches
-                forAll(matches, i)
+                for (const label matchi : matches)
                 {
-                    const word& thisKey = thisKeys[matches[i]];
-                    thisKeysSet.erase(thisKey);
+                    const word& k = thisKeys[matchi];
+                    thisKeysSet.erase(k);
                 }
                 changed = true;
             }
@@ -358,21 +352,18 @@ bool merge
                 );
 
                 // Add all matches
-                forAll(matches, i)
+                for (const label matchi : matches)
                 {
-                    const word& thisKey = thisKeys[matches[i]];
+                    const word& k = thisKeys[matchi];
 
-                    entry& thisEntry = const_cast<entry&>
-                    (
-                        thisDict.lookupEntry(thisKey, false, false)
-                    );
+                    entry* eptr = thisDict.findEntry(k, keyType::LITERAL);
 
                     if
                     (
                         addEntry
                         (
                             thisDict,
-                            thisEntry,
+                           *eptr,
                             mergeIter(),
                             literalRE,
                             HashTable<wordList>(0)    // no shortcuts
@@ -627,8 +618,7 @@ int main(int argc, char *argv[])
                         fieldDict.lookupEntry
                         (
                             doneKeys[i],
-                            false,
-                            true
+                            keyType::REGEX
                         ).clone()
                     );
                     fieldDict.remove(doneKeys[i]);
diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C
index d85d0e33898..51b3819f88b 100644
--- a/src/OpenFOAM/db/Time/Time.C
+++ b/src/OpenFOAM/db/Time/Time.C
@@ -342,11 +342,11 @@ void Foam::Time::setControls()
 
 void Foam::Time::setMonitoring(const bool forceProfiling)
 {
-    const dictionary* profilingDict = controlDict_.subDictPtr("profiling");
+    const dictionary* profilingDict = controlDict_.findDict("profiling");
     if (!profilingDict)
     {
         // ... or from etc/controlDict
-        profilingDict = debug::controlDict().subDictPtr("profiling");
+        profilingDict = debug::controlDict().findDict("profiling");
     }
 
     // initialize profiling on request
diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C
index 9fb3cc0c703..ea45f1b2f38 100644
--- a/src/OpenFOAM/db/Time/TimeIO.C
+++ b/src/OpenFOAM/db/Time/TimeIO.C
@@ -99,7 +99,7 @@ void Foam::Time::readDict()
     // DebugSwitches
     if
     (
-        (localDict = controlDict_.subDictPtr("DebugSwitches")) != nullptr
+        (localDict = controlDict_.findDict("DebugSwitches")) != nullptr
      && localDict->size()
     )
     {
@@ -146,7 +146,7 @@ void Foam::Time::readDict()
     // InfoSwitches
     if
     (
-        (localDict = controlDict_.subDictPtr("InfoSwitches")) != nullptr
+        (localDict = controlDict_.findDict("InfoSwitches")) != nullptr
      && localDict->size()
     )
     {
@@ -192,7 +192,7 @@ void Foam::Time::readDict()
     // OptimisationSwitches
     if
     (
-        (localDict = controlDict_.subDictPtr("OptimisationSwitches")) != nullptr
+        (localDict = controlDict_.findDict("OptimisationSwitches")) != nullptr
      && localDict->size()
     )
     {
@@ -273,7 +273,7 @@ void Foam::Time::readDict()
     if
     (
 
-        (localDict = controlDict_.subDictPtr("DimensionedConstants")) != nullptr
+        (localDict = controlDict_.findDict("DimensionedConstants")) != nullptr
      && localDict->size()
     )
     {
@@ -310,7 +310,7 @@ void Foam::Time::readDict()
     // DimensionSets
     if
     (
-        (localDict = controlDict_.subDictPtr("DimensionSets")) != nullptr
+        (localDict = controlDict_.findDict("DimensionSets")) != nullptr
         && localDict->size()
     )
     {
diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C
index 125c73e1279..4cdc9a754c3 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.C
+++ b/src/OpenFOAM/db/dictionary/dictionary.C
@@ -134,13 +134,14 @@ void Foam::dictionary::checkITstream
 
 Foam::dictionary::dictionary()
 :
+    name_(),
     parent_(dictionary::null)
 {}
 
 
 Foam::dictionary::dictionary(const fileName& name)
 :
-    dictionaryName(name),
+    name_(name),
     parent_(dictionary::null)
 {}
 
@@ -151,8 +152,8 @@ Foam::dictionary::dictionary
     const dictionary& dict
 )
 :
-    dictionaryName(dict.name()),
     parent_type(dict, *this),
+    name_(dict.name()),
     parent_(parentDict)
 {
     forAllIter(parent_type, *this, iter)
@@ -173,8 +174,8 @@ Foam::dictionary::dictionary
     const dictionary& dict
 )
 :
-    dictionaryName(dict.name()),
     parent_type(dict, *this),
+    name_(dict.name()),
     parent_(dictionary::null)
 {
     forAllIter(parent_type, *this, iter)
@@ -190,16 +191,14 @@ Foam::dictionary::dictionary
 }
 
 
-Foam::dictionary::dictionary
-(
-    const dictionary* dictPtr
-)
+Foam::dictionary::dictionary(const dictionary* dict)
 :
+    name_(),
     parent_(dictionary::null)
 {
-    if (dictPtr)
+    if (dict)
     {
-        operator=(*dictPtr);
+        operator=(*dict);
     }
 }
 
@@ -210,6 +209,7 @@ Foam::dictionary::dictionary
     dictionary&& dict
 )
 :
+    name_(),
     parent_(parentDict)
 {
     transfer(dict);
@@ -222,6 +222,7 @@ Foam::dictionary::dictionary
     dictionary&& dict
 )
 :
+    name_(),
     parent_(dictionary::null)
 {
     transfer(dict);
@@ -310,44 +311,50 @@ Foam::tokenList Foam::dictionary::tokens() const
 bool Foam::dictionary::found
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return csearch(keyword, recursive, patternMatch).found();
+    return csearch(keyword, matchOpt).found();
+}
+
+
+Foam::entry* Foam::dictionary::findEntry
+(
+    const word& keyword,
+    enum keyType::option matchOpt
+)
+{
+    return search(keyword, matchOpt).ptr();
 }
 
 
-const Foam::entry* Foam::dictionary::lookupEntryPtr
+const Foam::entry* Foam::dictionary::findEntry
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return csearch(keyword, recursive, patternMatch).ptr();
+    return csearch(keyword, matchOpt).ptr();
 }
 
 
-Foam::entry* Foam::dictionary::lookupEntryPtr
+const Foam::entry* Foam::dictionary::findScoped
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
-)
+    enum keyType::option matchOpt
+) const
 {
-    return search(keyword, recursive, patternMatch).ptr();
+    return csearchScoped(keyword, matchOpt).ptr();
 }
 
 
 const Foam::entry& Foam::dictionary::lookupEntry
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    const const_searcher finder(csearch(keyword, recursive, patternMatch));
+    const const_searcher finder(csearch(keyword, matchOpt));
 
     if (!finder.found())
     {
@@ -364,22 +371,10 @@ const Foam::entry& Foam::dictionary::lookupEntry
 Foam::ITstream& Foam::dictionary::lookup
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return lookupEntry(keyword, recursive, patternMatch).stream();
-}
-
-
-const Foam::entry* Foam::dictionary::lookupScopedEntryPtr
-(
-    const word& keyword,
-    bool recursive,
-    bool patternMatch
-) const
-{
-    return csearchScoped(keyword, recursive, patternMatch).ptr();
+    return lookupEntry(keyword, matchOpt).stream();
 }
 
 
@@ -394,7 +389,7 @@ bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry)
     const word varName(keyword.substr(1), false);
 
     // Lookup the variable name in the given dictionary
-    const const_searcher finder(csearch(varName, true, true));
+    const const_searcher finder(csearch(varName, keyType::REGEX_RECURSIVE));
 
     // If defined insert its entries into this dictionary
     if (finder.found())
@@ -428,7 +423,7 @@ bool Foam::dictionary::substituteScopedKeyword
     const word varName(keyword.substr(1), false);
 
     // Lookup the variable name in the given dictionary
-    const const_searcher finder(csearchScoped(varName, true, true));
+    const auto finder(csearchScoped(varName, keyType::REGEX_RECURSIVE));
 
     // If defined insert its entries into this dictionary
     if (finder.found())
@@ -449,29 +444,35 @@ bool Foam::dictionary::substituteScopedKeyword
 
 bool Foam::dictionary::isDict(const word& keyword) const
 {
-    // Find non-recursive with patterns
-    return csearch(keyword, false, true).isDict();
+    // Allow patterns, non-recursive
+    return csearch(keyword, keyType::REGEX).isDict();
 }
 
 
-const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
+Foam::dictionary* Foam::dictionary::findDict
+(
+    const word& keyword,
+    enum keyType::option matchOpt
+)
 {
-    // Find non-recursive with patterns
-    return csearch(keyword, false, true).dictPtr();
+    return search(keyword, matchOpt).dictPtr();
 }
 
 
-Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword)
+const Foam::dictionary* Foam::dictionary::findDict
+(
+    const word& keyword,
+    enum keyType::option matchOpt
+) const
 {
-    // Find non-recursive with patterns
-    return search(keyword, false, true).dictPtr();
+    return csearch(keyword, matchOpt).dictPtr();
 }
 
 
 const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
 {
-    // Find non-recursive with patterns
-    const const_searcher finder(csearch(keyword, false, true));
+    // Allow patterns, non-recursive
+    const const_searcher finder(csearch(keyword, keyType::REGEX));
 
     if (!finder.found())
     {
@@ -487,8 +488,8 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
 
 Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
 {
-    // Find non-recursive with patterns
-    searcher finder = search(keyword, false, true);
+    // Allow patterns, non-recursive
+    searcher finder(search(keyword, keyType::REGEX));
 
     if (!finder.found())
     {
@@ -508,8 +509,8 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
     const bool mandatory
 ) const
 {
-    // Find non-recursive with patterns
-    const const_searcher finder(csearch(keyword, false, true));
+    // Allow patterns, non-recursive
+    const const_searcher finder(csearch(keyword, keyType::REGEX));
 
     if (finder.isDict())
     {
@@ -543,7 +544,8 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
     const word& keyword
 ) const
 {
-    const const_searcher finder(csearch(keyword, false, true));
+    // Allow patterns, non-recursive
+    const const_searcher finder(csearch(keyword, keyType::REGEX));
 
     if (finder.isDict())
     {
@@ -565,15 +567,15 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
 
 Foam::wordList Foam::dictionary::toc() const
 {
-    wordList keys(size());
+    wordList list(size());
 
     label n = 0;
     forAllConstIters(*this, iter)
     {
-        keys[n++] = iter().keyword();
+        list[n++] = iter().keyword();
     }
 
-    return keys;
+    return list;
 }
 
 
@@ -585,19 +587,19 @@ Foam::wordList Foam::dictionary::sortedToc() const
 
 Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
 {
-    List<keyType> keys(size());
+    List<keyType> list(size());
 
     label n = 0;
     forAllConstIters(*this, iter)
     {
         if (iter().keyword().isPattern() ? patterns : !patterns)
         {
-            keys[n++] = iter().keyword();
+            list[n++] = iter().keyword();
         }
     }
-    keys.setSize(n);
+    list.resize(n);
 
-    return keys;
+    return list;
 }
 
 
@@ -746,7 +748,7 @@ Foam::entry* Foam::dictionary::set(entry* entryPtr)
     }
 
     // Find non-recursive with patterns
-    searcher finder(search(entryPtr->keyword(), false, true));
+    searcher finder(search(entryPtr->keyword(), keyType::REGEX));
 
     // Clear dictionary so merge acts like overwrite
     if (finder.isDict())
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index 6364c722cba..b031835b00b 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -112,70 +112,12 @@ class SHA1Digest;
 Istream& operator>>(Istream& is, dictionary& dict);
 Ostream& operator<<(Ostream& os, const dictionary& dict);
 
-/*---------------------------------------------------------------------------*\
-                        Class dictionaryName Declaration
-\*---------------------------------------------------------------------------*/
-
-//- Holds name for a dictionary
-class dictionaryName
-{
-    // Private data
-
-        fileName name_;
-
-
-public:
-
-    // Constructors
-
-        //- Construct null
-        dictionaryName()
-        {}
-
-        //- Construct as copy of the given fileName
-        dictionaryName(const fileName& name)
-        :
-            name_(name)
-        {}
-
-
-    // Member functions
-
-        //- Return the dictionary name
-        const fileName& name() const
-        {
-            return name_;
-        }
-
-        //- Return the dictionary name for modification (use with caution).
-        fileName& name()
-        {
-            return name_;
-        }
-
-        //- Return the local dictionary name (final part of scoped name)
-        word dictName() const
-        {
-            word scopedName(name_.name());
-
-            const auto i = scopedName.rfind('.');
-            if (i == std::string::npos)
-            {
-                return scopedName;
-            }
-
-            return scopedName.substr(i+1);
-        }
-};
-
-
 /*---------------------------------------------------------------------------*\
                          Class dictionary Declaration
 \*---------------------------------------------------------------------------*/
 
 class dictionary
 :
-    public dictionaryName,
     public IDLList<entry>
 {
 public:
@@ -250,7 +192,7 @@ public:
             {}
 
 
-            //- Entry was found.
+            //- True if entry was found
             inline bool found() const
             {
                 return eptr_;
@@ -298,6 +240,18 @@ public:
             {
                 return *reinterpret_cast<const Searcher<!Const>*>(this);
             }
+
+            //- A pointer to the entry (nullptr if not found)
+            pointer operator->() const
+            {
+                return eptr_;
+            }
+
+            //- A reference to the entry (Error if not found)
+            reference operator*() const
+            {
+                return *eptr_;
+            }
         };
 
 
@@ -326,6 +280,9 @@ private:
         //  Set/unset via an InfoSwitch
         static bool writeOptionalEntries;
 
+        //- The dictionary name
+        fileName name_;
+
         //- Parent dictionary
         const dictionary& parent_;
 
@@ -353,6 +310,21 @@ private:
 
     // Private Member Functions
 
+        //- Convert old-style (1806) boolean search specification to enum
+        //
+        //  \param recursive search parent dictionaries
+        //  \param pattern match using regular expressions as well
+        static inline enum keyType::option
+        matchOpt(bool recursive, bool pattern)
+        {
+            return
+                keyType::option
+                (
+                    (pattern ? keyType::REGEX : keyType::LITERAL)
+                  | (recursive ? keyType::RECURSIVE : 0)
+                );
+        }
+
         //- Search using a '.' for scoping.
         //  A leading dot means to use the parent dictionary.
         //  An intermediate dot separates a sub-dictionary or sub-entry.
@@ -363,13 +335,11 @@ private:
         //  The heuristic tries successively longer top-level entries
         //  until there is a suitable match.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the search mode
         const_searcher csearchDotScoped
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option matchOpt
         ) const;
 
         //- Search using a '/' for scoping.
@@ -379,11 +349,11 @@ private:
         //  ambiguity between separator and content.
         //  No possibility or need for recursion.
         //
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the search mode. Recursive is ignored.
         const_searcher csearchSlashScoped
         (
             const word& keyword,
-            bool patternMatch
+            enum keyType::option matchOpt
         ) const;
 
 
@@ -411,16 +381,17 @@ public:
         explicit dictionary(const fileName& name);
 
         //- Construct given the entry name, parent dictionary and Istream,
-        //- reading entries until EOF
+        //- reading entries until EOF, optionally keeping the header
         dictionary
         (
             const fileName& name,
             const dictionary& parentDict,
-            Istream& is
+            Istream& is,
+            bool keepHeader = false
         );
 
         //- Construct top-level dictionary from Istream,
-        //- reading entries until EOF
+        //- reading entries until EOF. Discards the header.
         dictionary(Istream& is);
 
         //- Construct top-level dictionary from Istream,
@@ -435,7 +406,7 @@ public:
 
         //- Construct top-level dictionary as copy from pointer to dictionary.
         //  A null pointer is treated like an empty dictionary.
-        dictionary(const dictionary* dictPtr);
+        dictionary(const dictionary* dict);
 
         //- Move construct for given parent dictionary
         dictionary(const dictionary& parentDict, dictionary&& dict);
@@ -458,6 +429,32 @@ public:
 
     // Access
 
+        //- The dictionary name
+        const fileName& name() const
+        {
+            return name_;
+        }
+
+        //- The dictionary name for modification (use with caution).
+        fileName& name()
+        {
+            return name_;
+        }
+
+        //- The local dictionary name (final part of scoped name)
+        word dictName() const
+        {
+            word scopedName(name_.name());
+
+            const auto i = scopedName.rfind('.');
+            if (i == std::string::npos)
+            {
+                return scopedName;
+            }
+
+            return scopedName.substr(i+1);
+        }
+
         //- Return the parent dictionary
         const dictionary& parent() const
         {
@@ -482,131 +479,137 @@ public:
 
     // Search and lookup
 
-        //- Search dictionary for given keyword.
-        //  Default search: non-recursive with patterns.
+        //- Search for an entry (const access) with the given keyword.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the default search is non-recursive with patterns
+        //
+        //  \return True if entry was found
         bool found
         (
             const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option matchOpt = keyType::REGEX
         ) const;
 
-        //- Find and return an entry pointer if present, or return a nullptr.
+        //- Find for an entry (non-const access) with the given keyword.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
-        const entry* lookupEntryPtr
+        //  \param matchOpt the search mode
+        //
+        //  \return the entry pointer found or a nullptr.
+        entry* findEntry
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option matchOpt = keyType::REGEX
+        );
+
+        //- Find an entry (const access) with the given keyword.
+        //
+        //  \param matchOpt the default search is non-recursive with patterns
+        //
+        //  \return the entry pointer found or a nullptr.
+        const entry* findEntry
+        (
+            const word& keyword,
+            enum keyType::option matchOpt = keyType::REGEX
         ) const;
 
-        //- Find and return an entry pointer for manipulation if present,
-        //- or return a nullptr.
+        //- Search for a scoped entry (const access) with the given keyword.
+        //  Allows scoping using '.'.
+        //  Special handling for an absolute anchor (^) at start of the keyword
+        //  and for '..' to ascend into the parent dictionaries.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
-        entry* lookupEntryPtr
+        //  \param matchOpt the default search is non-recursive with patterns
+        //
+        //  \return the entry pointer found or a nullptr.
+        const entry* findScoped
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option matchOpt = keyType::REGEX
+        ) const;
+
+        //- Find and return a sub-dictionary pointer if present
+        //  (and a sub-dictionary) otherwise return nullptr.
+        //
+        //  \param matchOpt the default search is non-recursive with patterns
+        dictionary* findDict
+        (
+            const word& keyword,
+            enum keyType::option matchOpt = keyType::REGEX
         );
 
-        //- Find and return an entry if present, otherwise FatalIOError.
+        //- Search for an entry (const access) with the given keyword.
+        //- Find and return a sub-dictionary pointer if present
+        //  (and a sub-dictionary) otherwise return nullptr.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the default search is non-recursive with patterns
+        const dictionary* findDict
+        (
+            const word& keyword,
+            enum keyType::option matchOpt = keyType::REGEX
+        ) const;
+
+        //
+        //  \param matchOpt the default search is non-recursive with patterns
+        //
+        //  \return return an entry if present, otherwise FatalIOError.
         const entry& lookupEntry
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option matchOpt
         ) const;
 
         //- Find and return a T.
-        //- FatalIOError if not found, or if there are excess tokens.
-        //  Default search: non-recursive with patterns.
+        //- FatalIOError if not found, or if the number of tokens is incorrect.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the default search is non-recursive with patterns
         template<class T>
         T get
         (
             const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option matchOpt = keyType::REGEX
         ) const;
 
         //- Find and return an entry data stream.
-        //  Default search: non-recursive with patterns.
+        //- FatalIOError if not found, or if the number of tokens is incorrect.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the default search is non-recursive with patterns
         ITstream& lookup
         (
             const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
-        ) const;
-
-        //- Find and return a T.
-        //- FatalIOError if not found, or if there are excess tokens.
-        //  Default search: non-recursive with patterns.
-        //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
-        //
-        //  \deprecated - same as the get() method
-        template<class T>
-        T lookupType
-        (
-            const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option matchOpt = keyType::REGEX
         ) const;
 
-        //- Find and return a T, or return the given default value
-        //- FatalIOError if it is found and there are excess tokens.
-        //  Default search: non-recursive with patterns.
+        //- Find and return a T, or return the given default value.
+        //- FatalIOError if it is found and the number of tokens is incorrect.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the default search is non-recursive with patterns
         template<class T>
         T lookupOrDefault
         (
             const word& keyword,
             const T& deflt,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option matchOpt = keyType::REGEX
         ) const;
 
         //- Find and return a T, or return the given default value
         //- and add it to dictionary.
-        //- FatalIOError if it is found and there are excess tokens.
-        //  Default search: non-recursive with patterns.
+        //- FatalIOError if it is found and the number of tokens is incorrect.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param matchOpt the default search is non-recursive with patterns
         template<class T>
         T lookupOrAddDefault
         (
             const word& keyword,
             const T& deflt,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option matchOpt = keyType::REGEX
         );
 
         //- Find entry and assign to T val.
-        //- FatalIOError if it is found and there are excess tokens.
-        //  Default search: non-recursive with patterns.
+        //- FatalIOError if it is found and the number of tokens is incorrect,
+        //- or it is mandatory and not found.
         //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param val the value to read into
+        //  \param matchOpt the default search is non-recursive with patterns
+        //  \param mandatory the keyword is mandatory
         //
         //  \return true if the entry was found.
         template<class T>
@@ -614,18 +617,16 @@ public:
         (
             const word& keyword,
             T& val,
-            bool recursive = false,
-            bool patternMatch = true,
+            enum keyType::option matchOpt = keyType::REGEX,
             bool mandatory = true
         ) const;
 
         //- Find an entry if present, and assign to T val.
-        //- FatalIOError if it is found and there are excess tokens.
+        //- FatalIOError if it is found and the number of tokens is incorrect.
         //  Default search: non-recursive with patterns.
         //
-        //  \param val the value to read
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
+        //  \param val the value to read into
+        //  \param matchOpt the default search is non-recursive with patterns
         //
         //  \return true if the entry was found.
         template<class T>
@@ -633,41 +634,14 @@ public:
         (
             const word& keyword,
             T& val,
-            bool recursive = false,
-            bool patternMatch = true
-        ) const;
-
-        //- Find and return an entry pointer if present, or return a nullptr.
-        //  Allows scoping using '.'.
-        //  Special handling for an absolute anchor (^) at start of the keyword
-        //  and for '..' to ascend into the parent dictionaries.
-        //
-        //  \param recursive search parent dictionaries
-        //  \param patternMatch use regular expressions
-        const entry* lookupScopedEntryPtr
-        (
-            const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option matchOpt = keyType::REGEX
         ) const;
 
-        //- Check if entry exists and is a sub-dictionary.
+        //- Check if entry is found and and is a sub-dictionary.
         //
         //  Search type: non-recursive with patterns.
         bool isDict(const word& keyword) const;
 
-        //- Find and return a sub-dictionary pointer if present
-        //  (and a sub-dictionary) otherwise return nullptr.
-        //
-        //  Search type: non-recursive with patterns.
-        const dictionary* subDictPtr(const word& keyword) const;
-
-        //- Find and return a sub-dictionary pointer if present
-        //  (and a sub-dictionary) otherwise return nullptr.
-        //
-        //  Search type: non-recursive with patterns.
-        dictionary* subDictPtr(const word& keyword);
-
         //- Find and return a sub-dictionary.
         //  Fatal if the entry does not exist or is not a sub-dictionary.
         //
@@ -856,8 +830,7 @@ public:
         const_searcher csearch
         (
             const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Search dictionary for given keyword
@@ -868,8 +841,7 @@ public:
         const_searcher search
         (
             const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Search dictionary for given keyword
@@ -880,8 +852,7 @@ public:
         searcher search
         (
             const word& keyword,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         );
 
         //- Search using scoping.
@@ -910,8 +881,7 @@ public:
         const_searcher csearchScoped
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option
         ) const;
 
         //- Search using dot or slash scoping.
@@ -921,8 +891,7 @@ public:
         const_searcher searchScoped
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option
         ) const;
 
         //- Search using dot or slash scoping.
@@ -932,25 +901,24 @@ public:
         searcher searchScoped
         (
             const word& keyword,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option
         );
 
         //- Locate a sub-dictionary using slash-scoping
         //  \return nullptr if the dictionary path does not exist
-        const dictionary* cfindScopedDictPtr(const fileName& dictPath) const;
+        const dictionary* cfindScopedDict(const fileName& dictPath) const;
 
         //- Locate a sub-dictionary using slash-scoping
         //  \return nullptr if the dictionary path does not exist
-        const dictionary* findScopedDictPtr(const fileName& dictPath) const;
+        const dictionary* findScopedDict(const fileName& dictPath) const;
 
         //- Locate a sub-dictionary using slash-scoping
         //  \return nullptr if the dictionary path does not exist
-        dictionary* findScopedDictPtr(const fileName& dictPath);
+        dictionary* findScopedDict(const fileName& dictPath);
 
         //- Locate existing or create sub-dictionary using slash-scoping
         //  \return nullptr if the dictionary path could not be created
-        dictionary* makeScopedDictPtr(const fileName& dictPath);
+        dictionary* makeScopedDict(const fileName& dictPath);
 
 
     // Compatibility helpers
@@ -969,8 +937,7 @@ public:
         (
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Search dictionary for given keyword and any compatibility names
@@ -984,8 +951,7 @@ public:
         (
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Find and return an entry pointer if present, or return a nullptr,
@@ -995,12 +961,11 @@ public:
         //      OpenFOAM version for which they were used.
         //  \param recursive search parent dictionaries
         //  \param patternMatch use regular expressions
-        const entry* lookupEntryPtrCompat
+        const entry* findCompat
         (
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option
         ) const;
 
         //- Find and return an entry if present, otherwise FatalIOError,
@@ -1014,8 +979,7 @@ public:
         (
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
-            bool recursive,
-            bool patternMatch
+            enum keyType::option
         ) const;
 
         //- Find and return a T
@@ -1032,8 +996,7 @@ public:
         (
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Find and return an entry data stream,
@@ -1048,8 +1011,7 @@ public:
         (
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Find and return a T, or return the given default value
@@ -1066,8 +1028,7 @@ public:
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
             const T& deflt,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
         //- Find entry and assign to T val
@@ -1088,8 +1049,7 @@ public:
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
             T& val,
-            bool recursive = false,
-            bool patternMatch = true,
+            enum keyType::option = keyType::REGEX,
             bool mandatory = true
         ) const;
 
@@ -1111,22 +1071,12 @@ public:
             const word& keyword,
             std::initializer_list<std::pair<const char*,int>> compat,
             T& val,
-            bool recursive = false,
-            bool patternMatch = true
+            enum keyType::option = keyType::REGEX
         ) const;
 
 
     // Member Operators
 
-        //- Find and return an entry data stream (identical to #lookup method).
-        //  Search: non-recursive with patterns.
-        //
-        //  \deprecated use lookup() method instead (deprecated JUL-2018)
-        ITstream& operator[](const word& keyword) const
-        {
-            return lookup(keyword);
-        }
-
         //- Copy assignment
         void operator=(const dictionary& rhs);
 
@@ -1152,19 +1102,196 @@ public:
         friend Ostream& operator<<(Ostream& os, const dictionary& dict);
 
 
-    // Shortcuts - may be more useable in templated code
+    // Housekeeping
+
+        //- Find and return an entry data stream (identical to #lookup method).
+        //
+        //  \deprecated use lookup() method instead (JUL-2018)
+        ITstream& operator[](const word& keyword) const
+        {
+            return lookup(keyword);
+        }
+
+        //- Find and return a T.
+        //  \deprecated - same as the get() method (OCT-2018)
+        template<class T>
+        T lookupType
+        (
+            const word& keyword,
+            bool recursive = false,
+            bool patternMatch = true
+        ) const
+        {
+            return get<T>(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Search dictionary for given keyword.
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        bool found
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch = true
+        ) const
+        {
+            return found(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return an entry pointer for manipulation if present,
+        //- or return a nullptr.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        entry* lookupEntryPtr
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        )
+        {
+            return findEntry(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return an entry pointer if present, or return a nullptr.
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        const entry* lookupEntryPtr
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const
+        {
+            return findEntry(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return an entry pointer if present, or return a nullptr.
+        //  Allows scoping using '.'.
+        //  Special handling for an absolute anchor (^) at start of the keyword
+        //  and for '..' to ascend into the parent dictionaries.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        const entry* lookupScopedEntryPtr
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const
+        {
+            return findScoped(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return a sub-dictionary pointer if present
+        //  (and a sub-dictionary) otherwise return nullptr.
+        //
+        //  Search type: non-recursive with patterns.
+        const dictionary* subDictPtr(const word& keyword) const
+        {
+            return findDict(keyword, keyType::REGEX);
+        }
+
+        //- Find and return a sub-dictionary pointer if present
+        //  (and a sub-dictionary) otherwise return nullptr.
+        //
+        //  Search type: non-recursive with patterns.
+        dictionary* subDictPtr(const word& keyword)
+        {
+            return findDict(keyword, keyType::REGEX);
+        }
+
+        //- Find and return an entry if present, otherwise FatalIOError.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        const entry& lookupEntry
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch
+        ) const
+        {
+            return lookupEntry(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return an entry data stream.
+        //  Default search: non-recursive with patterns.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        ITstream& lookup
+        (
+            const word& keyword,
+            bool recursive,
+            bool patternMatch = true
+        ) const
+        {
+            return lookup(keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return a T, or return the given default value
+        //- FatalIOError if it is found and there are excess tokens.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        template<class T>
+        T lookupOrDefault
+        (
+            const word& keyword,
+            const T& deflt,
+            bool recursive,
+            bool patternMatch = true
+        ) const
+        {
+            return
+                lookupOrDefault
+                (keyword, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find and return a T, or return the given default value
+        //- and add it to dictionary.
+        //- FatalIOError if it is found and there are excess tokens.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        template<class T>
+        T lookupOrAddDefault
+        (
+            const word& keyword,
+            const T& deflt,
+            bool recursive,
+            bool patternMatch = true
+        )
+        {
+            return
+                lookupOrAddDefault
+                (keyword, deflt, matchOpt(recursive, patternMatch));
+        }
+
+        //- Find an entry if present, and assign to T val.
+        //- FatalIOError if it is found and there are excess tokens.
+        //
+        //  \deprecated - use keyType::option version instead (OCT-2018)
+        template<class T>
+        bool readIfPresent
+        (
+            const word& keyword,
+            T& val,
+            bool recursive,
+            bool patternMatch = true
+        ) const
+        {
+            return
+                readIfPresent
+                (keyword, val, matchOpt(recursive, patternMatch));
+        }
+
+
+    // Shortcuts - when a templated classes also inherits from a dictionary
 
         #undef defineDictionaryGetter
-        #define defineDictionaryGetter(Func,Type)                             \
+        #define defineDictionaryGetter(Func, Type)                            \
             /** Same as get\<Type\> */                                        \
             Type Func                                                         \
             (                                                                 \
                 const word& keyword,                                          \
-                bool recursive = false,                                       \
-                bool patternMatch = true                                      \
+                enum keyType::option matchOpt = keyType::REGEX                \
             ) const                                                           \
             {                                                                 \
-                return get<Type>(keyword, recursive, patternMatch);           \
+                return get<Type>(keyword, matchOpt);                          \
             }
 
         defineDictionaryGetter(getBool, bool);
diff --git a/src/OpenFOAM/db/dictionary/dictionaryCompat.C b/src/OpenFOAM/db/dictionary/dictionaryCompat.C
index 49fb277fb54..c16f7de0d87 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryCompat.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryCompat.C
@@ -49,11 +49,10 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
 (
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    const_searcher finder(csearch(keyword, recursive, patternMatch));
+    const_searcher finder(csearch(keyword, matchOpt));
 
     if (finder.found())
     {
@@ -62,7 +61,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
 
     for (const std::pair<const char*,int>& iter : compat)
     {
-        finder = csearch(word::validate(iter.first), recursive, patternMatch);
+        finder = csearch(word::validate(iter.first), matchOpt);
 
         if (finder.found())
         {
@@ -99,23 +98,21 @@ bool Foam::dictionary::foundCompat
 (
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return csearchCompat(keyword, compat, recursive, patternMatch).found();
+    return csearchCompat(keyword, compat, matchOpt).found();
 }
 
 
-const Foam::entry* Foam::dictionary::lookupEntryPtrCompat
+const Foam::entry* Foam::dictionary::findCompat
 (
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return csearchCompat(keyword, compat, recursive, patternMatch).ptr();
+    return csearchCompat(keyword, compat, matchOpt).ptr();
 }
 
 
@@ -123,12 +120,10 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat
 (
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    const const_searcher
-        finder(csearchCompat(keyword, compat, recursive, patternMatch));
+    const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
 
     if (!finder.found())
     {
@@ -146,12 +141,10 @@ Foam::ITstream& Foam::dictionary::lookupCompat
 (
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return
-        lookupEntryCompat(keyword, compat, recursive, patternMatch).stream();
+    return lookupEntryCompat(keyword, compat, matchOpt).stream();
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C
index 7a51ae2d675..de4ff879aa2 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C
@@ -33,31 +33,26 @@ Foam::dictionary::dictionary
 (
     const fileName& name,
     const dictionary& parentDict,
-    Istream& is
+    Istream& is,
+    bool keepHeader
 )
 :
-    dictionaryName(parentDict.name() + '.' + name),
+    name_(parentDict.name() + '.' + name),
     parent_(parentDict)
 {
-    read(is);
+    read(is, keepHeader);
 }
 
 
 Foam::dictionary::dictionary(Istream& is)
 :
-    dictionaryName(is.name()),
-    parent_(dictionary::null)
-{
-    // Reset input mode as this is a "top-level" dictionary
-    entry::resetInputMode();
-
-    read(is);
-}
+    dictionary(is, false)
+{}
 
 
 Foam::dictionary::dictionary(Istream& is, bool keepHeader)
 :
-    dictionaryName(is.name()),
+    name_(is.name()),
     parent_(dictionary::null)
 {
     // Reset input mode as this is a "top-level" dictionary
diff --git a/src/OpenFOAM/db/dictionary/dictionarySearch.C b/src/OpenFOAM/db/dictionary/dictionarySearch.C
index 4c8ec03c078..902d10f07da 100644
--- a/src/OpenFOAM/db/dictionary/dictionarySearch.C
+++ b/src/OpenFOAM/db/dictionary/dictionarySearch.C
@@ -69,8 +69,7 @@ namespace
 Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     auto scopePos = keyword.find('.');
@@ -78,9 +77,12 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
     if (scopePos == string::npos)
     {
         // Normal, non-scoped search
-        return csearch(keyword, recursive, patternMatch);
+        return csearch(keyword, matchOpt);
     }
 
+    // It is '.' scoped - force non-recusive searching
+    matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
+
     if (scopePos == 0)
     {
         // Starting with a '.' -> go up for every further '.' found
@@ -113,8 +115,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
         return dictPtr->csearchDotScoped
         (
             keyword.substr(scopePos),
-            false,
-            patternMatch
+            matchOpt
         );
     }
 
@@ -122,8 +123,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
     const_searcher finder = csearchDotScoped
     (
         keyword.substr(0, scopePos),
-        false,
-        patternMatch
+        matchOpt
     );
 
     // Fall back to finding key with '.' so e.g. if keyword is
@@ -137,7 +137,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
             scopePos = keyword.find('.', scopePos+1);
 
             // Local entry:
-            finder = csearch(keyword.substr(0, scopePos), false, patternMatch);
+            finder = csearch(keyword.substr(0, scopePos), matchOpt);
 
             if (scopePos == string::npos)
             {
@@ -152,8 +152,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
         return finder.dict().csearchDotScoped
         (
             keyword.substr(scopePos),
-            false,
-            patternMatch
+            matchOpt
         );
     }
 
@@ -164,9 +163,13 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
 Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
 (
     const word& keyword,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
+
+    // With '/' scoping - recursive is never allowed
+    matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
+
     const dictionary* dictPtr = this;
 
     const auto slash = keyword.find('/');
@@ -175,7 +178,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
     {
         // No slashes:
         // Can use normal (non-scoped) search at the current dictionary level
-        return csearch(keyword, false, patternMatch);
+        return csearch(keyword, matchOpt);
     }
     else if (slash == 0)
     {
@@ -220,7 +223,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
             // Find entry
             const word key = word::validate(cmpt);
 
-            auto finder = dictPtr->csearch(key, false, patternMatch);
+            auto finder = dictPtr->csearch(key, matchOpt);
 
             if (finder.found())
             {
@@ -259,8 +262,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
 Foam::dictionary::const_searcher Foam::dictionary::csearch
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     const_searcher finder(this);
@@ -273,27 +275,22 @@ Foam::dictionary::const_searcher Foam::dictionary::csearch
         return finder;
     }
 
-    if (patternMatch && patterns_.size())
+    if ((matchOpt & keyType::REGEX) && patterns_.size())
     {
         pattern_const_iterator wcLink = patterns_.begin();
         regexp_const_iterator  reLink = regexps_.begin();
 
         // Find in patterns using regular expressions only
-        if (findInPatterns(patternMatch, keyword, wcLink, reLink))
+        if (findInPatterns(true, keyword, wcLink, reLink))
         {
             finder.set(*wcLink);
             return finder;
         }
     }
 
-    if (recursive && &parent_ != &dictionary::null)
+    if ((matchOpt & keyType::RECURSIVE) && &parent_ != &dictionary::null)
     {
-        return parent_.csearch
-        (
-            keyword,
-            recursive,
-            patternMatch
-        );
+        return parent_.csearch(keyword, matchOpt);
     }
 
     return finder;
@@ -303,22 +300,20 @@ Foam::dictionary::const_searcher Foam::dictionary::csearch
 Foam::dictionary::const_searcher Foam::dictionary::search
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return csearch(keyword, recursive, patternMatch);
+    return csearch(keyword, matchOpt);
 }
 
 
 Foam::dictionary::searcher Foam::dictionary::search
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 )
 {
-    const_searcher finder = csearch(keyword, recursive, patternMatch);
+    const_searcher finder = csearch(keyword, matchOpt);
 
     return static_cast<const searcher&>(finder);
 }
@@ -327,17 +322,19 @@ Foam::dictionary::searcher Foam::dictionary::search
 Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     if (keyword.find('/') != string::npos)
     {
-        return csearchSlashScoped(keyword, patternMatch);
+        return csearchSlashScoped(keyword, matchOpt);
     }
 
     if (keyword[0] == ':' || keyword[0] == '^')
     {
+        // It is ':' scoped - force non-recusive searching
+        matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
+
         // Ascend to top-level
         const dictionary* dictPtr = this;
         while (&dictPtr->parent_ != &dictionary::null)
@@ -345,43 +342,36 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
             dictPtr = &dictPtr->parent_;
         }
 
-        return dictPtr->csearchDotScoped
-        (
-            keyword.substr(1),
-            false,
-            patternMatch
-        );
+        return dictPtr->csearchDotScoped(keyword.substr(1), matchOpt);
     }
 
-    return csearchDotScoped(keyword, recursive, patternMatch);
+    return csearchDotScoped(keyword, matchOpt);
 }
 
 
 Foam::dictionary::const_searcher Foam::dictionary::searchScoped
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    return csearchScoped(keyword, recursive, patternMatch);
+    return csearchScoped(keyword, matchOpt);
 }
 
 
 Foam::dictionary::searcher Foam::dictionary::searchScoped
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 )
 {
-    const_searcher finder = csearchScoped(keyword, recursive, patternMatch);
+    const_searcher finder = csearchScoped(keyword, matchOpt);
 
     return static_cast<const searcher&>(finder);
 }
 
 
-const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
+const Foam::dictionary* Foam::dictionary::cfindScopedDict
 (
     const fileName& dictPath
 ) const
@@ -466,26 +456,26 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
 }
 
 
-const Foam::dictionary* Foam::dictionary::findScopedDictPtr
+const Foam::dictionary* Foam::dictionary::findScopedDict
 (
     const fileName& dictPath
 ) const
 {
-    return cfindScopedDictPtr(dictPath);
+    return cfindScopedDict(dictPath);
 }
 
 
-Foam::dictionary* Foam::dictionary::findScopedDictPtr
+Foam::dictionary* Foam::dictionary::findScopedDict
 (
     const fileName& dictPath
 )
 {
-    const dictionary* ptr = cfindScopedDictPtr(dictPath);
+    const dictionary* ptr = cfindScopedDict(dictPath);
     return const_cast<dictionary*>(ptr);
 }
 
 
-Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
+Foam::dictionary* Foam::dictionary::makeScopedDict(const fileName& dictPath)
 {
     // Or warning
     if (dictPath.empty())
@@ -536,7 +526,8 @@ Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
         else
         {
             // Non-recursive, no patternMatch
-            // -> can do direct lookup, without csearch(cmptName, false, false);
+            // -> can do direct lookup,
+            // without csearch(cmptName, keyType::LITERAL);
             const word cmptName(cmpt.str(), false);
 
             auto iter = dictPtr->hashedEntries_.find(cmptName);
diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
index fab47e64889..a8656dcb085 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C
@@ -53,12 +53,11 @@ template<class T>
 T Foam::dictionary::get
 (
     const word& keyword,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     T val;
-    readEntry<T>(keyword, val, recursive, patternMatch);
+    readEntry<T>(keyword, val, matchOpt);
     return val;
 }
 
@@ -68,12 +67,11 @@ T Foam::dictionary::getCompat
 (
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     T val;
-    readCompat<T>(keyword, compat, val, recursive, patternMatch);
+    readCompat<T>(keyword, compat, val, matchOpt);
     return val;
 }
 
@@ -84,13 +82,11 @@ bool Foam::dictionary::readCompat
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
     T& val,
-    bool recursive,
-    bool patternMatch,
+    enum keyType::option matchOpt,
     bool mandatory
 ) const
 {
-    const const_searcher
-        finder(csearchCompat(keyword, compat, recursive, patternMatch));
+    const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
 
     if (finder.found())
     {
@@ -113,29 +109,15 @@ bool Foam::dictionary::readCompat
 }
 
 
-// older name
-template<class T>
-T Foam::dictionary::lookupType
-(
-    const word& keyword,
-    bool recursive,
-    bool patternMatch
-) const
-{
-    return get<T>(keyword, recursive, patternMatch);
-}
-
-
 template<class T>
 T Foam::dictionary::lookupOrDefault
 (
     const word& keyword,
     const T& deflt,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    const const_searcher finder(csearch(keyword, recursive, patternMatch));
+    const const_searcher finder(csearch(keyword, matchOpt));
 
     if (finder.found())
     {
@@ -165,11 +147,10 @@ T Foam::dictionary::lookupOrAddDefault
 (
     const word& keyword,
     const T& deflt,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 )
 {
-    const const_searcher finder(csearch(keyword, recursive, patternMatch));
+    const const_searcher finder(csearch(keyword, matchOpt));
 
     if (finder.found())
     {
@@ -200,12 +181,11 @@ bool Foam::dictionary::readEntry
 (
     const word& keyword,
     T& val,
-    bool recursive,
-    bool patternMatch,
+    enum keyType::option matchOpt,
     bool mandatory
 ) const
 {
-    const const_searcher finder(csearch(keyword, recursive, patternMatch));
+    const const_searcher finder(csearch(keyword, matchOpt));
 
     if (finder.found())
     {
@@ -233,12 +213,11 @@ bool Foam::dictionary::readIfPresent
 (
     const word& keyword,
     T& val,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     // Read is non-mandatory
-    return readEntry<T>(keyword, val, recursive, patternMatch, false);
+    return readEntry<T>(keyword, val, matchOpt, false);
 }
 
 
@@ -248,12 +227,10 @@ T Foam::dictionary::lookupOrDefaultCompat
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
     const T& deflt,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
-    const const_searcher
-        finder(csearchCompat(keyword, compat, recursive, patternMatch));
+    const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
 
     if (finder.found())
     {
@@ -284,12 +261,11 @@ bool Foam::dictionary::readIfPresentCompat
     const word& keyword,
     std::initializer_list<std::pair<const char*,int>> compat,
     T& val,
-    bool recursive,
-    bool patternMatch
+    enum keyType::option matchOpt
 ) const
 {
     // Read is non-mandatory
-    return readCompat<T>(keyword, compat, val, recursive, patternMatch, false);
+    return readCompat<T>(keyword, compat, val, matchOpt, false);
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C
index 0e50a68e9b3..cd7a335c0ba 100644
--- a/src/OpenFOAM/db/dictionary/entry/entryIO.C
+++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C
@@ -241,7 +241,8 @@ bool Foam::entry::New
             const word varName = keyword.substr(1);
 
             // Lookup the variable name in the given dictionary
-            const auto finder = parentDict.csearchScoped(varName, true, true);
+            const auto finder =
+                parentDict.csearchScoped(varName, keyType::REGEX_RECURSIVE);
 
             if (finder.found())
             {
@@ -301,8 +302,8 @@ bool Foam::entry::New
         auto finder =
         (
             scoped
-          ? parentDict.searchScoped(keyword, false, false)
-          : parentDict.search(keyword, false, false)
+          ? parentDict.searchScoped(keyword, keyType::LITERAL)
+          : parentDict.search(keyword, keyType::LITERAL)
         );
 
         // How to manage duplicate entries
@@ -387,10 +388,7 @@ bool Foam::entry::New
             // Get or create the dictionary-path.
             // fileName::path == dictionary-path
             dictionary* subDictPtr =
-                parentDict.makeScopedDictPtr
-                (
-                    fileName::path(fullPath)
-                );
+                parentDict.makeScopedDict(fileName::path(fullPath));
 
             if (subDictPtr)
             {
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
index 25e452fce36..2a216f5c5f9 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C
@@ -61,8 +61,7 @@ bool Foam::functionEntries::removeEntry::execute
         if (key.isLiteral() && key.find('/') != string::npos)
         {
             // Remove scoped keyword, or keyword in the local scope
-            dictionary::searcher finder =
-                parentDict.searchScoped(key, false, false);
+            auto finder(parentDict.searchScoped(key, keyType::LITERAL));
 
             if (finder.found())
             {
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
index 0998353e9fa..3c8715a2c08 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
@@ -78,7 +78,8 @@ bool Foam::primitiveEntry::expandVariable
     // The $internalField would be matched by the ".*" !!!
 
     // Recursive, non-patterns
-    const entry* eptr = dict.lookupScopedEntryPtr(varName, true, false);
+    const entry* eptr = dict.findScoped(varName, keyType::LITERAL_RECURSIVE);
+
     if (!eptr)
     {
         // Not found - revert to environment variable
diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C
index f7dabea32c4..0cbb02b7a2c 100644
--- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C
+++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C
@@ -55,14 +55,14 @@ static inline void writeEntryIfPresent
 )
 {
     // non-recursive like dictionary::found, but no pattern-match either
-    const entry* ptr = dict.lookupEntryPtr(key, false, false);
+    const entry* eptr = dict.findEntry(key, keyType::LITERAL);
 
-    if (ptr)
+    if (eptr)
     {
         os.writeKeyword(key)
             << token::HASH << token::BEGIN_BLOCK;
 
-        os.writeQuoted(string(ptr->stream()), false)
+        os.writeQuoted(string(eptr->stream()), false)
             << token::HASH << token::END_BLOCK
             << token::END_STATEMENT << nl;
     }
diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C
index 6f410788678..a626aa78740 100644
--- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C
+++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C
@@ -44,50 +44,40 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
     // - necessary for compilation options, convenient for includes
     // and body.
 
-    const entry* codePtr = dict.lookupEntryPtr
-    (
-        "code",
-        false,
-        false
-    );
+    const entry* codePtr = dict.findEntry("code", keyType::LITERAL);
+
     if (codePtr)
     {
         code_ = stringOps::trim(codePtr->stream());
         stringOps::inplaceExpand(code_, dict);
     }
 
-    const entry* includePtr = dict.lookupEntryPtr
-    (
-        "codeInclude",
-        false,
-        false
-    );
+    const entry* includePtr = dict.findEntry("codeInclude", keyType::LITERAL);
+
     if (includePtr)
     {
         include_ = stringOps::trim(includePtr->stream());
         stringOps::inplaceExpand(include_, dict);
     }
 
-    const entry* optionsPtr = dict.lookupEntryPtr
-    (
-        "codeOptions",
-        false,
-        false
-    );
+    const entry* optionsPtr = dict.findEntry("codeOptions", keyType::LITERAL);
+
     if (optionsPtr)
     {
         options_ = stringOps::trim(optionsPtr->stream());
         stringOps::inplaceExpand(options_, dict);
     }
 
-    const entry* libsPtr = dict.lookupEntryPtr("codeLibs", false, false);
+    const entry* libsPtr = dict.findEntry("codeLibs", keyType::LITERAL);
+
     if (libsPtr)
     {
         libs_ = stringOps::trim(libsPtr->stream());
         stringOps::inplaceExpand(libs_, dict);
     }
 
-    const entry* localPtr = dict.lookupEntryPtr("localCode", false, false);
+    const entry* localPtr = dict.findEntry("localCode", keyType::LITERAL);
+
     if (localPtr)
     {
         localCode_ = stringOps::trim(localPtr->stream());
diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
index db9902b94f2..2fd7f11563d 100644
--- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
+++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
@@ -706,12 +706,8 @@ bool Foam::functionObjectList::read()
     }
 
     // Update existing and add new functionObjects
-    const entry* entryPtr = parentDict_.lookupEntryPtr
-    (
-        "functions",
-        false,
-        false
-    );
+    const entry* entryPtr =
+        parentDict_.findEntry("functions", keyType::LITERAL);
 
     if (entryPtr)
     {
diff --git a/src/OpenFOAM/global/debug/debug.C b/src/OpenFOAM/global/debug/debug.C
index 2b7206cc4fe..d9102084f1d 100644
--- a/src/OpenFOAM/global/debug/debug.C
+++ b/src/OpenFOAM/global/debug/debug.C
@@ -135,12 +135,9 @@ Foam::dictionary& Foam::debug::switchSet
 {
     if (!subDictPtr)
     {
-        entry* ePtr = controlDict().lookupEntryPtr
-        (
-            subDictName, false, false
-        );
+        entry* eptr = controlDict().findEntry(subDictName, keyType::LITERAL);
 
-        if (!ePtr || !ePtr->isDict())
+        if (!eptr || !eptr->isDict())
         {
             cerr<< "debug::switchSet(const char*, dictionary*&):\n"
                 << "    Cannot find " <<  subDictName << " in dictionary "
@@ -150,7 +147,7 @@ Foam::dictionary& Foam::debug::switchSet
             ::exit(1);
         }
 
-        subDictPtr = &ePtr->dict();
+        subDictPtr = &(eptr->dict());
     }
 
     return *subDictPtr;
@@ -179,7 +176,7 @@ int Foam::debug::debugSwitch(const char* name, const int defaultValue)
 {
     return debugSwitches().lookupOrAddDefault
     (
-        name, defaultValue, false, false
+        name, defaultValue, keyType::LITERAL
     );
 }
 
@@ -188,7 +185,7 @@ int Foam::debug::infoSwitch(const char* name, const int defaultValue)
 {
     return infoSwitches().lookupOrAddDefault
     (
-        name, defaultValue, false, false
+        name, defaultValue, keyType::LITERAL
     );
 }
 
@@ -197,7 +194,7 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
 {
     return optimisationSwitches().lookupOrAddDefault
     (
-        name, defaultValue, false, false
+        name, defaultValue, keyType::LITERAL
     );
 }
 
@@ -210,7 +207,7 @@ float Foam::debug::floatOptimisationSwitch
 {
     return optimisationSwitches().lookupOrAddDefault
     (
-        name, defaultValue, false, false
+        name, defaultValue, keyType::LITERAL
     );
 }
 
@@ -412,17 +409,17 @@ void listSwitches
 
         wordHashSet controlDictDebug
         (
-            controlDict.subDict("DebugSwitches").sortedToc()
+            controlDict.subDict("DebugSwitches").toc()
         );
 
         wordHashSet controlDictInfo
         (
-            controlDict.subDict("InfoSwitches").sortedToc()
+            controlDict.subDict("InfoSwitches").toc()
         );
 
         wordHashSet controlDictOpt
         (
-            controlDict.subDict("OptimisationSwitches").sortedToc()
+            controlDict.subDict("OptimisationSwitches").toc()
         );
 
 
diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C
index 03cf4bc80c5..a06170d7092 100644
--- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C
+++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C
@@ -50,8 +50,7 @@ namespace Foam
             "fileHandler",
             //Foam::fileOperations::uncollatedFileOperation::typeName,
             "uncollated",
-            false,
-            false
+            keyType::LITERAL
         )
     );
 }
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C
index 892f6569d1c..88a1f86380f 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C
@@ -43,8 +43,10 @@ Foam::word Foam::lduMatrix::preconditioner::getName
 {
     word name;
 
-    // handle primitive or dictionary entry
-    const entry& e = solverControls.lookupEntry("preconditioner", false, false);
+    // Handle primitive or dictionary entry
+    const entry& e =
+        solverControls.lookupEntry("preconditioner", keyType::LITERAL);
+
     if (e.isDict())
     {
         e.dict().readEntry("preconditioner", name);
@@ -67,8 +69,11 @@ Foam::lduMatrix::preconditioner::New
 {
     word name;
 
-    // handle primitive or dictionary entry
-    const entry& e = solverControls.lookupEntry("preconditioner", false, false);
+    // Handle primitive or dictionary entry
+
+    const entry& e =
+        solverControls.lookupEntry("preconditioner", keyType::LITERAL);
+
     if (e.isDict())
     {
         e.dict().readEntry("preconditioner", name);
diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C
index 33990232184..0e1bbaa0159 100644
--- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C
+++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C
@@ -43,8 +43,10 @@ Foam::lduMatrix::smoother::getName
 {
     word name;
 
-    // handle primitive or dictionary entry
-    const entry& e = solverControls.lookupEntry("smoother", false, false);
+    // Handle primitive or dictionary entry
+    const entry& e =
+        solverControls.lookupEntry("smoother", keyType::LITERAL);
+
     if (e.isDict())
     {
         e.dict().readEntry("smoother", name);
@@ -70,8 +72,10 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
 {
     word name;
 
-    // handle primitive or dictionary entry
-    const entry& e = solverControls.lookupEntry("smoother", false, false);
+    // Handle primitive or dictionary entry
+    const entry& e =
+        solverControls.lookupEntry("smoother", keyType::LITERAL);
+
     if (e.isDict())
     {
         e.dict().readEntry("smoother", name);
diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C
index b08dde5b91e..b2a3a07800d 100644
--- a/src/OpenFOAM/matrices/solution/solution.C
+++ b/src/OpenFOAM/matrices/solution/solution.C
@@ -35,9 +35,9 @@ namespace Foam
 
 // List of sub-dictionaries to rewrite
 static const Foam::List<Foam::word> subDictNames
-{
+({
     "preconditioner", "smoother"
-};
+});
 
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
@@ -184,14 +184,13 @@ Foam::label Foam::solution::upgradeSolverDict
             // 1) primitiveEntry w/o settings,
             // 2) or a dictionaryEntry.
             // transform primitiveEntry with settings -> dictionaryEntry
-            forAll(subDictNames, dictI)
+            for (const word& dictName : subDictNames)
             {
-                const word& dictName = subDictNames[dictI];
-                entry* ePtr = subdict.lookupEntryPtr(dictName,false,false);
+                entry* eptr = subdict.findEntry(dictName, keyType::LITERAL);
 
-                if (ePtr && !ePtr->isDict())
+                if (eptr && !eptr->isDict())
                 {
-                    Istream& is = ePtr->stream();
+                    Istream& is = eptr->stream();
                     is >> name;
 
                     if (!is.eof())
@@ -234,10 +233,8 @@ bool Foam::solution::cache(const word& name) const
 
         return cache_.found(name);
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C
index fe97b5acc22..9063d21f831 100644
--- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C
+++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C
@@ -57,7 +57,7 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
     }
     else
     {
-        Istream& is(dict.lookup(entryName, false));
+        Istream& is = dict.lookup(entryName); // non-recursive, allow patterns
 
         token firstToken(is);
         word Function1Type;
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H
index 608468105f9..cf9db5128f9 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyType.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H
@@ -82,6 +82,20 @@ public:
         static const keyType null;
 
 
+    // Public data types
+
+        //- Enumeration for search/match modes as bitmask
+        //  eg, (keyType::REGEX | keyType::RECURSIVE)
+        enum option
+        {
+            LITERAL = 0,        //!< String literal
+            REGEX   = 1,        //!< Regular expression
+            RECURSIVE = 0x10,   //!< Recursive search (eg, in dictionary)
+            LITERAL_RECURSIVE = (LITERAL | RECURSIVE),
+            REGEX_RECURSIVE   = (REGEX | RECURSIVE)
+        };
+
+
     // Constructors
 
         //- Construct null
@@ -100,19 +114,19 @@ public:
         inline keyType(const char* s);
 
         //- Copy construct from std::string with specified treatment
-        inline keyType(const std::string& s, const bool isPattern);
+        inline keyType(const std::string& s, bool isPattern);
 
         //- Move construct, retaining type (literal or regex)
         inline keyType(keyType&& s);
 
-        //- Move construct from word. Not treated as a regular expression
+        //- Move construct from word, treat as literal.
         inline keyType(word&& s);
 
-        //- Move construct from string. Treat as regular expression.
+        //- Move construct from string, treat as regular expression.
         inline keyType(string&& s);
 
         //- Move construct from std::string with specified treatment
-        inline keyType(std::string&& s, const bool isPattern);
+        inline keyType(std::string&& s, bool isPattern);
 
         //- Construct from Istream
         //  Treat as regular expression if surrounded by quotation marks.
diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
index bf84de6a238..3b4b0f32895 100644
--- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
+++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H
@@ -77,7 +77,7 @@ inline Foam::keyType::keyType(const char* s)
 {}
 
 
-inline Foam::keyType::keyType(const std::string& s, const bool isPattern)
+inline Foam::keyType::keyType(const std::string& s, bool isPattern)
 :
     word(s, false),
     isPattern_(isPattern)
@@ -107,7 +107,7 @@ inline Foam::keyType::keyType(string&& s)
 {}
 
 
-inline Foam::keyType::keyType(std::string&& s, const bool isPattern)
+inline Foam::keyType::keyType(std::string&& s, bool isPattern)
 :
     word(std::move(s), false),
     isPattern_(isPattern)
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
index 484ef5f9f5e..325e64051db 100644
--- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2017-2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -437,7 +437,7 @@ Foam::string Foam::stringOps::getVariable
 {
     string value;
 
-    const entry* eptr = dict.lookupScopedEntryPtr(name, true, false);
+    const entry* eptr = dict.findScoped(name, keyType::LITERAL_RECURSIVE);
 
     if (eptr)
     {
@@ -720,20 +720,16 @@ void Foam::stringOps::inplaceExpand
                         varBeg + 1 + delim,
                         varEnd - varBeg - 2*delim
                     ),
-                    false
+                    false   // Already validated
                 );
 
 
                 // Lookup in the dictionary without wildcards.
                 // See note in primitiveEntry
-                const entry* eptr = dict.lookupScopedEntryPtr
-                (
-                    varName,
-                    true,
-                    false
-                );
+                const entry* eptr =
+                    dict.findScoped(varName, keyType::LITERAL_RECURSIVE);
 
-                // if defined - copy its entries
+                // Copy its entries if defined
                 if (eptr)
                 {
                     OStringStream buf;
diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
index 9976ecb6dce..5b83bda346e 100644
--- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
+++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2017 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2017-2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -96,14 +96,14 @@ public:
         //  Note that 'REGEX' is implicit if 'ICASE' is specified alone.
         enum compOption
         {
-            LITERAL = 0, //!< Treat as a string literal
-            DETECT  = 1, //!< Detect if the string contains meta-characters
-            UNKNOWN = 1, //!< Unknown content.
-            REGEX   = 2, //!< Treat as regular expression
-            ICASE   = 4, //!< Ignore case in regular expression
-            NOCASE  = 4, //!< \deprecated Alias for ICASE (deprecated APR-2018)
+            LITERAL = 0, //!< String literal
+            REGEX   = 1, //!< Regular expression
+            ICASE   = 2, //!< Ignore case in regular expression
+            NOCASE  = 2, //!< \deprecated Alias for ICASE (deprecated APR-2018)
+            DETECT  = 4, //!< Detect if the string contains meta-characters
+            UNKNOWN = 4, //!< Unknown content.
+            REGEX_ICASE  = (REGEX|ICASE),   //!< Combined REGEX and ICASE
             DETECT_ICASE = (DETECT|ICASE),  //!< Combined DETECT and ICASE
-            REGEX_ICASE  = (REGEX|ICASE)    //!< Combined REGEX and ICASE
         };
 
 
diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C
index 8a5aadee53f..361fbe216e1 100644
--- a/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C
+++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C
@@ -62,53 +62,59 @@ bool Foam::motionSmootherAlgo::checkMesh
 {
     const scalar maxNonOrtho
     (
-        dict.get<scalar>("maxNonOrtho", true)
+        dict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE)
     );
     const scalar minVol
     (
-        dict.get<scalar>("minVol", true)
+        dict.get<scalar>("minVol", keyType::REGEX_RECURSIVE)
     );
     const scalar minTetQuality
     (
-        dict.get<scalar>("minTetQuality", true)
+        dict.get<scalar>("minTetQuality", keyType::REGEX_RECURSIVE)
     );
     const scalar maxConcave
     (
-        dict.get<scalar>("maxConcave", true)
+        dict.get<scalar>("maxConcave", keyType::REGEX_RECURSIVE)
     );
     const scalar minArea
     (
-        dict.get<scalar>("minArea", true)
+        dict.get<scalar>("minArea", keyType::REGEX_RECURSIVE)
     );
     const scalar maxIntSkew
     (
-        dict.get<scalar>("maxInternalSkewness", true)
+        dict.get<scalar>("maxInternalSkewness", keyType::REGEX_RECURSIVE)
     );
     const scalar maxBounSkew
     (
-        dict.get<scalar>("maxBoundarySkewness", true)
+        dict.get<scalar>("maxBoundarySkewness", keyType::REGEX_RECURSIVE)
     );
     const scalar minWeight
     (
-        dict.get<scalar>("minFaceWeight", true)
+        dict.get<scalar>("minFaceWeight", keyType::REGEX_RECURSIVE)
     );
     const scalar minVolRatio
     (
-        dict.get<scalar>("minVolRatio", true)
+        dict.get<scalar>("minVolRatio", keyType::REGEX_RECURSIVE)
     );
     const scalar minTwist
     (
-        dict.get<scalar>("minTwist", true)
+        dict.get<scalar>("minTwist", keyType::REGEX_RECURSIVE)
     );
     const scalar minTriangleTwist
     (
-        dict.get<scalar>("minTriangleTwist", true)
+        dict.get<scalar>("minTriangleTwist", keyType::REGEX_RECURSIVE)
+    );
+
+    const scalar minFaceFlatness
+    (
+        dict.lookupOrDefault<scalar>
+        (
+            "minFaceFlatness", -1, keyType::REGEX_RECURSIVE
+        )
     );
-    scalar minFaceFlatness = -1.0;
-    dict.readIfPresent("minFaceFlatness", minFaceFlatness, true);
     const scalar minDet
     (
-        dict.get<scalar>("minDeterminant", true)
+        dict.get<scalar>("minDeterminant", keyType::REGEX_RECURSIVE)
     );
     label nWrongFaces = 0;
 
@@ -467,53 +473,58 @@ bool Foam::motionSmootherAlgo::checkMesh
 {
     const scalar maxNonOrtho
     (
-        dict.get<scalar>("maxNonOrtho", true)
+        dict.get<scalar>("maxNonOrtho", keyType::REGEX_RECURSIVE)
     );
     const scalar minVol
     (
-        dict.get<scalar>("minVol", true)
+        dict.get<scalar>("minVol", keyType::REGEX_RECURSIVE)
     );
     const scalar minTetQuality
     (
-        dict.get<scalar>("minTetQuality", true)
+        dict.get<scalar>("minTetQuality", keyType::REGEX_RECURSIVE)
     );
     const scalar maxConcave
     (
-        dict.get<scalar>("maxConcave", true)
+        dict.get<scalar>("maxConcave", keyType::REGEX_RECURSIVE)
     );
     const scalar minArea
     (
-        dict.get<scalar>("minArea", true)
+        dict.get<scalar>("minArea", keyType::REGEX_RECURSIVE)
     );
     const scalar maxIntSkew
     (
-        dict.get<scalar>("maxInternalSkewness", true)
+        dict.get<scalar>("maxInternalSkewness", keyType::REGEX_RECURSIVE)
     );
     const scalar maxBounSkew
     (
-        dict.get<scalar>("maxBoundarySkewness", true)
+        dict.get<scalar>("maxBoundarySkewness", keyType::REGEX_RECURSIVE)
     );
     const scalar minWeight
     (
-        dict.get<scalar>("minFaceWeight", true)
+        dict.get<scalar>("minFaceWeight", keyType::REGEX_RECURSIVE)
     );
     const scalar minVolRatio
     (
-        dict.get<scalar>("minVolRatio", true)
+        dict.get<scalar>("minVolRatio", keyType::REGEX_RECURSIVE)
     );
     const scalar minTwist
     (
-        dict.get<scalar>("minTwist", true)
+        dict.get<scalar>("minTwist", keyType::REGEX_RECURSIVE)
     );
     const scalar minTriangleTwist
     (
-        dict.get<scalar>("minTriangleTwist", true)
+        dict.get<scalar>("minTriangleTwist", keyType::REGEX_RECURSIVE)
+    );
+    const scalar minFaceFlatness
+    (
+        dict.lookupOrDefault<scalar>
+        (
+            "minFaceFlatness", -1, keyType::REGEX_RECURSIVE
+        )
     );
-    scalar minFaceFlatness = -1.0;
-    dict.readIfPresent("minFaceFlatness", minFaceFlatness, true);
     const scalar minDet
     (
-        dict.get<scalar>("minDeterminant", true)
+        dict.get<scalar>("minDeterminant", keyType::REGEX_RECURSIVE)
     );
     label nWrongFaces = 0;
 
diff --git a/src/finiteVolume/cfdTools/general/solutionControl/loopControl/loopControl.C b/src/finiteVolume/cfdTools/general/solutionControl/loopControl/loopControl.C
index c403486a2c7..e8b4d8551a9 100644
--- a/src/finiteVolume/cfdTools/general/solutionControl/loopControl/loopControl.C
+++ b/src/finiteVolume/cfdTools/general/solutionControl/loopControl/loopControl.C
@@ -170,7 +170,7 @@ Foam::loopControl::loopControl
     loopControl(runTime, 0, dictName)
 {
     // The loop sub-dictionary
-    const dictionary* dictptr = algorithmDict.subDictPtr(dictName);
+    const dictionary* dictptr = algorithmDict.findDict(dictName);
 
     if (dictptr)
     {
@@ -192,13 +192,12 @@ Foam::loopControl::loopControl
     fvSolution fvsol(time_);
 
     // Eg, PIMPLE or SIMPLE from <system/fvSolution>
-    const dictionary* dictptr =
-        fvsol.solutionDict().subDictPtr(algorithmName);
+    const dictionary* dictptr = fvsol.solutionDict().findDict(algorithmName);
 
     if (dictptr)
     {
         // The loop sub-dictionary
-        dictptr = dictptr->subDictPtr(dictName);
+        dictptr = dictptr->findDict(dictName);
 
         if (dictptr)
         {
diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
index 62d65ffaf30..6b4136d3848 100644
--- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
+++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
@@ -193,12 +193,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
 
     dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
 
-    const entry* dataPtr = dict.lookupEntryPtr
-    (
-        "codeData",
-        false,
-        false
-    );
+    const entry* dataPtr = dict.findEntry("codeData", keyType::LITERAL);
     if (dataPtr)
     {
         codeData_ = stringOps::trim(dataPtr->stream());
@@ -211,12 +206,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
         );
     }
 
-    const entry* readPtr = dict.lookupEntryPtr
-    (
-        "codeRead",
-        false,
-        false
-    );
+    const entry* readPtr = dict.findEntry("codeRead", keyType::LITERAL);
     if (readPtr)
     {
         codeRead_ = stringOps::trim(readPtr->stream());
@@ -229,12 +219,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
         );
     }
 
-    const entry* execPtr = dict.lookupEntryPtr
-    (
-        "codeExecute",
-        false,
-        false
-    );
+    const entry* execPtr = dict.findEntry("codeExecute", keyType::LITERAL);
     if (execPtr)
     {
         codeExecute_ = stringOps::trim(execPtr->stream());
@@ -247,12 +232,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
         );
     }
 
-    const entry* writePtr = dict.lookupEntryPtr
-    (
-        "codeWrite",
-        false,
-        false
-    );
+    const entry* writePtr = dict.findEntry("codeWrite", keyType::LITERAL);
     if (writePtr)
     {
         codeWrite_ = stringOps::trim(writePtr->stream());
@@ -265,12 +245,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
         );
     }
 
-    const entry* endPtr = dict.lookupEntryPtr
-    (
-        "codeEnd",
-        false,
-        false
-    );
+    const entry* endPtr = dict.findEntry("codeEnd", keyType::LITERAL);
     if (endPtr)
     {
         codeEnd_ = stringOps::trim(endPtr->stream());
@@ -283,7 +258,7 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
         );
     }
 
-    if(!dataPtr && !readPtr && !execPtr && !writePtr && !endPtr)
+    if (!dataPtr && !readPtr && !execPtr && !writePtr && !endPtr)
     {
         IOWarningInFunction
         (
diff --git a/src/fvOptions/sources/general/codedSource/CodedSourceIO.C b/src/fvOptions/sources/general/codedSource/CodedSourceIO.C
index bf27297e0e1..8cbeeecda21 100644
--- a/src/fvOptions/sources/general/codedSource/CodedSourceIO.C
+++ b/src/fvOptions/sources/general/codedSource/CodedSourceIO.C
@@ -40,12 +40,9 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
 
         // Code snippets
         {
-            const entry& e = coeffs_.lookupEntry
-            (
-                "codeCorrect",
-                false,
-                false
-            );
+            const entry& e =
+                coeffs_.lookupEntry("codeCorrect", keyType::LITERAL);
+
             codeCorrect_ = stringOps::trim(e.stream());
             stringOps::inplaceExpand(codeCorrect_, coeffs_);
             dynamicCodeContext::addLineDirective
@@ -57,12 +54,9 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
         }
 
         {
-            const entry& e = coeffs_.lookupEntry
-            (
-                "codeAddSup",
-                false,
-                false
-            );
+            const entry& e =
+                coeffs_.lookupEntry("codeAddSup", keyType::LITERAL);
+
             codeAddSup_ = stringOps::trim(e.stream());
             stringOps::inplaceExpand(codeAddSup_, coeffs_);
             dynamicCodeContext::addLineDirective
@@ -74,12 +68,9 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
         }
 
         {
-            const entry& e = coeffs_.lookupEntry
-            (
-                "codeSetValue",
-                false,
-                false
-            );
+            const entry& e =
+                coeffs_.lookupEntry("codeSetValue", keyType::LITERAL);
+
             codeSetValue_ = stringOps::trim(e.stream());
             stringOps::inplaceExpand(codeSetValue_, coeffs_);
             dynamicCodeContext::addLineDirective
diff --git a/src/lumpedPointMotion/lumpedPointMovement.C b/src/lumpedPointMotion/lumpedPointMovement.C
index b29cc4e042e..3ef592ba709 100644
--- a/src/lumpedPointMotion/lumpedPointMovement.C
+++ b/src/lumpedPointMotion/lumpedPointMovement.C
@@ -300,7 +300,7 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
 
     const dictionary* scaleDict = nullptr;
 
-    if ((scaleDict = commDict.subDictPtr("scaleInput")))
+    if ((scaleDict = commDict.findDict("scaleInput")))
     {
         for (int i=0; i < scaleInput_.size(); ++i)
         {
@@ -318,7 +318,7 @@ void Foam::lumpedPointMovement::readDict(const dictionary& dict)
         }
     }
 
-    if ((scaleDict = commDict.subDictPtr("scaleOutput")))
+    if ((scaleDict = commDict.findDict("scaleOutput")))
     {
         for (int i=0; i < scaleOutput_.size(); ++i)
         {
diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C
index 175ecf96888..f1f6f81ccce 100644
--- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C
+++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C
@@ -369,7 +369,7 @@ void Foam::blockDescriptor::write
     const dictionary& d
 )
 {
-    const dictionary* varDictPtr = d.subDictPtr("namedBlocks");
+    const dictionary* varDictPtr = d.findDict("namedBlocks");
     if (varDictPtr)
     {
         blockMeshTools::write(os, val, *varDictPtr);
diff --git a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C
index 62f5347cf14..f136aa3d416 100644
--- a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C
+++ b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C
@@ -350,7 +350,7 @@ Foam::autoPtr<Foam::polyMesh> Foam::blockMesh::createTopology
     // Read the names/types for the unassigned patch faces
     // this is a bit heavy handed (and ugly), but there is currently
     // no easy way to rename polyMesh patches subsequently
-    if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
+    if (const dictionary* dictPtr = meshDescription.findDict("defaultPatch"))
     {
         dictPtr->readIfPresent("name", defaultPatchName);
         dictPtr->readIfPresent("type", defaultPatchType);
diff --git a/src/mesh/blockMesh/blockMeshTools/blockMeshTools.C b/src/mesh/blockMesh/blockMeshTools/blockMeshTools.C
index 45eebc49564..9e5bc55a9be 100644
--- a/src/mesh/blockMesh/blockMeshTools/blockMeshTools.C
+++ b/src/mesh/blockMesh/blockMeshTools/blockMeshTools.C
@@ -42,16 +42,13 @@ void Foam::blockMeshTools::read
     else if (t.isWord())
     {
         const word& varName = t.wordToken();
-        const entry* ePtr = dict.lookupScopedEntryPtr
-        (
-            varName,
-            true,
-            true
-        );
-        if (ePtr)
+        const entry* eptr =
+            dict.findScoped(varName, keyType::REGEX_RECURSIVE);
+
+        if (eptr)
         {
             // Read as label
-            val = Foam::readLabel(ePtr->stream());
+            val = Foam::readLabel(eptr->stream());
         }
         else
         {
diff --git a/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C b/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C
index bf601607232..653e38dfec0 100644
--- a/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C
+++ b/src/mesh/blockMesh/blockVertices/blockVertex/blockVertex.C
@@ -104,7 +104,7 @@ Foam::autoPtr<Foam::blockVertex> Foam::blockVertex::New
 
 Foam::label Foam::blockVertex::read(Istream& is, const dictionary& dict)
 {
-    const dictionary* varDictPtr = dict.subDictPtr("namedVertices");
+    const dictionary* varDictPtr = dict.findDict("namedVertices");
     if (varDictPtr)
     {
         return blockMeshTools::read(is, *varDictPtr);
@@ -120,7 +120,7 @@ void Foam::blockVertex::write
     const dictionary& d
 )
 {
-    const dictionary* varDictPtr = d.subDictPtr("namedVertices");
+    const dictionary* varDictPtr = d.findDict("namedVertices");
     if (varDictPtr)
     {
         blockMeshTools::write(os, val, *varDictPtr);
diff --git a/src/mesh/blockMesh/blockVertices/namedVertex/namedVertex.C b/src/mesh/blockMesh/blockVertices/namedVertex/namedVertex.C
index 5e9738602ed..017117e03d2 100644
--- a/src/mesh/blockMesh/blockVertices/namedVertex/namedVertex.C
+++ b/src/mesh/blockMesh/blockVertices/namedVertex/namedVertex.C
@@ -53,10 +53,10 @@ Foam::blockVertices::namedVertex::namedVertex
 {
     dictionary& d = const_cast<dictionary&>(dict);
 
-    dictionary* varDictPtr = d.subDictPtr("namedVertices");
+    dictionary* varDictPtr = d.findDict("namedVertices");
     if (varDictPtr)
     {
-        const_cast<dictionary&>(*varDictPtr).add(name_, index);
+        varDictPtr->add(name_, index);
     }
     else
     {
diff --git a/src/mesh/blockMesh/blocks/namedBlock/namedBlock.C b/src/mesh/blockMesh/blocks/namedBlock/namedBlock.C
index 023638b75ed..b24481803a7 100644
--- a/src/mesh/blockMesh/blocks/namedBlock/namedBlock.C
+++ b/src/mesh/blockMesh/blocks/namedBlock/namedBlock.C
@@ -54,10 +54,10 @@ Foam::blocks::namedBlock::namedBlock
     block(dict, index, vertices, edges, faces, is)
 {
     dictionary& d = const_cast<dictionary&>(dict);
-    dictionary* varDictPtr = d.subDictPtr("namedBlocks");
+    dictionary* varDictPtr = d.findDict("namedBlocks");
     if (varDictPtr)
     {
-        const_cast<dictionary&>(*varDictPtr).add(*this, index);
+        varDictPtr->add(*this, index);
     }
     else
     {
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C
index d7a02c0f428..2476b0922e7 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C
@@ -1205,7 +1205,8 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
             const labelList allFaces(identity(mesh_.nFaces()));
             label nWrongFaces = 0;
 
-            //const scalar minV(motionDict.get<scalar>("minVol", true));
+            //const scalar minV
+            //(motionDict.get<scalar>("minVol", keyType::REGEX_RECURSIVE));
             //if (minV > -GREAT)
             //{
             //    polyMeshGeometry::checkFacePyramids
diff --git a/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C
index 71a63b20f5b..ec4a95b43aa 100644
--- a/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C
+++ b/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C
@@ -184,7 +184,8 @@ Foam::refinementSurfaces::refinementSurfaces
     {
         const word& geomName = allGeometry_.names()[geomI];
 
-        const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true);
+        const entry* ePtr =
+            surfacesDict.findEntry(geomName, keyType::LITERAL);
 
         if (ePtr)
         {
diff --git a/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C b/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C
index 210a4232484..8de4a57b4d9 100644
--- a/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C
+++ b/src/mesh/snappyHexMesh/shellSurfaces/shellSurfaces.C
@@ -578,13 +578,11 @@ Foam::shellSurfaces::shellSurfaces
 
     // Count number of shells.
     label shellI = 0;
-    forAll(allGeometry.names(), geomI)
+    for (const word& geomName : allGeometry_.names())
     {
-        const word& geomName = allGeometry_.names()[geomI];
-
         if (shellsDict.found(geomName))
         {
-            shellI++;
+            ++shellI;
         }
     }
 
@@ -615,12 +613,12 @@ Foam::shellSurfaces::shellSurfaces
     {
         const word& geomName = allGeometry_.names()[geomI];
 
-        const entry* ePtr = shellsDict.lookupEntryPtr(geomName, false, true);
+        const entry* eptr = shellsDict.findEntry(geomName, keyType::LITERAL);
 
-        if (ePtr)
+        if (eptr)
         {
-            const dictionary& dict = ePtr->dict();
-            unmatchedKeys.erase(ePtr->keyword());
+            const dictionary& dict = eptr->dict();
+            unmatchedKeys.erase(eptr->keyword());
 
             shells_[shellI] = geomI;
             modes_[shellI] = refineModeNames_.lookup("mode", dict);
@@ -637,12 +635,9 @@ Foam::shellSurfaces::shellSurfaces
                 labelPair(labelMax, labelMin),
                 labelVector::zero
             );
-            const entry* levelPtr = dict.lookupEntryPtr
-            (
-                "levelIncrement",
-                false,
-                true
-            );
+            const entry* levelPtr =
+                dict.findEntry("levelIncrement", keyType::REGEX);
+
             if (levelPtr)
             {
                 // Do reading ourselves since using labelPair would require
diff --git a/src/meshTools/coordinate/systems/coordinateSystem.C b/src/meshTools/coordinate/systems/coordinateSystem.C
index 1b6cb2911dd..4f80e3a8d45 100644
--- a/src/meshTools/coordinate/systems/coordinateSystem.C
+++ b/src/meshTools/coordinate/systems/coordinateSystem.C
@@ -78,7 +78,7 @@ void Foam::coordinateSystem::assign(const dictionary& dict)
     const auto finder = dict.csearchCompat
     (
         "rotation", {{"coordinateRotation", -1806}},
-        false, false
+        keyType::LITERAL
     );
 
     if (finder.isDict())
diff --git a/src/meshTools/coordinate/systems/coordinateSystemNew.C b/src/meshTools/coordinate/systems/coordinateSystemNew.C
index 13c21578eda..af2d569c7db 100644
--- a/src/meshTools/coordinate/systems/coordinateSystemNew.C
+++ b/src/meshTools/coordinate/systems/coordinateSystemNew.C
@@ -42,7 +42,7 @@ const Foam::dictionary* Foam::coordinateSystem::subDictCompat
     {
         // Non-recursive, no pattern matching in the search
         const auto finder =
-            dictPtr->csearch(coordinateSystem::typeName_(), false, false);
+            dictPtr->csearch(coordinateSystem::typeName_(), keyType::LITERAL);
 
         if (finder.isDict())
         {
diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
index 110f57feeb9..791c8d993ba 100644
--- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
+++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
@@ -100,7 +100,7 @@ Foam::fileName Foam::triSurfaceMesh::checkFile
 )
 {
     fileName fName;
-    if (dict.readIfPresent("file", fName, false, false))
+    if (dict.readIfPresent("file", fName, keyType::LITERAL))
     {
         fName = relativeFilePath(io, fName, isGlobal);
 
@@ -318,7 +318,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
     outsideVolType_(volumeType::UNKNOWN)
 {
     // Reading from supplied file name instead of objectPath/filePath
-    if (dict.readIfPresent("file", fName_, false, false))
+    if (dict.readIfPresent("file", fName_, keyType::LITERAL))
     {
         fName_ = relativeFilePath
         (
@@ -418,7 +418,7 @@ Foam::triSurfaceMesh::triSurfaceMesh
     outsideVolType_(volumeType::UNKNOWN)
 {
     // Reading from supplied file name instead of objectPath/filePath
-    if (dict.readIfPresent("file", fName_, false, false))
+    if (dict.readIfPresent("file", fName_, keyType::LITERAL))
     {
         fName_ = relativeFilePath
         (
diff --git a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C
index 378516e3341..c354832edfa 100644
--- a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C
+++ b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMesh.C
@@ -306,11 +306,11 @@ bool Foam::dynamicOversetFvMesh::interpolateFields()
     // Use whatever the solver has set up as suppression list
     const dictionary* dictPtr
     (
-        this->schemesDict().subDictPtr("oversetInterpolationSuppressed")
+        this->schemesDict().findDict("oversetInterpolationSuppressed")
     );
     if (dictPtr)
     {
-        suppressed.insert(dictPtr->sortedToc());
+        suppressed.insert(dictPtr->toc());
     }
 
     interpolate<volScalarField>(suppressed);
diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.C b/src/overset/oversetPolyPatch/oversetFvPatchField.C
index c60307d6358..16905ef7ac5 100644
--- a/src/overset/oversetPolyPatch/oversetFvPatchField.C
+++ b/src/overset/oversetPolyPatch/oversetFvPatchField.C
@@ -136,12 +136,12 @@ void Foam::oversetFvPatchField<Type>::initEvaluate
 
             const dictionary* dictPtr
             (
-                fvSchemes.subDictPtr("oversetInterpolationSuppressed")
+                fvSchemes.findDict("oversetInterpolationSuppressed")
             );
 
             if (dictPtr)
             {
-                suppressed.insert(dictPtr->sortedToc());
+                suppressed.insert(dictPtr->toc());
             }
 
             if (!suppressed.found(fldName))
diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
index d2cec72e0b3..26da76af43a 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
+++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
@@ -121,7 +121,7 @@ void Foam::decompositionMethod::readConstraints()
     // Read any constraints
     wordList constraintTypes;
 
-    const dictionary* dictptr = decompositionDict_.subDictPtr("constraints");
+    const dictionary* dictptr = decompositionDict_.findDict("constraints");
 
     if (dictptr)
     {
diff --git a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C
index 728e782cbba..da1772e30df 100644
--- a/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C
+++ b/src/parallel/decompose/decompositionMethods/multiLevelDecomp/multiLevelDecomp.C
@@ -68,9 +68,9 @@ void Foam::multiLevelDecomp::createMethodsDict()
     if
     (
         // non-recursive, no patterns
-        coeffsDict_.readIfPresent("method", defaultMethod, false, false)
+        coeffsDict_.readIfPresent("method", defaultMethod, keyType::LITERAL)
         // non-recursive, no patterns
-     && coeffsDict_.readIfPresent("domains", domains, false, false)
+     && coeffsDict_.readIfPresent("domains", domains, keyType::LITERAL)
     )
     {
         // Short-cut version specified by method, domains only
@@ -169,14 +169,14 @@ void Foam::multiLevelDecomp::createMethodsDict()
             (
                 iter().isDict()
                 // non-recursive, no patterns
-             && iter().dict().found("numberOfSubdomains", false, false)
+             && iter().dict().found("numberOfSubdomains", keyType::LITERAL)
             )
             {
                 // No method specified? can use a default method?
 
                 const bool addDefaultMethod
                 (
-                    !(iter().dict().found("method", false, false))
+                    !(iter().dict().found("method", keyType::LITERAL))
                  && !defaultMethod.empty()
                 );
 
diff --git a/src/parallel/decompose/metisDecomp/metisDecomp.C b/src/parallel/decompose/metisDecomp/metisDecomp.C
index 43b16be9f66..5fabedf464a 100644
--- a/src/parallel/decompose/metisDecomp/metisDecomp.C
+++ b/src/parallel/decompose/metisDecomp/metisDecomp.C
@@ -72,7 +72,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
     word method("recursive");
 
     const dictionary* coeffsDictPtr =
-        decompositionDict_.subDictPtr("metisCoeffs");
+        decompositionDict_.findDict("metisCoeffs");
 
     label numCells = xadj.size()-1;
 
diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C
index c2abb3cd236..8641753fd8c 100644
--- a/src/regionModels/regionModel/regionModel/regionModel.C
+++ b/src/regionModels/regionModel/regionModel/regionModel.C
@@ -149,9 +149,9 @@ bool Foam::regionModels::regionModel::read()
     {
         if (active_)
         {
-            if (const dictionary* dictPtr = subDictPtr(modelName_ + "Coeffs"))
+            if (const dictionary* dictptr = findDict(modelName_ + "Coeffs"))
             {
-                coeffs_ <<= *dictPtr;
+                coeffs_ <<= *dictptr;
             }
 
             infoOutput_.readIfPresent("infoOutput", *this);
@@ -159,10 +159,8 @@ bool Foam::regionModels::regionModel::read()
 
         return true;
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
@@ -170,18 +168,16 @@ bool Foam::regionModels::regionModel::read(const dictionary& dict)
 {
     if (active_)
     {
-        if (const dictionary* dictPtr = dict.subDictPtr(modelName_ + "Coeffs"))
+        if (const dictionary* dictptr = dict.findDict(modelName_ + "Coeffs"))
         {
-            coeffs_ <<= *dictPtr;
+            coeffs_ <<= *dictptr;
         }
 
         infoOutput_.readIfPresent("infoOutput", dict);
         return true;
     }
-    else
-    {
-        return false;
-    }
+
+    return false;
 }
 
 
-- 
GitLab