C++: merge and apply weren't being cleaned up quite right.