Generify parallelization code