begin moving sync code into its own module