Improved hash function.