some bugs fixed and possibility to run R CMD check

Signed-off-by: AK2083 <ankh.egypt.public@googlemail.com>