Code refactoring and optimization.