Fix sorting by distance, make some things public.