Better main
basic r-scripting in place