PostgreSQL fixes

This fixes a couple of remaining issues with PostgreSQL.