Dont cast data we wont use right now.
Typo :p saw on @Lubenica998 paste
Use the index loop, it is faster.
Use raw queries on gamemode changes and prevent the gamemode from changing if something goes wrong.