Backport Hammerflex 7c1e89e changes
https://github.com/ChrisHammond/HammerFlex/commit/7c1e89eb9f94219c722479433c920b10c45c74fc