Fix memory leak + Fix issue 199