fix memory leak where temprary segment sets where not getting freed