Refractor mpi diameter algorithm
Refractor function exchange_counters.