diff --git a/.gitignore b/.gitignore
index 0639d63c1bb891639e80d4d69393c05474c4e5ef..296f8d03675bb503be69f68d9260a60b4cacfde4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,9 @@ SiCortex*Gcc*/
 solaris*Gcc*/
 SunOS*Gcc*/
 
+# reinstate wmake/rules that might look like build folders
+!wmake/rules/*/
+
 # doxygen generated documentation
 doc/[Dd]oxygen/html
 doc/[Dd]oxygen/latex
diff --git a/Allwmake b/Allwmake
index ca2113e522cf92ccfa3d626acb9c16b30bdc1a41..c01c6c0d1a3c292cb0bd8c00ac66a35fc520180f 100755
--- a/Allwmake
+++ b/Allwmake
@@ -1,13 +1,13 @@
 #!/bin/sh
 cd ${0%/*} || exit 1    # run from this directory
-set -x
 
 # wmake is required for subsequent targets
 ( cd wmake/src && make )
 
 # build ThirdParty sources
-( cd $WM_THIRD_PARTY_DIR && ./Allwmake )
+$WM_THIRD_PARTY_DIR/Allwmake
 
+# build OpenFOAM libraries and applications
 src/Allwmake
 applications/Allwmake
 
diff --git a/README b/README
index fe5b67e0590f69580de8a240efe8166bdd3ebe91..390dd8edb581455cc4c7b1fa1ebfddbb58bb8bde 100644
--- a/README
+++ b/README
@@ -30,8 +30,8 @@
     check whether Qt4 is installed, and the version, type:
     + qmake --version
 
-    Both 32- and 64-bit version of ParaView were compiled with Qt-4.4.3 (with
-    openSuSE-11.1).  If the user finds that a ParaView binary fails to run, then
+    Both 32-bit and 64-bit version of ParaView were compiled with Qt-4.4.3 (with
+    openSUSE-11.1).  If the user finds that a ParaView binary fails to run, then
     it is almost certainly due to a conflict in compiled and installed Qt
     versions and they will need to consult the section below on "Compiling
     ParaView and the PV3FoamReader module."
@@ -40,10 +40,10 @@
     + ubuntu-7.10:   Version 4.3.2
     + ubuntu-8.04:   Version 4.3.4
     + ubuntu-9.04:   Version 4.5.0
-    + openSuSE-10.2: Version 4.2.1 - too old
-    + openSuSE-10.3: Version 4.3.1
-    + openSuSE-11.0: Version 4.4.0
-    + openSuSE-11.1: Version 4.4.3
+    + openSUSE-10.2: Version 4.2.1 - too old
+    + openSUSE-10.3: Version 4.3.1
+    + openSUSE-11.0: Version 4.4.0
+    + openSUSE-11.1: Version 4.4.3
 
     Compilation and running of ParaView has been successful using the libraries
     downloaded in the "libqt4-dev" package on ubuntu.
@@ -51,7 +51,7 @@
     If you don't have an appropriate version of Qt installed you can download
     the sources from TrollTech e.g.:
     ftp://ftp.trolltech.com/qt/source/qt-x11-opensource-src-4.3.5.tar.bz2
-    and compile and install in /usr/local or some other location that does to
+    and compile and install in /usr/local or some other location that does not
     conflict with the pre-installed version.
 
 * Installation
@@ -112,7 +112,7 @@
   which may be obtained from http://gcc.gnu.org/.
 
   Install the compiler in
-  $WM_PROJECT_INST_DIR/ThirdParty/gcc-<GCC_VERSION>/platforms/$WM_ARCH$WM_COMPILER_ARCH/
+  $WM_THIRD_PARTY_DIR/gcc-<GCC_VERSION>/platforms/$WM_ARCH$WM_COMPILER_ARCH/
   and change the gcc version number in $WM_PROJECT_DIR/etc/settings.sh and
   $WM_PROJECT_DIR/etc/settings.csh appropriately and finally update the
   environment variables as in section 3.
@@ -120,7 +120,7 @@
   Now go to the top-level source directory $WM_PROJECT_DIR and execute the
   top-level build script './Allwmake'.  In principle this will build everything,
   but if problems occur with the build order it may be necessary to update the
-  environment variables and re-execute 'Allwmake'.
+  environment variables and re-execute './Allwmake'.
 
   If you experience difficulties with building the source-pack, or your platform
   is not currently supported, please contact <enquiries@OpenCFD.co.uk> to
@@ -160,12 +160,13 @@
 * Compiling Paraview 3.6.1 and the PV3FoamReader module
   If there are problems encountered with ParaView, then it may be necessary to
   compile ParaView from sources.  The compilation
-  is a fairly simple process using the supplied makeParaView script that
-  has worked in our tests with other packages supplied in the ThirdParty
-  directory, namely cmake-2.6.4 and gcc-4.3.3.  Execute the following:
+  is a fairly simple process using the makeParaView script
+  (found in ThirdParty directory), which has worked in our tests with other
+  packages supplied in the ThirdParty directory, namely cmake-2.6.4 and
+  gcc-4.3.3.  Execute the following:
   + cd $WM_THIRD_PARTY_DIR
   + rm -rf paraview-3.6.1/platforms
-  + makeParaView
+  + ./makeParaView
 
   The PV3FoamReader module is an OpenFOAM utility that can be compiled in the
   usual manner as follows:
diff --git a/applications/test/fileNameClean/Make/files b/applications/test/fileNameClean/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..8363e079a201fdccb4dfe708a75b6b7d44136d20
--- /dev/null
+++ b/applications/test/fileNameClean/Make/files
@@ -0,0 +1,3 @@
+fileNameCleanTest.C
+
+EXE = $(FOAM_USER_APPBIN)/fileNameCleanTest
diff --git a/applications/test/fileNameClean/Make/options b/applications/test/fileNameClean/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/applications/test/fileNameClean/fileNameCleanTest.C b/applications/test/fileNameClean/fileNameCleanTest.C
new file mode 100644
index 0000000000000000000000000000000000000000..b41cc434ca0c51a070de7fceedb11065ffc25008
--- /dev/null
+++ b/applications/test/fileNameClean/fileNameCleanTest.C
@@ -0,0 +1,104 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM; if not, write to the Free Software Foundation,
+    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Application
+    fileNameCleanTest
+
+Description
+
+
+\*---------------------------------------------------------------------------*/
+
+#include "argList.H"
+#include "fileName.H"
+#include "SubList.H"
+#include "IOobject.H"
+#include "IOstreams.H"
+#include "OSspecific.H"
+
+
+using namespace Foam;
+
+void printCleaning(fileName& pathName)
+{
+    Info<< "fileName = " << pathName << nl
+        << "  path() = " << pathName.path() << nl
+        << "  name() = " << pathName.name() << nl
+        << "  joined = " << pathName.path()/pathName.name() << nl << nl;
+
+    pathName.clean();
+
+    Info<< "cleaned  = " << pathName << nl
+        << "  path() = " << pathName.path() << nl
+        << "  name() = " << pathName.name() << nl
+        << "  joined = " << pathName.path()/pathName.name() << nl << nl;
+
+    IOobject::writeDivider(Info);
+}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    argList::noBanner();
+    argList::noParallel();
+    argList::validArgs.insert("fileName .. fileNameN");
+
+    argList args(argc, argv, false, true);
+
+    if (args.additionalArgs().empty())
+    {
+        args.printUsage();
+    }
+
+    if (args.optionFound("case"))
+    {
+        fileName pathName = args.option("case");
+        Info<< nl
+            << "-case" << nl
+            << "path = " << args.path() << nl
+            << "root = " << args.rootPath() << nl
+            << "case = " << args.caseName() << nl
+            << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
+            << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
+            << endl;
+
+        printCleaning(pathName);
+    }
+
+    forAll(args.additionalArgs(), argI)
+    {
+        fileName pathName = args.additionalArgs()[argI];
+        printCleaning(pathName);
+    }
+
+    Info<< "\nEnd" << endl;
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/test/foamVersion/foamVersionString.C b/applications/test/foamVersion/foamVersionString.C
index be63290a30afe3525c9e290b56ed7b2f0ee9b71b..17ac2679e1f76bd6d63523dbdd571c86c1069abf 100644
--- a/applications/test/foamVersion/foamVersionString.C
+++ b/applications/test/foamVersion/foamVersionString.C
@@ -27,6 +27,7 @@ Application
 
 Description
     Print the OpenFOAM version strings.
+
     Simultaneously the smallest possible program to use a minimal bit of
     the OpenFOAM library
 
@@ -37,9 +38,9 @@ Description
 
 int main()
 {
-    std::cerr
-        << "build   " << Foam::FOAMbuild << "\n"
-        << "version " << Foam::FOAMversion << "\n";
+    std::cout
+        << "version " << Foam::FOAMversion << "\n"
+        << "build   " << Foam::FOAMbuild << "\n";
 
     return 0;
 }
diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake
index ae71b400fa5dda71248426baa4d181889f94b4a0..2791c1121e2f77b7a7a60ed67ceb7db539d5e836 100755
--- a/applications/utilities/mesh/conversion/Optional/Allwmake
+++ b/applications/utilities/mesh/conversion/Optional/Allwmake
@@ -5,9 +5,8 @@
 cd ${0%/*} || exit 1    # run from this directory
 set -x
 
-
 # build libccmio and create lnInclude directory
-( cd $WM_THIRD_PARTY_DIR && ./AllwmakeLibccmio )
+$WM_THIRD_PARTY_DIR/AllwmakeLibccmio
 
 # if the library built properly, the headers should exist too
 if [ -e $FOAM_LIBBIN/libccmio.so ]
diff --git a/bin/foamTags b/bin/foamTags
index e00795d8e68ea29dfbdb2b8010d1c3884298216b..9c173497f600f2e64bf174c4f9f6b54bffa7e333 100755
--- a/bin/foamTags
+++ b/bin/foamTags
@@ -31,17 +31,29 @@
 #
 #------------------------------------------------------------------------------
 
-if [ $# -ne 0 ]; then
-   echo "Usage : ${0##*/}"
-   echo ""
-   echo "Build the tags files for all the .C and .H files"
-   echo ""
-   exit 1
+if [ $# -ne 0 ]
+then
+    echo "Usage : ${0##*/}"
+    echo ""
+    echo "Build the tags files for all the .C and .H files"
+    echo ""
+    exit 1
 fi
 
-cd $WM_PROJECT_DIR
+
+for cmd in etags ectags
+do
+    type $cmd >/dev/null 2>&1 || {
+        echo "${0##*/} cannot build tag files: '$cmd' command not found"
+        exit
+    }
+done
+
+
+cd $WM_PROJECT_DIR || exit
 mkdir .tags 2>/dev/null
 
+
 etagsCmd="etags --declarations -l c++ -o .tags/etags -"
 #etagsDefCmd="etags -l c++ -o .tags/etagsDef -"
 #etagsDecCmd="etags --declarations -l c++ -o .tags/etagsDec -"
diff --git a/bin/tools/foamThirdParty b/bin/tools/foamThirdParty
deleted file mode 100755
index 0df42920c766824b198ab7e45644c0a5486014ee..0000000000000000000000000000000000000000
--- a/bin/tools/foamThirdParty
+++ /dev/null
@@ -1,398 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-use File::Spec;
-use Getopt::Long;
-
-#############################################################################
-# SETTINGS
-#
-my %config = (
-    thirdParty => "$ENV{WM_PROJECT_INST_DIR}/ThirdParty",
-    project    => ( $ENV{WM_PROJECT} || '' ) . "-"
-      . ( $ENV{WM_PROJECT_VERSION} || '' ),
-);
-
-my %packages = (
-    cmake => {
-        -opt => 1,
-        url  => "http://www.cmake.org/files/v2.6/cmake-2.6.0.tar.gz",
-    },
-
-    lam => {
-        -opt => 1,
-        url  => "http://www.lam-mpi.org/download/files/lam-7.1.4.tar.bz2",
-    },
-
-    libccmio => {
-        -opt => 1,
-        url  =>
-          "https://wci.llnl.gov/codes/visit/3rd_party/libccmio-2.6.1.tar.gz",
-    },
-
-    openmpi => {
-        url =>
-"http://www.open-mpi.org/software/ompi/v1.2/downloads/openmpi-1.2.6.tar.bz2",
-    },
-
-    metis => {
-        url =>
-          "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.0pre2.tar.gz"
-    },
-    mico => {
-        -opt => 1,
-        url  => "http://www.mico.org/mico-2.3.12.tar.gz",
-    },
-
-    mpich => {
-        -opt => 1,
-        url  => "ftp://ftp.mcs.anl.gov/pub/mpi/old/mpich-1.2.4.tar.gz",
-    },
-
-    ParMetis => {
-        url =>
-"http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/ParMetis-3.1.tar.gz",
-    },
-
-    ParMGridGen => {
-        url =>
-"http://www-users.cs.umn.edu/~moulitsa/download/ParMGridGen-1.0.tar.gz",
-    },
-
-    zlib => { url => "http://www.zlib.net/zlib-1.2.3.tar.gz", },
-
-    hoard => {
-        -opt => 1,
-        url  =>
-          "http://www.cs.umass.edu/%7Eemery/hoard/hoard-3.7.1/hoard-371.tar.gz"
-    },
-
-##    # this really doesn't work well, but code needs minor patching anyhow:
-##    fbsdmalloc => {
-##        url =>
-##        "http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libc/stdlib/malloc.c?rev=1.171",
-##
-##    },
-);
-
-#
-# END OF SETTINGS
-############################################################################
-
-( my $Script = $0 ) =~ s{^.*/}{};
-
-# --------------------------------------------------------------------------
-sub usage {
-    my ( @req, @opt );
-
-    for ( sort keys %packages ) {
-        if ( $packages{$_}{-opt} ) {
-            push @opt, $_;
-        }
-        else {
-            push @req, $_;
-        }
-    }
-
-    $! = 0;    # clean exit
-    warn "@_\n" if @_;
-    die <<"USAGE";
-usage:
-    $Script [OPTION] [package1 .. packageN]
-
-options:
-  -help     usage
-  -status   show status  [default]
-  -list     list versions and resource locations
-  -version  list versions only
-  -dir      list unpack directory
-  -reldir   list unpack directory relative to cwd
-  -get      get packages as required (uses curl)
-  -unpack   unpack packages where required and possible
-
-Simple management of 3rd party software for '$config{project}'
-using the directory
-    $config{thirdParty}
-
-Packages:  @req
-Optional:  @opt
-
-Return codes:
-  -status -get -unpack   number of missing packages or errors
-
-USAGE
-}
-
-# --------------------------------------------------------------------------
-my %opt;
-
-# default action is -status
-@ARGV or $opt{status}++;
-GetOptions(
-    \%opt,    ##
-    "help",   "status", "list", "version", "dir",
-    "reldir", "get",    "unpack",
-  )
-  or usage;
-
-$opt{help} and usage;
-
--d $config{thirdParty} or usage "ERROR: no '$config{thirdParty}' dir";
-
-#
-# complete the config
-#
-if ( not exists $config{sources} ) {
-    $config{sources} = "$config{thirdParty}/sources";
-    -d $config{sources} or mkdir $config{sources};
-}
-
-#
-# cleanup the packages table
-#
-for my $name ( keys %packages ) {
-    my $href = $packages{$name};
-
-    if ( not $href->{url} ) {
-        warn "$name without url\n";
-        delete $packages{$name};
-        next;
-    }
-
-    if ( not exists $href->{file} ) {
-        ( $href->{file} = $href->{url} ) =~ s{^.*/|\?.*$}{}g;
-    }
-
-    if ( not exists $href->{dir} ) {
-        ( $href->{dir} = $href->{file} ) =~ s{\.(zip|tar(\.(gz|bz2))?)$}{};
-    }
-}
-
-#
-# check for names in the packages
-#
-sub selectNames {
-    my @names;
-    my $req;
-
-    while ( @_ and $_[0] =~ /^-/ ) {
-        my $opt = shift;
-        if ( $opt =~ /^-req/ ) {
-            $req++;
-        }
-    }
-
-    if (@_) {
-        my ( %seen, @reject );
-        for my $name (@_) {
-            next if $seen{$name}++;
-            if ( exists $packages{$name} ) {
-                push @names, $name;
-            }
-            else {
-                push @reject, $name;
-            }
-        }
-
-        usage "unknown package(s): @reject" if @reject;
-    }
-    else {
-        @names =
-          grep { not $req or not $packages{$_}{-opt} } sort keys %packages;
-    }
-
-    @names or usage "no packages";
-
-    return @names;
-}
-
-#
-# list the current status
-#
-if ( $opt{status} ) {
-    my @names = selectNames @ARGV;
-
-    my $nMissing = 0;
-
-    for my $name (@names) {
-        my $href = $packages{$name};
-        my ( $dir, $file, $url ) = @$href{qw( dir file url )};
-
-        my @status;
-        if ( -e "$config{sources}/$file" ) {
-            push @status, "  packed: $config{sources}/$file";
-        }
-
-        if ( -d "$config{thirdParty}/$dir" ) {
-            push @status, "unpacked: $config{thirdParty}/$dir";
-        }
-
-        unless (@status) {
-            $nMissing++;
-            @status = "missing";
-        }
-
-        for (@status) {
-            printf "%-16s %-16s %s", $name, $dir, $_;
-
-            if ( $href->{-opt} ) {
-                print "  [optional]";
-            }
-            print "\n";
-        }
-    }
-
-    exit $nMissing;
-}
-
-#
-# show an overview of the versions and the resource locations
-#
-if ( $opt{list} ) {
-    my @names = selectNames @ARGV;
-
-    for my $name (@names) {
-        my $href = $packages{$name};
-        my ( $dir, $file, $url ) = @$href{qw( dir file url )};
-
-        printf "%-16s %-16s %s", $name, $dir, $url;
-        if ( $href->{-opt} ) {
-            print "  [optional]";
-        }
-        print "\n";
-
-    }
-
-    exit 0;
-}
-
-#
-# show the version (directory name) only
-#
-if ( $opt{version} ) {
-    my @names = selectNames @ARGV;
-
-    for my $name (@names) {
-        my $href = $packages{$name};
-        my ( $dir, $file, $url ) = @$href{qw( dir file url )};
-
-        print $dir, "\n";
-    }
-
-    exit 0;
-}
-
-#
-# show the unpack directory name
-#
-if ( $opt{dir} or $opt{reldir} ) {
-    my @names = selectNames @ARGV;
-    my $base  = $config{thirdParty};
-
-    if ( $opt{reldir} ) {
-        $base = File::Spec->abs2rel($base);
-        length $base or $base = '.';
-    }
-
-    for my $name (@names) {
-        my $href = $packages{$name};
-        my ( $dir, $file, $url ) = @$href{qw( dir file url )};
-
-        print File::Spec->catfile( $base, $dir ), "\n";
-    }
-
-    exit 0;
-}
-
-#
-# get and/or unpack packages as required and possible
-# avoid getting/unpacking optional packages
-#
-if ( $opt{get} or $opt{unpack} ) {
-    my @names = selectNames -required => @ARGV;
-
-    my $nError = 0;
-
-    for my $name (@names) {
-        my $href = $packages{$name};
-        my ( $dir, $file, $url ) = @$href{qw( dir file url )};
-
-        my $flags = "";
-        if ( $href->{-opt} ) {
-            $flags .= "[optional]";
-        }
-
-        warn '-' x 70, "\n", "$name  ($dir)  $flags\n";
-
-        if ( -d "$config{thirdParty}/$dir" ) {
-            warn "unpacked: $config{thirdParty}/$dir\n";
-            next;
-        }
-
-        if ( $opt{get} ) {
-            if ( -e "$config{sources}/$file" ) {
-                warn "  packed: $config{sources}/$file\n";
-            }
-            else {
-                my $fetch = "curl -k -o $file";
-
-                # curl seems to hang on anonymous ftp?
-                if ( $url =~ /^ftp:/ ) {
-                    $fetch = "wget -v";
-                }
-
-                system "set -x; cd $config{sources} && $fetch $url";
-
-                if ( not -e "$config{sources}/$file" ) {
-                    $nError++;
-                    warn "  download failed!?\n";
-                    next;
-                }
-            }
-        }
-
-        if ( $opt{unpack} ) {
-            if ( -e "$config{sources}/$file" ) {
-                my $unpack;
-                if ( $file =~ m{\.zip$} ) {
-                    $unpack = "unzip";
-                }
-                elsif ( $file =~ m{\.tar$} ) {
-                    $unpack = "tar -xf";
-                }
-                elsif ( $file =~ m{\.tar\.bz2$} ) {
-                    $unpack = "tar -xjf";
-                }
-                elsif ( $file =~ m{\.(tgz|tar\.gz)$} ) {
-                    $unpack = "tar -xzf";
-                }
-                else {
-                    $nError++;
-                    warn "  no unpack defined for $file\n";
-                    next;
-                }
-
-                system
-"set -x; cd $config{thirdParty} && $unpack $config{sources}/$file";
-
-                # catch isolated cases where it unpacks without a version number
-                if ( -d "$config{thirdParty}/$name"
-                    and not -d "$config{thirdParty}/$dir" )
-                {
-                    rename "$config{thirdParty}/$name",
-                      "$config{thirdParty}/$dir";
-                }
-
-                unless ( -d "$config{thirdParty}/$dir" ) {
-                    $nError++;
-                    warn "unpack failed!?\n";
-                    next;
-                }
-            }
-        }
-    }
-
-    warn '-' x 70, "\n\n";
-    exit $nError;
-}
-
-# --------------------------------------------------------------------------
diff --git a/bin/tools/thirdPartyGetFunctions b/bin/tools/thirdPartyGetFunctions
deleted file mode 100644
index b1e94ae8b31b1cee3724fa023ea0e46504a45c73..0000000000000000000000000000000000000000
--- a/bin/tools/thirdPartyGetFunctions
+++ /dev/null
@@ -1,78 +0,0 @@
-#---------------------------------*- sh -*-------------------------------------
-# =========                 |
-# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-#  \\    /   O peration     |
-#   \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
-#    \\/     M anipulation  |
-#------------------------------------------------------------------------------
-# License
-#     This file is part of OpenFOAM.
-#
-#     OpenFOAM is free software; you can redistribute it and/or modify it
-#     under the terms of the GNU General Public License as published by the
-#     Free Software Foundation; either version 2 of the License, or (at your
-#     option) any later version.
-#
-#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-#     for more details.
-#
-#     You should have received a copy of the GNU General Public License
-#     along with OpenFOAM; if not, write to the Free Software Foundation,
-#     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# Script
-#     thirdPartyGetFunctions
-#
-# Description
-#     Functions for managing the third-party packages
-#
-#------------------------------------------------------------------------------
-
-#
-# get, unpack and change to third party directory
-# - call from within a sub-shell, since it uses 'cd'
-#
-getUnpack() {
-   [ "$#" -eq 1 ] || {
-      echo "getUnpack called with incorrect arguments $@"
-      return 1
-   }
-
-   d=$(foamThirdParty -dir $1 2>/dev/null) || {
-      echo "nothing know about '$1'"
-      return 1
-   }
-
-   foamThirdParty -get -unpack $1 && [ -d "$d" ] || return 1
-
-   [ -d "$d" ] && chmod -R ugo+rX $d 2>/dev/null
-
-   echo $d
-}
-
-#
-# copy Make/{files,options} from wmakeFiles/PACKAGE
-#
-cpMakeFiles() {
-   [ "$#" -eq 2 ] || {
-      echo "cpMakeFiles called with incorrect arguments $@"
-      return 1
-   }
-
-   pkg=$1
-   dst=$2
-
-   for i in $(cd wmakeFiles/$pkg && find . -type f)
-   do
-      d=$(dirname  $i)
-      b=$(basename $i)
-
-      mkdir -p $dst/$d/Make 2>/dev/null
-      [ -e $dst/$d/Make/$b ] || cp wmakeFiles/$pkg/$i $dst/$d/Make/$b
-   done
-}
-
-
-# ----------------------------------------------------------------- end-of-file
diff --git a/bin/touchapp b/bin/touchapp
index abe4d6f5c1b636202532c68a016c1ecc3dd97b3f..a753357566553cd1d4d6bccb9c4b74fb9f3f5cdc 100755
--- a/bin/touchapp
+++ b/bin/touchapp
@@ -32,17 +32,17 @@
 
 if [ "$#" -ne 0 ]
 then
-   echo "Usage: ${0##*/}"
-   echo "    touch FOAM_APPBIN"
-   exit 1
+    echo "Usage: ${0##*/}"
+    echo "    touch FOAM_APPBIN"
+    exit 1
 fi
 
 
 if [ -d "$FOAM_APPBIN" ]
 then
-   echo "touching FOAM_APPBIN: $FOAM_APPBIN"
-   touch $FOAM_APPBIN/*
+    echo "touching FOAM_APPBIN: $FOAM_APPBIN"
+    touch $FOAM_APPBIN/*
 else
-   echo "no FOAM_APPBIN: $FOAM_APPBIN"
+    echo "no FOAM_APPBIN: $FOAM_APPBIN"
 fi
 #------------------------------------------------------------------------------
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C
index 37caa6ddb3cec81d85afdc60507e7c2288d88bdb..16f216adf6f58368c4cce88ff19d875925917121 100644
--- a/src/OpenFOAM/global/argList/argList.C
+++ b/src/OpenFOAM/global/argList/argList.C
@@ -66,14 +66,14 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
 
     // note: we also re-write directly into args_
     // and use a second pass to sort out args/options
-    for (int argi=0; argi < argc; argi++)
+    for (int argI = 0; argI < argc; argI++)
     {
-        if (strcmp(argv[argi], "(") == 0)
+        if (strcmp(argv[argI], "(") == 0)
         {
             level++;
             tmpString += "(";
         }
-        else if (strcmp(argv[argi], ")") == 0)
+        else if (strcmp(argv[argI], ")") == 0)
         {
             if (level >= 1)
             {
@@ -87,19 +87,19 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
             }
             else
             {
-                args_[nArgs++] = argv[argi];
+                args_[nArgs++] = argv[argI];
             }
         }
         else if (level)
         {
             // quote each string element
             tmpString += "\"";
-            tmpString += argv[argi];
+            tmpString += argv[argI];
             tmpString += "\"";
         }
         else
         {
-            args_[nArgs++] = argv[argi];
+            args_[nArgs++] = argv[argI];
         }
     }
 
@@ -129,12 +129,18 @@ void Foam::argList::getRootCase()
         casePath = iter();
         casePath.clean();
 
-        // handle degenerate form and '-case .' like no -case specified
         if (casePath.empty() || casePath == ".")
         {
+            // handle degenerate form and '-case .' like no -case specified
             casePath = cwd();
             options_.erase("case");
         }
+        else if (casePath[0] != '/' && casePath.name() == "..")
+        {
+            // avoid relative cases ending in '..' - makes for very ugly names
+            casePath = cwd()/casePath;
+            casePath.clean();
+        }
     }
     else
     {
@@ -169,11 +175,11 @@ Foam::argList::argList
 {
     // Check if this run is a parallel run by searching for any parallel option
     // If found call runPar (might filter argv)
-    for (int argi=0; argi<argc; argi++)
+    for (int argI = 0; argI < argc; argI++)
     {
-        if (argv[argi][0] == '-')
+        if (argv[argI][0] == '-')
         {
-            const char *optionName = &argv[argi][1];
+            const char *optionName = &argv[argI][1];
 
             if (validParOptions.found(optionName))
             {
@@ -195,14 +201,14 @@ Foam::argList::argList
     int nArgs = 1;
     string argListString = args_[0];
 
-    for (int argi = 1; argi < args_.size(); argi++)
+    for (int argI = 1; argI < args_.size(); argI++)
     {
         argListString += ' ';
-        argListString += args_[argi];
+        argListString += args_[argI];
 
-        if (args_[argi][0] == '-')
+        if (args_[argI][0] == '-')
         {
-            const char *optionName = &args_[argi][1];
+            const char *optionName = &args_[argI][1];
 
             if
             (
@@ -216,8 +222,8 @@ Foam::argList::argList
                 )
             )
             {
-                argi++;
-                if (argi >= args_.size())
+                argI++;
+                if (argI >= args_.size())
                 {
                     FatalError
                         << "option " << "'-" << optionName << '\''
@@ -226,8 +232,8 @@ Foam::argList::argList
                 }
 
                 argListString += ' ';
-                argListString += args_[argi];
-                options_.insert(optionName, args_[argi]);
+                argListString += args_[argI];
+                options_.insert(optionName, args_[argI]);
             }
             else
             {
@@ -236,9 +242,9 @@ Foam::argList::argList
         }
         else
         {
-            if (nArgs != argi)
+            if (nArgs != argI)
             {
-                args_[nArgs] = args_[argi];
+                args_[nArgs] = args_[argI];
             }
             nArgs++;
         }
@@ -529,21 +535,19 @@ Foam::argList::argList
     // Set the case and case-name as an environment variable
     if (rootPath_[0] == '/')
     {
-        // absolute path
+        // absolute path - use as-is
         setEnv("FOAM_CASE", rootPath_/globalCase_, true);
-    }
-    else if (rootPath_ == ".")
-    {
-        // relative to the current working directory
-        setEnv("FOAM_CASE", cwd()/globalCase_, true);
+        setEnv("FOAM_CASENAME", globalCase_, true);
     }
     else
     {
         // qualify relative path
-        setEnv("FOAM_CASE", cwd()/rootPath_/globalCase_, true);
-    }
-    setEnv("FOAM_CASENAME", globalCase_, true);
+        fileName casePath = cwd()/rootPath_/globalCase_;
+        casePath.clean();
 
+        setEnv("FOAM_CASE", casePath, true);
+        setEnv("FOAM_CASENAME", casePath.name(), true);
+    }
 
     // Switch on signal trapping. We have to wait until after Pstream::init
     // since this sets up its own ones.
diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C
index ac6dc75025101ea605372c9d4efdc551d0088805..e157c15e34ccf9c4c21e2dea76f91c4dbcd82919 100644
--- a/src/OpenFOAM/primitives/strings/fileName/fileName.C
+++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C
@@ -55,18 +55,115 @@ Foam::fileName::Type Foam::fileName::type() const
 }
 
 
+//
+// * remove repeated slashes
+//       /abc////def        -->   /abc/def
+//
+// * remove '/./'
+//       /abc/def/./ghi/.   -->   /abc/def/./ghi
+//       abc/def/./         -->   abc/def
+//
+// * remove '/../'
+//       /abc/def/../ghi/jkl/nmo/..   -->   /abc/ghi/jkl
+//       abc/../def/ghi/../jkl        -->   abc/../def/jkl
+//
+// * remove trailing '/'
+//
 bool Foam::fileName::clean()
 {
-    bool changed = false;
+    // the top slash - we are never allowed to go above it
+    register string::size_type top = this->find('/');
+
+    // no slashes - nothing to do
+    if (top == string::npos)
+    {
+        return false;
+    }
+
+    // start with the '/' found:
+    register char prev = '/';
+    register string::size_type nChar  = top+1;
+    register string::size_type maxLen = this->size();
+
+    for
+    (
+        register string::size_type src = nChar;
+        src < maxLen;
+        /*nil*/
+    )
+    {
+        register char c = operator[](src++);
+
+        if (prev == '/')
+        {
+            // repeated '/' - skip it
+            if (c == '/')
+            {
+                continue;
+            }
+
+            // could be '/./' or '/../'
+            if (c == '.')
+            {
+                // found trailing '/.' - skip it
+                if (src >= maxLen)
+                {
+                    continue;
+                }
+
+
+                // peek at the next character
+                register char c1 = operator[](src);
+
+                // found '/./' - skip it
+                if (c1 == '/')
+                {
+                    src++;
+                    continue;
+                }
+
+                // it is '/..' or '/../'
+                if (c1 == '.' && (src+1 >= maxLen || operator[](src+1) == '/'))
+                {
+                    string::size_type parent;
+
+                    // backtrack to find the parent directory
+                    // minimum of 3 characters:  '/x/../'
+                    // strip it, provided it is above the top point
+                    if
+                    (
+                        nChar > 2
+                     && (parent = this->rfind('/', nChar-2)) != string::npos
+                     && parent >= top
+                    )
+                    {
+                        nChar = parent + 1;   // retain '/' from the parent
+                        src += 2;
+                        continue;
+                    }
+
+                    // bad resolution, eg 'abc/../../'
+                    // retain the sequence, but move the top to avoid it being
+                    // considered a valid parent later
+                    top = nChar + 2;
+                }
+            }
+        }
+        operator[](nChar++) = prev = c;
+    }
+
+    // remove trailing slash
+    if (nChar > 1 && operator[](nChar-1) == '/')
+    {
+        nChar--;
+    }
 
-    changed = this->removeRepeated('/') || changed;
-    changed = this->removeTrailing('/') || changed;
+    this->resize(nChar);
 
-    return changed;
+    return (nChar != maxLen);
 }
 
 
-// Return string with repeated characters removed
 Foam::fileName Foam::fileName::clean() const
 {
     fileName fName(*this);
diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties
index 56a5040225902b055c3bf75d809e50b6d0ff1482..4b87511c200888dd04b9f79d0d5c6adb8a4edcd7 100644
--- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties
+++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/parcelInjectionProperties
@@ -16,9 +16,9 @@ FoamFile
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // x y z u v w d rho mDot T cp Y0..YN
 (
-    (0.1 0.32 0.0 0.5 0.25 0.0 0.001 1000 0.2 300 4200 1.0)
-    (0.1 0.44 0.0 0.5 0.1 0.0 0.001 1000 0.2 300 4200 1.0)
-    (0.1 0.56 0.0 0.5 -0.1.0 0.0 0.001 1000 0.2 300 4200 1.0)
+    (0.1 0.32 0.0 0.5  0.25 0.0 0.001 1000 0.2 300 4200 1.0)
+    (0.1 0.44 0.0 0.5  0.10 0.0 0.001 1000 0.2 300 4200 1.0)
+    (0.1 0.56 0.0 0.5 -0.10 0.0 0.001 1000 0.2 300 4200 1.0)
     (0.1 0.68 0.0 0.5 -0.25 0.0 0.001 1000 0.2 300 4200 1.0)
 );