Fix problem with TermRef equality.

Equality was not symmetric between TermRefs and TermrefWithSignatures.
Made TypeVars uncahable keys

TypeVars can appear as keys in baseType caches. The problem is that
their base types depend on their instantiation, which is not always
know yet when the test is performed. So results of baseType on
type variables should never be cached.

Todo: check whether there are any other caching problems involving typevars.