More robust environment support
Merge pull request #17 from GrahamCampbell/env

More robust environment support