When the color was black, the original value was not initialized and get a NaN value with unexpected results. Also cleanup code.
When the color was black, the original value was not initialized and get a NaN value with unexpected results. Also cleanup code.