Lots of rewriting of `rebuild`.