basic structure and template cleanup