diff --git a/io/src/TFile.cxx b/io/src/TFile.cxx
index 70cfc71b538a6fa635ad01cf0435f7a4535a1969..131b77f40bf228ed88e50c9fcf8343660169eda5 100644
--- a/io/src/TFile.cxx
+++ b/io/src/TFile.cxx
@@ -1424,10 +1424,7 @@ TProcessID  *TFile::ReadProcessID(UShort_t pidf)
    //if not set, read the process uid from file
    char pidname[32];
    sprintf(pidname,"ProcessID%d",pidf);
-   TDirectory *dirsav = gDirectory;
-   this->cd();
    pid = (TProcessID *)Get(pidname);
-   if (dirsav) dirsav->cd();
    if (gDebug > 0) {
       printf("ReadProcessID, name=%s, file=%s, pid=%lx\n",pidname,GetName(),(Long_t)pid);
    }
@@ -2364,19 +2361,16 @@ UShort_t TFile::WriteProcessID(TProcessID *pidd)
       if (pids->At(i) == pid) return (UShort_t)i;
    }
 
-   TDirectory *dirsav = gDirectory;
-   this->cd();
    this->SetBit(TFile::kHasReferences);
    pids->AddAtAndExpand(pid,npids);
    pid->IncrementCount();
    char name[32];
    sprintf(name,"ProcessID%d",npids);
-   pid->Write(name);
+   this->WriteTObject(pid,name);
    this->IncrementProcessIDs();
    if (gDebug > 0) {
       printf("WriteProcessID, name=%s, file=%s\n",name,GetName());
    }
-   if (dirsav) dirsav->cd();
    return (UShort_t)npids;
 }
 
@@ -2413,10 +2407,6 @@ void TFile::WriteStreamerInfo()
    // always write with compression on
    Int_t compress = fCompress;
    fCompress = 1;
-   TFile * fileSave = gFile;
-   TDirectory *dirSave = gDirectory;
-   gFile = this;
-   gDirectory = this;
 
    //free previous StreamerInfo record
    if (fSeekInfo) MakeFree(fSeekInfo,fSeekInfo+fNbytesInfo-1);
@@ -2429,8 +2419,6 @@ void TFile::WriteStreamerInfo()
    key.WriteFile(0);
 
    fClassIndex->fArray[0] = 0;
-   gFile = fileSave;
-   gDirectory = dirSave;
    fCompress = compress;
 }
 
diff --git a/io/src/TKey.cxx b/io/src/TKey.cxx
index 637e2211cc87d244be33a24a7c71de65c7031351..4e5ed2cc56f4c69cc463a5c6872bd901b0d2b0a3 100644
--- a/io/src/TKey.cxx
+++ b/io/src/TKey.cxx
@@ -694,7 +694,6 @@ TObject *TKey::ReadObj()
 
    fBufferRef->SetBufferOffset(fKeylen);
    TObject *tobj = 0;
-   TDirectory *cursav = gDirectory;
    // Create an instance of this class
 
    char *pobj = (char*)cl->New();
@@ -756,7 +755,6 @@ CLEAR:
    delete fBufferRef;
    fBufferRef = 0;
    fBuffer    = 0;
-   gDirectory = cursav;
 
    return tobj;
 }
@@ -811,7 +809,6 @@ void *TKey::ReadObjectAny(const TClass* expectedClass)
    Version_t kvers = fBufferRef->ReadVersion();
 
    fBufferRef->SetBufferOffset(fKeylen);
-   TDirectory *cursav = gDirectory;
    TClass *cl = TClass::GetClass(fClassName.Data());
    if (!cl) {
       Error("ReadObjectAny", "Unknown class %s", fClassName.Data());
@@ -885,7 +882,8 @@ void *TKey::ReadObjectAny(const TClass* expectedClass)
          TDirectory *dir = dynamic_cast<TDirectoryFile*>(tobj);
          dir->SetName(GetName());
          dir->SetTitle(GetTitle());
-         gDirectory->Append(dir);
+         dir->SetMother(fMotherDir);
+         fMotherDir->Append(dir);
       }
    }
 
@@ -893,7 +891,6 @@ void *TKey::ReadObjectAny(const TClass* expectedClass)
    delete fBufferRef;
    fBufferRef = 0;
    fBuffer    = 0;
-   gDirectory = cursav;
 
    return ( ((char*)pobj) + baseOffset );
 }
@@ -924,7 +921,6 @@ Int_t TKey::Read(TObject *obj)
       ReadFile();                    //Read object structure from file
    }
    fBufferRef->SetBufferOffset(fKeylen);
-   TDirectory *cursav = gDirectory;
    if (fObjlen > fNbytes-fKeylen) {
       char *objbuf = fBufferRef->Buffer() + fKeylen;
       UChar_t *bufcur = (UChar_t *)&fBuffer[fKeylen];
@@ -948,7 +944,6 @@ Int_t TKey::Read(TObject *obj)
    delete fBufferRef;
    fBufferRef = 0;
    fBuffer    = 0;
-   gDirectory = cursav;
    return fNbytes;
 }