Refactored to MVC structure.