Simplify initial search. Determine 'backup' properly.
Add missing line.
Fix tests for #18841.
Fix tests for #18841.