Optimization and refactoring.