start cleaning up internal functions & roxygen documentation