More memory leak fixes.

- Sorry for this, first time I have had to convert ARC code to manually managed reference counting.