Switched env detection back to use uname -s, tr and, sed and made tr more robust at translating upper to lower case