Added MPI barriers at the end of each routine, fixing certain errors.