Bugfix in connected component function.