Added additional comile logic and added some autodetection of default env variables