Significant cleanup to the fit.inner function