Continued refactoring into MVC. Not done yet.