fix bug and some exception improvement

Signed-off-by: anti-freak <antifreak2011@gmail.com>