diff --git a/pb_utils/.gitignore b/pb_utils/.gitignore
index 4cd39960308d23f2976091aacffa42a8eb828ee4..48ef480a33be31ec42e4c4de0e953a5f1ba80ce0 100644
--- a/pb_utils/.gitignore
+++ b/pb_utils/.gitignore
@@ -1,3 +1,2 @@
 build/
 mod_gen/mods
-mod_gen_new/test
\ No newline at end of file
diff --git a/pb_utils/mod_gen/Makefile b/pb_utils/mod_gen/Makefile
deleted file mode 100644
index aadd2f5d958b0a5d25b5ee9ddaabb293506f8726..0000000000000000000000000000000000000000
--- a/pb_utils/mod_gen/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-obj-m += measure.o
-
-all:
-	make -C /home/kelvin/git/master_thesis_linux/ M=$(PWD) modules
-
-clean:
-	make -C /home/kelvin/git/master_thesis_linux/ M=$(PWD) clean
diff --git a/pb_utils/mod_gen/build.sh b/pb_utils/mod_gen/build.sh
index d977d82482c3bf03453f52c918814eeb836f4021..a4c1c8d36c9eeadb5e24f8b803ff88cf377e2bb5 100755
--- a/pb_utils/mod_gen/build.sh
+++ b/pb_utils/mod_gen/build.sh
@@ -1,12 +1,15 @@
 #!/bin/bash
 
-#make
-mkdir -p mnt
-
-sudo mount -o loop ../build/qemu-image.img ./mnt
-sudo cp ./mods/plan_same_v.ko ./mnt/root
-sudo cp ./mods/random_v.ko ./mnt/root
-
-sudo umount ./mnt
-
-echo "All done. Run ./run_qemu.sh now"
+if [ ! -d "/mnt/pb_utils/mod_gen" ]; then
+    echo "are you running this in chroot or the build system?"
+    exit 1
+fi
+
+cd /mnt/pb_utils/mod_gen/
+rm -rf mods
+./plan_to_module.pl
+cd mods && make
+
+echo "################################################"
+echo "modules created and copied to /root"
+echo "use 'insmod <file' to run within the test system"
diff --git a/pb_utils/mod_gen/measure.c b/pb_utils/mod_gen/measure.c
deleted file mode 100644
index 009f8f0d93d73c901b0fef33b021344c357d7fe3..0000000000000000000000000000000000000000
--- a/pb_utils/mod_gen/measure.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/kthread.h>
-#include <../kernel/sched/sched.h>
-
-
-MODULE_LICENSE("GPL");
-
-static int __init pb_client_init(void)
-{
-    struct rq *rq;
-
-    rq = this_rq();
-    set_pb_measure_on(&rq->pb);
-
-    return 0;
-}
-
-static void __exit pb_client_cleanup(void)
-{
-    struct rq *rq;
-    rq = this_rq();
-    set_pb_measure_off(&rq->pb);
-
-}
-
-module_init(pb_client_init);
-module_exit(pb_client_cleanup);
diff --git a/pb_utils/mod_gen/parse_dmesg.pl b/pb_utils/mod_gen/parse_dmesg.pl
deleted file mode 100755
index 905c2e7469f4d66c0ff2e1fbbcf973b4cfde7392..0000000000000000000000000000000000000000
--- a/pb_utils/mod_gen/parse_dmesg.pl
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/perl
-
-use Plan;
-
-my $argc = @ARGV;
-
-my $dmesg_log = $ARGV[0];
-
-my $last_time = 0;
-my $last_nr = 0;
-my @results;
-
-open (FILE, $dmesg_log);
-
-while (<FILE>)
-{
-    unless (/^.*(EXEC|IDLE),(START|STOP),\d*,\d*.*/)
-    {
-        next;
-    }
-    chomp;
-
-    ($dirty_mode, $state, $entry, $time) = split(/,/);
-
-    $mode = "";
-    if ($dirty_mode =~ /.*(EXEC|IDLE).*/)
-    {
-        $mode = $1;
-    }
-
-    if ( $state eq "START" )
-    {
-        $last_time = $time;
-        $last_nr = $entry;
-    }
-
-    if ( $state eq "STOP" )
-    {
-        $result = $time - $last_time;
-        push(@results, { mode => $mode, nr => $last_nr, time => $result });
-    }
-}
-close (FILE);
-
-if ( $argc > 1 )
-{
-    my $plan_csv = $ARGV[1];
-    print_compared_result ($plan_csv, @results);
-}
-else
-{
-    print_simple_result (@results);
-}
-
-sub print_simple_result
-{
-    my (@results) = @_;
-
-    foreach (@results)
-    {
-        print ($_->{mode}.'['.$_->{nr}.']'.': '.$_->{time}."\n");
-    }
-}
-
-sub print_compared_result
-{
-    my ($plan_csv_file, @results) = @_;
-    my @expected_results = parse_plan_csv($plan_csv_file);
-
-    push(@results, {mode => 'IDLE', nr => $results[-1]{nr}, time => 0});
-
-    for (my $i=0; $i <= $#results; $i++)
-    {
-        my $expected = $expected_results[$i]->{time};
-        my $actual = $results[$i]->{time};
-        my $diff = abs($expected - $actual);
-
-        print ($results[$i]->{mode}.'['.$results[$i]->{nr}.']'.' actual: '.$actual.', expected: '.$expected.', diff: '.$diff."\n");
-    }
-}
diff --git a/pb_utils/mod_gen/tmpl/Makefile.tt b/pb_utils/mod_gen/tmpl/Makefile.tt
index 9cdbc1ac98b4749420bdb5123dc26f5c03fc3395..362fe2c616d316b26c591c9fc089f52ca15fb020 100644
--- a/pb_utils/mod_gen/tmpl/Makefile.tt
+++ b/pb_utils/mod_gen/tmpl/Makefile.tt
@@ -2,6 +2,10 @@
 [% END %]
 all:
 	make -C [% linux_src_dir %] M=$(PWD) modules
+	[% FOREACH module_name IN module_names %]cp [% module_name %].ko /root
+	[% END %]
 
 clean:
 	make -C [% linux_src_dir %] M=$(PWD) clean
+	[% FOREACH module_name IN module_names %]rm /root/[% module_name %].ko
+	[% END %]
diff --git a/pb_utils/mod_gen/tmpl/module.tt b/pb_utils/mod_gen/tmpl/module.tt
index efa4adb9d6154cefaadec7342862b2155b0206cd..4855ac59bed0357ff1161a0dbb687554d3b40f78 100644
--- a/pb_utils/mod_gen/tmpl/module.tt
+++ b/pb_utils/mod_gen/tmpl/module.tt
@@ -27,7 +27,7 @@ static void init_rq(struct rq *rq)
 {
     struct pb_rq *pb_rq = &rq->pb;
     struct task_struct *proxy_task;
-    int i;
+
     proxy_task = kthread_create(loop_thread_func, NULL, "PB proxy thread");
     proxy_task->sched_class = &pb_sched_class;
     set_pb_plan_size(pb_rq, [% plan_size %]);
diff --git a/pb_utils/readme.md b/pb_utils/readme.md
index eb5f75153bd9abdf1d6b5f371d2d75d900e5052d..f7f06bf91c68da4c03b155e64214d652269f58f2 100644
--- a/pb_utils/readme.md
+++ b/pb_utils/readme.md
@@ -20,6 +20,12 @@ cd /mnt
 ./build
 ```
 
+## chroot into debian rootfs to build test modules
+run `./chroot_image.sh`, this drops you in a shell on the created debian and run
+```bash
+/mnt/pb_utils/mod_gen/build.sh
+```
+
 # run the build kernel with the created rootfs
 run `./run_qemu.sh`