fix memory leaks for object