Refactor parsing engine