Refactor config parsing