Clean up (refactor) discovery a little; no functional changes.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation