Backport HammerFlex a2ff040 changes
https://github.com/ChrisHammond/HammerFlex/commit/a2ff040ead155d54fc20027c89dfa28b77e1838b