tidied up distance stuff.