Refactorings and code readability improvements