More refactoring and upstream sync