Code cleanup; handle case where no spanning tree exists