Clean up fit script, merging the 1/2/3D methods.