Added database output, restructure functions

-Add configuration function
-Change agent discovery