Better code for hash table generation