fixed some bugs, and moved the HashDist to outside the module