Avoid NullReferenceException when environment variable not set.

Fixes issue #299.