Use SafeStringStream instead of std::stringstream to try to fix random crashes on OS X.