R: removed some memory leaks from the SCG functions.