rework demos and R functions a little