various fixes for postgres

Fixes for postgres.