nicely refactored code, added statistics to fittings