Various fixes for PostgreSQL support.