Reorganized code as per MVC standards.