Fix #398 for mainline (2.4)