fix some includes and Rscript calls