Move CModel implementation to functions with output arguments

Using output arguments lets us update the result incrementally and
return partial results even if we throw.
Save center position used in CModel fits via the plugin interface
Code to write diagnostics in CModel