Some code refactoring in the sync daemon.