Fix bugs for pig template