Some bugs in distances solved. Now I have distances that work