Hacking, trying to get stuff to work correctly.
Updated to use the WeightedQuickUnion data type.