Fixes bug in RGB driver and improves code readability