Fixed some bugs and add some function

Signed-off-by: Rye <rye.y.cn@gmail.com>