fixes PR #171.
Merge pull request #195 from robmorgan/pr162-better-postgres-support

fixes PR #171. better postgres support