[#56] Add roxygen docs and some minor code refactoring