Rewrite template to deal with multicore.