General template cleanup