working on curve fitting and a number of other little fixes