Fix NullPointerExceptions when syncing