Buildings retargeting on training unit (bugfix request)

Would we be able to fix how buildings retarget after training a unit, specifically the town center and castle? It can be frustrating when you look away and then your castle is shooting at a mining camp instead of what you had targeted.