If mods store unit_numbers or even entity objects, those are no longer valid after a fast replace. It would be possible to check .valid before each access and look for the replacement if false, but that would add both complexity and runtime.
You are right, I was looking at the .4 code when writing this, and only quickly checked the changelog for .5 when posting.