Finished code clean-up for #23830 code review.
This includes some additional refactoring of the file finding logic to
make it more maintainable.
Closes #25