Postgresql support

Slight modifications to support postgresql