Some refactoring of TextParser logic