Deduplicate search reference management code