fix some bugs and crash bugs.