Tidied up Mapping class and computation logic

This was prompted by a bug report, whuch turned out to be not
a bug at all. But the code wasn't all that clear here, so hopefully
better now.