More bugfixes to sweep and prune