More refactoring and code modernizing