diff --git a/biopet.wdl b/biopet.wdl
index c40115d355f92e187400456b223fb62fab8e2b39..e74fc6123196712113e724790e29506fe753b277 100644
--- a/biopet.wdl
+++ b/biopet.wdl
@@ -2,8 +2,9 @@
 # This makes searching a lot easier.
 task BaseCounter {
     String? preCommand
-    String tool_jar #Should this be of type File?
+    String tool_jar
     File bam
+    File bamIndex
     File refFlat
     String outputDir
     String prefix
@@ -14,8 +15,8 @@ task BaseCounter {
     Int mem = ceil(select_first([memory, 12.0]))
     command {
         set -e -o pipefail
-        ${preCommand}
         mkdir -p ${outputDir}
+        ${preCommand}
         java -Xmx${mem}G -jar ${tool_jar} \
         -b ${bam} \
         -r ${refFlat} \
diff --git a/htseq.wdl b/htseq.wdl
index 6376e3ebeac324848bc20fe2a73f6be9fa6a13b2..b634bf5ee0f08128729723eaf71e77536bf401f6 100644
--- a/htseq.wdl
+++ b/htseq.wdl
@@ -11,6 +11,7 @@ task HTSeqCount {
 
     command {
         set -e -o pipefail
+        mkdir -p ${sub(outputTable, basename(outputTable), "")}
         ${preCommand}
         htseq-count \
         -f ${default="bam" format} \
diff --git a/stringtie.wdl b/stringtie.wdl
index 5fdcd6ddedcac23e06eb4728b01289a95eaa665e..77f287e9711388142c2ddf73948344d1acd17cef 100644
--- a/stringtie.wdl
+++ b/stringtie.wdl
@@ -10,6 +10,7 @@ task Stringtie {
 
     command {
         set -e -o pipefail
+        mkdir -p ${sub(assembledTranscriptsFile, basename(assembledTranscriptsFile), "")}
         ${preCommand}
         stringtie \
         ${"-p " + threads} \