Handle transpositions correctly using a hash table.