Refactored BestHashGenerator to implement HashGenerator interface.