Modified some stuff in order to support PostgreSQL