Refactor and improve color handling.