changes to accommodate cran checks

mostly documentation, split the code into a few files, etc.