Improved resolving environment variables and store result.
Fixed CString concatenation