Consolidated code into single file
Reconfigured for CRAN check