Refactor loader and config