- Redesigned update_template() to avoid generating empty or invalid elements and to verify/reformat generated syntax by loading it as a DOM document.
- Added check to avoid exporting local AS to itself.
- Minor bug fixes.