Postgres server as a library

global state was a mistake