WIP - generic algorithm for two-way sync