fixed mpi issue and some minnor problems