Adds datafile, unifies distance functions