Several bugfixes plus Postgres basic support