Use ostringstream instead of stringstream where possible