Fix memory leaks.
Merge branch 'release_31' into development

Fix memory leaks.