Cache hashes

The displacement finding loop iterates a _lot_