Fix history operator memory leak