moving to templates and cleanup
Finish first step of moving to templates