Add better (not good) environmnet awareness so that the script can be run by cron sucessfully.