Refactor container replacement.