Updated mapPotential to support N-dimensional topology (and other improvements)