Fixed some bugs in the hashing function.