minor refactoring, code cleanup