Finished the sync logic and documented some stuff.