Refactored some of the auto sync code.