add clear button, fix some bugs