Template cleanup

Makes the template file structure more sensible and updates the UI changes to match the new structure.