TRQ-2277. Fix some memory leaks.