Pull Request for Issue971: Memory Leaks Related to Opening Scans

Fixed leaks found while opening scans from the database. Tested and appears to work. No crashes and the leaks go away.