V4.0 mario

Rebase #2610. It's a huge pull request. @masterbee you got to send PR more often.

There were some conflicts around some file being deleted in one branch but not the other so I kept all of them to be safe. They can be deleted later if necessary.