About the legendary IVs issue. You said:
"Normally, when you catch a Pokemon, data for its IVs is copied from the "wild" data slot to the "box/party" data slot.
However, on a roaming Pokemon, the copying messes up, copying only the last eight bits instead of all 30 of them. The uncopied bits are all set to zero."
The last sentence is my query. Are we sure the uncopied bits are actually set? What if they're instead left as what was previously in the memory location? And what happens when you deposit or release a Pokemon - is the relevant data all zeroed out, or is only some of it changed? The point is, might it be possible to have the legendary appear with IVs of what previously occupied its party or box slot, instead of the usual zeroes?