Make use of _replace.

This completes the refactoring started in a045c03.