Fixing Postgres and db errors