Adding Postgres support

I have rebased this