bugfixes
some postgres and logging fixes