Main template cleanup