[1.2.4] Backport of #1137

See #1131 and #1137