-Fixed memory leaks upon reopening files/opening new files.