fix #398, fix #353, fix #350