Added various fixes required to pass CRAN checks