fix #322, fix #319