seemingly working min spanning tree building and lots of other changes