more robust handling of circular references when printing records