MPI code optimization