small cleanup and refactoring