can now clean up templates in DOMDocument