diff --git a/CEP/BB/MWImager/src/mwimager b/CEP/BB/MWImager/src/mwimager
index a99961f61d52ec9c8a4a4d9fde0980327ad1fab2..5436be23c91dd7b74ee8aad809988eb18848b8aa 100755
--- a/CEP/BB/MWImager/src/mwimager
+++ b/CEP/BB/MWImager/src/mwimager
@@ -29,7 +29,7 @@ pgmpath=`cd $pgmpath > /dev/null 2>&1  &&  pwd`
 
 # Check if LOFARROOT is set.
 if test "$LOFARROOT" = ""; then
-  echo "LOFARROT is undefined; source lofarinit.(c)sh first"
+  echo "LOFARROOT is undefined; source lofarinit.(c)sh first"
   exit 1
 fi
 
@@ -41,7 +41,9 @@ if test $# = 0; then
   echo "       parset-file   name of parset file"
   echo "       clusterdesc   name of clusterdesc file"
   echo "                     default is $HOME/CEP.clusterdesc"
-  echo "       wd            working directory in subprocesses"
+  echo "       wd            working directory in subprocesses which will get"
+  echo "                     the images and log files"
+  echo "                     default is same directory as MS"
   echo "       logfile       root name of logfile of each subprocess"
   echo "                     A sequence number gets appended to it"
   echo "                     default is mwimager.log"
@@ -67,9 +69,6 @@ if test $# != 0; then
   wd=$1
   shift
 fi
-if test "$wd" = ""; then
-  wd=.
-fi
 logfile=
 if test $# != 0; then
   logfile=$1
@@ -90,7 +89,6 @@ if test $# != 0; then
 fi
 
 # Make all file names absolute.
-wd=`cd $wd > /dev/null; pwd`
 dn=`dirname $psn`
 psn=`cd $dn > /dev/null; pwd`/`basename $psn`
 dn=`dirname $cdn`
@@ -101,8 +99,14 @@ if test "$hfn" != ""; then
 fi
 
 # Get dataset name from the parset.
+# If it is an MS, operate directly on it (as rank 0).
 msvds=`getparsetvalue $psn dataset` || exit 1
+if test -d "$msvds"  -a  -e "$msvds/table.dat"; then
+  echo "mwimager-part '' '' '' '' 0 '$msvds' '$LOFARROOT' '$psn' '$wd' '$dry'"
+  mwimager-part "" "" "" "" 0 "$msvds" "$LOFARROOT" "$psn" "$wd" "$dry" 
 
-# Start the imager processes on the various machines.
-echo "startdistproc -mode 0 -nomasterhost -dsn $msvds -hfn "$hfn" -cdn $cdn -logfile "$logfile" $pgmpath/mwimager-part $LOFARROOT $psn $wd $dry"
-startdistproc -mode 0 -nomasterhost -dsn "$msvds" -hfn "$hfn" -cdn "$cdn" -logfile "$logfile" $pgmpath/mwimager-part "$LOFARROOT" "$psn" "$wd" "$dry"
+else
+  # Start the imager processes on the various machines.
+  echo "startdistproc -mode 0 -nomasterhost -dsn '$msvds' -hfn '$hfn' -cdn '$cdn' -logfile '$logfile' $pgmpath/mwimager-part '$LOFARROOT' '$psn' '$wd' '$dry'"
+  startdistproc -mode 0 -nomasterhost -dsn "$msvds" -hfn "$hfn" -cdn "$cdn" -logfile "$logfile" $pgmpath/mwimager-part "$LOFARROOT" "$psn" "$wd" "$dry"
+fi
diff --git a/CEP/BB/MWImager/src/mwimager-part b/CEP/BB/MWImager/src/mwimager-part
index 81f0bf96bcaf713b40322168bd2ae764b4243590..87a852b4c5fca4de324128e8e942132ee39ca54a 100755
--- a/CEP/BB/MWImager/src/mwimager-part
+++ b/CEP/BB/MWImager/src/mwimager-part
@@ -48,9 +48,21 @@ psnbase=`basename $psn`
 
 # Initialize lofar environment.
 . $lroot/lofarinit.sh
+
+# Get the data set name and the directory name of it.
+if test "$wd" = ""; then
+  wd=`dirname "$msn"`
+fi
+
 # Set to working directory.
 cd $wd
 
+# If an MS name is given, create a temporary description file for it.
+if test -d "$msn"  -a  -e "$msn/table.dat"; then
+  makevds "" "$msn" "$msn.tmpvds"
+  msn="$msn.tmpvds"
+fi
+
 # Add channel info to the parset file.
 cp $psn $psnbase.part$seqnr
 schan=`getparsetvalue $psnbase.part$seqnr firstchan 2>/dev/null` || schan=0