fix #2320

see commit message and #2320 for more info.