Fixes some issues with PostgreSQL on couples of queries