Improved how db and server data are handled in main func