Fixing postgres errors