fixed formatting and a few async flow errors in Postgres code