Fix hash table comparisons and some implicit narrowing conversions.
Likely fixes issue #8596.