Some old stuff seems to have snuck with this PR, maybe you could break it down in smaller, independent PR, this is kinda big to read as it currently is.