fixed hash calculation, added some debugging prints