Apart from the CI failure I identified as irrelevant, all CIs are happy at this point. That makes this PR ready for review. @hlandau, this touched a lot of code you're written, please take an extra look to see that I haven't screwed things up too badly...