RDoc comments and small refactoring