Use strbufs instead of open-coded string manipulation