Implement --rebuild-broken logic