Backports from nospiffs fork

Some imo straight forward backports from @notspiff