Fix a bug and add validation for the config.