Refactored config factory