[R] cleanup and add some comments