fix memory leak in issue #18