style cleanup and refactoring