Add sort by hue
Refactor code into something slightly more sane