Added all changes to SAM sorted scripts, v3 is the attempt at reducing memory usage