Moved logic for getting environment name into Environment, reorganized script a bit