Basically you can improve the behavior slightly by modifying the distance formations are checked each time and reducing it.
descr_pathfinding.txt