Ok it's pretty much functional now. Only issue left is there are just red, empty brackets where it should say "[BR]":
Just a minor issue, though. I checked and it is indeed only putting the brackets on the groups with non-US leaders, so it's usable as-is. I don't see any more errors.
Thank you very much!