some code cleanup
Refactored some templates and views