Fix some bugs. Make sure state management is done properly between
RestoreThread and main thread so we don't leave jobs in limbo.