Add first_or_none; use it in a couple DNS utils

(Reduces execution time by somewhere between 1/8 and 1/4.)