Fixed rehash function.