Fixed the momeory leak issue.