Imported code from jwir3/proton-pack