safety checks for template rendering during publish
another safety check for listen elements
cleanup and attributes in publish output