Fix some stuff and improve whitelist generation.