Fixed some bugs in text parser