convert template lookup to hash table
Merge pull request #2239 from WalterBright/hash_instance

convert template lookup from array to hash table