Added some sanity checks to hash functions.