Also fixes a few errors in the measuring logic. Bug: 15170399 Change-Id: I7ce7edef0a08dc00ef747988cd64e40a9fbae192