Better error handling. Also wait for all promises to be fulfilled or rejected when syncing.