fix memory leak, clearer outputs