fixed memory leaks on reload