working dir moved to set conf, some logs also since its all in the same function.