Fixing small memory leaks.
A couple of tests to reproduce a known crash and a known (but very minuscule) memory leak.