Minor improvement in expr sorting.
Attempt to optimise Product construction, enforcing assumption of two operands.
Cache hash in Terminals by default.
Cache hash in GeometricQuantity as well.
Optimize Sum construction, introducing the hard constraint that Sum is
a binary operation.

It was previously working as an n-ary operation but that was hardly if
ever used.

The optimization is fairly significant because a lot of Sums are created.
Minor optimization in traverse_terminals and specialised mergedicts for two dicts.
Rewrite has_type to a couple of more specialised algorithms and use
them in partextracter.
Bugfix.