Refactored the internal M object out of the model package

It was making the interface to the package confusing (using M sometimes but not others),
and it felt like an unnecessary complexity that could be left out entirely by just using
package-local variables.