fix memory leaks;