mild cleanup and refactoring