Adding preFit() to initialize variables before fit.