Bug fixes for fitting_function calls