how much of this code is copy-pasta? I’d rather put this into an external file and chain-load on demand rather than including it in the plugin. This makes including upstream changes much easier.