Correct colour distance function and make adjustments

Seems to work for most cases now.