Some more fixes to the PSQL layer

That was tough!! :sweat_smile: :sweat_drops: 

@Oldiesmann there is something in this PR that may be of interest for you too (well, I can't keep my word on certain matters... :stuck_out_tongue: ).