The AI should probably have a better understanding of what the axis of advance and the line of battle are. That way it would not constantly try to turn to attack targets far from the axis of advance, which should be SOMEBODY ELSE'S PROBLEM. Trying to "avoid being flanked" by targeting a flanking ship that someone else can deal with tends to actually result in getting flanked.
The AI also likes to flank a little too much, even when this is counterproductive and results in becoming isolated and flanked yourself, or when getting behind the enemy is the wrong course of action, like a pursuit battle, where you don't want to be BEHIND the enemy, you want to cut him off by getting in front of him so he cannot leave, so the desired position should always be between the enemy and where he wants to go.