cleaned up R functions
further integration with r2admb