Added better handling of env. variables