Fixed buffer overflow and segfault for mpi in 2D