add basic distance function; bug fix in construct_haplotypes