Fix some bugs with hash computing