Set credentials early so they're available when sync starts
Don't close file too early
Include local changes in initial sync