Refactoring and optimization.