Debugging of some functions, all is now a working R package.