Refactor config loading