Fix several problems in PR#786

Signed-off-by: Yanbing Du <ydu@redhat.com>