Fixed up postgres support, needs testing both for compiling and functionality.