r# code cleanup