added some better config resolution
Added better error checking