Hue fixes and the start of a refactoring