master merge

I did it as two commits because the first one was more complex

cc @zerebubuth @hollinger