Refactor config loader