various fixes to postgres adapter