Made some changes to sync to let it work better as a module