More cleanups.

Summary:

Test Plan:

Reviewers:

CC:
Settled on an algorithm design.

Summary:

Test Plan:

Reviewers:

CC: