Remove code duplication in blacklist/whitelist logic.
Cosmetic changes.