Pulled vector and array allocations out of loop.