Pull out the duplicate `remove-all` function

It leaves behind duplicate code as well but this is just temporary.