Fix to handle null fields in documents