Merge fix for TRQ-2525, TRQ-2548, TRQ-2549: Valgrind issues.