diff --git a/old_bedpostX b/old_bedpostX
index 7b499c54ce782e1ce8780703772b54c7c02e9a71..00e407c9a1ddf462c68f95eedd54eb69d10cb05c 100644
--- a/old_bedpostX
+++ b/old_bedpostX
@@ -108,21 +108,6 @@ fi
 
 Lock;
 
-#parse option arguments
-nfibres=2
-fudge=1
-burnin=1000
-while [ ! -z "$2" ]
-do
-  case "$2" in
-      -n) nfibres=$3;shift;;
-      -w) fudge=$3;shift;;
-      -b) burnin=$3;shift;;
-      *) break;;
-  esac
-  shift
-done
-
 
 subjdir=`make_absolute $1`
 subjdir=`echo $subjdir | sed 's/\/$/$/g'`
@@ -163,6 +148,22 @@ if [ `${FSLDIR}/bin/imtest ${subjdir}/nodif_brain_mask` -eq 0 ]; then
 fi
 
 
+#parse option arguments
+nfibres=2
+fudge=1
+burnin=1000
+while [ ! -z "$2" ]
+do
+  case "$2" in
+      -n) nfibres=$3;shift;;
+      -w) fudge=$3;shift;;
+      -b) burnin=$3;shift;;
+      *) break;;
+  esac
+  shift
+done
+
+
 echo making bedpostX directory
 mkdir -p ${subjdir}.bedpostX/
 mkdir -p ${subjdir}.bedpostX/diff_slices
@@ -216,7 +217,7 @@ done
 
 
 numfib=`${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_0000/f*samples |wc -w`
-
+echo number of fibres $numfib
 
 fib=1;
 while [ $fib -le $numfib ];do
@@ -232,9 +233,6 @@ while [ $fib -le $numfib ];do
     fib=`echo "$fib +1"|bc`;
 done
 
-${FSLDIR}/bin/avwmerge -z ${subjdir}.bedpostX/meanSignal  `${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_*/meanSignal`
-${FSLDIR}/bin/avwmerge -z ${subjdir}.bedpostX/stdSignal  `${FSLDIR}/bin/imglob -oneperimage ${subjdir}.bedpostX/diff_slices/data_slice_*/stdSignal`
-
 echo Removing intermediate files
 
 if [ `imtest ${subjdir}.bedpostX/merged_th1samples` -eq 1 ];then
diff --git a/old_bedpostX_proc b/old_bedpostX_proc
index 56d192ee61a62be7a3e1988839c42fdd8069de9e..54814bc280f5ca5130009fd68d2b5c9e6fa98bb4 100644
--- a/old_bedpostX_proc
+++ b/old_bedpostX_proc
@@ -14,6 +14,11 @@ Usage() {
 
 [ "$2" = "" ] && Usage
 
+
+subjdir=$1
+nslices=$2
+
+
 #parse option arguments
 nfibres=2
 fudge=1.5
@@ -29,13 +34,16 @@ do
   shift
 done
 
+echo subjdir $subjdir
+echo nslices $nslices
+echo nfibres $nfibres
+echo fudge $fudge
+echo burnin $burnin
+echo piddir $piddir
 
 [ "$piddir" = "" ] || touch ${piddir}/`hostname`_fdt_${$}
 
 
-subjdir=$1
-nslices=$2
-
 slice=0
 while [ $slice -lt $nslices ];do
     slicezp=`${FSLDIR}/bin/zeropad $slice 4`
diff --git a/probtrackxOptions.h b/probtrackxOptions.h
index 07724aaa1af3aa60fbdd4178df00f1db86ea45c5..95617682078bf2326fdeb620a4e527eba4d6a565 100644
--- a/probtrackxOptions.h
+++ b/probtrackxOptions.h
@@ -48,6 +48,7 @@ class probtrackxOptions {
   Option<string> seedref;
   Option<string> mask2;
   Option<string> waypoints;
+  Option<bool>   waypoints_and;
   Option<string> meshfile;
   FmribOption<string> lrmask;
   Option<string> logdir; 
@@ -129,8 +130,8 @@ class probtrackxOptions {
    outfile(string("-o,--out"), string(""),
 	   string("Output file (only for single seed voxel mode)"),
 	   false, requires_argument),
-   rubbishfile(string("--rubbish"), string(""),
-	       string("Rubbish file"),
+   rubbishfile(string("--avoid"), string(""),
+	       string("Reject pathways passing through locations given by this mask"),
 	       false, requires_argument),
    stopfile(string("--stop"), string(""),
 	       string("Stop tracking at locations given by this mask file"),
@@ -147,13 +148,16 @@ class probtrackxOptions {
 	 string("second mask in twomask_symm mode."),
        false, requires_argument),
  waypoints(string("--waypoints"), string(""),
-	 string("Waypoint mask or ascii list of waypoint masks."),
-       false, requires_argument), 
+	 string("Waypoint mask or ascii list of waypoint masks"),
+       false, requires_argument),
+ waypoints_and(string("--network"), true,
+	 string("Searches for pathways connecting every seed to at least one waypoint"),
+       false, no_argument), 
  meshfile(string("--mesh"), string(""),
 	 string(""),
        false, requires_argument),
   lrmask(string("--lrmask"), string(""),
-	 string("low resolution binary brain mask for stroring connectivity distribution in matrix2 mode."),
+	 string("low resolution binary brain mask for stroring connectivity distribution in matrix2 mode"),
        false, requires_argument),
   logdir(string("--dir"), string(""),
 	    string("Directory to put the final volumes in - code makes this directory"),
@@ -206,6 +210,7 @@ class probtrackxOptions {
        options.add(skipmask);
        options.add(mask2);
        options.add(waypoints);
+       options.add(waypoints_and);
        options.add(meshfile);
        options.add(lrmask);
        options.add(seedref);
diff --git a/streamlines.cc b/streamlines.cc
index 5a4c6d6d7431c1e270a157e82098176a10a823f0..341aa7e5b87c21fa4eee402cee347155b28d2635 100644
--- a/streamlines.cc
+++ b/streamlines.cc
@@ -94,6 +94,7 @@ namespace TRACT{
     m_part.change_xyz(x,y,z);
     int partlength=0;
     bool rubbish_passed=false;
+    bool stop_flag=false;
       //NB - this only goes in one direction!!
     for(unsigned int pf=0;pf<m_passed_flags.size();pf++) {
       m_passed_flags[pf]=false;  /// only keep it if this streamline went through all the masks
@@ -150,9 +151,10 @@ namespace TRACT{
 	}
 	if(opts.stopfile.value()!=""){
 	  if(m_stop(x_s,y_s,z_s)!=0){
-	    m_path.pop_back();
-	    break;
+	    stop_flag=true;
 	  }
+	  else
+	    if(stop_flag)break;
 	}	  
 	
 	  
diff --git a/xfibres.cc b/xfibres.cc
index 0baed21bf997712b0eee145e53f33692ec0f6d0d..53d4ed1133fefde27c5dbca45ebef1f585d594d8 100644
--- a/xfibres.cc
+++ b/xfibres.cc
@@ -360,12 +360,12 @@ public:
       mean_fsamples_out.push_back(m_mean_fsamples[f]);
 
     Log& logger = LogSingleton::getInstance();
-    tmp.setmatrix(m_dsamples,mask);
-    save_volume4D(tmp,logger.appendDir("dsamples"));
-    tmp.setmatrix(m_S0samples,mask);
-    save_volume4D(tmp,logger.appendDir("S0samples"));
-    tmp.setmatrix(m_lik_energy,mask);
-    save_volume4D(tmp,logger.appendDir("lik_energy"));
+    //tmp.setmatrix(m_dsamples,mask);
+    //save_volume4D(tmp,logger.appendDir("dsamples"));
+    //tmp.setmatrix(m_S0samples,mask);
+    //save_volume4D(tmp,logger.appendDir("S0samples"));
+    //tmp.setmatrix(m_lik_energy,mask);
+    //save_volume4D(tmp,logger.appendDir("lik_energy"));
 
     //Sort the output based on mean_fsamples
     //