Restructure streams and environment access.

Update documentation and example.  Export new helper GETENV.