Cleanup and improve clustering and disjoint sets code.

In particular, use insert instead of emplace with unordered_map and multimap
for compat.
Move clustering code in the gamelogic.