fixed pgsql driver returning '' instead of null if no error
refactor stats collection