diff --git a/probtrackx.cc b/probtrackx.cc
index 7a4b57570bded57772b469b80932ff74560ca66e..95095458076156706bd91492c71811958ca8b54b 100644
--- a/probtrackx.cc
+++ b/probtrackx.cc
@@ -35,8 +35,12 @@ int main ( int argc, char **argv ){
   if(opts.mode.value()=="simple")
     track();
   string tmpin=opts.seedfile.value();
-  if(fsl_imageexists(opts.mask2.value())){ twomasks();}
-  else if(fsl_imageexists(opts.seedfile.value())){ seedmask();}
+  if(fsl_imageexists(opts.seedfile.value())){ 
+    if(fsl_imageexists(opts.mask2.value())){ twomasks();}
+    else{ seedmask(); }
+  }
+  else{ nmasks(); }
+
   //else if(fopen(tmpin.c_str(),"r")!=NULL ){ track();}
 
   // else if(opts.mode.value()=="seeds_to_targets")
diff --git a/probtrackx.h b/probtrackx.h
index 2f52f3ec6d045fb9af0883a4dd6b744604d3b33a..8610f9f046b6a5e8e72b27b6e725e34ebd4b60b2 100644
--- a/probtrackx.h
+++ b/probtrackx.h
@@ -7,3 +7,4 @@
 #include "ptx_simple.h"
 #include "ptx_seedmask.h"
 #include "ptx_twomasks.h"
+#include "ptx_nmasks.h"
diff --git a/ptx_simple.cc b/ptx_simple.cc
index d1406a0c3802243a6664e1857bdb7381e5f79e4e..a0cb0b590634c4593a5a52ee1c751c6dc9749491 100644
--- a/ptx_simple.cc
+++ b/ptx_simple.cc
@@ -34,8 +34,8 @@ void track(){
   Counter counter(seedref,stline);
   counter.initialise();
   Seedmanager seedmanager(counter);
-
-    
+  
+  
   Matrix Seeds = read_ascii_matrix(opts.seedfile.value());
   for(int SN=1; SN<=Seeds.Nrows();SN++){
     float xst=Seeds(SN,1);
diff --git a/streamlines.cc b/streamlines.cc
index fb42395deed83d691f899bd38884ceb23390cc62..5a4c6d6d7431c1e270a157e82098176a10a823f0 100644
--- a/streamlines.cc
+++ b/streamlines.cc
@@ -195,11 +195,20 @@ namespace TRACT{
     if(opts.loopcheck.value()){
       m_loopcheck=0;
     }
+    
     bool accept_path=true;
     if(m_passed_flags.size()!=0){
-      for(unsigned int i=0; i<m_passed_flags.size();i++)
-	if(!m_passed_flags[i])
-	  accept_path=false;
+      if(opts.waypoints_and.value()){
+	for(unsigned int i=0; i<m_passed_flags.size();i++)
+	  if(!m_passed_flags[i])
+	    accept_path=false;
+      }
+      else{
+	accept_path=false;
+	for(unsigned int i=0; i<m_passed_flags.size();i++)
+	  if(m_passed_flags[i])
+	    accept_path=true;
+      }
     }   
     if(rubbish_passed)
       accept_path=false;
diff --git a/streamlines.h b/streamlines.h
index b09fc3b5559854130f7d49463ec2700e31957dc3..af95f0ab0dbc2dc5e6a3b50f88332d8e384f641b 100644
--- a/streamlines.h
+++ b/streamlines.h
@@ -28,6 +28,7 @@ namespace TRACT{
     volume<int> m_mask;
     volume<int> m_skipmask;
     volume<int> m_rubbish;
+    volume<int> m_stop;
     volume4D<float> m_loopcheck;
     vector<volume<int>* > m_waymasks;
     vector<bool> m_passed_flags;