Handles XML formatting problems more gracefully; moved some TSS-specific stuff to TSSHandler.