more refactoring, some comments