Initial implementation of sync function

Config needs to be moved out and still shelling out in some places, but should work otherwise.