Improve hash calculation algorythm, more bug fix working dir