Free allocated data here to fix memory leaks