Do some refactors.

Signed-off-by: yushijinhun <yushijinhun@gmail.com>