html to template and cleanup