lots of refactoring, added basic Model loading functionality