Fix #16671
Add some safetly to mods
don't shadow mod_data
more type checks
Merge pull request #16685 from thatch45/mods_fix

Assignment to mods where it was defaulting to None