Changed some parallel loops to contain criticals rather than atomics