Update header and fix memory leaks.