diff --git a/bin/foamCreateVideo b/bin/foamCreateVideo
index c5c4abeb979a3c8450b8600b76007d5ec93177d3..6fb419bbc37fac80aba0b912b026465948ea491e 100755
--- a/bin/foamCreateVideo
+++ b/bin/foamCreateVideo
@@ -33,7 +33,7 @@
 
 # Input defaults
 dirName='.'
-prefix='image'
+prefix='image.'
 inputMask='%04d'    # (avconv only)
 unset startNumber   # (avconv only)
 
@@ -52,24 +52,22 @@ usage () {
 
 Usage: ${0##*/} [OPTIONS] ...
 options:
-  -d | -dir <dir>       input directory with png images (default: '.')
-  -f | -fps <fps>       frames per second (default = 10)
-  -i | -image <name>    prefix for input image sequence (default: 'image')
-  -o | -out <name>      name of output video file (default: 'video')
-  -start <frame>        start frame number (avconv only)
+  -d | -dir <dir>       input directory with png images  (default: '.')
+  -f | -fps <fps>       frames per second  (default: 10)
+  -i | -image <name>    input image sequence prefix  (default: 'image.')
+  -o | -out <name>      output video name  (default: 'video')
+  -mask <width>         input mask width for avconv  (default: 4)
+  -start <frame>        start frame number for avconv
   -webm                 WebM output video file format (avconv only)
-  -mask <width>         input mask width (avconv only, default: 4)
   -h | -help            help
 
 Creates a video file from a sequence of PNG images.
-For example, image.0000.png, image.0001.png, ...
-
-- Can use -i/-image to specify other values. Eg, -i "pressure_" ...
-- The output format is MPEG-4
+With the default prefix ('image.'), from image.0000.png, image.0001.png, ...
+- The output format is MPEG4
 - The output name (with mp4 format), is "video.mp4"
 - By default the video codec is high resolution
 
-MPEG-4 output requires avconv or mencoder.
+MPEG4 output requires avconv or mencoder.
 WebM  output requires avconv.
 
 USAGE
@@ -118,8 +116,8 @@ do
         shift
         ;;
     -mask)
-        [ "$#" -ge 2 ] || die "'-out' requires an argument"
-        digits="$(( $2 + 0))"
+        [ "$#" -ge 2 ] || die "'-mask' requires an argument"
+        digits="$(( $2 + 0 ))"
         if [ "$digits" -gt 0 ]
         then
             inputMask="%0${digits}d"
@@ -152,16 +150,6 @@ done
 
 #------------------------------------------------------------------------------
 
-# Add trailing '.' to the prefix if it does not already end with [-._]
-case "$prefix" in
-    *[-_.])
-        : # OK, use prefix as it is
-        ;;
-    (*)
-        prefix="$prefix."
-    ;;
-esac
-
 # See how many files exist
 nFiles="$(\ls $dirName/$prefix*.png 2>/dev/null | wc -l)"
 
@@ -182,7 +170,7 @@ then
         echo "Creating video with avconv..."
         avconv \
             -framerate $frameRate $startNumber \
-            -i "${dirName}/${prefix}$inputMask.png" \
+            -i "$dirName/$prefix$inputMask.png" \
             -c:v libvpx -crf 15 -b:v 1M \
             "$outputPrefix.$outputFormat"
     else
@@ -194,7 +182,7 @@ else
         echo "Creating video with avconv..."
         avconv \
             -framerate $frameRate $startNumber \
-            -i "${dirName}/${prefix}$inputMask.png" \
+            -i "$dirName/$prefix$inputMask.png" \
             -c:v libx264 -pix_fmt yuv420p \
             "$outputPrefix.$outputFormat"
 
diff --git a/bin/foamExec b/bin/foamExec
index cb6bd4496a55e476195a53505e08e8a8cf3bf94a..85b20547e14936f248f140bb21b33503f5b573bb 100755
--- a/bin/foamExec
+++ b/bin/foamExec
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 #-------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -38,10 +38,10 @@
 #     \endcode
 #
 # Note
-#     This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/
-#     or $FOAM_INST_DIR/openfoam<VERSION>/bin/ (for the debian version)
+#     This script must exist in $WM_PROJECT_INST_DIR/OpenFOAM-<VERSION>/bin
+#     or $WM_PROJECT_INST_DIR/openfoam<VERSION>/bin (debian)
 #
-#     foamEtcFile must be found in the same directory as this script
+#     foamEtcFile located in the same directory as this script
 #
 # See also
 #    foamEtcFile
@@ -57,7 +57,7 @@ Usage: ${0##*/} [OPTION] <application> ...
 options:
   -mode=MODE        Any combination of u(user), g(group), o(other)
   -prefix=DIR       Specify an alternative installation prefix
-                    pass through to foamEtcFile and set as FOAM_INST_DIR
+                    pass through to foamEtcFile
   -version=VER      Specify alternative OpenFOAM version (eg, 3.0, 1612, ...)
                     pass through to foamEtcFile
   -help             Print the usage
@@ -71,11 +71,9 @@ USAGE
 #-------------------------------------------------------------------------------
 binDir="${0%/*}"                # The bin dir
 projectDir="${binDir%/bin}"     # The project dir
-prefixDir="${projectDir%/*}"    # The prefix dir (same as $WM_PROJECT_INST_DIR)
-
-## projectDirName="${projectDir##*/}"      # The project directory name
+# prefixDir="${projectDir%/*}"    # The prefix dir (same as $WM_PROJECT_INST_DIR)
 
-version="${WM_PROJECT_VERSION:-unknown}"
+projectVersion="${WM_PROJECT_VERSION:-unknown}"
 
 unset etcOpts
 # parse options
@@ -90,11 +88,10 @@ do
         ;;
     -prefix=/*)
         etcOpts="$etcOpts $1"       # pass-thru to foamEtcFile
-        prefixDir="${1#*=}"
         ;;
     -version=*)
         etcOpts="$etcOpts $1"       # pass-thru to foamEtcFile
-        version="${1#*=}"
+        projectVersion="${1#*=}"    # for reporting
         ;;
     -m | -mode)
         [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
@@ -104,13 +101,12 @@ do
     -p | -prefix)
         [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
         etcOpts="$etcOpts $1 $2"    # pass-thru to foamEtcFile
-        prefixDir="$2"
         shift
         ;;
     -v | -version)
         [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
         etcOpts="$etcOpts $1 $2"    # pass-thru to foamEtcFile
-        version="$2"
+        projectVersion="$2"         # for reporting
         shift
         ;;
     --)
@@ -127,27 +123,23 @@ do
     shift
 done
 
-#
-# Find and source OpenFOAM settings (bashrc)
+
+# Find and source the OpenFOAM <etc/bashrc>
 # placed in function to preserve command-line arguments
-#
-sourceRc()
+sourceBashrc()
 {
     rcFile="$($binDir/foamEtcFile $etcOpts bashrc)" || {
-        echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
-        exit 1
+        echo "Error: bashrc file could not be found for OpenFOAM-$projectVersion" 1>&2
+        exit 2
     }
 
-    # set to consistent value before sourcing the bashrc
-    export FOAM_INST_DIR="$prefixDir"
-
     . $rcFile $FOAM_SETTINGS
 }
 
 
 [ "$#" -ge 1 ] || usage "no application specified"
 
-sourceRc
+sourceBashrc
 exec "$@"
 
 #------------------------------------------------------------------------------
diff --git a/bin/foamJob b/bin/foamJob
index 802122e9def4900b53483aee30ec3f70f14576a8..8ec2dfae0ab9cac26aa61dab8256297af4888f55 100755
--- a/bin/foamJob
+++ b/bin/foamJob
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 #-------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -42,7 +42,7 @@ options:
   -screen           also sends output to screen
   -append           append to log file instead of overwriting it
   -wait             wait for execution to complete (when not using -screen)
-  -version <ver>    specify an alternative OpenFOAM version
+  -version=VER      specify an alternative OpenFOAM version
   -help             print the usage
 
 * run an OpenFOAM job in background.
@@ -56,8 +56,8 @@ USAGE
 echoArgs() {
     addSpace=""
 
-    for stringItem in "$@"; do
-
+    for stringItem in "$@"
+    do
         echo -n "${addSpace}"
 
         if [ "${stringItem##* }" = "$stringItem" ]
@@ -68,13 +68,11 @@ echoArgs() {
             echo -n "'$stringItem'"
             addSpace=" "
         fi
-
     done
 
     unset stringItem addSpace
 }
 
-unset version
 
 # Replacement for possibly buggy 'which'
 findExec() {
@@ -111,81 +109,79 @@ findExec() {
 # Main script
 #~~~~~~~~~~~~
 unset parallelOpt screenOpt waitOpt
-
+unset projectVersion
 
 # Parse options
 while [ "$#" -gt 0 ]
 do
-   case "$1" in
-   -h | -help*)
-      usage
-      ;;
-   -case)
-      [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
-      cd "$2" 2>/dev/null || usage "directory does not exist:  '$2'"
-      shift 2
-      ;;
-   -p | -parallel)
-      parallelOpt=true
-      shift
-      ;;
-   -s | -screen)
-      screenOpt=true
-      shift
-      ;;
-   -a | -append)
-      appendOpt=true
-      shift
-      ;;
-   -w | -wait)
-      waitOpt=true
-      shift
-      ;;
-   -v | -version)
-      [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
-      version="$2"
-      shift 2
-      ;;
-   --)
-      shift
-      break
-      ;;
-   -*)
-      usage "invalid option '$1'"
-      ;;
-   *)
-      break
-      ;;
-   esac
+    case "$1" in
+    -h | -help*)
+        usage
+        ;;
+    -case)
+        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        cd "$2" 2>/dev/null || usage "directory does not exist:  '$2'"
+        shift
+        ;;
+    -p | -parallel)
+        parallelOpt=true
+        ;;
+    -s | -screen)
+        screenOpt=true
+        ;;
+    -a | -append)
+        appendOpt=true
+        ;;
+    -w | -wait)
+        waitOpt=true
+        ;;
+    -version=*)
+        projectVersion="${1#*=}"    # for foamExec
+        ;;
+    -v | -version)
+        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
+        projectVersion="$2"         # for foamExec
+        shift
+        ;;
+    --)
+        shift
+        break
+       ;;
+    -*)
+        usage "invalid option '$1'"
+        ;;
+    *)
+        break
+        ;;
+    esac
+    shift
 done
 
+# ------------------------------------------------------------------------------
+
 [ "$#" -ge 1 ] || usage "No application specified"
 
+# The requested application
+appName="$1"
 
 # Use foamExec for a specified version
 # Also need foamExec for remote (parallel) runs
-if [ -n "$version" -o "$parallelOpt" = true ]
+if [ -n "$projectVersion" -o "$parallelOpt" = true ]
 then
     # When possible, determine if application even exists
-    if [ -z "$version" ]
+    if [ -z "$projectVersion" ]
     then
-        findExec $1 >/dev/null || usage "Application '$1' not found"
+        findExec "$appName" >/dev/null || usage "Application '$appName' not found"
     fi
 
     # Use foamExec for dispatching
-    APPLICATION=`findExec foamExec` || usage "'foamExec' not found"
+    APPLICATION=$(findExec foamExec) || usage "'foamExec' not found"
 
-    [ -n "$version" ] && APPLICATION="$APPLICATION -version $version"
-
-    # Attempt to preserve the installation directory 'FOAM_INST_DIR'
-    if [ -d "$FOAM_INST_DIR" ]
-    then
-        APPLICATION="$APPLICATION -prefix $FOAM_INST_DIR"
-    fi
+    [ -n "$projectVersion" ] && APPLICATION="$APPLICATION -version $projectVersion"
 
 else
-    APPLICATION=`findExec $1` || usage "Application '$1' not found"
-    echo "Application : $1"
+    APPLICATION=$(findExec "$appName") || usage "Application '$appName' not found"
+    echo "Application : $appName"
     shift
 fi
 
@@ -200,7 +196,7 @@ then
     #
     if [ -r "processor0" -o -r "processors" ]
     then
-        NPROCS="$(foamDictionary -entry numberOfSubdomains -value system/decomposeParDict)"
+        nprocs="$(foamDictionary -entry numberOfSubdomains -value system/decomposeParDict 2>/dev/null)"
     else
         echo "Case is not currently decomposed"
         if [ -r system/decomposeParDict ]
@@ -218,16 +214,16 @@ then
     #
     # Find mpirun
     #
-    mpirun=`findExec mpirun` || usage "'mpirun' not found"
-    mpiopts="-np $NPROCS"
+    mpirun=$(findExec mpirun) || usage "'mpirun' not found"
+    mpiopts="-np $nprocs"
 
     #
     # Check if the machine ready to run parallel
     #
-    echo "Parallel processing using $WM_MPLIB with $NPROCS processors"
+    echo "Parallel processing using $WM_MPLIB with $nprocs processors"
     case "$WM_MPLIB" in
     *OPENMPI)
-        # add hostfile info
+        # Add hostfile info
         for hostfile in \
             hostfile \
             machines \
@@ -242,12 +238,9 @@ then
             fi
         done
 
-        #
         # Send FOAM_SETTINGS to parallel processes, so that the proper
         # definitions are sent as well.
-        #
         mpiopts="$mpiopts -x FOAM_SETTINGS"
-
         ;;
     esac
 
diff --git a/bin/mpirunDebug b/bin/mpirunDebug
index d92858d9bf3b03a588757a5d14d25183af71bd19..249dfbf60bef484e2b3abf84b2e334199575cb3d 100755
--- a/bin/mpirunDebug
+++ b/bin/mpirunDebug
@@ -191,6 +191,8 @@ then
 fi
 
 
+sourceFoam=false    # Fallback command
+
 # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
 # check ~/.$WM_PROJECT/
 # check <installedProject>/etc/
@@ -210,18 +212,16 @@ then
     done
 fi
 
-# Construct test string for remote execution.
 # Source OpenFOAM settings if OpenFOAM environment not set.
-# attempt to preserve the installation directory 'FOAM_INST_DIR'
 # use FOAM_SETTINGS to pass command-line settings
-if [ -n "$FOAM_INST_DIR" ]
-then
-    sourceFoam="FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
-else
+
+case "$sourceFoam" in
+*/bashrc)
     sourceFoam=". $sourceFoam $FOAM_SETTINGS"
-fi
+    ;;
+esac
 
-echo "**sourceFoam:$sourceFoam"
+echo "**sourceFoam: $sourceFoam"
 
 rm -f $PWD/mpirun.schema
 touch $PWD/mpirun.schema
diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths
index 126489bf9b70c177bde72f3e592c2bc6135a8a4b..b99f37986b88ae1beaf3624bb2ec8c91f3001506 100755
--- a/bin/tools/foamConfigurePaths
+++ b/bin/tools/foamConfigurePaths
@@ -181,7 +181,7 @@ do
     -foamInstall | --foamInstall)
         # Replace FOAM_INST_DIR=...
         [ "$#" -ge 2 ] || die "'$1' option requires an argument"
-        foamInstDir="$2"
+        prefixDir="$2"
         _inlineSed \
             etc/bashrc \
             '\(.*BASH_SOURCE.*\)' \
@@ -195,8 +195,8 @@ do
         _inlineSed \
             etc/bashrc \
             '^ *FOAM_INST_DIR=.*' \
-            'FOAM_INST_DIR='"$foamInstDir" \
-            "Setting FOAM_INST_DIR to '$foamInstDir'"
+            'FOAM_INST_DIR='"$prefixDir" \
+            "Setting fallback FOAM_INST_DIR to '$prefixDir'"
 
         adjusted=true
         shift
diff --git a/etc/bashrc b/etc/bashrc
index 658883d95cb57303e6371afd9a0f6bb63df8e0ba..07e5411ce3f836b0024016df3ad3344f2e316312 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -47,7 +47,6 @@ FOAM_INST_DIR=$HOME/$WM_PROJECT
 # END OF (NORMAL) USER EDITABLE PART
 ################################################################################
 : # Extra safety - if the user commented out all fallback values
-export FOAM_INST_DIR
 unset rc
 
 # Configuration environment variables.
@@ -199,6 +198,7 @@ fi
 . $WM_PROJECT_DIR/etc/config.sh/functions
 
 # Variables (done as the last statement for a clean exit code)
+unset FOAM_INST_DIR     # Old variable name (OpenFOAM-v1606) - now unneeded
 unset cleaned foamOldDirs
 
 #------------------------------------------------------------------------------
diff --git a/etc/config.csh/aliases b/etc/config.csh/aliases
index d423c053e4f9a29c36f28f367a99a971b26be48f..d607fbf69cd1dfdc4c11de27678d89cc82c68685 100644
--- a/etc/config.csh/aliases
+++ b/etc/config.csh/aliases
@@ -57,13 +57,13 @@ alias uutil 'cd $WM_PROJECT_USER_DIR/applications/utilities'
 
 # Refresh the environment
 # ~~~~~~~~~~~~~~~~~~~~~~~
-alias wmRefresh 'set wmProjectDir=$WM_PROJECT_DIR; set foamSettings=$FOAM_SETTINGS; wmUnset; source $wmProjectDir/etc/cshrc $foamSettings'
+alias wmRefresh 'set projectDir=$WM_PROJECT_DIR; set foamSettings=$FOAM_SETTINGS; wmUnset; source $projectDir/etc/cshrc $foamSettings'
 
 
 # Change OpenFOAM version
 # ~~~~~~~~~~~~~~~~~~~~~~~
 alias foamVersion \
-    'if ( "\!*" != "" ) source $FOAM_INST_DIR/OpenFOAM-\!*/etc/cshrc; foam; echo OpenFOAM-$WM_PROJECT_VERSION'
+    'if ( "\!*" != "" ) source ${WM_PROJECT_DIR:h}/OpenFOAM-\!*/etc/cshrc; foam; echo OpenFOAM-$WM_PROJECT_VERSION'
 
 
 # Change ParaView version
diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases
index f93b5c6818185305c97a2ac72bef918a276f1f0f..2a5c5790642871914d971350d795309d35c38b44 100644
--- a/etc/config.sh/aliases
+++ b/etc/config.sh/aliases
@@ -65,31 +65,30 @@ wmRefresh()
 }
 
 
-# Change OpenFOAM version
-# ~~~~~~~~~~~~~~~~~~~~~~~
+# Query the current OpenFOAM version
+# or change to another version (if installed in a parallel directory)
 unset -f foamVersion 2>/dev/null
 foamVersion()
 {
     if [ "$#" -gt 0 ]
     then
+        local dir="${WM_PROJECT_DIR%/*}"    # Parent directory
         local ver=$1
         shift
-        # The variable foamInstDir had meaning for older OpenFOAM versions
-        foamInstDir=$FOAM_INST_DIR
-        if [ -f "$foamInstDir/OpenFOAM-$ver/etc/bashrc" ]
+
+        if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ]
         then
             wmUnset
-            . $foamInstDir/OpenFOAM-$ver/etc/bashrc
-            unset foamInstDir
+            . $dir/OpenFOAM-$ver/etc/bashrc
             foam
             echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2
         else
-            unset foamInstDir
-            echo "No OpenFOAM-$ver available" 1>&2
+            echo "No OpenFOAM-$ver available in $dir" 1>&2
             echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2
             return 1
         fi
     else
+        # Treat as query. Report current version
         echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2
     fi
 }
diff --git a/etc/cshrc b/etc/cshrc
index 8a95894abf960d2bbbd1844de246bbd753e26e39..a1125b5b70b1ef8b0c2f95cd3f03e1916b4d1cc9 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -38,11 +38,11 @@ setenv WM_PROJECT_VERSION plus
 #    should work when sourced by CSH or TCSH shells. If this however fails,
 #    set one of the fallback values to an appropriate path.
 # --
-setenv FOAM_INST_DIR `lsof +p $$ |& \
+set FOAM_INST_DIR=`lsof +p $$ |& \
     sed -n -e 's@[^/]*@@' -e 's@/'$WM_PROJECT'[^/]*/etc/cshrc.*@@p'`
-# setenv FOAM_INST_DIR  $HOME/$WM_PROJECT
-# setenv FOAM_INST_DIR  /opt/$WM_PROJECT
-# setenv FOAM_INST_DIR  /usr/local/$WM_PROJECT
+# set FOAM_INST_DIR=$HOME/$WM_PROJECT
+# set FOAM_INST_DIR=/opt/$WM_PROJECT
+# set FOAM_INST_DIR=/usr/local/$WM_PROJECT
 #
 # END OF (NORMAL) USER EDITABLE PART
 ################################################################################
@@ -240,6 +240,7 @@ unalias _foamAddLib
 unalias _foamAddLibAuto
 
 # Variables (done as the last statement for a clean exit code)
+unset FOAM_INST_DIR     # Old variable name (OpenFOAM-v1606) - now unneeded
 unset cleaned foamOldDirs
 
 #------------------------------------------------------------------------------
diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler
index 98e645baf3ed9a65d4fc8b6322bc27659e8cdf13..ff07cb488917b97129542adeea2f6232619e1f41 100755
--- a/wmake/wmakeScheduler
+++ b/wmake/wmakeScheduler
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 #-------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -45,7 +45,6 @@
 #
 #     WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
 #     before calling this routine.
-#     FOAM_INST_DIR may possibly have been set (to find installation)
 #
 #-------------------------------------------------------------------------------
 Script=${0##*/}
@@ -90,7 +89,7 @@ esac
 # Check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
 # Check ~/.$WM_PROJECT/
 # Check <installedProject>/etc/
-if [ "$WM_PROJECT" ]
+if [ -n "$WM_PROJECT" ]
 then
     for i in \
         $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
@@ -108,20 +107,13 @@ fi
 
 # Construct test string for remote execution.
 # Source WM_PROJECT settings if WM_PROJECT environment not set.
-# Attempt to preserve the installation directory 'FOAM_INST_DIR'
 # Use FOAM_SETTINGS to pass command-line settings
-case $sourceFoam in
+case "$sourceFoam" in
 */bashrc)
-    if [ "$FOAM_INST_DIR" ]
-    then
-        sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
-    else
-        sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
-    fi
+    sourceFoam='[ -n "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
     ;;
 
 */cshrc)
-    # TODO: csh equivalent to bash code (preserving FOAM_INST_DIR)
     sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam $FOAM_SETTINGS"
     ;;
 esac
diff --git a/wmake/wmakeSchedulerUptime b/wmake/wmakeSchedulerUptime
index 19a346a8097f1324f2699b3f780ac3f2a3aa3814..569470fb56e727ed75708f00b7aa8bb04cc72a88 100755
--- a/wmake/wmakeSchedulerUptime
+++ b/wmake/wmakeSchedulerUptime
@@ -4,7 +4,7 @@
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
 #   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-#    \\/     M anipulation  |
+#    \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 #-------------------------------------------------------------------------------
 # License
 #     This file is part of OpenFOAM.
@@ -45,7 +45,6 @@
 #
 #     WM_PROJECT_DIR, WM_PROJECT and WM_PROJECT_VERSION will have been set
 #     before calling this routine.
-#     FOAM_INST_DIR may possibly have been set (to find installation)
 #
 #-------------------------------------------------------------------------------
 Script=${0##*/}
@@ -89,7 +88,7 @@ esac
 # Check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/
 # Check ~/.$WM_PROJECT/
 # Check <installedProject>/etc/
-if [ "$WM_PROJECT" ]
+if [ -n "$WM_PROJECT" ]
 then
     for i in \
         $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \
@@ -107,20 +106,13 @@ fi
 
 # Construct test string for remote execution.
 # Source WM_PROJECT settings if WM_PROJECT environment not set.
-# Attempt to preserve the installation directory 'FOAM_INST_DIR'
 # Use FOAM_SETTINGS to pass command-line settings
-case $sourceFoam in
+case "$sourceFoam" in
 */bashrc)
-    if [ "$FOAM_INST_DIR" ]
-    then
-        sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam $FOAM_SETTINGS"
-    else
-        sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
-    fi
+    sourceFoam='[ -n "$WM_PROJECT" ] || '". $sourceFoam $FOAM_SETTINGS"
     ;;
 
 */cshrc)
-    # TODO: csh equivalent to bash code (preserving FOAM_INST_DIR)
     sourceFoam='if ( ! $?WM_PROJECT ) source '"$sourceFoam $FOAM_SETTINGS"
     ;;
 esac
@@ -151,7 +143,7 @@ set -o pipefail
 #
 colourPipe()
 {
-    if [ "$1" ]
+    if [ -n "$1" ]
     then
     (
         while read line