working version; ready for deployment to CRAN