Rework Mod into a class.
Mod currently modifies 4 global arrays, including some that are 'public'.
The logic flow is easier to understand if this becomes a real class with const-correctness and public/private methods.
Differential Revision: https://code.wildfiregames.com/D3981