Refactor PGWrapper