Fixed postgresql issues