improve rendering performance dramatically in certain situations (upstream issue #770)