Code Refactor.

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