fix the last master merge, sorry for the problems

Now I carefully re-merged all the conflicts and tested some builds.
Hopefully it's all OK now.