Adding external config and refactoring a bunch.