How do I keep datatables from being corrupted?

I’ve resolved this myself. The problem was in accessing datatables too early. I wrapped all datatable access with if (GetWorld()) and that solved the issue