sync 4.1-dev branch with 4.1.6.h2 branch

While studying the changes in the various 4.1.6 branches, we noticed that some changes present in the `4.1.6.h2` branch were not included in the `4.1-dev` branch.
The naming scheme of the branches suggests that `4.1-dev` is (always) the latest and greatest of version `4.1.x`, while `4.1.6.h2` is bug fixes on top of the `4.1.6` release.

This PR syncs `4.1-dev` with `4.1.6.h2` by including commits that are present in `4.1.6.h2` but not in `4.1-dev` (including an important segfault fix). The commits that are not in `4.1.6.h2` are considered to be deliberately only in `4.1-dev`.

If I'm misunderstanding the branching scheme, feel free to simply close this PR again. If that's the case, where can we find more info on the branching scheme and the intention of the various branches?