refactoring, more code comments