some cleanup and addition of RGR calclulation