Hi, weaving & head bobbing are 'stereotypic' behaviours that start out as coping mechanisms for horses under a lot of stress. But they are obsessive compulsive behaviours that are often hard or impossible to 'cure' even once the stress is removed. The longer the stress & behaviour have been allowed to go on, the harder it is to 'treat'.
So first & foremost, try to avoid those stressful situations. For his physical health as well as mental, try to find somewhere for him that he doesn't have to be stabled. 24/7 turnout with company should make him much happier & healthier. Also avoid putting him in the round yard, if this is where he's most unhappy. Instead, play & work with him out in the paddock or wherever he's comfortable and develop your relationship there, before then gradually (using approach & retreat) reintroducing him to the round pen.