Added functions + started Rcpp conversion

blah