massive readability refactoring