Refactor configuration loading to allow better typechecking.