Collect properly the references and remove orphaned globals due to death of a GV.
Collect properly the references and remove orphaned globals due to death of a GV.

Cleanup and optimize the code.

dfunke/root,BerserkerTroll/root,veprbl/root,CristinaCristescu/root,sbinet/cxx-root,satyarth934/root,CristinaCristescu/root,abhinavmoudgil95/root,simonpf/root,agarciamontoro/root,gganis/root,arch1tect0r/root,omazapa/root,buuck/root,beniz/root,karies/root,dfunke/root,zzxuanyuan/root-compressor-dummy,jrtomps/root,veprbl/root,lgiommi/root,mkret2/root,bbockelm/root,Duraznos/root,nilqed/root,karies/root,satyarth934/root,perovic/root,nilqed/root,jrtomps/root,smarinac/root,perovic/root,omazapa/root,mkret2/root,Y--/root,krafczyk/root,root-mirror/root,thomaskeck/root,dfunke/root,pspe/root,Y--/root,sbinet/cxx-root,buuck/root,davidlt/root,buuck/root,zzxuanyuan/root,beniz/root,gbitzes/root,sbinet/cxx-root,vukasinmilosevic/root,agarciamontoro/root,thomaskeck/root,0x0all/ROOT,thomaskeck/root,vukasinmilosevic/root,Y--/root,BerserkerTroll/root,zzxuanyuan/root,perovic/root,davidlt/root,nilqed/root,CristinaCristescu/root,nilqed/root,arch1tect0r/root,dfunke/root,bbockelm/root,mhuwiler/rootauto,sawenzel/root,omazapa/root,gganis/root,buuck/root,simonpf/root,esakellari/my_root_for_test,beniz/root,georgtroska/root,omazapa/root-old,mkret2/root,krafczyk/root,georgtroska/root,mkret2/root,omazapa/root,olifre/root,nilqed/root,jrtomps/root,sawenzel/root,agarciamontoro/root,evgeny-boger/root,gbitzes/root,veprbl/root,Duraznos/root,evgeny-boger/root,krafczyk/root,mattkretz/root,vukasinmilosevic/root,omazapa/root-old,davidlt/root,mkret2/root,zzxuanyuan/root-compressor-dummy,lgiommi/root,Duraznos/root,esakellari/root,satyarth934/root,nilqed/root,zzxuanyuan/root,omazapa/root-old,zzxuanyuan/root-compressor-dummy,Y--/root,arch1tect0r/root,gbitzes/root,perovic/root,zzxuanyuan/root,mattkretz/root,sawenzel/root,esakellari/my_root_for_test,georgtroska/root,satyarth934/root,sawenzel/root,omazapa/root,Duraznos/root,nilqed/root,BerserkerTroll/root,pspe/root,sirinath/root,zzxuanyuan/root,abhinavmoudgil95/root,mhuwiler/rootauto,0x0all/ROOT,veprbl/root,beniz/root,veprbl/root,esakellari/root,sirinath/root,gganis/root,vukasinmilosevic/root,veprbl/root,buuck/root,lgiommi/root,karies/root,agarciamontoro/root,root-mirror/root,gganis/root,dfunke/root,arch1tect0r/root,veprbl/root,root-mirror/root,buuck/root,smarinac/root,pspe/root,smarinac/root,bbockelm/root,Y--/root,root-mirror/root,pspe/root,olifre/root,beniz/root,olifre/root,gbitzes/root,satyarth934/root,perovic/root,krafczyk/root,georgtroska/root,CristinaCristescu/root,sirinath/root,evgeny-boger/root,CristinaCristescu/root,mhuwiler/rootauto,sirinath/root,Duraznos/root,abhinavmoudgil95/root,BerserkerTroll/root,0x0all/ROOT,beniz/root,jrtomps/root,zzxuanyuan/root-compressor-dummy,evgeny-boger/root,Y--/root,simonpf/root,thomaskeck/root,esakellari/root,thomaskeck/root,olifre/root,mhuwiler/rootauto,arch1tect0r/root,krafczyk/root,esakellari/my_root_for_test,root-mirror/root,mhuwiler/rootauto,omazapa/root-old,jrtomps/root,omazapa/root,zzxuanyuan/root,nilqed/root,bbockelm/root,vukasinmilosevic/root,buuck/root,georgtroska/root,sirinath/root,gbitzes/root,pspe/root,sirinath/root,sbinet/cxx-root,agarciamontoro/root,BerserkerTroll/root,BerserkerTroll/root,jrtomps/root,smarinac/root,vukasinmilosevic/root,sirinath/root,simonpf/root,omazapa/root-old,perovic/root,mattkretz/root,vukasinmilosevic/root,sbinet/cxx-root,dfunke/root,dfunke/root,mhuwiler/rootauto,satyarth934/root,thomaskeck/root,BerserkerTroll/root,sirinath/root,perovic/root,CristinaCristescu/root,beniz/root,omazapa/root,smarinac/root,zzxuanyuan/root-compressor-dummy,smarinac/root,0x0all/ROOT,bbockelm/root,jrtomps/root,georgtroska/root,karies/root,davidlt/root,CristinaCristescu/root,agarciamontoro/root,simonpf/root,pspe/root,davidlt/root,lgiommi/root,esakellari/my_root_for_test,krafczyk/root,omazapa/root,davidlt/root,Duraznos/root,esakellari/root,krafczyk/root,smarinac/root,olifre/root,mkret2/root,BerserkerTroll/root,sawenzel/root,lgiommi/root,sbinet/cxx-root,georgtroska/root,arch1tect0r/root,georgtroska/root,omazapa/root-old,beniz/root,dfunke/root,0x0all/ROOT,karies/root,gbitzes/root,buuck/root,dfunke/root,mkret2/root,beniz/root,gganis/root,sawenzel/root,arch1tect0r/root,zzxuanyuan/root,esakellari/root,lgiommi/root,mkret2/root,gbitzes/root,mattkretz/root,gganis/root,CristinaCristescu/root,veprbl/root,bbockelm/root,lgiommi/root,sirinath/root,vukasinmilosevic/root,zzxuanyuan/root-compressor-dummy,mhuwiler/rootauto,gganis/root,evgeny-boger/root,0x0all/ROOT,gbitzes/root,Duraznos/root,thomaskeck/root,omazapa/root-old,abhinavmoudgil95/root,krafczyk/root,omazapa/root-old,karies/root,buuck/root,zzxuanyuan/root,esakellari/my_root_for_test,karies/root,perovic/root,karies/root,simonpf/root,evgeny-boger/root,smarinac/root,georgtroska/root,evgeny-boger/root,lgiommi/root,sawenzel/root,olifre/root,sawenzel/root,lgiommi/root,jrtomps/root,0x0all/ROOT,buuck/root,root-mirror/root,jrtomps/root,sawenzel/root,mattkretz/root,abhinavmoudgil95/root,abhinavmoudgil95/root,karies/root,mhuwiler/rootauto,veprbl/root,buuck/root,davidlt/root,agarciamontoro/root,mattkretz/root,dfunke/root,olifre/root,sbinet/cxx-root,krafczyk/root,agarciamontoro/root,smarinac/root,esakellari/my_root_for_test,zzxuanyuan/root-compressor-dummy,omazapa/root,gganis/root,olifre/root,pspe/root,simonpf/root,BerserkerTroll/root,thomaskeck/root,perovic/root,gbitzes/root,arch1tect0r/root,pspe/root,Y--/root,olifre/root,satyarth934/root,Y--/root,sirinath/root,georgtroska/root,jrtomps/root,simonpf/root,sawenzel/root,mkret2/root,simonpf/root,nilqed/root,satyarth934/root,omazapa/root,pspe/root,esakellari/root,abhinavmoudgil95/root,zzxuanyuan/root,omazapa/root-old,smarinac/root,root-mirror/root,krafczyk/root,dfunke/root,thomaskeck/root,pspe/root,abhinavmoudgil95/root,mattkretz/root,arch1tect0r/root,georgtroska/root,krafczyk/root,omazapa/root-old,bbockelm/root,davidlt/root,olifre/root,bbockelm/root,zzxuanyuan/root-compressor-dummy,pspe/root,omazapa/root-old,esakellari/root,lgiommi/root,esakellari/root,sawenzel/root,mattkretz/root,root-mirror/root,beniz/root,root-mirror/root,lgiommi/root,mattkretz/root,karies/root,esakellari/my_root_for_test,evgeny-boger/root,satyarth934/root,zzxuanyuan/root-compressor-dummy,BerserkerTroll/root,root-mirror/root,root-mirror/root,vukasinmilosevic/root,zzxuanyuan/root-compressor-dummy,davidlt/root,agarciamontoro/root,sbinet/cxx-root,Duraznos/root,omazapa/root,0x0all/ROOT,arch1tect0r/root,0x0all/ROOT,gbitzes/root,perovic/root,Duraznos/root,mattkretz/root,olifre/root,simonpf/root,karies/root,sbinet/cxx-root,Y--/root,mhuwiler/rootauto,BerserkerTroll/root,Y--/root,davidlt/root,CristinaCristescu/root,mattkretz/root,zzxuanyuan/root,CristinaCristescu/root,evgeny-boger/root,bbockelm/root,CristinaCristescu/root,thomaskeck/root,abhinavmoudgil95/root,evgeny-boger/root,agarciamontoro/root,Duraznos/root,gbitzes/root,esakellari/my_root_for_test,nilqed/root,bbockelm/root,esakellari/root,davidlt/root,nilqed/root,esakellari/my_root_for_test,veprbl/root,gganis/root,gganis/root,esakellari/my_root_for_test,agarciamontoro/root,perovic/root,abhinavmoudgil95/root,jrtomps/root,bbockelm/root,mhuwiler/rootauto,zzxuanyuan/root,veprbl/root,satyarth934/root,esakellari/root,sbinet/cxx-root,sbinet/cxx-root,abhinavmoudgil95/root,beniz/root,mkret2/root,vukasinmilosevic/root,sirinath/root,vukasinmilosevic/root,Y--/root,esakellari/root,Duraznos/root,mhuwiler/rootauto,gganis/root,satyarth934/root,simonpf/root,zzxuanyuan/root-compressor-dummy,arch1tect0r/root,evgeny-boger/root,zzxuanyuan/root,mkret2/root