Another attempt at fixing the rendering bugs