Fix some bugs and change exception as print out