MZ Strange behavior from custom Object type after loading a file.

I'm fairly new to creating my own plugins, so far I've mostly been able to troubleshoot most of my problems through trial and error, but I'm at a loss currently and I'm not sure how to proceed.

I'll try providing images to provide as much context as possible.

To begin with I'm using RPG Maker MZ.

Here are the changes made to the DataManager functions in my plugin, factions.js, as well as the declaration of my custom global variable:

plugin - dataManager.png


And this is everything relating to my object class, Game_Factions:

plugin - GameFactions.png


When I run the game, plugin commands add the first 3 factions that are used in my testing room.
If I press F12 and open the debug menu, this is how $gameFactions looks:

plugin - Debug 1.png

This is how I believe it should look, now this is what it looks like after I save the game, and load my file again:
plugin - Debug 2.png

I'm not an expert, so it's difficult to tell exactly what happened here, but if I had to guess, upon loading the game the interpreter was unable to re-assign the contents:faction back to the correct typing.

I tried something that I thought might help, I tried creating a new Game_Factions object and passing on the information from contents.faction over to the new instance, but what I got when I looked at the debug menu, was this:

plugin - Debug 3.png

It once again looks wrong, it lost that last component at the end.

As is, everything works perfectly, until I save the game and reload, attempting to access any of Game_Factions's functions will cause the game to crash because they are no longer valid functions for $gameFaction to access. And this causes several plugin commands that I've created to stop working on load as well.

For now I'll take a small break and come back to this later after more studying. I'm creating this plugin for a friend's game, so I would like to know where the issue is coming from so he could begin using this plugin as soon as possible.

If anyone knows where I might've gone wrong I would very much appreciate the help.
Okay so this is a bit embarrassing, I actually managed to figure out the solution on my own and it really wasn't all that difficult.

For those struggling with a similar problem in the future, I'll try to describe what I did to fix it.

I noticed that a lot of the objects that hold the game's information, such as $gameActors and $gameVariables, didn't declare any functions, rather all of their information is handled by static classes, the ones ending with the word Manager.

So I created my own FactionManager static class that handles all of the functions relating to $gameFaction, and now my game seems to work perfectly even after loading a file.

Original thread: https://forums.rpgmakerweb.com/threads/strange-behavior-from-custom-object-type-after-loading-a-file.159046/