Imported from https://github.com/neka-nat/probreg