Thanks so much, for working on this!
I would guess compartmentalization, but feel free to dig around to see where these scripts are called, and why. If it can be simplified, by all means, throw in a patch and we can test.
(The reason I put such emphasis on studying what is already there, is to understand the intended feature set, and to avoid regressions while simplifying or refactoring code.)
-Thom