Added UnionFind class
Merged from master