R# code cleanup