Refactor environment to use get/set