subtle refactorings and comments