Replaced ~str with StrBuf where necessary. Avoided changing API for now, so used .into_owned() to convert back to ~str for return.