Fix unsigned integer wrapping issue in phash search system.
Also, path reset issue when reloading the tree.