Refactored colorspace algorithms.