Initial implementation of the syncing algorithm.