Clean off comments and unwanted nodes from templates