rechecked functions for new upload to CRAN; fixed bugs