Initial implementation of sync function

It shells out in some places it shouldn't and needs to have config moved out of the function, but handles the functionality.