More refactor, decode pig.script at client side instead.