Bug fixes. Minimize memory leak problem.