Split out filtering from the synchronization logic.

While this amounts to more lines of code it is cleaner and more linear.
It should also be faster as the the pure synchronization use no longer
bears the overhead of filtering, each id is only ever checked againt
the filter once, and most importantly it groups changes better resulting
in fewer updates of any connected view.