Fixed up the sync function for arbitrary commands