Rewriting code to use a flat array which is quicker than a Vector of Vectors based on memory layout