Regarding the non-OT Pokemon disobedience you mentioned, ensure that the Player's Pokemon data is such that the OT name and ID matches that of the trainer. For Gary, ensure that his Pokemon's data is not that of the Player.
Does this only happen during the very first battle? If so, it might be safe to simply remove that battle event and script your own to take its place. Think Shiny Gold rival battle...
For sample data chunk (although in AR hex form), look here:
*pokemonpalace link removed*. Note that this completely creates a Pokemon with all IVs, attributes, held item, moves, ribbons, etc fully customizable, for the data is directly manipulated rather than randomly assigned as in a Recieve Pokemon script. Shiny pokemon can easily be hacked in this way, for there is a shiny flag that can be set (see "Shiny" checkbox). Unfortunately, this app is designed so that the Pokemon data will be created in a box slot. Further modification is required to create it in the trainer's party.