pig labs refactor