improved config file selection and generation