Code Refactor to avoid message display issues.

Signed-off-by: Pengcheng Bian <pbian@actuate.com>