Refactored code and moved templates to new views.