whitelist.py: Break up whitelist_check function into individual components.