Simplify implementation of 'retain'.