Fixed some bugs in the R demos