also contains backport of !1514 (merged) to preserver linear history and simplify final backport to master