Clean up and tweak parallel code