Rewriting the Distance function with the Term interface, part 1
Started migrating nonlinfit to polymorphic inheritance