Cleaned up the R class a little bit.
Merged changes from yesterday with xml update.