Edits to roxygen comments, also changes to functions for efficiency