Major rewrite of tstring, many bugs corrected