added safeguards that preserve search index integrity