Reorganiziation of the RD loop to make more sense. Change-Id: Ia1e3b0ff9b70747b3725391de59f230edab767d7