He does not behave when the trainer is around because your trainer feeds him. Ain't ever happened.
He is not bored!
He doesn't try to 'upset' you!
He is simply spoiled and disrespectful under saddle. He has found that he can only do what he wants to do when he wants to do it. You have never made him suffer serious consequences for NOT doing what you ask him to do. This is totally a lack of respect.
The very first time he 'stalled out' and refused to go forward, you should have spanked his butt good and hard and it would have all been over with before it ever got going. Instead, you looked for reasons why and tried to humor him and as a result, he figured put that he did not have to take you seriously.
Horses are 'creatures of habit'. This means that they do things just because they have done them before. They may have had a 'reason' they did something the first time, but they will continue doing the behavior after that just because they did it before. The one thing that is consistent with them all if that once they have done something disobedient, they will continue to do it until someone gives them a good reason not to do it.
People need to understand that horses become spoiled because they can. It is not a 'personal' thing to them. They do not behave correctly because they 'like' a rider or handler and they do not misbehave because they want to upset someone or do not like them. When you 'open' a door to them and 'close' all others, they go through the open door. You did not close the door behind him when it should have been closed and he has found that he can 'back out of doing what you want'. This is not uncommon and is always progressive. It leads to rearing, spinning around and doing 180s, running backwards and falling up-side-down when a hind foot gets caught on something and eventually can lead to rearing and flipping and refusing to go forward at all -- even with other horses around.
A confident rider will be able to get on him and he will either not even stall out or a quick spanking or spur will tell him that he better get his butt in gear and go forward. This is ultimately going to have to be something that you have to handle.
When I used to get horses in like this for re-training, I got them straightened out, rode them out in the pastures and on the trails by themselves and then, had the owners come and ride them out under my direction. I told them that their horse would only 'stay straight' as long as they were able to put enough pressure on it to make it mind. Otherwise, they needed to sell it and start over.
The best trainer in the world can teach a horse to do anything that horse and that trainer is capable of doing; BUT I have not met the trainer that can take anything out of a horse's head. This is why so many spoiled horses go back to the bad behavior when they get home. A trainer has to spend more time training the owner / rider than the horse. The horses 'fix' a lot more quickly.
One thing I would definitely do is get this horse out of the arena and get it over being 'barn sour', 'arena sour' and 'herd bound'.