refactor how state is persisted, call doSaveState only from the indexer thread, except there is none. fixes #60781 fixes #52931 fixes #51629 fixes #52035