Fixed bugs in PostgreSQL part.