Major refactoring. Corrected some MVC mistakes.