Use POSIX compliant functions

"replace" is not a POSIX function and is not available on
*nix. Instances of "replace" have been changed to instances of "sed".