Avoid NullReferenceException when environment variable not set.

Fixes issue #299.
Merge pull request #300 from bkryl/missing-environment-variable-exception

Avoid NullReferenceException when environment variable not set.