Fixes to make all the tests pass: fixed if-then-else arguments of the
'replace' and removed "duplicate" code due to the recent merge.