And fix a couple of other inefficiencies. Fixes bug 15444410. Change-Id: Idad95d4e4d70bc7d2965e1bd6ff3d3135b73dd9c