Added private(i,j) to #pragma omp for statements in order to fix erroneous loop
behavior in parallelized threads.