Making privates public to use stand-alone ad hoc-defined functions.
Renamed buf => buffer.
Added replace() (incomplete: doesn't support a function replacer yet).