[1.2.4] Backport bug fixes from #1347

See #1347