Postgres fixes

Several postgresql fixes. DB check/update works now, saving entries, etc. Still experimental.

Fixes #399
Fixes #396
Fixes #395
Fixes #391