R: small bug fixes