Partially fix Bug 21718 - Lack of polish in open dialog
Fix some memory leaks.