refactored MPI master and worker node into classes