Move ID creation and storage to unused argument of replace method. #400