Refactoring and optimization of config