added TEI cleanup and debug scripts