HEX smearing

This is a draft implementation of HEX smearing that appears to be fully functional. The pull request (into the reference smearing branch) is for purposes of code review and testing. Further polish on the smearing routines is needed, but this can hopefully be done gradually and with straightforward checks to prevent the breaking of functionality.