More refactoring and changes.