Refactoring, added comments
Changed layout
Added resources to templates