fix memory leak from issue #33