Proper hashing for records in codegen.

This commit introduces a proper hashCode function for case classes and
tuples used in codegen. It also changes the internal datastructure for
maps and sets from TreeX to HashX.