Remove uses of HD, replacing with case expressions where possible.