Fix outstanding memory management issues

These commits resolve all issues identified by Xcode's static analyzer.