Fix postgres

This is a first attempt to fix the postgres installation on osx. It runs fine on my virtual machine, but may need additional testing, especially on ubuntu.