Fix #2268 (manually implementing PR #2269)