refactored code for external use. commented out a few builds in the cmake file while issue is being investigated