Revert last commit, fix memory leak the right way.