Add option for RGB or HEX output.
Add comments and some code cleanup.