Refactor peparse and expose additional functions