Fix some bugs and add %hook.