More refactoring/code style changes