Refactor and clean up configuration loading and support hierarchical configuration resolution.
Fix merge conflicts.