Also refactor some RD code, remove some comments, and cosmetic changes. Change-Id: I43806ae573ab5a5036602ac4425d750bbfa1e812