Should use wostringstream and wstring for envStr above to avoid the casting here?