Merge "Improve algorithm for deciding which dim layers to animate."