Big changes to Fitting code