cleanup template code