Refactor config loading.