refactoring and sync improvement