fix #899 #948 #788