[1.2.4] Backport of bugfixes from 1.3.0

See #1375