Fix tons of color conversion bugs. Reorganize things more rationally and so that more code is shared.