Merge "Avoid inconsistent state when remove fails." into ics-mr1