template cleaning