Got rid of flicker by reordering painting of components