Code Refactor. Fix code issues introduced by other enhancement.  

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