Fixes for sync command

I've been encountering an error during sync sometimes, so I fixed it!  The error is detailed in b900e00