Added untested refactoring of the sync process
Added untested refactoring of the sync process

This commit adds the bulk of the actual sync process, which was copied &
refactored from the existing code.  It's not tested at this time, but
will be tomorrow.

obmarg/synchg