Added more flexible support for replacement options