the code related to setting up the mods is just shy of 2000 lines, about 3/4ths of which exists just to make sure various structs aren't misaligned by any tinkering.
That probably shouldn't be pasted in.