Fix issue #179
Fix memory leak