(Details) This is a known bug that you can easily work around by separating your unit groups in chunks of 16 max.
Fixing this is kinda tricky and low priority precisely because of this easy workaround.
It happens because the locations where the stat (de)buffs are stored in RAM is shared with the higher part of the loaded unit buffer (higher part being the units past the 16th).
(Also from what I read it seems you are not using the buildfile method to do your edits. I'd recommend you looking at that, especially if you want to use the skill system as a base, which is built using that same method, excuse me if I'm wrong tho)