fix #1340 and fix #1336