massive refactoring, hopefully working mvc