TDQ-9468 backport to 5.5(fix 2 problems).