fixed segfault when running over multiple samples
runs smoother and fixed segfaults
Merge branch 'CleanupPointers'