Completed first pass on env handling