Fix leaks, bad memory accesses and preserve dvr entries when the tvh is terminated..