At the end of the day the Glock has several things going against it for real accuracy - it is polymer framed, which allows more flex; it has itty bitty frame rails; it locks up loose as a goose.
One of the simplest was to tighten groups with a stock barrel might be to tighten the lock up by using a slightly oversized 'match' slide lock:
https://www.kingglock.com/Detail.aspx?PROD=799507
An aftermarket barrel for Gens 1-4, is going to also help, even a direct drop-in with no fitting in my limited experience.
That being said, 3 inches at 25 is doable with decent ammo and practice.