Bunch of commits

I am not restructuring the changes into distinct PRs for each part, as there could be dependencies, some of the fixes apply for all of them etc... I hope you'll manage, Alan :)