Some code cleanup. Fixed race condition where multiple threads tried to write colour data at the same time.