Refactor loading to make it cleaner and less layered.