Fix several bugs and improve algorithm by calculating colors volume.