Cleaning up code for HEX.