Forked from HazardX master branch. Required for MIV.