Fixed some memory issue.