STP, RSTP and MSTP are well known solutions for both loop detection and redundancy. Spanning-tree will determine the root switch and from that point it will calculate the link cost to the device. After the determination of the shortest path it will disable the more costly paths.
But this won’t always result in the best network topology. So how is this root switch appointed? Root switches are chosen because of two things their priority settings and after that who has the lowest MAC-address. This is why if you just let it determine the paths it won’t always be the best topology.
HP ProCurve (and maybe also other) switches are configured with the default priority 8. This way when you enable STP on them they just look at the lowest MAC-address. To optimize the topology you might want to set the priority of your main switch lower as the default priority (8). This way your switch is chosen as root switch and all paths are calculated from there.
The way to change the priority on HP ProCurve switches from CLI goes as follows:
[hostname](config)#spanning-tree priority [n]
[n] can be anything from 0 to 15. 0 being the highest priority and 15 being the lowest.