Backports from nospiffs fork

Some imo straight forward backports from @nospiff