Finish env usage refactoring