Refactor TRE parsing, and implement file level parsing.