Small improvements + refactoring.