Fix warnings on initial startup (i.e. without a state file).

Fixes #3606