bug fixes + connected component extraction