Transformed the partitioning into a loop-recur.
Reduced memory usage drastically in scatter phase.