fix #1646 (and more)