Fixed some bugs

Signed-off-by: Jimmy Yu <jimmy.w.j.yu@gmail.com>