DRYing up sanitization and added restoring after sanitization'