fix for memory leak when dom object not emptied