Cleanup, add comments and address review comments.

No functional changes.