remove several getenv() calls

by reusing their return value.