some cleanup and common redact logic