added r reporting functionality, and fixed bugs