Wrote a first pass at assigning conditional distances in a dataset.
I updated lots of things in this code.