Found a serious issue caused by array reallocation - this is probably the cause of your bug as well.
Added this part in SerializeObject to fix
Lemme know how it goes