Refactorings and optimization.