Add support for Postgres.
Remove duplicate code.