big improvements on fitting calculation and saving