Move CModel Swig bindings to a separate file.
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.