Cherrypicked fix for remove-keep